| java.lang.Object gnu.mapping.PropertySet gnu.mapping.Procedure gnu.mapping.Procedure0 gnu.expr.Expression gnu.expr.ScopeExp gnu.expr.LambdaExp
All known Subclasses: gnu.expr.ModuleExp, gnu.expr.ClassExp,
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 True if any parameter default expression captures a parameter. | 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 public static int | NO_FIELD | final public static int | OVERLOADABLE_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. | 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. | public Expression[] | defaultArgs | 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. | Initializer | initChain Rembembers stuff to do in of this class. | public Keyword[] | keywords | public int | max_args Maximum number of actual arguments; -1 if variable. | public int | min_args Minumnum number of parameters.
Does not count implicit isThisParameter(). | public Declaration | nameDecl If non-null, a Declaration whose value is (only) this LambdaExp. | public LambdaExp | nextSibling | 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. | public 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 | ReferenceExp[] | throwsSpecification Expressions that name classes that may be thrown. | ClassType | type | final static ApplyExp | unknownContinuation A magic value to indicate there is no unique return continuation. |
Method Summary | |
final void | addApplyMethod(Compilation comp) | void | addMethodFor(Compilation comp, ObjectType closureEnvType) | void | addMethodFor(ClassType ctype, Compilation comp, ObjectType closureEnvType) | public void | allocChildClasses(Compilation comp) | void | allocChildMethods(Compilation comp) | Field | allocFieldFor(Compilation comp) | public void | allocFrame(Compilation comp) | void | allocParameters(Compilation comp) | public void | apply(CallContext ctx) | public void | capture(Declaration decl) | 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 | generateApplyMethods(Compilation comp) | Declaration | getArg(int i) Get the i'the formal parameter. | public int | getCallConvention() Specify the calling convention used for this function.
One of the CALL_WITH_xxx values in Compilation. | public LambdaExp | getCaller() For an INLINE_ONLY function, return the function it gets inlined in. | final public boolean | getCanCall() | final public boolean | getCanRead() | protected ClassType | getCompiledClassType(Compilation comp) Return the ClassType of the Procedure this is being compiled into. | final protected String | getExpClassName() | public ClassType | getHeapFrameType() | 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. | final 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. | 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 LambdaExp | getOwningLambda() | 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. | public Expression | inline(ApplyExp exp, InlineCalls walker, Declaration decl) | boolean | inlinedIn(LambdaExp outer) True if given LambdaExp is inlined in this function, perhaps indirectly.
Is false if this is not inline-only or if getCaller() is not inlined is
outer. | 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. | protected boolean | mustCompile() | 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) | public void | setExceptions(ReferenceExp[] exceptions) | final public void | setImportsLexVars(boolean importsLexVars) | final public void | setImportsLexVars() | final public void | setInlineOnly(boolean inlineOnly) | 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 void | setType(ClassType type) | 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) | | True if any parameter default expression captures a parameter.
|
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 public static int NO_FIELD(Code) | | |
OVERLOADABLE_FIELD | final public static int OVERLOADABLE_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.)
|
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 if 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.
|
max_args | public int max_args(Code) | | Maximum number of actual arguments; -1 if variable.
|
min_args | public int min_args(Code) | | Minumnum number of parameters.
Does not count implicit isThisParameter().
|
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 | public 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.
|
throwsSpecification | ReferenceExp[] throwsSpecification(Code) | | Expressions that name classes that may be thrown.
|
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) | | |
getCallConvention | public int getCallConvention()(Code) | | Specify the calling convention used for this function.
One of the CALL_WITH_xxx values in Compilation. |
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 | protected 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 | final 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.
|
inlinedIn | boolean inlinedIn(LambdaExp outer)(Code) | | True if given LambdaExp is inlined in this function, perhaps indirectly.
Is false if this is not inline-only or if getCaller() is not inlined is
outer. Usually the same as (this.outerLambdaNotInline()==outer),
except in the case that outer.getInlineOnly().
|
isClassGenerated | final public boolean isClassGenerated()(Code) | | True if a class is generated for this procedure.
|
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.
|
mustCompile | protected boolean mustCompile()(Code) | | |
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) | | |
Methods inherited from gnu.expr.ScopeExp | public void add(Declaration decl)(Code)(Java Doc) public void add(Declaration prev, Declaration decl)(Code)(Java Doc) final public Declaration addDeclaration(Object name)(Code)(Java Doc) final public Declaration addDeclaration(Object name, Type type)(Code)(Java Doc) final public void addDeclaration(Declaration decl)(Code)(Java Doc) public int countDecls()(Code)(Java Doc) public LambdaExp currentLambda()(Code)(Java Doc) public ModuleExp currentModule()(Code)(Java Doc) public static void duplicateDeclarationError(Declaration oldDecl, Declaration newDecl, Compilation comp)(Code)(Java Doc) public Declaration firstDecl()(Code)(Java Doc) public Declaration getDefine(Object name, char severity, Compilation parser)(Code)(Java Doc) public Declaration getNoDefine(Object name)(Code)(Java Doc) public Scope getVarScope()(Code)(Java Doc) public Declaration lookup(Object sym)(Code)(Java Doc) public Declaration lookup(Object sym, Language language, int namespace)(Code)(Java Doc) public static int nesting(ScopeExp sc)(Code)(Java Doc) public void popScope(CodeAttr code)(Code)(Java Doc) public void remove(Declaration decl)(Code)(Java Doc) public void remove(Declaration prev, Declaration decl)(Code)(Java Doc) public void replaceFollowing(Declaration prev, Declaration newDecl)(Code)(Java Doc) protected void setIndexes()(Code)(Java Doc) public String toString()(Code)(Java Doc) protected Expression walk(ExpWalker walker)(Code)(Java Doc)
|
Methods inherited from gnu.expr.Expression | public void apply(CallContext ctx) throws Throwable(Code)(Java Doc) final public Object apply0() throws Throwable(Code)(Java Doc) abstract public void compile(Compilation comp, Target target)(Code)(Java Doc) final public void compile(Compilation comp, Type type)(Code)(Java Doc) final public void compile(Compilation comp, Declaration lhs)(Code)(Java Doc) public static void compileButFirst(Expression exp, Compilation comp)(Code)(Java Doc) final public void compileNotePosition(Compilation comp, Target target, Expression position)(Code)(Java Doc) final public void compileWithPosition(Compilation comp, Target target)(Code)(Java Doc) final public void compileWithPosition(Compilation comp, Target target, Expression position)(Code)(Java Doc) final public Object eval(CallContext ctx) throws Throwable(Code)(Java Doc) final public Object eval(Environment env) throws Throwable(Code)(Java Doc) final public int getColumnNumber()(Code)(Java Doc) final public String getFileName()(Code)(Java Doc) public boolean getFlag(int flag)(Code)(Java Doc) public int getFlags()(Code)(Java Doc) final public int getLineNumber()(Code)(Java Doc) public String getPublicId()(Code)(Java Doc) public String getSystemId()(Code)(Java Doc) public Type getType()(Code)(Java Doc) public Expression inline(ApplyExp exp, InlineCalls walker, Declaration decl)(Code)(Java Doc) public boolean isStableSourceLocation()(Code)(Java Doc) public static Expression makeWhile(Object cond, Object body, Compilation parser)(Code)(Java Doc) final public int match0(CallContext ctx)(Code)(Java Doc) abstract protected boolean mustCompile()(Code)(Java Doc) final public void print(Consumer out)(Code)(Java Doc) abstract public void print(OutPort ps)(Code)(Java Doc) public void printLineColumn(OutPort out)(Code)(Java Doc) final public void setFile(String filename)(Code)(Java Doc) public void setFlag(boolean setting, int flag)(Code)(Java Doc) public void setFlag(int flag)(Code)(Java Doc) final public Expression setLine(Expression old)(Code)(Java Doc) final public void setLine(int lineno, int colno)(Code)(Java Doc) final public void setLine(int lineno)(Code)(Java Doc) public void setLine(Compilation comp)(Code)(Java Doc) final public void setLocation(SourceLocator location)(Code)(Java Doc) public boolean side_effects()(Code)(Java Doc) public String toString()(Code)(Java Doc) public Object valueIfConstant()(Code)(Java Doc) protected Expression walk(ExpWalker walker)(Code)(Java Doc) protected void walkChildren(ExpWalker walker)(Code)(Java Doc)
|
Methods inherited from gnu.mapping.Procedure | public void apply(CallContext ctx) throws Throwable(Code)(Java Doc) public static void apply(Procedure proc, CallContext ctx) throws Throwable(Code)(Java Doc) abstract public Object apply0() throws Throwable(Code)(Java Doc) abstract public Object apply1(Object arg1) throws Throwable(Code)(Java Doc) abstract public Object apply2(Object arg1, Object arg2) throws Throwable(Code)(Java Doc) abstract public Object apply3(Object arg1, Object arg2, Object arg3) throws Throwable(Code)(Java Doc) abstract public Object apply4(Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable(Code)(Java Doc) abstract public Object applyN(Object[] args) throws Throwable(Code)(Java Doc) public void check0(CallContext ctx)(Code)(Java Doc) public void check1(Object arg1, CallContext ctx)(Code)(Java Doc) public void check2(Object arg1, Object arg2, CallContext ctx)(Code)(Java Doc) public void check3(Object arg1, Object arg2, Object arg3, CallContext ctx)(Code)(Java Doc) public void check4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)(Code)(Java Doc) public static void checkArgCount(Procedure proc, int argCount)(Code)(Java Doc) public void checkN(Object[] args, CallContext ctx)(Code)(Java Doc) public Procedure getSetter()(Code)(Java Doc) public String getSourceLocation()(Code)(Java Doc) public int match0(CallContext ctx)(Code)(Java Doc) public int match1(Object arg1, CallContext ctx)(Code)(Java Doc) public int match2(Object arg1, Object arg2, CallContext ctx)(Code)(Java Doc) public int match3(Object arg1, Object arg2, Object arg3, CallContext ctx)(Code)(Java Doc) public int match4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)(Code)(Java Doc) public int matchN(Object[] args, CallContext ctx)(Code)(Java Doc) final public int maxArgs()(Code)(Java Doc) final public int minArgs()(Code)(Java Doc) public int numArgs()(Code)(Java Doc) public void set0(Object result) throws Throwable(Code)(Java Doc) public void set1(Object arg1, Object value) throws Throwable(Code)(Java Doc) public void setN(Object[] args) throws Throwable(Code)(Java Doc) public void setSetter(Procedure setter)(Code)(Java Doc) public void setSourceLocation(String file, int line)(Code)(Java Doc) public String toString()(Code)(Java Doc)
|
|
|