java.lang.Object
java.lang.Record
technology.sola.script.parser.Stmt.Return
- Record Components:
keyword- theTokenfor 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 while optionally returning a value for the caller to use.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReturn is an exception utilized by theInterpreterto throw when aStmt.Returnis being interpreted so that the wrappingSolaScriptFunctioncan 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> Raccept(Stmt.Visitor<R> visitor) Executes this statement via the desiredStmt.Visitorfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.keyword()Returns the value of thekeywordrecord component.final StringtoString()Returns a string representation of this record class.@Nullable Exprvalue()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
accept
Description copied from interface:StmtExecutes this statement via the desiredStmt.Visitor- Specified by:
acceptin interfaceStmt- Type Parameters:
R- the return type- Parameters:
visitor- theStmt.Visitorto 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 thekeywordrecord component.- Returns:
- the value of the
keywordrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-