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.

[View source]

643
644
645
646
# File 'lib/idl/ast.rb', line 643

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

[View source]

663
664
665
666
667
668
# File 'lib/idl/ast.rb', line 663

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

[View source]

671
672
673
# File 'lib/idl/ast.rb', line 671

def to_idl
  var_decl_with_init.to_idl
end

#type(symtab) ⇒ Object

[View source]

654
655
656
# File 'lib/idl/ast.rb', line 654

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

#type_check(symtab) ⇒ Object

[View source]

649
650
651
# File 'lib/idl/ast.rb', line 649

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

#value(symtab) ⇒ Object

[View source]

659
660
661
# File 'lib/idl/ast.rb', line 659

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

#var_decl_with_initVariableDeclationWithInitializationAst

Returns The initializer.

Returns:

  • (VariableDeclationWithInitializationAst)

    The initializer

[View source]

639
640
641
# File 'lib/idl/ast.rb', line 639

def var_decl_with_init
  @children[0]
end