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, #_nydp_wrapper
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 ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nydp/builtin/ruby_wrap.rb', line 11 def arg_mapper case size when 0 ; "" when 1 ; ", a0" when 2 ; ", a0, a1" when 3 ; ", a0, a1, a2" when 4 ; ", a0, a1, a2, a3" when 5 ; ", a0, a1, a2, a3, a4" 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 |
# 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_invoke_#{msize} vm#{ arg_mapper } vm.push_arg(#{code}) end def builtin_invoke vm, args vm.push_arg(#{generic_code}) end end CODE end |