Class: NScript::SplatNode

Inherits:
Node
  • Object
show all
Defined in:
lib/nscript/parser/nodes.rb

Constant Summary

Constants inherited from Node

Node::TAB

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject

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