Class ListLiteralGenerator

java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.ListLiteralGenerator
All Implemented Interfaces:
Function<ExprProcessingDetails, List<IRInstr>>

public final class ListLiteralGenerator extends AbstractGenerator implements Function<ExprProcessingDetails, List<IRInstr>>
Generates IR instructions for list literal expressions.

Handles the syntax: ["element1", "element2", ...]

IR Generation Strategy:
List literals emit a single LIST_LITERAL instruction containing:

  1. Setup instructions: element expression evaluation + RETAIN/SCOPE_REGISTER
  2. List literal details: collection type FQN, element temps, element count

The backend uses element count for pre-sized allocation (JVM: new ArrayList(N)) and element temps for bulk population via _addAss() calls.

Example:
["one", "two"] generates:

_temp1 = LIST_LITERAL org.ek9.lang::_List_HASH [size=2] [_temp2, _temp3]

Where setup instructions contain:

_temp2 = LOAD_LITERAL one, org.ek9.lang::String
RETAIN _temp2
SCOPE_REGISTER _temp2, _scope_1
_temp3 = LOAD_LITERAL two, org.ek9.lang::String
RETAIN _temp3
SCOPE_REGISTER _temp3, _scope_1