Class SynthesisedCallMetaData

java.lang.Object
org.ek9lang.compiler.phase7.calls.SynthesisedCallMetaData

public final class SynthesisedCallMetaData extends Object
THE way a phase-7 SYNTHESISED call site obtains its CallMetaDataDetails. Use this - never hand-write new CallMetaDataDetails(true, 0).

Call metadata (purity, complexity, side-effects) is a property of the callee, and for a callee that is part of the EK9 language surface it is a fact about the program: the user wrote as pure, phase 5 measured the complexity from their code, and an AI can change either by editing source. Fabricating a constant here asserts a measured-looking falsehood about user code - ? and <=> are user-overridable, so a hard-coded (true, 0) reports a user's impure or complex operator as pure with zero complexity. Phase 12 gates fusability on exactly this field, so a fabricated pure=true is strictly worse than no answer at all.

A site reaching for this must be calling a real EK9 method or operator. Compiler↔runtime plumbing (_true, _false, _ofTrue, _ofFalse, _set, _of, and the Ek9Async/Ek9Group/... stream helpers) has no EK9 symbol for the callee because it is not EK9 surface at all - it is the compiler's own lowering, which no edit can affect. Those sites must carry no metadata clause, not a fabricated one.

There are exactly TWO honest sources, in preference order: the resolved callee symbol (which carries the user's authored purity and phase 5's measured complexity), and - when the target declares no resolvable member - the OperatorMap declaration of that operator. Anything else is a fabrication. Failing both, this throws rather than silently reintroducing a default tuple.

See Also:
  • Constructor Details

    • SynthesisedCallMetaData

      public SynthesisedCallMetaData(IRGenerationContext stackContext)
    • SynthesisedCallMetaData

      public SynthesisedCallMetaData(Ek9Types ek9Types)
      For generators that hold Ek9Types directly rather than a full generation context - the Scenario 2 wrapper generators. Resolution needs no context at all; only the extraction does.
  • Method Details

    • fromOperatorDeclaration

      public static CallMetaDataDetails fromOperatorDeclaration(String methodName)
      THE OperatorMap-derived metadata for a declared EK9 operator - the second honest source, used when the target type carries no resolvable member for the callee.

      The live case is an operator on a function type: delegate? lowers to _isSet on a FunctionSymbol, which is not an aggregate and so has no members to resolve. Nothing is lost by reading the declaration instead of a symbol - a function's ? is fixed language surface, not something a user can override. This is the same derivation the parsed path uses for a path-B operator, and both callers share this method so the two cannot drift.

      Throws:
      CompilerException - when the name is not a declared operator either - then there is no honest source and the site is either a phase 3 gap or compiler plumbing
    • forNamedOperatorOnly

      public static CallMetaDataDetails forNamedOperatorOnly(String methodName)
      The honest metadata for a callee with NO target symbol available at all - the OperatorMap declaration where the name is a declared EK9 operator, otherwise no clause. For callers that hold neither a generation context nor a target type, such as the synthesis method-call builder.
    • apply

      public CallMetaDataDetails apply(ISymbol targetType, String methodName)
      Metadata for a zero-argument call (operand._isSet(), resource._close()).
    • forConstructor

      public CallMetaDataDetails forConstructor(ISymbol targetType, List<ISymbol> argumentTypes)
      Metadata for a CONSTRUCTOR call on the given type - the default constructor when argumentTypes is empty, otherwise the matching overload (e.g. the copy constructor).

      Constructors are keyed in the symbol table by the aggregate's UNQUALIFIED name (see AggregateManipulator.addConstructorIfRequired), which is the one thing a caller reaching for apply(ISymbol, String) would get wrong. Route constructors through here so that naming rule lives in one place. A user's constructor can be impure and arbitrarily complex, so the copy-on-access and range-iteration lowerings must not keep asserting a fixed (true, 1, RETURN_MUTATION).

    • forSynthesisedCallee

      public CallMetaDataDetails forSynthesisedCallee(ISymbol target, String methodName, List<ISymbol> argumentTypes)
      Metadata for a callee the COMPILER itself synthesised, where a symbol may legitimately not exist - returns null, meaning no metadata clause, when there is nothing measured to report.

      Use this ONLY where the callee is known to be compiler-generated: a dynamic function's constructor (a FunctionSymbol is not an aggregate, so it has no resolvable members), or an application lifecycle method such as _prepare. Every other site must use apply(ISymbol, String) and fail loud, because for a real EK9 callee a resolution miss is a bug, not an absence.

      Resolution tries the aggregate-member route first and then the construct's own SCOPE, which is what reaches a function's members. Returning null rather than a default tuple keeps the two-state rule: metadata read from a symbol, or no clause at all. Recording something here would mean measuring the synthesised body, which phase 5 - being parse-tree driven - never visits.

    • forSynthesisedConstructor

      public CallMetaDataDetails forSynthesisedConstructor(ISymbol targetType, List<ISymbol> argumentTypes)
      A compiler-synthesised CONSTRUCTOR - see forSynthesisedCallee(ISymbol, String, List). Constructors are keyed by the target's unqualified name.
    • apply

      public CallMetaDataDetails apply(ISymbol targetType, String methodName, List<ISymbol> argumentTypes)
      Resolve methodName(argumentTypes) on targetType and read the metadata off the resolved callee.
      Parameters:
      targetType - the type the call is made ON, as a resolved SYMBOL (never an FQN String)
      methodName - the JVM method name (_isSet), EK9 name (?) or, for a constructor, the target type's unqualified name
      argumentTypes - resolved argument types, driving overload selection
      Returns:
      the callee's measured metadata
      Throws:
      CompilerException - when neither honest source has an answer