Class IterationSourceLowering
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.IterationSourceLowering
THE lowering of an iteration SOURCE - shared by
for x in source (ForInGenerator) and a stream's
cat source (StreamStatementGenerator); use it, never a third copy.
The source is an expression evaluated into a fresh managed temp, or - when the expression names an enumeration
TYPE, a base enum or a CONSTRAINED one (IsEnumerationType) - an unset instance of that type
made by its default constructor, whose iterator() yields the enumeration's own values (a constrained
enum's subset). The two generators used to decide "is it an enumeration" differently: the stream tested only for
a base enum, so cat RedSuit loaded the type name as a local and failed JVM verification
(runtimeFuzz streamCatConstrainedEnum).
-
Field Summary
Fields inherited from class AbstractGenerator
stackContext, symbolTypeOrException, typeNameOrException, variableNameForIR -
Constructor Summary
ConstructorsConstructorDescriptionIterationSourceLowering(IRGenerationContext stackContext, GeneratorSet generators) -
Method Summary
Modifier and TypeMethodDescription(package private) StringenumInstanceForIteration(IAggregateSymbol enumType, DebugInfo debugInfo, List<IRInstr> instructions) An unset instance of an enumeration type, made by its default constructor, in a fresh managed temp.(package private) StringiteratorOf(IAggregateSymbol sourceType, String sourceVar, IAggregateSymbol iteratorType, DebugInfo debugInfo, List<IRInstr> instructions) sourceVar.iterator()into a fresh managed temp, typediteratorType.(package private) StringsourceValue(EK9Parser.ExpressionContext sourceCtx, IAggregateSymbol sourceType, DebugInfo debugInfo, List<IRInstr> instructions) The source's value in a fresh managed temp: the enumeration instance (enumInstanceForIteration(IAggregateSymbol, DebugInfo, List)) or the evaluated expression.
-
Constructor Details
-
IterationSourceLowering
IterationSourceLowering(IRGenerationContext stackContext, GeneratorSet generators)
-
-
Method Details
-
sourceValue
String sourceValue(EK9Parser.ExpressionContext sourceCtx, IAggregateSymbol sourceType, DebugInfo debugInfo, List<IRInstr> instructions) The source's value in a fresh managed temp: the enumeration instance (enumInstanceForIteration(IAggregateSymbol, DebugInfo, List)) or the evaluated expression. -
enumInstanceForIteration
String enumInstanceForIteration(IAggregateSymbol enumType, DebugInfo debugInfo, List<IRInstr> instructions) An unset instance of an enumeration type, made by its default constructor, in a fresh managed temp. The enumeration'siterator()does not readthis: it lists the type's own values. -
iteratorOf
String iteratorOf(IAggregateSymbol sourceType, String sourceVar, IAggregateSymbol iteratorType, DebugInfo debugInfo, List<IRInstr> instructions) sourceVar.iterator()into a fresh managed temp, typediteratorType.
-