Class OperationFactory
java.lang.Object
org.ek9lang.compiler.support.CommonFactory
org.ek9lang.compiler.support.OperationFactory
-
Field Summary
Fields inherited from class CommonFactory
aggregateManipulator, checkContextNotNull, parsedModule -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMethodsToAny(AggregateSymbol anyTypeSymbol) booleanA bit of a beast this method.voidCompletes a bare 'default operator' once types are known - THE second half ofaddMissingDefaultOperators(EK9Parser.DefaultOperatorContext, IAggregateSymbol).voidcompleteSameness(IAggregateSymbol aggregate, IToken bareToken) THE completion of a type's sameness once types are known (B18 - a type defines sameness once; Steve, 2026-09-30).New CallSymbol for switch case expression operator.newMethod(EK9Parser.MethodDeclarationContext ctx, String methodName, IScopedSymbol scopedSymbol) Create a new method with a specific name.newMethod(EK9Parser.MethodDeclarationContext ctx, IScopedSymbol scopedSymbol) Create a new method that represents an EK9 class/component method.newOperationCall(EK9Parser.OperationCallContext ctx, IScope scope) New call but modelled as an operator if marked as such.newOperator(EK9Parser.OperatorDeclarationContext ctx, IAggregateSymbol aggregate) Create a new aggregate that represents an EK9 operator, uses a method for this.newOperatorCall(String operator, EK9Parser.ExpressionContext ctx, IScope scope) Create a CallSymbol for an operator in an expression.Create a new aggregate that represents an EK9 type, constrained or enumeration.
-
Constructor Details
-
OperationFactory
OperationFactory(ParsedModule parsedModule)
-
-
Method Details
-
newOperator
public MethodSymbol newOperator(EK9Parser.OperatorDeclarationContext ctx, IAggregateSymbol aggregate) Create a new aggregate that represents an EK9 operator, uses a method for this. -
addMissingDefaultOperators
public boolean addMissingDefaultOperators(EK9Parser.DefaultOperatorContext ctx, IAggregateSymbol aggregate) A bit of a beast this method. Check if operator is not present if so add one in. But as it is used in very early phase of compilation not all types will be known. So here this method just uses the raw name of the method. -
completeBareDefaultOperators
public void completeBareDefaultOperators(EK9Parser.DefaultOperatorContext ctx, IAggregateSymbol aggregate) Completes a bare 'default operator' once types are known - THE second half ofaddMissingDefaultOperators(EK9Parser.DefaultOperatorContext, IAggregateSymbol). Phase 1 can only compare names, so an operator of the same NAME but taking a different argument (a Point's==(Integer)) hid the default==(Point): 'first == second' did not compile, and a defaulted<>relying on it crashed code generation (front-end audit FE74, F2).Here each default the type still lacks is generated when none of the type's OWN operators of that name accepts the default's arguments - exactly phase 1's rule, by signature instead of by name. An operator of the type itself that already accepts it (a user's
==(Any)) is never taken over, and inherited operators are ignored, as in phase 1 - so the result does not depend on the order types are processed in. The test isDefaultOperatorCoverage, which the editors share. -
completeSameness
THE completion of a type's sameness once types are known (B18 - a type defines sameness once; Steve, 2026-09-30). Runs at the end of EXPLICIT_TYPE_SYMBOL_DEFINITION, supers and traits first, before any call is resolved, soa < bfinds the generated operator.- A bare
default operatorgives the type defaulted sameness - a<=>, retracted later if a field cannot be ordered, leaving field-wise==- unless the type already inherits sameness (it is sealed where it is declared) or the author declared their own. - The comparisons are then ALWAYS generated from the sameness: from
<=>,==<><<=>>=; from==alone,<>; and#?with DEFAULTED sameness (hand-written sameness needs the author's#?, E07184). They are never written or requested (E07181), are markedGENERATED_FROM_SAMENESS, and carryDEFAULTED_BAREwhen the sameness itself is bare so they are retracted with it.
- Parameters:
aggregate- the type to completebareToken- the baredefault operatorof this type, if it has one
- A bare
-
newMethod
Create a new method that represents an EK9 class/component method. -
newMethod
public MethodSymbol newMethod(EK9Parser.MethodDeclarationContext ctx, String methodName, IScopedSymbol scopedSymbol) Create a new method with a specific name. -
newType
Create a new aggregate that represents an EK9 type, constrained or enumeration. -
newAny
-
addMethodsToAny
-
newOperationCall
New call but modelled as an operator if marked as such. -
newCaseExpressionCall
New CallSymbol for switch case expression operator. Every case expression represents an implicit operator call on the switch variable. If no explicit operator is provided, we infer equality (==). -
newOperatorCall
Create a CallSymbol for an operator in an expression. Same pattern as newCaseExpressionCall but for general binary/unary operators.
-