Class: PartialRuby::Context
- Inherits:
-
Object
- Object
- PartialRuby::Context
- Defined in:
- lib/partialruby.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#emul(tree) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/partialruby.rb', line 55 def emul(tree) begin # first, try to emul the node return ruby_emul(tree) rescue NoMethodError => e if tree "#{object_ref self}.run(#{object_ref tree}, PartialRuby::Frame.new(binding,self) )" else "nil; " end end end |
#object_ref(obj) ⇒ Object
46 47 48 |
# File 'lib/partialruby.rb', line 46 def object_ref(obj) "ObjectSpace._id2ref(#{obj.object_id})" end |
#ruby_emul(tree) ⇒ Object
50 51 52 53 |
# File 'lib/partialruby.rb', line 50 def ruby_emul(tree) nodetype = tree.first send("ruby_emul_"+nodetype.to_s, tree) end |
#run(tree, frame) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/partialruby.rb', line 68 def run(tree, frame) return nil unless tree nodetype = tree.first code = nil begin # first, try to emul the node code = ruby_emul(tree) rescue NoMethodError => e end if code then eval(code, frame._binding) else send("handle_node_"+nodetype.to_s, tree, frame) end end |