Class: Baba::Stmt::If

Inherits:
Object
  • Object
show all
Defined in:
lib/baba/stmt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition, then_branch, else_branch) ⇒ If

Returns a new instance of If.



54
55
56
# File 'lib/baba/stmt.rb', line 54

def initialize(condition, then_branch, else_branch)
  @condition = condition; @then_branch = then_branch; @else_branch = else_branch
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



52
53
54
# File 'lib/baba/stmt.rb', line 52

def condition
  @condition
end

#else_branchObject (readonly)

Returns the value of attribute else_branch.



52
53
54
# File 'lib/baba/stmt.rb', line 52

def else_branch
  @else_branch
end

#then_branchObject (readonly)

Returns the value of attribute then_branch.



52
53
54
# File 'lib/baba/stmt.rb', line 52

def then_branch
  @then_branch
end

Instance Method Details

#accept(visitor) ⇒ Object



58
59
60
# File 'lib/baba/stmt.rb', line 58

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