Class: Idl::IsaAst
Overview
top-level AST node
Instance Method Summary collapse
-
#add_global_symbols(symtab) ⇒ Object
Add all the global symbols to symtab.
-
#bitfields ⇒ Array<AstNode>
List of all bitfield definitions.
- #definitions ⇒ Object
-
#enums ⇒ Array<AstNode>
List of all enum definitions.
-
#functions ⇒ Array<AstNode>
List of all function definitions.
-
#globals ⇒ Array<AstNode>
List of all global variable definitions.
-
#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.
-
#structs ⇒ Array<AstNode>
List of all struct definitions.
-
#type_check(symtab) ⇒ void
type check this node and all children.
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
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 |
#bitfields ⇒ Array<AstNode>
Returns List of all bitfield definitions.
733 |
# File 'lib/idl/ast.rb', line 733 def bitfields = definitions.select { |e| e.is_a?(BitfieldDefinitionAst) } |
#definitions ⇒ Object
724 |
# File 'lib/idl/ast.rb', line 724 def definitions = children |
#enums ⇒ Array<AstNode>
Returns 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) } |
#functions ⇒ Array<AstNode>
Returns List of all function definitions.
739 |
# File 'lib/idl/ast.rb', line 739 def functions = definitions.select { |e| e.is_a?(FunctionDefAst) } |
#globals ⇒ Array<AstNode>
Returns 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
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 |
#structs ⇒ Array<AstNode>
Returns 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
769 770 771 |
# File 'lib/idl/ast.rb', line 769 def type_check(symtab) definitions.each { |d| d.type_check(symtab) } end |