Class: Johnson::TraceMonkey::Runtime
- Defined in:
- lib/johnson/tracemonkey/runtime.rb
Overview
native
Constant Summary collapse
- CONTEXT_MAP_KEY =
:johnson_context_map
Constants inherited from Runtime
Runtime::PRELUDE, Runtime::PRELUDE_PATH
Instance Attribute Summary collapse
-
#traps ⇒ Object
readonly
Returns the value of attribute traps.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_gcthing(thing) ⇒ Object
called from js_land_proxy.c:make_js_land_proxy.
-
#compile(script, filename = nil, linenum = nil, global = nil) ⇒ Object
Compile
script
withfilename
andlinenum
. - #current_context ⇒ Object
- #debugger? ⇒ Boolean
- #evaluate(script, filename = nil, linenum = nil, global = nil, scope = nil) ⇒ Object
- #evaluate_compiled_script(script, scope = nil) ⇒ Object
- #evaluate_compiled_script_without_clearing_traps ⇒ Object
-
#initialize(options = {}) ⇒ Runtime
constructor
A new instance of Runtime.
-
#remove_gcthing(object_id) ⇒ Object
called from js_land_proxy.c:finalize.
- #version ⇒ Object
Methods inherited from Runtime
#[], #[]=, #delegate, #global, #load, new, #require
Constructor Details
#initialize(options = {}) ⇒ Runtime
Returns a new instance of Runtime.
11 12 13 14 15 16 17 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 11 def initialize(={}) @debugger = nil @gcthings = {} @traps = [] initialize_native() super() end |
Instance Attribute Details
#traps ⇒ Object (readonly)
Returns the value of attribute traps.
10 11 12 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 10 def traps @traps end |
Class Method Details
.parse_io(*args) ⇒ Object
63 64 65 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 63 def parse_io *args Johnson::TraceMonkey::ImmutableNode.parse_io( *args ) end |
.raise_js_exception(jsex) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 67 def raise_js_exception(jsex) raise jsex if Exception === jsex raise Johnson::Error.new(jsex.to_s) unless Johnson::TraceMonkey::RubyLandProxy === jsex stack = jsex.stack rescue nil = jsex['message'] || jsex.to_s at = "(#{jsex['fileName']}):#{jsex['lineNumber']}" ex = Johnson::Error.new("#{} at #{at}") if stack js_caller = stack.split("\n").find_all { |x| x != '@:0' } ex.set_backtrace(js_caller + caller) else ex.set_backtrace(caller) end raise ex end |
Instance Method Details
#add_gcthing(thing) ⇒ Object
called from js_land_proxy.c:make_js_land_proxy
20 21 22 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 20 def add_gcthing(thing) @gcthings[thing.object_id] = thing end |
#compile(script, filename = nil, linenum = nil, global = nil) ⇒ Object
Compile script
with filename
and linenum
55 56 57 58 59 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 55 def compile(script, filename=nil, linenum=nil, global=nil) filename ||= 'none' linenum ||= 1 native_compile(script, filename, linenum, global) end |
#current_context ⇒ Object
33 34 35 36 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 33 def current_context contexts = (Thread.current[CONTEXT_MAP_KEY] ||= {}) contexts[self.object_id] ||= Context.new(self) end |
#debugger? ⇒ Boolean
29 30 31 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 29 def debugger? not @debugger.nil? end |
#evaluate(script, filename = nil, linenum = nil, global = nil, scope = nil) ⇒ Object
38 39 40 41 42 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 38 def evaluate(script, filename = nil, linenum = nil, global=nil, scope=nil) return nil if script.nil? compiled_script = compile(script, filename, linenum, global) evaluate_compiled_script(compiled_script, scope) end |
#evaluate_compiled_script(script, scope = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 45 def evaluate_compiled_script script, scope=nil evaluate_compiled_script_without_clearing_traps(script,scope) ensure @traps.each do |trap_tuple| clear_trap(*trap_tuple) end end |
#evaluate_compiled_script_without_clearing_traps ⇒ Object
44 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 44 alias :evaluate_compiled_script_without_clearing_traps :evaluate_compiled_script |
#remove_gcthing(object_id) ⇒ Object
called from js_land_proxy.c:finalize
25 26 27 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 25 def remove_gcthing(object_id) @gcthings.delete(object_id) if defined? @gcthings end |
#version ⇒ Object
4 5 6 |
# File 'lib/johnson/tracemonkey/runtime.rb', line 4 def version TraceMonkey::VERSION end |