| java.lang.Object gnu.expr.Expression gnu.expr.ScopeExp gnu.expr.LambdaExp
All known Subclasses: gnu.expr.MemberLambdaExp, gnu.expr.ModuleExp, gnu.expr.ClassExp, gnu.expr.ConstructorExp,
LambdaExp | public class LambdaExp extends ScopeExp (Code) | | Class used to implement Scheme lambda expressions.
author: Per Bothner |
Field Summary | |
final static int | CANNOT_INLINE | final static int | CAN_CALL | final static int | CAN_READ | final static int | CLASS_METHOD | final static int | DEFAULT_CAPTURES_ARG | final static int | IMPORTS_LEX_VARS | final static int | INLINE_ONLY | final static int | METHODS_COMPILED | final static int | NEEDS_STATIC_LINK | final protected static int | NEXT_AVAIL_FLAG | final static int | NO_FIELD | final public static int | SEQUENCE_RESULT | Vector | applyMethods Set of visible top-level LambdaExps that need apply methods. | Variable | argsArray | public Expression | body | Declaration | capturedVars A list of Declarations, chained using Declaration's nextCapturedVar.
All the Declarations are allocated in the current heapFrame. | Initializer | clinitChain Rembembers stuff to do in of this class. | Variable | closureEnv A variable that points to the closure environment passed in.
It can be any one of:
null, if no closure environment is needed;
this, if this object is its parent's heapFrame;
a local variable initialized from this.closureEnv;
a parameter (only if !getCanRead()); or
a copy of our caller's closureEnv or heapFrame (only if getInlineOnly()).
See declareClosureEnv and closureEnvField. | public Field | closureEnvField If non-null, this is a Field that is used for implementing lexical closures. | static int | counter | public Expression[] | defaultArgs | public static String | fileFunctionName The name to give to a dummy implicit function that surrounds a file. | public LambdaExp | firstChild | Variable | heapFrame A local variable that points to the heap-allocated part of the frame.
Each captured variable is a field in the heapFrame. | int | id Unique id number, to ease print-outs and debugging. | Initializer | initChain Rembembers stuff to do in of this class. | public Keyword[] | keywords | java.util.Hashtable | literalTable | Literal | literalsChain Rembembers literals to initialize (in ). | public int | max_args | public int | min_args | public String | name | public Declaration | nameDecl If non-null, a Declaration whose value is (only) this LambdaExp. | public LambdaExp | nextSibling | public java.util.Stack[] | parameterCopies | Method[] | primMethods Methods used to implement this functions. | Object[] | properties If non-null, a sequence of (key, value)-pairs.
These will be used to call setProperty at run-time. | public ApplyExp | returnContinuation The unique caller that calls this lambda.
The value is null, if no callers have been seen.
A value of unknownContinuation means there are multiple call sites.
Tail-recursive calls do not count as multiple call sites. | protected Type | returnType If non-null, the type of values returned by this function.
If null, the return type has not been set or calculated yet. | static Method | searchForKeywordMethod3 | static Method | searchForKeywordMethod4 | int | selectorValue If non-zero, the selector field of the ModuleMethod for this. | public Field | staticLinkField Field in heapFrame.getType() that contains the static link.
It is used by child functions to get to outer environments.
Its value is this function's closureEnv value. | Procedure | thisValue A cache if this has already been evaluated. | Variable | thisVariable | ClassType | type | final static ApplyExp | unknownContinuation A magic value to indicate there is no unique return continuation. |
Method Summary | |
final void | addApplyMethod(LambdaExp lexp) | void | addAttributes(AttrContainer bytecode) | public void | addBytecodeAttribute(Attribute a) List attributes that should be added to the main primitive method
generated for this lambdaExp. | void | addClassInitializer(Initializer elem) | void | addInitializer(Initializer elem) | void | addMethodFor(Compilation comp, ObjectType closureEnvType) | void | addMethodFor(ClassType ctype, Compilation comp, ObjectType closureEnvType) | public void | allocChildClasses(Compilation comp) | Field | allocFieldFor(Compilation comp) | public void | allocFrame(Compilation comp) | void | allocParameters(Compilation comp) | public void | compile(Compilation comp, Target target) | void | compileAsMethod(Compilation comp) | public void | compileBody(Compilation comp) | void | compileChildMethods(Compilation comp) | public void | compileEnd(Compilation comp) | public Field | compileSetField(Compilation comp) | public Variable | declareClosureEnv() | public Variable | declareThis(ClassType clas) | void | enterFunction(Compilation comp) | public void | forceGeneration() | void | generateClassInit(Compilation comp) | Declaration | getArg(int i) Get the i'the formal parameter. | public Type[] | getArgTypes() | public LambdaExp | getCaller() For an INLINE_ONLY function, return the function it gets inlined in. | final public boolean | getCanCall() | final public boolean | getCanRead() | public ClassType | getCompiledClassType(Compilation comp) Return the ClassType of the Procedure this is being compiled into. | final protected String | getExpClassName() | public ClassType | getHeapFrameType() | public LambdaExp | getHeapLambda() | final public boolean | getImportsLexVars() True iff this lambda "captures" (uses) lexical variables from outside. | final public boolean | getInlineOnly() True iff this lambda is only "called" inline. | Field | getInstanceField() | public Method | getMainMethod() Get the method that contains the actual body of the procedure. | final public Method | getMethod(int argCount) Select the method used given an argument count. | public String | getName() | final public boolean | getNeedsClosureEnv() | final public boolean | getNeedsStaticLink() True if a child lambda uses lexical variables from outside.
Hence, a child heapFrame needs a staticLink to outer frames. | public Object | getProperty(Object key, Object defaultValue) | final public Type | getReturnType() The return type of this function, i.e the type of its returned values. | int | getSelectorValue(Compilation comp) | public Type | getType() | public int | incomingArgs() Number of argument variable actually passed by the caller.
For functions that accept more than 4 argument, or take a variable number,
this is 1, since in that all arguments are passed in a single array. | final public boolean | isClassGenerated() True if a class is generated for this procedure. | final public boolean | isClassMethod() True if this is a method in an ClassExp. | final public boolean | isHandlingTailCalls() | final public boolean | isModuleBody() True iff this is the dummy top-level function of a module body. | public void | loadHeapFrame(Compilation comp) Generate code to load heapFrame on the JVM stack. | public ClassExp | outerClass() Return the englobing ClassExp or null. | public LambdaExp | outerLambda() | public LambdaExp | outerLambdaNotInline() Return the closest outer non-inlined LambdaExp. | public void | print(OutPort out) | final public Type | restArgType() Return the parameter type of the "keyword/rest" parameters. | void | setCallersNeedStaticLink() | final public void | setCanCall(boolean called) | final public void | setCanRead(boolean read) | final public void | setClassMethod(boolean isMethod) | final public void | setImportsLexVars(boolean importsLexVars) | final public void | setImportsLexVars() | final public void | setInlineOnly(boolean inlineOnly) | public void | setName(String name) | final public void | setNeedsStaticLink(boolean needsStaticLink) | final public void | setNeedsStaticLink() | public synchronized void | setProperty(Object key, Object value) | final public void | setReturnType(Type returnType) | public String | toString() | final public boolean | variable_args() | protected Expression | walk(ExpWalker walker) | protected void | walkChildren(ExpWalker walker) | final protected void | walkChildrenOnly(ExpWalker walker) | final protected void | walkProperties(ExpWalker walker) |
CANNOT_INLINE | final static int CANNOT_INLINE(Code) | | |
CAN_CALL | final static int CAN_CALL(Code) | | |
CAN_READ | final static int CAN_READ(Code) | | |
CLASS_METHOD | final static int CLASS_METHOD(Code) | | |
DEFAULT_CAPTURES_ARG | final static int DEFAULT_CAPTURES_ARG(Code) | | |
IMPORTS_LEX_VARS | final static int IMPORTS_LEX_VARS(Code) | | |
INLINE_ONLY | final static int INLINE_ONLY(Code) | | |
METHODS_COMPILED | final static int METHODS_COMPILED(Code) | | |
NEEDS_STATIC_LINK | final static int NEEDS_STATIC_LINK(Code) | | |
NEXT_AVAIL_FLAG | final protected static int NEXT_AVAIL_FLAG(Code) | | |
NO_FIELD | final static int NO_FIELD(Code) | | |
SEQUENCE_RESULT | final public static int SEQUENCE_RESULT(Code) | | |
applyMethods | Vector applyMethods(Code) | | Set of visible top-level LambdaExps that need apply methods.
|
capturedVars | Declaration capturedVars(Code) | | A list of Declarations, chained using Declaration's nextCapturedVar.
All the Declarations are allocated in the current heapFrame.
|
closureEnv | Variable closureEnv(Code) | | A variable that points to the closure environment passed in.
It can be any one of:
null, if no closure environment is needed;
this, if this object is its parent's heapFrame;
a local variable initialized from this.closureEnv;
a parameter (only if !getCanRead()); or
a copy of our caller's closureEnv or heapFrame (only if getInlineOnly()).
See declareClosureEnv and closureEnvField.
|
closureEnvField | public Field closureEnvField(Code) | | If non-null, this is a Field that is used for implementing lexical closures.
If getName() is "closureEnv", it is our parent's heapFrame,
which is an instance of one of our siblings.
(Otherwise, we use "this" as the implicit "closureEnv" field.)
|
counter | static int counter(Code) | | |
fileFunctionName | public static String fileFunctionName(Code) | | The name to give to a dummy implicit function that surrounds a file.
|
heapFrame | Variable heapFrame(Code) | | A local variable that points to the heap-allocated part of the frame.
Each captured variable is a field in the heapFrame. A procedure has
a heapFrame iff it has a parameter or local variable that is
referenced ("captured") by a non-inline inferior procedure.
(I.e there is a least one non-inline procedure that encloses the
reference but not the definition.) Note that an inline procedure may
have a heapFrame if it encloses a non-inline procedure. This is
necessary because we represent loops as tail-recursive inline procedures.
|
id | int id(Code) | | Unique id number, to ease print-outs and debugging.
|
literalsChain | Literal literalsChain(Code) | | Rembembers literals to initialize (in ).
|
max_args | public int max_args(Code) | | |
min_args | public int min_args(Code) | | |
nameDecl | public Declaration nameDecl(Code) | | If non-null, a Declaration whose value is (only) this LambdaExp.
|
primMethods | Method[] primMethods(Code) | | Methods used to implement this functions.
primMethods[0] is used if the argument count is min_args;
primMethods[1] is used if the argument count is min_args+1;
primMethods[primMethods.length-1] is used otherwise.
|
properties | Object[] properties(Code) | | If non-null, a sequence of (key, value)-pairs.
These will be used to call setProperty at run-time.
|
returnContinuation | public ApplyExp returnContinuation(Code) | | The unique caller that calls this lambda.
The value is null, if no callers have been seen.
A value of unknownContinuation means there are multiple call sites.
Tail-recursive calls do not count as multiple call sites. (With a
little more analysis, we could also allow multiple non-self tail-calls
as long as they all are ultimately called from the same place.)
This is used to see if we can inline the function at its unique
call site.
|
returnType | protected Type returnType(Code) | | If non-null, the type of values returned by this function.
If null, the return type has not been set or calculated yet.
|
searchForKeywordMethod3 | static Method searchForKeywordMethod3(Code) | | |
searchForKeywordMethod4 | static Method searchForKeywordMethod4(Code) | | |
selectorValue | int selectorValue(Code) | | If non-zero, the selector field of the ModuleMethod for this.
|
staticLinkField | public Field staticLinkField(Code) | | Field in heapFrame.getType() that contains the static link.
It is used by child functions to get to outer environments.
Its value is this function's closureEnv value.
|
thisValue | Procedure thisValue(Code) | | A cache if this has already been evaluated.
|
unknownContinuation | final static ApplyExp unknownContinuation(Code) | | A magic value to indicate there is no unique return continuation.
|
LambdaExp | public LambdaExp()(Code) | | |
LambdaExp | public LambdaExp(int args)(Code) | | |
addBytecodeAttribute | public void addBytecodeAttribute(Attribute a)(Code) | | List attributes that should be added to the main primitive method
generated for this lambdaExp.
|
forceGeneration | public void forceGeneration()(Code) | | |
getCaller | public LambdaExp getCaller()(Code) | | For an INLINE_ONLY function, return the function it gets inlined in.
|
getCanCall | final public boolean getCanCall()(Code) | | |
getCanRead | final public boolean getCanRead()(Code) | | |
getCompiledClassType | public ClassType getCompiledClassType(Compilation comp)(Code) | | Return the ClassType of the Procedure this is being compiled into.
|
getExpClassName | final protected String getExpClassName()(Code) | | |
getImportsLexVars | final public boolean getImportsLexVars()(Code) | | True iff this lambda "captures" (uses) lexical variables from outside.
|
getInlineOnly | final public boolean getInlineOnly()(Code) | | True iff this lambda is only "called" inline.
|
getMainMethod | public Method getMainMethod()(Code) | | Get the method that contains the actual body of the procedure.
(The other methods are just stubs that call that method.)
|
getMethod | final public Method getMethod(int argCount)(Code) | | Select the method used given an argument count.
|
getNeedsClosureEnv | final public boolean getNeedsClosureEnv()(Code) | | |
getNeedsStaticLink | final public boolean getNeedsStaticLink()(Code) | | True if a child lambda uses lexical variables from outside.
Hence, a child heapFrame needs a staticLink to outer frames.
|
getReturnType | final public Type getReturnType()(Code) | | The return type of this function, i.e the type of its returned values.
|
incomingArgs | public int incomingArgs()(Code) | | Number of argument variable actually passed by the caller.
For functions that accept more than 4 argument, or take a variable number,
this is 1, since in that all arguments are passed in a single array.
|
isClassGenerated | final public boolean isClassGenerated()(Code) | | True if a class is generated for this procedure.
We don't need a class if this is only called inline.
We also don't need a class if all callers are known, and we can
invoke a method for this procedure.
However, the last optimization is not available when using tail calls.
|
isClassMethod | final public boolean isClassMethod()(Code) | | True if this is a method in an ClassExp.
|
isHandlingTailCalls | final public boolean isHandlingTailCalls()(Code) | | |
isModuleBody | final public boolean isModuleBody()(Code) | | True iff this is the dummy top-level function of a module body.
|
loadHeapFrame | public void loadHeapFrame(Compilation comp)(Code) | | Generate code to load heapFrame on the JVM stack.
|
outerClass | public ClassExp outerClass()(Code) | | Return the englobing ClassExp or null.
|
outerLambdaNotInline | public LambdaExp outerLambdaNotInline()(Code) | | Return the closest outer non-inlined LambdaExp.
|
restArgType | final public Type restArgType()(Code) | | Return the parameter type of the "keyword/rest" parameters.
|
setCallersNeedStaticLink | void setCallersNeedStaticLink()(Code) | | |
setCanCall | final public void setCanCall(boolean called)(Code) | | |
setCanRead | final public void setCanRead(boolean read)(Code) | | |
setClassMethod | final public void setClassMethod(boolean isMethod)(Code) | | |
setImportsLexVars | final public void setImportsLexVars(boolean importsLexVars)(Code) | | |
setImportsLexVars | final public void setImportsLexVars()(Code) | | |
setInlineOnly | final public void setInlineOnly(boolean inlineOnly)(Code) | | |
setNeedsStaticLink | final public void setNeedsStaticLink(boolean needsStaticLink)(Code) | | |
setNeedsStaticLink | final public void setNeedsStaticLink()(Code) | | |
setReturnType | final public void setReturnType(Type returnType)(Code) | | |
variable_args | final public boolean variable_args()(Code) | | |
walkChildrenOnly | final protected void walkChildrenOnly(ExpWalker walker)(Code) | | |
|
|