Class EnumPrimitiveOperatorGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.EnumPrimitiveOperatorGenerator
THE generator for the enumeration operators that are "primitive field in, at most one call, out"
(_eq, _cmp, _isSet, _string/_promote, _hashcode and _json); each operator is one row, a
EnumPrimitiveOperatorGenerator.Shape.
Enum fields are Java primitives (_ordinal int, _name java.lang.String, _isEnumSet boolean), so every one of these operators has the same skeleton:
[guard: this (and other) must be set -> return unset]
for each receiver (this, then other when binary):
prim = LOAD_FIELD receiver.field
ek9 = Ek9Type._of(prim)
[result = ek9(this)._call(ek9(other))]
STORE rtn; RETAIN rtn; BRANCH returnResult
[return-unset block]
return-result block
The ORDER of every generateLabelName and generateTempName call is what numbers labels and temporaries in the IR, so the skeleton keeps the order the six original classes used: labels first (unset, then result), then temporaries in body order. Enumeration operators with real bodies (first/last, increment/decrement, constructor, iterator, and the String-parameter comparisons) are not rows here.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordThe one call made on the converted receiver(s); a null call means the converted field IS the result.(package private) static enumWhich "is set" guards run before the body.(package private) static final recordOne row of the table: the operator, its return type, the guard, the primitive field loaded from each receiver, how that primitive converts to an EK9 type, and the optional call on the converted value.Nested classes/interfaces inherited from class AbstractSyntheticGenerator
AbstractSyntheticGenerator.CycleGuardEntry, AbstractSyntheticGenerator.ScopeSetup -
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext, synthesisedCallMetaData -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) EnumPrimitiveOperatorGenerator.Shape_cmp: ordinals compared with Integer._cmp.(package private) EnumPrimitiveOperatorGenerator.Shape_eq: ordinals compared with Integer._eq.generate(EnumPrimitiveOperatorGenerator.Shape shape, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) (package private) EnumPrimitiveOperatorGenerator.Shape_hashcode: the hashcode of the ordinal as an Integer.(package private) EnumPrimitiveOperatorGenerator.Shape_isSet: the _isEnumSet boolean converted to a Boolean; needs no guard, it IS the guard.(package private) EnumPrimitiveOperatorGenerator.Shape_json: the JSON of the name as a String.(package private) EnumPrimitiveOperatorGenerator.ShapestringShape(String methodName) _string and _promote (methodName): the _name converted to a String.Methods inherited from class AbstractSyntheticGenerator
aggregateHasOperator, constructorCall, createDebugInfo, createSynthesisScope, cycleTarget, differentTypeLabel, fieldTypeHasRealOperator, generateBinaryOperatorGuards, generateBooleanBranch, generateCycleGuardedRegion, generateCycleGuardEnter, generateFieldLoad, generateFieldLoad, generateFieldSetStatusCheck, generateIsSetGuard, generateIsSetGuard, generateLabelName, generatePoisonableCycleGuardedRegion, generateReplacingUnsetReturnBlockWithLabel, generateResultReturnBlock, generateResultReturnBlock, generateStringLiteralLoad, generateTempName, generateThisIsSetGuard, generateThisIsSetGuard, generateUnsetReturnBlockWithLabel, generateUnsetReturnBlockWithLabel, getAnyType, getAnyTypeName, getBitsType, getBitsTypeName, getBooleanType, getBooleanTypeName, getIntegerType, getIntegerTypeName, getReturnBlockHelper, getStringType, getStringTypeName, getSuperTypeName, getSyntheticFields, getType, getTypeName, getVoidTypeName, initializeScope, initializeScopeNoReturn, isAnyType, isTraitType, methodCall, nearestSuperOperator, needsCycleGuard, rendersNothing, returnVariableNameFor, runtimeTypeCheck, runUnderCycleGuard, servingOperatorParameterTypeName, superCallOwner, superCallParameterTypeName, superContributesRepresentation, superHasOperator
-
Constructor Details
-
EnumPrimitiveOperatorGenerator
EnumPrimitiveOperatorGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
equalsShape
EnumPrimitiveOperatorGenerator.Shape equalsShape()_eq: ordinals compared with Integer._eq. -
compareShape
EnumPrimitiveOperatorGenerator.Shape compareShape()_cmp: ordinals compared with Integer._cmp. -
isSetShape
EnumPrimitiveOperatorGenerator.Shape isSetShape()_isSet: the _isEnumSet boolean converted to a Boolean; needs no guard, it IS the guard. -
stringShape
_string and _promote (methodName): the _name converted to a String. -
hashCodeShape
EnumPrimitiveOperatorGenerator.Shape hashCodeShape()_hashcode: the hashcode of the ordinal as an Integer. -
jsonShape
EnumPrimitiveOperatorGenerator.Shape jsonShape()_json: the JSON of the name as a String. -
generate
List<IRInstr> generate(EnumPrimitiveOperatorGenerator.Shape shape, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
-