Tea Java Runtime API
Version 3.1.0

com.pdmfc.tea.runtime
Class SLambdaFunctionVarArg

java.lang.Object
  |
  +--com.pdmfc.tea.runtime.SLambdaFunctionVarArg
All Implemented Interfaces:
SObjFunction

public class SLambdaFunctionVarArg
extends java.lang.Object
implements SObjFunction

A function defined inside a Tea program with a variable number of arguments. 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 proc is the return value of the last statement of the block.


Constructor Summary
  SLambdaFunctionVarArg(SObjSymbol argName, SObjBlock body)
          Initializes the new object.
protected SLambdaFunctionVarArg(SObjSymbol argName, SObjBlock body, int firstArg)
          Initializes the new object.
 
Method Summary
 java.lang.Object exec(SObjFunction obj, SContext context, java.lang.Object[] args)
          Executes the command.
protected  void initProcContext(SObjFunction func, SContext procContext, java.lang.Object[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLambdaFunctionVarArg

protected SLambdaFunctionVarArg(SObjSymbol argName,
                                SObjBlock body,
                                int firstArg)
Initializes the new object.
Parameters:
argName - The name of the local variable that will contain a list with the actual parameters at the time of the command execution.
block - Block of code, representing the body of the command.
firstArg - The index of the first argument to the command that counts as an argument.

SLambdaFunctionVarArg

public SLambdaFunctionVarArg(SObjSymbol argName,
                             SObjBlock body)
Initializes the new object.
Parameters:
argName - The name of the local variable that will contain a list with the actual parameters at the time of the command execution.
block - Block of code, representing the body of the command.
firstArg - The index of the first argument to the command that counts as an argument.
Method Detail

exec

public java.lang.Object exec(SObjFunction obj,
                             SContext context,
                             java.lang.Object[] args)
                      throws STeaException
Executes the command. A new context is created, descending from the context where the block was created. A local variable, named after the formal command parameter is initialized with the a list where the elements are 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.

initProcContext

protected void initProcContext(SObjFunction func,
                               SContext procContext,
                               java.lang.Object[] args)

Tea Java Runtime API
Version 3.1.0

© 2002 PDM&FC, All Rights Reserved.