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.



3729
3730
3731
# File 'lib/idl/ast.rb', line 3729

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

Instance Method Details

#actionObject



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

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



3739
3740
3741
3742
3743
3744
3745
3746
# File 'lib/idl/ast.rb', line 3739

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



3749
3750
3751
3752
3753
3754
3755
3756
# File 'lib/idl/ast.rb', line 3749

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



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

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:



3734
3735
3736
# File 'lib/idl/ast.rb', line 3734

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