Sha256: 503ccca887c7ceec5a5bcad8262fef011dd5369e1c3ee94e85079153aad7a891

Contents?: true

Size: 1.07 KB

Versions: 39

Compression:

Stored size: 1.07 KB

Contents

#!/usr/local/bin/ruby

require 'lsapi'

class CodeCache
    def [](filename)
		mtime = File.mtime( filename )		
		
		entry = @cache[filename];
		if entry != nil 
			return entry
						
		end
		code = compile(filename)
		#entry = CodeEntry.new( filename, mtime, code )
		@cache[filename] = code
		return code
    end

    private

    def initialize
      @cache = {}
    end

    def compile(filename)
		open(filename) do |f|
			s = f.read
			s.untaint
			binding = eval_string_wrap("binding")
			return eval(format("Proc.new {\n%s\n}", s), binding, filename, 0)
		end
    end
end


$count = 0;

$cache = CodeCache.new


while true
	$req = LSAPI.accept 
	break if $req == nil 
	
	filename = ENV['SCRIPT_FILENAME']
	filename.untaint

	filename =~ %r{^(\/.*?)\/*([^\/]+)$}
	path   = $1
	Dir.chdir( path )
	#load( filename, true )	
    code = $cache[filename]
    code.call
	
end

class CodeEntry
	public :path, :name, :mtime, :opcode 
	
	def initizlize( filename, mtime, opcode )
		filename =~ %r{^(\/.*?)\/*([^\/]+)$}
		@path   = $1
		@name   = $2
		@mtime  = mtime
		@opcode = opcode
	end

end


Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ruby-lsapi-5.7 scripts/lsruby_runner.rb
ruby-lsapi-5.6 scripts/lsruby_runner.rb
ruby-lsapi-5.5 scripts/lsruby_runner.rb
ruby-lsapi-5.4 scripts/lsruby_runner.rb
ruby-lsapi-5.2 scripts/lsruby_runner.rb
ruby-lsapi-5.1 scripts/lsruby_runner.rb
ruby-lsapi-5.0 scripts/lsruby_runner.rb
ruby-lsapi-4.4 scripts/lsruby_runner.rb
ruby-lsapi-4.3 scripts/lsruby_runner.rb
ruby-lsapi-4.2 scripts/lsruby_runner.rb
ruby-lsapi-4.1 scripts/lsruby_runner.rb
ruby-lsapi-4.0 scripts/lsruby_runner.rb
ruby-lsapi-1.5 scripts/lsruby_runner.rb
ruby-lsapi-1.10 scripts/lsruby_runner.rb
ruby-lsapi-1.4 scripts/lsruby_runner.rb
ruby-lsapi-1.11 scripts/lsruby_runner.rb
ruby-lsapi-1.13 scripts/lsruby_runner.rb
ruby-lsapi-1.12 scripts/lsruby_runner.rb
ruby-lsapi-1.3 scripts/lsruby_runner.rb
ruby-lsapi-2.9 scripts/lsruby_runner.rb