java.lang.Object
java.lang.Record
technology.sola.script.parser.Stmt.Return
- Record Components:
keyword
- theToken
for the return keywordvalue
- the value to return to the caller or null
- All Implemented Interfaces:
Stmt
- Enclosing interface:
- Stmt
public static record Stmt.Return(Token keyword, @Nullable Expr value)
extends Record
implements Stmt
Return statement exits a function or method while optionally returning a value for the caller to use.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Return is an exception utilized by theInterpreter
to throw when aStmt.Return
is being interpreted so that the wrappingSolaScriptFunction
can catch it and return the value as the result of theExpr.Call
.Nested classes/interfaces inherited from interface technology.sola.script.parser.Stmt
Stmt.Block, Stmt.Expression, Stmt.Function, Stmt.If, Stmt.Return, Stmt.Val, Stmt.Var, Stmt.Visitor<R>, Stmt.While
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R> R
accept
(Stmt.Visitor<R> visitor) Executes this statement via the desiredStmt.Visitor
final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.keyword()
Returns the value of thekeyword
record component.final String
toString()
Returns a string representation of this record class.@Nullable Expr
value()
Returns the value of thevalue
record component.
-
Constructor Details
-
Method Details
-
accept
Description copied from interface:Stmt
Executes this statement via the desiredStmt.Visitor
- Specified by:
accept
in interfaceStmt
- Type Parameters:
R
- the return type- Parameters:
visitor
- theStmt.Visitor
to execute this statement- Returns:
- the return value from the executed statement
-
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
keyword
Returns the value of thekeyword
record component.- Returns:
- the value of the
keyword
record component
-
value
Returns the value of thevalue
record component.- Returns:
- the value of the
value
record component
-