Class: IV::Phonic::AST::VariableStatement

Inherits:
Statement show all
Defined in:
lib/iv/phonic/ast.rb

Instance Method Summary collapse

Methods inherited from Statement

as

Methods inherited from Node

#begin_position, #end_position, #program, #source

Constructor Details

#initialize(parent, stmt) ⇒ VariableStatement

Returns a new instance of VariableStatement.



97
98
99
100
101
# File 'lib/iv/phonic/ast.rb', line 97

def initialize parent, stmt
  super parent, stmt
  @body = stmt[:body].map{|decl| Declaration.new self, decl }
  @const = stmt[:const]
end

Instance Method Details

#to_source(lv) ⇒ Object



103
104
105
# File 'lib/iv/phonic/ast.rb', line 103

def to_source lv
  "#{@const ? 'const' : 'var' } #{ @body.map{|decl| decl.to_source lv }.join(', ') };".indent(lv)
end