evaluate method

  1. @override
LangVal<LangType> evaluate(
  1. SymbolTable table
)
override

Evaluates the integer literal by generating LLVM IR to create the constant value.

Uses the LLVM idiom of adding 0 to create a constant value, which allows the optimizer to recognize and optimize constant expressions.

Parameters:

  • table: The symbol table (not used for literals)

Returns: A LangVal containing the generated LLVM register and integer type

Implementation

@override
LangVal evaluate(SymbolTable table) {
  Node.addIrLine("%val$id = add i64 0, $nodeValue");
  return LangVal("%val$id", const PrimitiveType(PrimitiveTypes.int));
}