Node<T, E> class
abstract
Abstract base class for all AST nodes in the Balbismo compiler.
This class defines the fundamental structure and behavior that all AST nodes must implement. Each node represents a construct in the Balbismo language and is responsible for generating the corresponding LLVM IR code.
The generic type parameters provide type safety:
T
: The type of the node's value (e.g., String for identifiers, int for literals)E
: The type returned by the evaluate method (typicallyvoid
for statements, LangVal for expressions)
Key responsibilities of AST nodes:
- Code Generation: Generate LLVM IR instructions via the evaluate method
- Type Checking: Ensure type safety during compilation
- Symbol Resolution: Interact with the symbol table for variable/function lookup
- Error Reporting: Provide meaningful error messages for invalid constructs
All nodes automatically receive a unique ID for LLVM register naming and participate in the global LLVM IR generation process.
Constructors
Properties
-
children
→ List<
Node> -
Child nodes that form the structure of this node.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ int
-
Unique identifier for this node, used for LLVM register naming.
getter/setter pair
- nodeValue → T
-
The primary value associated with this node (varies by node type).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
evaluate(
SymbolTable table) → E - Evaluates this AST node and generates corresponding LLVM IR code.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- i ↔ int
-
Global counter for generating unique node IDs.
getter/setter pair
- ir ↔ String
-
Global LLVM IR code accumulator.
getter/setter pair
- irIndent ↔ int
-
Current indentation level for LLVM IR formatting.
getter/setter pair
- strCount ↔ int
-
Global counter for generating unique string constant names.
getter/setter pair
Static Methods
-
addConstantString(
String value) → String - Adds a string constant to the LLVM IR and returns its global name.
-
addHeaderIrLine(
String line) → dynamic - Adds a line to the LLVM IR header section.
-
addIrLine(
String line) → dynamic - Adds a line to the LLVM IR with current indentation.
-
addIrlLabel(
String label) → dynamic - Adds a labeled block to the LLVM IR and increases indentation.
-
endIrLabel(
) → dynamic - Ends a labeled block by decreasing indentation.
-
newId(
) → int - Generates a new unique ID for node identification.