Class: Nydp::Builtin::RubyWrap::Coder
- Defined in:
- lib/nydp/builtin/ruby_wrap.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#helpers ⇒ Object
Returns the value of attribute helpers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
Methods inherited from Struct
#_nydp_procs, #_nydp_whitelist
Methods included from AutoWrap
#_nydp_get, #_nydp_ok?, #_nydp_procify?, #_nydp_safe_send
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
8 9 10 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 8 def code @code end |
#helpers ⇒ Object
Returns the value of attribute helpers
8 9 10 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 8 def helpers @helpers end |
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 8 def name @name end |
#size ⇒ Object
Returns the value of attribute size
8 9 10 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 8 def size @size end |
Instance Method Details
#arg_mapper_novm ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 11 def arg_mapper_novm case size when 0 ; "" when 1 ; "a0=nil" when 2 ; "a0=nil, a1=nil" when 3 ; "a0=nil, a1=nil, a2=nil" when 4 ; "a0=nil, a1=nil, a2=nil, a3=nil" when 5 ; "a0=nil, a1=nil, a2=nil, a3=nil, a4=nil" else ; raise "maximum 5 arguments!" end end |
#msize ⇒ Object
9 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 9 def msize ; size + 1 ; end |
#to_ruby ⇒ Object
23 24 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 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 23 def to_ruby generic_code = code. gsub(/a0/, "args.car"). gsub(/a1/, "args.cdr.car"). gsub(/a2/, "args.cdr.cdr.car"). gsub(/a3/, "args.cdr.cdr.cdr.car"). gsub(/a4/, "args.cdr.cdr.cdr.cdr.car") <<CODE class #{name} include Nydp::Builtin::Base, Singleton#{helpers} def builtin_call #{ arg_mapper_novm } (#{code}) end # return the ruby equivalent of this code if it was inlined inside another builtin def inline_code arg_expressions #{code.inspect}. gsub(/a0/, arg_expressions[0]). gsub(/a1/, arg_expressions[1]). gsub(/a2/, arg_expressions[2]). gsub(/a3/, arg_expressions[3]). gsub(/a4/, arg_expressions[4]) end end CODE end |