Class: Idl::PostIncrementExpressionAst
- Includes:
- Executable
- Defined in:
- lib/idl/ast.rb
Overview
represents a post-increment expression
for example:
i++
Instance Method Summary collapse
-
#execute(symtab) ⇒ void
“execute” the statement by updating the variables in the symbol table.
-
#execute_unknown(symtab) ⇒ void
“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.
-
#initialize(input, interval, rval) ⇒ PostIncrementExpressionAst
constructor
A new instance of PostIncrementExpressionAst.
- #rval ⇒ Object
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
-
#type(symtab) ⇒ Type
Given a specific symbol table, return the type of this node.
-
#type_check(symtab) ⇒ void
type check this node and all children.
Constructor Details
#initialize(input, interval, rval) ⇒ PostIncrementExpressionAst
Returns a new instance of PostIncrementExpressionAst.
3310 3311 3312 |
# File 'lib/idl/ast.rb', line 3310 def initialize(input, interval, rval) super(input, interval, [rval]) end |
Instance Method Details
#execute(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement by updating the variables in the symbol table
3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 |
# File 'lib/idl/ast.rb', line 3327 def execute(symtab) var = symtab.get(rval.text_value) value_result = value_try do internal_error "No symbol named '#{rval.text_value}'" if var.nil? value_error "#{rval.text_value} is not compile-time-known" if var.value.nil? var.value = var.value + 1 end value_else(value_result) do var.value = nil value_error "#{rval.text_value} is not compile-time-known" if var.value.nil? end end |
#execute_unknown(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.
3344 3345 3346 |
# File 'lib/idl/ast.rb', line 3344 def execute_unknown(symtab) symtab.get(rval.text_value).value = nil end |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
3349 |
# File 'lib/idl/ast.rb', line 3349 def to_idl = "#{rval.to_idl}++" |
#type(symtab) ⇒ Type
Given a specific symbol table, return the type of this node.
Should not be called until #type_check is called with the same arguments
3322 3323 3324 |
# File 'lib/idl/ast.rb', line 3322 def type(symtab) rval.type(symtab) end |
#type_check(symtab) ⇒ void
This method returns an undefined value.
type check this node and all children
Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError
3315 3316 3317 3318 3319 |
# File 'lib/idl/ast.rb', line 3315 def type_check(symtab) rval.type_check(symtab) var = symtab.get(rval.text_value) type_error "Post increment variable must be integral" unless var.type.integral? end |