| java.lang.Object oscript.compiler.CompilerScope
CompilerScope | public class CompilerScope (Code) | | This class helps the compiler track declarations of variables within a
scope, in order to optimize resolving references to variables by caching
and, when possible, statically resolving the reference in order to avoid
performing the normal hashtable lookup(s). It is also responsible for
generating the
Scope.createMember and
Scope.lookupInScope code, so that the rest of the compiler does not need to worry about what
optimization strategy (if any) is used to resolve references.
Note that this class is fairly tightly coupled to
CompilerVisitor .
It would be an inner class if it were not for file size issues.
author: Rob Clark (rob@ti.com) version: 0 |
Field Summary | |
CompilerVisitor | cv The compiler for the compiled unit within which this scope is
declared. |
Constructor Summary | |
| CompilerScope(CompilerVisitor cv, int slot, int[] argIds) | | CompilerScope(CompilerVisitor cv, CompilerScope prev, boolean hasFxnInScope) Constructor to represent a scope constructed by this node-evaluator.
Parameters: cv - the compiler that declares this scope Parameters: prev - the enclosing scope Parameters: hasFxnInScope - a flag from the parser indicating if there is(or might be) a function declaration within this scope. |
CompilerScope | CompilerScope(CompilerVisitor cv, int slot, int[] argIds)(Code) | | Constructor for scope to represent a scope passed in to the
node-evaluator, rather than constructed by the node-evaluator
Parameters: cv - the compiler that declares this scope Parameters: slot - the local variable slot of the externally constructedscope object Parameters: argIds - array of argument ids and attributes |
CompilerScope | CompilerScope(CompilerVisitor cv, CompilerScope prev, boolean hasFxnInScope)(Code) | | Constructor to represent a scope constructed by this node-evaluator.
Parameters: cv - the compiler that declares this scope Parameters: prev - the enclosing scope Parameters: hasFxnInScope - a flag from the parser indicating if there is(or might be) a function declaration within this scope. If thereis no function in this scope, scope storage can be allocated fromthe stack |
createMember | void createMember(NodeToken id, int attr)(Code) | | Generate the
Scope.createMember call. The code is generated
at the current position in the compiler that this scope is declared
in. Stack:
... -> ... , Value
Parameters: id - the <IDENTIFIER> token Parameters: attr - the permissions attribute |
enterConditional | void enterConditional()(Code) | | Called by the compiler to indicate that compilation has entered a
potentially condional path within this scope. (It does not matter
if this scope is entirely enclosed by a conditional path, what does
matter is a conditional path enclosed by this scope.)
See Also: CompilerScope.leaveConditional |
getSharedMemberIndexTableIdxs | int[] getSharedMemberIndexTableIdxs()(Code) | | Get the instance-constant indexs of the SMIT... this is needed for the
topmost CompilerScope in a function, so that the compiler can generate
an accessor method.
|
getSlot | int getSlot()(Code) | | Get the slot for the local variable that refers to this scope object
|
inConditional | boolean inConditional()(Code) | | |
leaveConditional | void leaveConditional()(Code) | | Called by the compiler to indicate that compilation has left a
potentially conditional path within this scope.
See Also: CompilerScope.enterConditional |
markOpen | void markOpen()(Code) | | Mark this scope as open. An open scope may possibly have members
declared in it that the compiler does not know about, such as
because of an eval or import statement.
|
pop | CompilerScope pop()(Code) | | Called when processing has reached the end of this scope, to pop
this scope of the stack
|
|
|