Class: Idl::ElseIfAst
- Includes:
- Returns
- Defined in:
- lib/idl/ast.rb
Instance Method Summary collapse
- #body ⇒ Object
- #cond ⇒ Object
-
#initialize(input, interval, body_interval, cond, body_stmts) ⇒ ElseIfAst
constructor
A new instance of ElseIfAst.
- #return_value(symtab) ⇒ Object included from Returns
- #return_values(symtab) ⇒ Object
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
- #type_check(symtab) ⇒ Object
Constructor Details
#initialize(input, interval, body_interval, cond, body_stmts) ⇒ ElseIfAst
Returns a new instance of ElseIfAst.
5379 5380 5381 5382 |
# File 'lib/idl/ast.rb', line 5379 def initialize(input, interval, body_interval, cond, body_stmts) body = IfBodyAst.new(input, body_interval, body_stmts) super(input, interval, [cond, body]) end |
Instance Method Details
#body ⇒ Object
5377 |
# File 'lib/idl/ast.rb', line 5377 def body = @children[1] |
#cond ⇒ Object
5376 |
# File 'lib/idl/ast.rb', line 5376 def cond = @children[0] |
#return_value(symtab) ⇒ Object Originally defined in module Returns
#return_values(symtab) ⇒ Object
5400 5401 5402 5403 5404 5405 5406 5407 5408 |
# File 'lib/idl/ast.rb', line 5400 def return_values(symtab) value_result = value_try do return cond.value(symtab) ? body.return_values(symtab) : EMPTY_ARRAY end value_else(value_result) do # might be taken, so add the possible return values body.return_values(symtab) end end |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
5411 5412 5413 |
# File 'lib/idl/ast.rb', line 5411 def to_idl " else if (#{cond.to_idl}) { #{body.to_idl} }" end |
#type_check(symtab) ⇒ Object
5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 |
# File 'lib/idl/ast.rb', line 5384 def type_check(symtab) cond.type_check(symtab) cond_value = nil value_try do cond_value = cond.value(symtab) end unless cond.type(symtab).convertable_to?(:boolean) type_error "'#{cond.text_value}' is not boolean" end body.type_check(symtab) unless cond_value == false end |