oscript.data
Class ForkScope

java.lang.Object
  extended by oscript.data.Value
      extended by oscript.data.Scope
          extended by oscript.data.ForkScope
All Implemented Interfaces:
java.io.Serializable

public class ForkScope
extends Scope

The ForkScope is used to implement a fork in the scope chain. This is needed because when evaluating a superFxn, or a method defined in the superFxn, the scope chain should use the scope that the superFxn is defined in, rather than the scope of the derived function.

This is basically just a simple wrapper for the obj, with the exception that lookupInScope uses env as the previous instead. This means that any member created in this scope is actually created in the obj scope.

Author:
Rob Clark (rob@ti.com)
See Also:
Serialized Form

Field Summary
 
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
 
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.
 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 getSuper()
          Lookup the "super" within a scope.
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.
 
Methods inherited from class oscript.data.Scope
__setJavaObject, createMember, createMember, findDesc, getCallee, getInstanceMemberImpl, getMemberImpl, getPreviousScope, getThis, getThis, lookupInScope, lookupInScope
 
Methods inherited from class oscript.data.Value
_getTypeMember, _populateTypeMemberSet, bopBitwiseAnd, bopBitwiseAndR, bopBitwiseOr, bopBitwiseOrR, bopBitwiseXor, bopBitwiseXorR, bopCast, bopCastR, bopDivide, bopDivideR, bopEquals, bopEqualsR, bopGreaterThan, bopGreaterThanOrEquals, bopGreaterThanOrEqualsR, bopGreaterThanR, bopInstanceOf, bopInstanceOfR, bopLeftShift, bopLeftShiftR, bopLessThan, bopLessThanOrEquals, bopLessThanOrEqualsR, bopLessThanR, bopLogicalAnd, bopLogicalAndR, bopLogicalOr, bopLogicalOrR, bopMinus, bopMinusR, bopMultiply, bopMultiplyR, bopNotEquals, bopNotEqualsR, bopPlus, bopPlusR, bopRemainder, bopRemainderR, bopSignedRightShift, bopSignedRightShiftR, bopUnsignedRightShift, bopUnsignedRightShiftR, callAsConstructor, callAsConstructor, callAsConstructor, callAsExtends, callAsExtends, callAsExtends, callAsFunction, callAsFunction, callAsFunction, castToBoolean, castToExactNumber, castToInexactNumber, castToJavaObject, castToString, elementAt, elementsAt, getMember, getMember, getMember, getMember, getMember, getMonitor, getType, getTypeMember, getTypeMember, isA, length, memberSet, noSuchMember, opAssign, populateMemberSet, populateTypeMemberSet, readExternal, toString, unhand, uopBitwiseNot, uopDecrement, uopIncrement, uopLogicalNot, uopMinus, uopPlus, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isSafe

public boolean isSafe()
Specified by:
isSafe in class Scope

getTypeImpl

protected Value getTypeImpl()
Get the type of this object. The returned type doesn't have to take into account the possibility of a script type extending a built-in type, since that is handled by Value.getType().

Specified by:
getTypeImpl in class Value
Returns:
the object's type

getSafeCopy

public 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. resource allocated from stack), return a copy of the scope that is safe to keep after the stack frame returns.

Overrides:
getSafeCopy in class Scope

getSuper

public Value getSuper()
Lookup the "super" within a scope. Within a function body, "super" is the overriden function (if there is one).

Overrides:
getSuper in class Scope
Returns:
the "this" ScriptObject within this scope

createMember

public Value createMember(int id,
                          int attr)
Create a member of this object with the specified value.

Specified by:
createMember in class Scope
Parameters:
id - the id of the symbol that maps to the member
attr - the attributes of the object (see Reference.)
See Also:
Reference

mixin

public void mixin(Value val)
"mixin" the specified variable into the current scope.

Specified by:
mixin in class Scope
Parameters:
val - the value to mixin to this scope

getMember

public Value getMember(int id,
                       boolean exception)
                throws PackagedScriptObjectException
Get a member of this object.

Overrides:
getMember in class Value
Parameters:
id - the id of the symbol that maps to the member
exception - whether an exception should be thrown if the member object is not resolved
Returns:
a reference to the member
Throws:
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException

__getInstanceMember

public Value __getInstanceMember(int id)
Specified by:
__getInstanceMember in class Scope

lookupInScope

public Value lookupInScope(int id)
                    throws PackagedScriptObjectException
Get a member from this scope. This is used to access local variables and object attributes from methods of the object. If the attribute isn't in this node in the scope chain, then the previous node in the scope chain is checked.

Specified by:
lookupInScope in class Scope
Parameters:
id - the id of the symbol that maps to the member
Throws:
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException

free

public void free()
Indicate that this scope is no longer needed

Specified by:
free in class Scope