Class: Idl::IsaAst

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

Overview

top-level AST node

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Idl::AstNode

Instance Method Details

#add_global_symbols(symtab) ⇒ Object

Add all the global symbols to symtab

Parameters:



744
745
746
747
748
749
750
751
752
# File 'lib/idl/ast.rb', line 744

def add_global_symbols(symtab)
  raise "Symtab is not at global scope" unless symtab.levels == 1

  enums.each { |g| g.add_symbol(symtab) }
  bitfields.each { |g| g.add_symbol(symtab) }
  globals.each { |g| g.add_symbol(symtab) }
  structs.each { |g| g.add_symbol(symtab) }
  functions.each { |g| g.add_symbol(symtab) }
end

#bitfieldsArray<AstNode>

Returns List of all bitfield definitions.

Returns:

  • (Array<AstNode>)

    List of all bitfield definitions



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

def bitfields = definitions.select { |e| e.is_a?(BitfieldDefinitionAst) }

#definitionsObject



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

def definitions = children

#enumsArray<AstNode>

Returns List of all enum definitions.

Returns:

  • (Array<AstNode>)

    List of all enum definitions



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

def enums = definitions.select { |e| e.is_a?(EnumDefinitionAst) || e.is_a?(BuiltinEnumDefinitionAst) }

#functionsArray<AstNode>

Returns List of all function definitions.

Returns:

  • (Array<AstNode>)

    List of all function definitions



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

def functions = definitions.select { |e| e.is_a?(FunctionDefAst) }

#globalsArray<AstNode>

Returns List of all global variable definitions.

Returns:

  • (Array<AstNode>)

    List of all global variable definitions



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

def globals = definitions.select { |d| d.is_a?(GlobalWithInitializationAst) || d.is_a?(GlobalAst) }

#replace_include!(include_ast, isa_ast) ⇒ Object

replaces an include statement with the ast in that file, making it a direct child of this IsaAst

Parameters:



759
760
761
762
763
764
765
766
# File 'lib/idl/ast.rb', line 759

def replace_include!(include_ast, isa_ast)
  # find the index of the child
  idx = children.index(include_ast)
  internal_error "Can't find include ast in children" if idx.nil?

  @children[idx] = isa_ast.children
  @children.flatten!
end

#structsArray<AstNode>

Returns List of all struct definitions.

Returns:

  • (Array<AstNode>)

    List of all struct definitions



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

def structs = definitions.select { |e| e.is_a?(StructDefinitionAst) }

#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:



769
770
771
# File 'lib/idl/ast.rb', line 769

def type_check(symtab)
  definitions.each { |d| d.type_check(symtab) }
end