Class ReturnStmt
- java.lang.Object
-
- com.tonic.analysis.source.ast.stmt.ReturnStmt
-
-
Constructor Summary
Constructors Constructor Description ReturnStmt()Creates a void return statement.ReturnStmt(Expression value)Creates a return statement with an unknown location.ReturnStmt(Expression value, SourceLocation location)Creates a return statement and parents the value to it when present.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.List<ASTNode>getChildren()Lists the direct children a node holds, in source order.SourceLocationgetLocation()Gets the source location of this node.SourceTypegetMethodReturnType()ASTNodegetParent()Gets the parent node in the AST tree.ExpressiongetValue()booleanisVoidReturn()voidsetLocation(SourceLocation location)Sets this statement's source location.voidsetMethodReturnType(SourceType methodReturnType)Sets the declared return type of the enclosing method.voidsetParent(ASTNode parent)Sets the enclosing AST node.voidsetValue(Expression value)Replaces the returned expression, reparenting old and new nodes.StringtoString()ReturnStmtwithValue(Expression value)Replaces the returned expression, reparenting old and new nodes.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Constructor Detail
-
ReturnStmt
public ReturnStmt(Expression value, SourceLocation location)
Creates a return statement and parents the value to it when present.- Parameters:
value- the returned expression, or null for a void returnlocation- source location, or null for unknown
-
ReturnStmt
public ReturnStmt(Expression value)
Creates a return statement with an unknown location.- Parameters:
value- the returned expression, or null for a void return
-
ReturnStmt
public ReturnStmt()
Creates a void return statement.
-
-
Method Detail
-
getValue
public Expression getValue()
- Returns:
- the value
-
setValue
public void setValue(Expression value)
Replaces the returned expression, reparenting old and new nodes.- Parameters:
value- the new value, or null for a void return
-
getLocation
public SourceLocation getLocation()
Description copied from interface:ASTNodeGets the source location of this node.- Specified by:
getLocationin interfaceASTNode- Returns:
- the location
-
getParent
public ASTNode getParent()
Description copied from interface:ASTNodeGets the parent node in the AST tree.
-
setParent
public void setParent(ASTNode parent)
Sets the enclosing AST node.
-
getMethodReturnType
public SourceType getMethodReturnType()
- Returns:
- the method return type
-
setMethodReturnType
public void setMethodReturnType(SourceType methodReturnType)
Sets the declared return type of the enclosing method.- Parameters:
methodReturnType- the enclosing method's return type
-
isVoidReturn
public boolean isVoidReturn()
- Returns:
- true if this return has no value
-
withValue
public ReturnStmt withValue(Expression value)
Replaces the returned expression, reparenting old and new nodes.- Parameters:
value- the new value, or null for a void return- Returns:
- this statement
-
getChildren
public List<ASTNode> getChildren()
Description copied from interface:ASTNodeLists the direct children a node holds, in source order.- Specified by:
getChildrenin interfaceASTNode- Returns:
- the direct children, empty for a leaf
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
setLocation
public void setLocation(SourceLocation location)
Description copied from interface:StatementSets this statement's source location.- Specified by:
setLocationin interfaceStatement- Parameters:
location- the provenance to stamp, or null forSourceLocation.UNKNOWN
-
-