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) ⇒ Integer, ...
included
from Returns
Evaluate the compile-time return value of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on the taken path), execute the node and update the symtab.
-
#return_values(symtab) ⇒ Array<Integer>, Array<Boolean>
Evaluate all possible compile-time return values of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on a possible path), execute the node and update the symtab.
-
#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.
5414 5415 5416 5417 |
# File 'lib/idl/ast.rb', line 5414 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
#return_value(symtab) ⇒ Integer, ... Originally defined in module Returns
Evaluate the compile-time return value of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on the taken path), execute the node and update the symtab
#return_values(symtab) ⇒ Array<Integer>, Array<Boolean>
Evaluate all possible compile-time return values of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on a possible path), execute the node and update the symtab
5435 5436 5437 5438 5439 5440 5441 5442 5443 |
# File 'lib/idl/ast.rb', line 5435 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)
5446 5447 5448 |
# File 'lib/idl/ast.rb', line 5446 def to_idl " else if (#{cond.to_idl}) { #{body.to_idl} }" end |
#type_check(symtab) ⇒ Object
[View source]
5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 |
# File 'lib/idl/ast.rb', line 5419 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 |