Record Class CallContext
java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase7.calls.CallContext
public record CallContext(ISymbol targetType, String targetVariable, String methodName, List<ISymbol> argumentTypes, List<String> argumentVariables, String scopeId, ISymbol returnType, org.antlr.v4.runtime.ParserRuleContext parseContext, boolean explicitSuperReceiver)
extends Record
Context information needed for resolving method calls and constructing CallDetails.
Contains all the information needed to perform cost-based method resolution
and parameter-by-parameter promotion checking.
-
Constructor Summary
ConstructorsConstructorDescriptionCallContext(ISymbol targetType, String targetVariable, String methodName, List<ISymbol> argumentTypes, List<String> argumentVariables, String scopeId, ISymbol returnType, org.antlr.v4.runtime.ParserRuleContext parseContext) Every call site that is not an explicitsuperreceiver - which is all of them but one.CallContext(ISymbol targetType, String targetVariable, String methodName, List<ISymbol> argumentTypes, List<String> argumentVariables, String scopeId, ISymbol returnType, org.antlr.v4.runtime.ParserRuleContext parseContext, boolean explicitSuperReceiver) Creates an instance of aCallContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargumentTypesrecord component.Returns the value of theargumentVariablesrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theexplicitSuperReceiverrecord component.static CallContextforBinaryOperation(ISymbol leftType, ISymbol rightType, ISymbol returnType, String methodName, String leftVariable, String rightVariable, String scopeId) Create context for binary operation: left.method(right)static CallContextforBinaryOperationWithContext(ISymbol leftType, ISymbol rightType, ISymbol returnType, String methodName, String leftVariable, String rightVariable, String scopeId, org.antlr.v4.runtime.ParserRuleContext parseContext) Create context for binary operation with parseContext: left.method(right) Used when Phase 3 has already resolved the method (e.g., switch case comparisons)static CallContextforFunctionCall(ISymbol targetType, List<ISymbol> argumentTypes, String methodName, String targetVariable, List<String> argumentVariables, String scopeId, EK9Parser.CallContext parseContext) Create context for function call: function(args...)static CallContextforPrimaryReferenceOperation(ISymbol leftType, ISymbol rightType, ISymbol returnType, String methodName, String leftVariable, String rightVariable, String scopeId, boolean isSuperReceiver) Create context for a method-based operator applied to an explicitthisorsuperprimary reference -super :=: source,super :~: source, and friends.static CallContextforUnaryOperation(ISymbol targetType, String methodName, String targetVariable, ISymbol returnType, String scopeId) Create context for unary operation: target.method()static CallContextforUnaryOperation(ISymbol targetType, String methodName, String targetVariable, ISymbol returnType, String scopeId, boolean isSuperReceiver) Context for a unary operator applied to an explicitsuperprimary reference -$super,#?super,$$super.final inthashCode()Returns a hash code value for this object.Returns the value of themethodNamerecord component.org.antlr.v4.runtime.ParserRuleContextReturns the value of theparseContextrecord component.Returns the value of thereturnTyperecord component.scopeId()Returns the value of thescopeIdrecord component.Returns the value of thetargetTyperecord component.Returns the value of thetargetVariablerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CallContext
public CallContext(ISymbol targetType, String targetVariable, String methodName, List<ISymbol> argumentTypes, List<String> argumentVariables, String scopeId, ISymbol returnType, org.antlr.v4.runtime.ParserRuleContext parseContext) Every call site that is not an explicitsuperreceiver - which is all of them but one.Kept so the shape fact can be added without touching call sites that cannot express it.
-
CallContext
public CallContext(ISymbol targetType, String targetVariable, String methodName, List<ISymbol> argumentTypes, List<String> argumentVariables, String scopeId, ISymbol returnType, org.antlr.v4.runtime.ParserRuleContext parseContext, boolean explicitSuperReceiver) Creates an instance of aCallContextrecord class.- Parameters:
targetType- the value for thetargetTyperecord componenttargetVariable- the value for thetargetVariablerecord componentmethodName- the value for themethodNamerecord componentargumentTypes- the value for theargumentTypesrecord componentargumentVariables- the value for theargumentVariablesrecord componentscopeId- the value for thescopeIdrecord componentreturnType- the value for thereturnTyperecord componentparseContext- the value for theparseContextrecord componentexplicitSuperReceiver- the value for theexplicitSuperReceiverrecord component
-
-
Method Details
-
forPrimaryReferenceOperation
public static CallContext forPrimaryReferenceOperation(ISymbol leftType, ISymbol rightType, ISymbol returnType, String methodName, String leftVariable, String rightVariable, String scopeId, boolean isSuperReceiver) Create context for a method-based operator applied to an explicitthisorsuperprimary reference -super :=: source,super :~: source, and friends.The receiver is emitted as a temp (the IR reads
_temp1 = LOAD super), so by the time CallDetails is built the super-ness is no longer visible in the receiver name. It has to travel with the context instead:super.m()names the PARENT's body specifically and MUST be a direct call. Deriving dispatch from the target's openness alone makes it virtual - a super class has to beas opento be extended at all - which on the LLVM back-end vtable-dispatches straight back into the override that issued the call, and recurses until the stack dies.- Parameters:
isSuperReceiver- true when the primary reference issuper, false forthis
-
forBinaryOperation
-
forBinaryOperationWithContext
public static CallContext forBinaryOperationWithContext(ISymbol leftType, ISymbol rightType, ISymbol returnType, String methodName, String leftVariable, String rightVariable, String scopeId, org.antlr.v4.runtime.ParserRuleContext parseContext) Create context for binary operation with parseContext: left.method(right) Used when Phase 3 has already resolved the method (e.g., switch case comparisons) -
forUnaryOperation
-
forUnaryOperation
public static CallContext forUnaryOperation(ISymbol targetType, String methodName, String targetVariable, ISymbol returnType, String scopeId, boolean isSuperReceiver) Context for a unary operator applied to an explicitsuperprimary reference -$super,#?super,$$super. LikeforPrimaryReferenceOperation(ISymbol, ISymbol, ISymbol, String, String, String, String, boolean), the super-ness has to travel with the context (isSuperReceiver) rather than the receiver name: it names the PARENT's operator specifically and MUST be a non-virtual (direct) call, otherwise virtual dispatch re-enters the override on the receiver's runtime type and recurses forever. -
forFunctionCall
public static CallContext forFunctionCall(ISymbol targetType, List<ISymbol> argumentTypes, String methodName, String targetVariable, List<String> argumentVariables, String scopeId, EK9Parser.CallContext parseContext) Create context for function call: function(args...) -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
targetType
Returns the value of thetargetTyperecord component.- Returns:
- the value of the
targetTyperecord component
-
targetVariable
Returns the value of thetargetVariablerecord component.- Returns:
- the value of the
targetVariablerecord component
-
methodName
Returns the value of themethodNamerecord component.- Returns:
- the value of the
methodNamerecord component
-
argumentTypes
-
argumentVariables
-
scopeId
Returns the value of thescopeIdrecord component.- Returns:
- the value of the
scopeIdrecord component
-
returnType
Returns the value of thereturnTyperecord component.- Returns:
- the value of the
returnTyperecord component
-
parseContext
public org.antlr.v4.runtime.ParserRuleContext parseContext()Returns the value of theparseContextrecord component.- Returns:
- the value of the
parseContextrecord component
-
explicitSuperReceiver
public boolean explicitSuperReceiver()Returns the value of theexplicitSuperReceiverrecord component.- Returns:
- the value of the
explicitSuperReceiverrecord component
-