com.pdmfc.tea.runtime
Class SLambdaFunction
java.lang.Object
|
+--com.pdmfc.tea.runtime.SLambdaFunction
- All Implemented Interfaces:
- SObjFunction
- public class SLambdaFunction
- extends java.lang.Object
- implements SObjFunction
A function defined inside a Tea program. A function is defined by
a list of symbols, that are its formal parameters, and a block,
that is the code to be executed when the command is invoked.
The block is executed in a new context. This new context is an
imediate descendent of the context where the block was
created. Before the block is actually executed, variables named
after the formal parameters are created and initialized with the
values with which the command was invoked. The return value of the
function is the return value of the last statement of the
block.
|
Method Summary |
java.lang.Object |
exec(SObjFunction func,
SContext context,
java.lang.Object[] args)
Executes the Tea function. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SLambdaFunction
public SLambdaFunction(SObjSymbol[] argNames,
SObjBlock body)
- Initializes the new object.
- Parameters:
argNames - List of symbols representing the formal parameters.block - Block of code, representing the body of the command.
exec
public java.lang.Object exec(SObjFunction func,
SContext context,
java.lang.Object[] args)
throws STeaException
- Executes the Tea function. A new context is created, descending
from the context where the block was created. Local variables,
named after the formal command parameters are initialized with the
values received as arguments.
This method is supposed to be called with args having at least
one element.
- Specified by:
exec in interface SObjFunction
- Parameters:
context - The context where this command is being invoked.args - Array with the arguments passed to the command.- Throws:
STeaException - Thrown if there is not two arguments for the command.
© 2002 PDM&FC, All Rights Reserved.