|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.data.Value
oscript.data.Scope
Scope is an internal object use to represent a scope of execution. It is
used to implement nested scope, ie. if a lookup in this scope fails, the
lookup will procedue in the previous
scope, and so on.
Field Summary | |
protected Scope |
previous
Previous in object scope chain. |
Fields inherited from class oscript.data.Value |
DEBUG, MEMBER_NAMES, NULL, PARENT_TYPE_NAME, TYPE, TYPE_NAME, UNDEFINED |
Constructor Summary | |
protected |
Scope(Scope previous)
Class Constructor. |
Method Summary | |
abstract Value |
__getInstanceMember(int id)
|
void |
__setJavaObject(java.lang.Object javaObject)
Set the java-object associated with a script object... |
abstract Value |
createMember(int id,
int attr)
Create a member of this object with the specified value. |
Value |
createMember(java.lang.String name,
int attr)
Create a member of this object with the specified value. |
Value |
createMember(Value name,
int attr)
Create a member of this object with the specified value. |
protected static java.lang.String |
findDesc(Scope scope)
|
abstract void |
free()
Indicate that this scope is no longer needed. |
Value |
getCallee()
Lookup the "callee" within a scope. |
protected Value |
getMemberImpl(int id)
|
Scope |
getPreviousScope()
Get the previous scope in the scope chain. |
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 |
getThis()
Lookup the "this" within a scope. |
abstract boolean |
isSafe()
|
abstract Value |
lookupInScope(int id)
Get a member from this scope. |
Value |
lookupInScope(java.lang.String name)
Get a member from this scope. |
Value |
lookupInScope(Value name)
Get a member from this scope. |
abstract void |
mixin(Value val)
"mixin" the specified variable into the current scope. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Scope previous
lookupInScope
,
when the member being looked-up doesn't exist in this object (ie scope
chain node)
Constructor Detail |
protected Scope(Scope previous)
previous
- previous in environment scope chainMethod Detail |
public Scope getPreviousScope()
null
if this is the global-
scope (ie. topmost scope in the scope chain)public void __setJavaObject(java.lang.Object javaObject)
javaObject
- the java-objectpublic Value getThis()
public Value getCallee()
public final Value createMember(java.lang.String name, int attr)
name
- the name of the memberattr
- the attributes of the object (see Reference
.)Reference
public final Value createMember(Value name, int attr)
name
- the name of the memberattr
- the attributes of the object (see Reference
.)Reference
public abstract Value createMember(int id, int attr)
id
- the id of the symbol that maps to the memberattr
- the attributes of the object (see Reference
.)Reference
public abstract void mixin(Value val)
mixin java.lang.Math; // defines "min", "max", etc var c = min( a, b ); var d = max( a, b );Mixins can also be used to implement OO composition, so a constructor function can mixin members of another object. (Note that this will not make the resulting object an instanceof this mixed in object's type... this could be made to work at some point in the future for script code, but not for java code, if that was deemed a good thing..)
function ListAndStuff() { public function foo() { ... } var list = new java.util.LinkedList(); mixin list; } var obj = new ListAndStuff(); obj.foo(); obj.add(1); obj.add("two"); for( var o : obj ) writeln("list member: " + o);
val
- the value to mixin to this scopeprotected Value getMemberImpl(int id)
public abstract Value __getInstanceMember(int id)
public final Value lookupInScope(java.lang.String name) throws PackagedScriptObjectException
previous
node in the scope chain is checked. This method is provided for
convenience.
name
- the name of the member
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public final Value lookupInScope(Value name) throws PackagedScriptObjectException
previous
node in the scope chain is checked.
name
- the name of the member
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public abstract Value lookupInScope(int id) throws PackagedScriptObjectException
previous
node in the scope chain is checked.
id
- the id of the symbol that maps to the member
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public Scope getSafeCopy()
public abstract boolean isSafe()
public abstract void free()
protected static final java.lang.String findDesc(Scope scope)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |