Record Class DefStatement

java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.DefStatement
Record Components:
exported - true unless the private modifier is present
name - the function name; must not be blank
parameters - the typed parameter list; must not be null
returnType - the declared return type; must not be null
body - the scalar expression body; must not be null
location - the source location of this statement; never null
All Implemented Interfaces:
Statement

public record DefStatement(boolean exported, String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body, SourceLocation location) extends Record implements Statement
A def statement — defines a scalar user-defined function.

Syntax:

   def double(x: NUMBER): NUMBER := { x * 2 };

   def label(score: NUMBER): STRING := {
       CASE WHEN score >= 90 THEN "A" WHEN score >= 70 THEN "B" ELSE "C" END
   };

   private def helper(x: NUMBER): NUMBER := { x + 1 };
 

The body is a fully-parsed scalar Operand expression, produced by delegating the { ... } block to the operand parser.

A DefStatement corresponds directly to a ScalarFunctionSymbol with a non-empty body — the semantic layer creates the symbol and registers it in the symbol table.

  • Constructor Details

  • Method Details

    • of

      public static DefStatement of(String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body)
      Creates an exported def statement (the common case).
    • 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 '=='.
      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.
    • exported

      public boolean exported()
      Returns the value of the exported record component.
      Returns:
      the value of the exported record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • parameters

      public List<ParameterDefinition> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component
    • returnType

      public ScalarType returnType()
      Returns the value of the returnType record component.
      Returns:
      the value of the returnType record component
    • body

      public Operand body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface Statement
      Returns:
      the value of the location record component