Module: FastRuby::DefnTranslator
- Defined in:
- lib/fastruby/translator/modules/defn.rb
Instance Method Summary collapse
Instance Method Details
#to_c_defn(tree) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fastruby/translator/modules/defn.rb', line 25 def to_c_defn(tree) method_name = tree[1] args_tree = tree[2].select{|x| x.to_s[0] != ?&} global_klass_variable = add_global_name("VALUE", "Qnil"); hash = Hash.new value_cast = ( ["VALUE"]*(args_tree.size+2) ).join(",") strmethodargs = "self,block,(VALUE)&frame" anonymous_method_name = anonymous_dispatcher(global_klass_variable, method_name) = .dup .delete(:self) .delete(:main) inline_block " rb_define_method(plocals->self, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1 ); #{global_klass_variable} = plocals->self; // set tree rb_funcall(#{literal_value FastRuby}, #{intern_num :set_tree}, 5, #{global_klass_variable}, rb_str_new2(#{method_name.to_s.inspect}), #{literal_value tree}, #{literal_value snippet_hash}, #{literal_value } ); " end |
#to_c_defs(tree) ⇒ Object
61 62 63 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 90 91 92 93 94 95 96 97 |
# File 'lib/fastruby/translator/modules/defn.rb', line 61 def to_c_defs(tree) method_name = tree[2] args_tree = tree[3].select{|x| x.to_s[0] != ?&} global_klass_variable = add_global_name("VALUE", "Qnil"); hash = Hash.new value_cast = ( ["VALUE"]*(args_tree.size+2) ).join(",") strmethodargs = "self,block,(VALUE)&frame" anonymous_method_name = anonymous_dispatcher(global_klass_variable, method_name) = .dup .delete(:self) .delete(:main) inline_block " VALUE obj = #{to_c tree[1]}; rb_define_singleton_method(obj, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1 ); #{global_klass_variable} = CLASS_OF(obj); // set tree rb_funcall(#{literal_value FastRuby}, #{intern_num :set_tree}, 5, #{global_klass_variable}, rb_str_new2(#{method_name.to_s.inspect}), #{literal_value tree}, #{literal_value snippet_hash}, #{literal_value } ); " end |
#to_c_scope(tree) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/fastruby/translator/modules/defn.rb', line 99 def to_c_scope(tree) if tree[1] to_c(tree[1]) else "Qnil" end end |