Record Class CallConventions

java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.data.CallConventions
Record Components:
ownedArguments - zero-based positions of the arguments the callee consumes
unmanagedResult - true when the result carries no count (an Ek9Async handle)
mayThrow - false only when the call is proven never to throw

public record CallConventions(Set<Integer> ownedArguments, boolean unmanagedResult, boolean mayThrow) extends Record
The ownership facts of one call (EK9_IR_OWNERSHIP_MODEL.md ยง5): which arguments the callee CONSUMES (every other argument is GUARANTEED - borrowed for the call), whether the result is OWNED (+1, the caller must end it) or UNMANAGED (no count at all), and whether the call may throw.

DEFAULT is exactly today's convention - arguments borrowed, result owned, may throw - so a call that says nothing means what every call has always meant. Only a difference from the default is rendered in the IR text.

  • Field Details

    • DEFAULT

      public static final CallConventions DEFAULT
      Arguments borrowed, result owned, may throw - today's meaning of every call.
  • Constructor Details

    • CallConventions

      public CallConventions(Set<Integer> ownedArguments, boolean unmanagedResult, boolean mayThrow)
      Creates an instance of a CallConventions record class.
      Parameters:
      ownedArguments - the value for the ownedArguments record component
      unmanagedResult - the value for the unmanagedResult record component
      mayThrow - the value for the mayThrow record component
  • Method Details

    • withUnmanagedResult

      public CallConventions withUnmanagedResult()
      The same conventions with an UNMANAGED result.
    • withOwnedArgument

      public CallConventions withOwnedArgument(int position)
      The same conventions with the argument at position consumed by the callee.
    • withNoThrow

      public CallConventions withNoThrow()
      The same conventions, proven never to throw.
    • consumesArgument

      public boolean consumesArgument(int position)
      True when the callee consumes the argument at position.
    • clauses

      public List<String> clauses()
      The bracket clauses that differ from DEFAULT, in a fixed order: owned=0,2, unmanaged, nothrow. Empty for the default.
    • toString

      public final 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.
    • ownedArguments

      public Set<Integer> ownedArguments()
      Returns the value of the ownedArguments record component.
      Returns:
      the value of the ownedArguments record component
    • unmanagedResult

      public boolean unmanagedResult()
      Returns the value of the unmanagedResult record component.
      Returns:
      the value of the unmanagedResult record component
    • mayThrow

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