Class: Loxxy::Ast::LoxForStmt

Inherits:
LoxCompoundExpr show all
Defined in:
lib/loxxy/ast/lox_for_stmt.rb

Instance Attribute Summary collapse

Attributes inherited from LoxCompoundExpr

#subnodes

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxNode

#done!

Constructor Details

#initialize(aPosition, initialization, testExpr, updateExpr) ⇒ LoxForStmt

Returns a new instance of LoxForStmt.

Parameters:



21
22
23
24
25
26
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 21

def initialize(aPosition, initialization, testExpr, updateExpr)
  child = initialization ? [initialization] : []
  super(aPosition, child)
  @test_expr = testExpr
  @update_expr = updateExpr
end

Instance Attribute Details

#body_stmtLoxNode

Returns body statement.

Returns:



15
16
17
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 15

def body_stmt
  @body_stmt
end

#test_exprLoxNode (readonly)

Returns test expression.

Returns:



9
10
11
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 9

def test_expr
  @test_expr
end

#update_exprLoxNode (readonly)

Returns update expression.

Returns:



12
13
14
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 12

def update_expr
  @update_expr
end

Instance Method Details

#accept(visitor) ⇒ Object

Part of the 'visitee' role in Visitor design pattern.

Parameters:



30
31
32
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 30

def accept(visitor)
  visitor.visit_for_stmt(self)
end

#conditionLoxNode

Accessor to the condition expression

Returns:



36
37
38
# File 'lib/loxxy/ast/lox_for_stmt.rb', line 36

def condition
  subnodes[0]
end