Class: NScript::SplatNode
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
Instance Method Summary collapse
- #compile_node(o = {}) ⇒ Object
- #compile_param(o) ⇒ Object
- #compile_value(o, name, index) ⇒ Object
-
#initialize(name) ⇒ SplatNode
constructor
A new instance of SplatNode.
Methods inherited from Node
#children, children, #compile, #compile_closure, #contains?, #idt, statement, #statement?, statement_only, #statement_only?, top_sensitive, #top_sensitive?, #unwrap, #write
Constructor Details
#initialize(name) ⇒ SplatNode
Returns a new instance of SplatNode.
611 612 613 |
# File 'lib/nscript/parser/nodes.rb', line 611 def initialize(name) @name = name end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
609 610 611 |
# File 'lib/nscript/parser/nodes.rb', line 609 def index @index end |
Instance Method Details
#compile_node(o = {}) ⇒ Object
615 616 617 |
# File 'lib/nscript/parser/nodes.rb', line 615 def compile_node(o={}) write(@index ? compile_param(o) : @name.compile(o)) end |
#compile_param(o) ⇒ Object
619 620 621 622 |
# File 'lib/nscript/parser/nodes.rb', line 619 def compile_param(o) o[:scope].find(@name) "#{@name} = Array.prototype.slice.call(arguments, #{@index})" end |
#compile_value(o, name, index) ⇒ Object
624 625 626 |
# File 'lib/nscript/parser/nodes.rb', line 624 def compile_value(o, name, index) "Array.prototype.slice.call(#{name}, #{index})" end |