Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/fastruby.rb,
lib/fastruby/object.rb,
lib/fastruby/object.rb,
lib/fastruby/sexp_extension.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fastruby(*arguments, &blk) ⇒ Object
- #fastruby? ⇒ Boolean
- #gc_register_object ⇒ Object
- #infer(a) ⇒ Object
- #to_fastruby_sexp ⇒ Object
Class Method Details
.decode64(value) ⇒ Object
30 31 32 |
# File 'lib/fastruby.rb', line 30 def self.decode64(value) Base64.decode64(value) end |
.execute_tree(tree, *options_hashes) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fastruby/object.rb', line 127 def self.execute_tree(tree,*) = {:validate_lvar_types => true} .each do |opt| .merge!(opt) end require "fastruby/fastruby_sexp" method_name = tree[1] self_ = [:self] self_ = self unless self_.instance_of? Class FastRuby.set_tree(self_, method_name, tree, ) class << self $metaclass = self end self_.build([$class_self],method_name,true) end |
Instance Method Details
#fastruby(*arguments, &blk) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/fastruby/object.rb', line 71 def fastruby(*arguments, &blk) if blk method_container = Class.new class << method_container attr_accessor :_self attr_accessor :fastruby_options end method_container._self = self method_container. = arguments.inject({},&:merge) def method_container.method_added(mname) m = instance_method(mname) if [:fastruby_only] tree = FastRuby::FastRubySexp.parse m.source FastRuby.set_tree(_self, tree[1], tree, ) else @_self.fastruby m.source, end end method_container.class_eval(&blk) return nil end = arguments[1..-1] argument = arguments.first = {:validate_lvar_types => true} .each do |opt| .merge!(opt) end tree = nil require "fastruby/fastruby_sexp" unless defined? FastRuby::FastRubySexp if argument.instance_of? FastRuby::FastRubySexp tree = argument elsif argument.instance_of? String unless defined? RubyParser require "rubygems" require "ruby_parser" end tree = RubyParser.new.parse(argument).to_fastruby_sexp else raise ArgumentError end return unless tree method_name = "_anonymous_" + Digest::SHA1.hexdigest(tree.inspect) Object.execute_tree(FastRuby.encapsulate_tree(tree,method_name), {:main => method_name, :self => self}.merge()) end |
#fastruby? ⇒ Boolean
63 64 65 |
# File 'lib/fastruby/object.rb', line 63 def fastruby? false end |
#gc_register_object ⇒ Object
148 149 150 151 |
# File 'lib/fastruby/object.rb', line 148 def gc_register_object $refered_from_code_array = Array.new unless $refered_from_code_array $refered_from_code_array << self end |
#infer(a) ⇒ Object
70 |
# File 'lib/fastruby/object.rb', line 70 def infer(a); self; end |
#to_fastruby_sexp ⇒ Object
27 28 29 |
# File 'lib/fastruby/sexp_extension.rb', line 27 def to_fastruby_sexp self end |