org.millscript.millscript.expr
Class LambdaExpr

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<Action>
      extended by org.millscript.millscript.expr.LambdaExpr
All Implemented Interfaces:
OneResult

public final class LambdaExpr
extends Expr<Action>
implements OneResult

This class implements a lambda expression. A lambda expression always returns a single result, which is a wrapped lambda function. A lambda expression can have a fixed or variable(with some fixed) number of arguments.

See Also:
DefineSyntax, LambdaFunction, MakeClosureAction

Constructor Summary
LambdaExpr(java.lang.String nm, org.millscript.commons.util.IList<NameExpr> a, NameExpr r, Expr<?> b)
          Creates a new lambda expression with the specified name, arguments and body expressions.
 
Method Summary
 Action compileIt()
          Compiles this expression into an action.
 org.millscript.commons.util.IList<NameExpr> getArgs()
          Returns the list of argument name expressions for this lambda expression.
 java.lang.String getName()
          Returns the name for this lamba expression.
 NameExpr getRest()
          Returns the name expression for the list of unspecified arguments to this lambda expression.
 void resolve(CompilerState state)
          Resolves any NameExpr in the tree so that they refer to the correct ident.
 
Methods inherited from class org.millscript.millscript.expr.Expr
arity, compile, isIntegerExpr, resolveList, setLineNumber, setOrigin, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LambdaExpr

public LambdaExpr(java.lang.String nm,
                  org.millscript.commons.util.IList<NameExpr> a,
                  NameExpr r,
                  Expr<?> b)
Creates a new lambda expression with the specified name, arguments and body expressions.

Parameters:
nm - a string containing the lambda expression name
a - a list of name expressions for the lambda expression arguments
r - a name expression for a list, to contain any additional arguments, or null
b - the lambda expression body expression
Method Detail

compileIt

public Action compileIt()
Description copied from class: Expr
Compiles this expression into an action.

Specified by:
compileIt in class Expr<Action>
Returns:
the Action for this expression
See Also:
Expr.compileIt()

getArgs

public org.millscript.commons.util.IList<NameExpr> getArgs()
Returns the list of argument name expressions for this lambda expression.

Returns:
a list of name expressions for this lambda expressions arguments.

getName

public java.lang.String getName()
Returns the name for this lamba expression.

Returns:
a String holding the lambda expression name

getRest

public NameExpr getRest()
Returns the name expression for the list of unspecified arguments to this lambda expression.

Returns:
a NameExpr for the list of unspecified arguments, or null

resolve

public void resolve(CompilerState state)
Description copied from class: Expr
Resolves any NameExpr in the tree so that they refer to the correct ident. e.g. This method is responsible for ensuring that references to a function argument in the body of a function actually refer to the correct value.

Specified by:
resolve in class Expr<Action>
Parameters:
state - the compiler state we are resolving in
See Also:
Expr.resolve(org.millscript.millscript.vm.CompilerState)


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.