Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java @ 13836:64c77f0577bb
More documentation and improvements of Simple Language
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 30 Jan 2014 17:53:27 -0800 |
parents | b16ec83edc73 |
children | afd6fa5e8229 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java Thu Jan 30 17:52:24 2014 -0800 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java Thu Jan 30 17:53:27 2014 -0800 @@ -27,6 +27,13 @@ import com.oracle.truffle.sl.nodes.*; import com.oracle.truffle.sl.runtime.*; +/** + * Implementation of the SL return statement. We need to unwind an unknown number of interpreter + * frames that are between this {@link SLReturnNode} and the {@link SLFunctionBodyNode} of the + * method we are exiting. This is done by throwing an {@link SLReturnException exception} that is + * caught by the {@link SLFunctionBodyNode#executeGeneric function body}. The exception transports + * the return value. + */ @NodeInfo(shortName = "return") public class SLReturnNode extends SLStatementNode { @@ -42,6 +49,7 @@ if (valueNode != null) { result = valueNode.executeGeneric(frame); } else { + /* Return statement that was not followed by an expression, so return the SL null value. */ result = SLNull.SINGLETON; } throw new SLReturnException(result);