Class DictLiteralGenerator
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.DictLiteralGenerator
- All Implemented Interfaces:
Function<ExprProcessingDetails, List<IRInstr>>
public final class DictLiteralGenerator
extends AbstractGenerator
implements Function<ExprProcessingDetails, List<IRInstr>>
Generates IR instructions for dict literal expressions.
Handles the syntax: {"key1": value1, "key2": value2, ...}
IR Generation Strategy:
Dict literals emit a single DICT_LITERAL instruction containing:
- Setup instructions: key/value expression evaluation + RETAIN/SCOPE_REGISTER
- Dict literal details: collection type FQN, DictEntry type FQN, key/value type FQNs, key/value temp pairs, entry count
The backend creates the dict, then for each entry constructs a DictEntry wrapper
and calls _addAss(DictEntry) on the dict wrapper.
Example:
{"greeting": "hello", "farewell": "goodbye"} generates:
_temp1 = DICT_LITERAL org.ek9.lang::_Dict_HASH [size=2] [_temp2: _temp3, _temp4: _temp5]
-
Field Summary
Fields inherited from class AbstractGenerator
debugInfoCreator, instructionBuilder, MAX_MESSAGE_LENGTH, stackContext, typeNameOrException -
Constructor Summary
ConstructorsConstructorDescriptionDictLiteralGenerator(IRGenerationContext stackContext, GeneratorSet generators) Constructor for dict literal IR generator. -
Method Summary
Methods inherited from class AbstractGenerator
addCoverageProbe, createTempVariable, createTempVariableFromContext, extractReturnType, getRecordedSymbolOrException, processBlockStatements, processBlockStatements, truncateMessage, truncateMessage, validateNoPreFlowStatement, validateStatementFormOnly
-
Constructor Details
-
DictLiteralGenerator
DictLiteralGenerator(IRGenerationContext stackContext, GeneratorSet generators) Constructor for dict literal IR generator.- Parameters:
stackContext- IRGenerationContext for scope and symbol accessgenerators- GeneratorSet for accessing other generators (expression processor, etc.)
-
-
Method Details
-
apply
- Specified by:
applyin interfaceFunction<ExprProcessingDetails, List<IRInstr>>
-