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:

  1. Setup instructions: key/value expression evaluation + RETAIN/SCOPE_REGISTER
  2. 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]