Class: Idl::GlobalWithInitializationAst

Inherits:
AstNode
  • Object
show all
Includes:
Declaration, Executable
Defined in:
lib/idl/ast.rb

Overview

global variable declared with an initializer,

e.g.,

Bits<65> UNDEFINED_LEGAL = 65’h10000000000000000; Bits<FLEN> f = [0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0];

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, var_decl_with_init) ⇒ GlobalWithInitializationAst

Returns a new instance of GlobalWithInitializationAst.



641
642
643
644
# File 'lib/idl/ast.rb', line 641

def initialize(input, interval, var_decl_with_init)
  super(input, interval, [var_decl_with_init])
  var_decl_with_init.make_global
end

Instance Method Details

#add_symbol(symtab) ⇒ Object



661
662
663
664
665
666
# File 'lib/idl/ast.rb', line 661

def add_symbol(symtab)
  raise "Symtab should be at global scope" unless symtab.levels == 1

  # globals never have a compile-time value
  var_decl_with_init.add_symbol(symtab)
end

#execute(symtab) ⇒ void Originally defined in module Executable

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

#execute_unknown(symtab) ⇒ void Originally defined in module Executable

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

#to_idlObject



669
670
671
# File 'lib/idl/ast.rb', line 669

def to_idl
  var_decl_with_init.to_idl
end

#type(symtab) ⇒ Object



652
653
654
# File 'lib/idl/ast.rb', line 652

def type(symtab)
  var_decl_with_init.type(symtab)
end

#type_check(symtab) ⇒ Object



647
648
649
# File 'lib/idl/ast.rb', line 647

def type_check(symtab)
  var_decl_with_init.type_check(symtab)
end

#value(symtab) ⇒ Object



657
658
659
# File 'lib/idl/ast.rb', line 657

def value(symtab)
  var_decl_with_init.value(symtab)
end

#var_decl_with_initVariableDeclationWithInitializationAst

Returns The initializer.

Returns:

  • (VariableDeclationWithInitializationAst)

    The initializer



637
638
639
# File 'lib/idl/ast.rb', line 637

def var_decl_with_init
  @children[0]
end