|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.data.Value
oscript.data.Scope
oscript.data.BasicScope
Scope is an internal object use to represent a scope of execution. This
class implements a basic scope which can have members created and accessed
via lookupInScope
or getMember
.
Different instances of a scope that represent the same part of the syntax tree can share the hashtable that maps member name to member index. This reduces the number of hashtables that need to be created as scopes are created, to improve performance. The member index is an index into each scope instances array of members.
In cases where it is safe to allocate storage for this scope from the
stack, the current StackFrame
may be passed to the constructor,
in which case this object will try and allocate it's member storage from
the stack. It is only safe to use the stack for storage allocation in
cases where this scope does not enclose a function instance, so if the
scope does enclose a function declaration, null
must be
passed in to the constructor instead of the current stack frame.
Field Summary | |
protected MemberTable |
members
The table of members of the scope. |
protected Value[] |
mixins
List of mixed in vars, or null if none. |
protected SymbolTable |
smit
The shared member index table maps member name to an index into the members array. |
Fields inherited from class oscript.data.Scope |
previous |
Fields inherited from class oscript.data.Value |
DEBUG, MEMBER_NAMES, NULL, PARENT_TYPE_NAME, TYPE, TYPE_NAME, UNDEFINED |
Constructor Summary | |
|
BasicScope(Scope previous)
Class Constructor. |
|
BasicScope(Scope previous,
SymbolTable smit)
Class Constructor. |
protected |
BasicScope(Scope previous,
SymbolTable smit,
MemberTable members)
Class Constructor. |
Method Summary | |
Value |
__getInstanceMember(int id)
|
Value |
createMember(int id,
int attr)
Create a member of this object with the specified value. |
void |
free()
Indicate that this scope is no longer needed |
Value |
getMember(int id,
boolean exception)
Get a member of this object. |
protected Value |
getMemberImpl(int id)
|
Scope |
getSafeCopy()
In case a scope has any resource allocated from a source which will no long be valid after a stack frame has returned (ie. |
Value |
getType()
Get the type of this object. |
protected Value |
getTypeImpl()
Get the type of this object. |
boolean |
isSafe()
|
Value |
lookupInScope(int id)
Get a member from this scope. |
void |
mixin(Value val)
"mixin" the specified variable into the current scope. |
protected void |
populateMemberSet(java.util.Set s,
boolean debugger)
Derived classes that implement getMember(int, boolean) should also
implement this. |
void |
reset()
Reset this scope object. |
Methods inherited from class oscript.data.Scope |
__setJavaObject, createMember, createMember, findDesc, getCallee, getPreviousScope, getThis, lookupInScope, lookupInScope |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected SymbolTable smit
members
array.
protected MemberTable members
protected Value[] mixins
null
if none.
Constructor Detail |
public BasicScope(Scope previous)
previous
- previous in environment scope chainpublic BasicScope(Scope previous, SymbolTable smit)
previous
- previous in environment scope chainsmit
- shared member idx tableprotected BasicScope(Scope previous, SymbolTable smit, MemberTable members)
previous
- previous scopesmit
- shared-member-index-tablemembers
- members, can be used by function scope to directly
map arguments to the function into the function's scopeMethod Detail |
protected Value getTypeImpl()
getType()
.
getTypeImpl
in class Value
public Scope getSafeCopy()
getSafeCopy
in class Scope
public boolean isSafe()
isSafe
in class Scope
protected Value getMemberImpl(int id)
getMemberImpl
in class Scope
public Value __getInstanceMember(int id)
__getInstanceMember
in class Scope
public final void reset()
public Value getType()
instanceof
getType
in class Value
public Value createMember(int id, int attr)
Note that the theory behind not synchronizing this is that it can only be a race condition against itself, not against getMember, etc, and that this will only be called from a single thread context.
createMember
in class Scope
id
- the id of the symbol that maps to the memberattr
- the attributes of the object (see Reference
.)Reference
public void mixin(Value val)
mixin
in class Scope
val
- the value to mixin to this scopepublic Value getMember(int id, boolean exception) throws PackagedScriptObjectException
getMember
in class Value
id
- the id of the symbol that maps to the memberexception
- whether an exception should be thrown if the
member object is not resolved
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public Value lookupInScope(int id) throws PackagedScriptObjectException
previous
node in the scope chain is checked.
lookupInScope
in class Scope
id
- the id of the symbol that maps to the member
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public void free()
free
in class Scope
protected void populateMemberSet(java.util.Set s, boolean debugger)
getMember(int, boolean)
should also
implement this.
populateMemberSet
in class Value
s
- the set to populatedebugger
- true
if being used by debugger, in
which case both public and private/protected field names should
be returnedgetMember(int, boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |