Class StringInterpolationAsmGenerator
java.lang.Object
org.ek9lang.compiler.backend.jvm.AbstractAsmGenerator
org.ek9lang.compiler.backend.jvm.StringInterpolationAsmGenerator
- All Implemented Interfaces:
Consumer<StringInterpolationInstr>
final class StringInterpolationAsmGenerator
extends AbstractAsmGenerator
implements Consumer<StringInterpolationInstr>
Generates JVM bytecode for STRING_INTERPOLATION IR instructions.
Each part is materialised as an org.ek9.lang.String (literals via
String._of(java.lang.String); variable parts are already EK9 Strings produced by the
instruction's setup $ conversions) and the parts are folded left with the EK9
+ operator String._add(String).
Using String._add (rather than StringConcatFactory/toString()) is
deliberate: EK9 is tri-state, and +/$ propagate unset. An interpolation is sugar
for "lit" + $x + "lit", so any UNSET part must yield an UNSET String — the same behaviour
as the native backend and the +/$ operators. StringConcatFactory would
coalesce an unset part to "" (via toString()), silently breaking tri-state.
-
Field Summary
Fields inherited from class AbstractAsmGenerator
classWriter, constructTargetTuple -
Constructor Summary
ConstructorsConstructorDescriptionStringInterpolationAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StringInterpolationInstr instr) Generate JVM bytecode for a string interpolation instruction.Methods inherited from class AbstractAsmGenerator
convertToJvmDescriptor, convertToJvmName, extractFieldName, generateBooleanLiteral, generateCharacterLiteral, generateDebugInfo, generateFloatLiteral, generateIntegerLiteral, generateLoadVariable, generateLocalVariableTable, generateMethodDescriptor, generateObjectLiteral, generateStackOperation, generateStoreVariable, generateStoreVariableAsInt, generateStringLiteral, getCurrentMethodVisitor, getFieldDescriptor, getMethodContext, getOrCreateLabel, getOwnerClassName, getVariableIndex, isFieldAccess, isVariableAllocated, isVariableFieldAccess, setCurrentMethodVisitor, setSharedMethodContext, toJvmFieldName, trackTempVariableFromLiteral, trackTempVariableFromLoad
-
Constructor Details
-
StringInterpolationAsmGenerator
StringInterpolationAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter)
-
-
Method Details
-
accept
Generate JVM bytecode for a string interpolation instruction.- Specified by:
acceptin interfaceConsumer<StringInterpolationInstr>
-