Class: Object

Inherits:
BasicObject
Defined in:
lib/fastruby.rb,
lib/fastruby/object.rb,
lib/fastruby/sexp_extension.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decode64(value) ⇒ Object



29
30
31
# File 'lib/fastruby.rb', line 29

def self.decode64(value)
  Base64.decode64(value)
end

.execute_tree(tree, *options_hashes) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fastruby/object.rb', line 91

def self.execute_tree(tree,*options_hashes)
  options_hash = {:validate_lvar_types => true}
  options_hashes.each do |opt|
    options_hash.merge!(opt)
  end

  require "fastruby/fastruby_sexp"
  method_name = tree[1]

  self_ = options_hash[:self]
  self_ = self unless self_.instance_of? Class

  FastRuby.set_tree(self_, method_name, tree, options_hash[:snippet_hash], options_hash)

  class << self
    $metaclass = self
  end

  self_.build([$class_self],method_name,true)
end

Instance Method Details

#fastruby(argument, *options_hashes) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fastruby/object.rb', line 64

def fastruby(argument, *options_hashes)
  options_hash = {:validate_lvar_types => true}
  options_hashes.each do |opt|
    options_hash.merge!(opt)
  end
  
    tree = nil

    require "fastruby/fastruby_sexp"
    if argument.instance_of? FastRuby::FastRubySexp
      tree = argument
    elsif argument.instance_of? String
      require "rubygems"
      require "ruby_parser"
      require "fastruby/sexp_extension"
      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(options_hash))


end

#gc_register_objectObject



112
113
114
115
# File 'lib/fastruby/object.rb', line 112

def gc_register_object
  $refered_from_code_array = Array.new unless $refered_from_code_array
  $refered_from_code_array << self
end

#infer(a) ⇒ Object



63
# File 'lib/fastruby/object.rb', line 63

def infer(a); self; end

#to_fastruby_sexpObject



27
28
29
# File 'lib/fastruby/sexp_extension.rb', line 27

def to_fastruby_sexp
  self
end