Class: Idl::StatementAst

Inherits:
AstNode show all
Includes:
Executable
Defined in:
lib/idl/ast.rb

Overview

represents a simple, one-line statement

for example:

Bits<64> new_variable;
new_variable = 4;
func();

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, action) ⇒ StatementAst

Returns a new instance of StatementAst.



3752
3753
3754
# File 'lib/idl/ast.rb', line 3752

def initialize(input, interval, action)
  super(input, interval, [action])
end

Instance Method Details

#actionObject



3750
# File 'lib/idl/ast.rb', line 3750

def action = @children[0]

#execute(symtab) ⇒ void

This method returns an undefined value.

“execute” the statement by updating the variables in the symbol table

Parameters:

  • symtab (SymbolTable)

    The symbol table for the context

Raises:

  • ValueError if some part of the statement cannot be executed at compile time



3762
3763
3764
3765
3766
3767
3768
3769
# File 'lib/idl/ast.rb', line 3762

def execute(symtab)
  if action.is_a?(Declaration)
    action.add_symbol(symtab)
  end
  if action.is_a?(Executable)
    action.execute(symtab)
  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.

Parameters:

  • symtab (SymbolTable)

    The symbol table for the context

Raises:

  • ValueError if some part of the statement cannot be executed at compile time



3772
3773
3774
3775
3776
3777
3778
3779
# File 'lib/idl/ast.rb', line 3772

def execute_unknown(symtab)
  if action.is_a?(Declaration)
    action.add_symbol(symtab)
  end
  if action.is_a?(Executable)
    action.execute_unknown(symtab)
  end
end

#to_idlString

Return valid IDL representation of the node (and its subtree)

Returns:

  • (String)

    IDL code for the node



3782
# File 'lib/idl/ast.rb', line 3782

def to_idl = "#{action.to_idl};"

#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

Parameters:

Raises:



3757
3758
3759
# File 'lib/idl/ast.rb', line 3757

def type_check(symtab)
  action.type_check(symtab)
end