Record Class DefStatement
java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.DefStatement
- Record Components:
exported-trueunless theprivatemodifier is presentname- the function name; must not be blankparameters- the typed parameter list; must not be nullreturnType- the declared return type; must not be nullbody- the scalar expression body; must not be nulllocation- 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 Summary
ConstructorsConstructorDescriptionDefStatement(boolean exported, String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body) Convenience constructor for tests; usesSourceLocation.UNKNOWN.DefStatement(boolean exported, String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body, SourceLocation location) Creates an instance of aDefStatementrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the value of thebodyrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanexported()Returns the value of theexportedrecord component.final inthashCode()Returns a hash code value for this object.location()Returns the value of thelocationrecord component.name()Returns the value of thenamerecord component.static DefStatementof(String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body) Creates an exported def statement (the common case).Returns the value of theparametersrecord component.Returns the value of thereturnTyperecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DefStatement
public DefStatement(boolean exported, String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body, SourceLocation location) Creates an instance of aDefStatementrecord class.- Parameters:
exported- the value for theexportedrecord componentname- the value for thenamerecord componentparameters- the value for theparametersrecord componentreturnType- the value for thereturnTyperecord componentbody- the value for thebodyrecord componentlocation- the value for thelocationrecord component
-
DefStatement
public DefStatement(boolean exported, String name, List<ParameterDefinition> parameters, ScalarType returnType, Operand body) Convenience constructor for tests; usesSourceLocation.UNKNOWN.
-
-
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
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. -
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. -
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 '=='. -
exported
public boolean exported()Returns the value of theexportedrecord component.- Returns:
- the value of the
exportedrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
parameters
Returns the value of theparametersrecord component.- Returns:
- the value of the
parametersrecord component
-
returnType
Returns the value of thereturnTyperecord component.- Returns:
- the value of the
returnTyperecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-
location
Returns the value of thelocationrecord component.
-