Record Class CallEdge

java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase5.callgraph.CallEdge
Record Components:
caller - Fully-qualified name of the calling function/method
callee - Fully-qualified name of the called function/method
sourceToken - Token at the call site for error reporting
callType - Classification of the call (function, method, dispatcher, etc.)
isPolymorphic - True if this call may dispatch to multiple targets at runtime

public record CallEdge(String caller, String callee, IToken sourceToken, CallType callType, boolean isPolymorphic) extends Record
Represents an edge in the call graph from caller to callee. Each edge captures the source location and call type for precise error reporting.

The call graph uses fully-qualified names for callables to ensure uniqueness. For methods, the format is "module::ClassName._methodName" or "module::functionName".

  • Constructor Details

    • CallEdge

      public CallEdge(String caller, String callee, IToken sourceToken, CallType callType, boolean isPolymorphic)
      Create a call edge with validation.
  • Method Details

    • direct

      public static CallEdge direct(String caller, String callee, IToken token, CallType type)
      Create a direct (non-polymorphic) call edge.
    • polymorphic

      public static CallEdge polymorphic(String caller, String callee, IToken token, CallType type)
      Create a polymorphic call edge (dispatcher or trait method).
    • getSourceFile

      public String getSourceFile()
      Get the source file name from the token.
    • getLine

      public int getLine()
      Get the line number of the call site.
    • getColumn

      public int getColumn()
      Get the column position of the call site.
    • formatLocation

      public String formatLocation()
      Format the source location for error messages.
      Returns:
      Location string in format "filename:line:column"
    • toString

      @Nonnull public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • caller

      public String caller()
      Returns the value of the caller record component.
      Returns:
      the value of the caller record component
    • callee

      public String callee()
      Returns the value of the callee record component.
      Returns:
      the value of the callee record component
    • sourceToken

      public IToken sourceToken()
      Returns the value of the sourceToken record component.
      Returns:
      the value of the sourceToken record component
    • callType

      public CallType callType()
      Returns the value of the callType record component.
      Returns:
      the value of the callType record component
    • isPolymorphic

      public boolean isPolymorphic()
      Returns the value of the isPolymorphic record component.
      Returns:
      the value of the isPolymorphic record component