org.mozilla.javascript
Class ScriptRuntime

java.lang.Object
  |
  +--org.mozilla.javascript.ScriptRuntime
Direct Known Subclasses:
OptRuntime

public class ScriptRuntime
extends java.lang.Object

This is the class that implements the runtime.

Author:
Norris Boyd

Field Summary
static java.lang.Class BooleanClass
           
static java.lang.Class ByteClass
           
static java.lang.Class CharacterClass
           
static java.lang.Class ClassClass
           
static java.lang.Class DoubleClass
           
static java.lang.Object[] emptyArgs
           
static java.lang.Class FloatClass
           
static java.lang.Class FunctionClass
           
static java.lang.Class IntegerClass
           
static java.lang.Class LongClass
           
static double NaN
           
static java.lang.Double NaNobj
           
static double negativeZero
           
static java.lang.Class NumberClass
           
static java.lang.Class ObjectClass
           
static java.lang.Class ScriptableClass
           
static java.lang.Class ShortClass
           
static java.lang.Class StringClass
           
static java.lang.Class UndefinedClass
           
 
Method Summary
static java.lang.Object add(java.lang.Object val1, java.lang.Object val2)
           
static Scriptable bind(Scriptable scope, java.lang.String id)
          Returns the object in the scope chain that has a given property.
static java.lang.Object call(Context cx, java.lang.Object fun, java.lang.Object thisArg, java.lang.Object[] args)
           
static java.lang.Object call(Context cx, java.lang.Object fun, java.lang.Object thisArg, java.lang.Object[] args, Scriptable scope)
           
static java.lang.Object callSpecial(Context cx, java.lang.Object fun, java.lang.Object thisArg, java.lang.Object[] args, Scriptable enclosingThisArg, Scriptable scope, java.lang.String filename, int lineNumber)
           
static int cmp_LE(java.lang.Object val1, java.lang.Object val2)
           
static java.lang.Boolean cmp_LEB(java.lang.Object val1, java.lang.Object val2)
           
static int cmp_LT(java.lang.Object val1, java.lang.Object val2)
           
static java.lang.Boolean cmp_LTB(java.lang.Object val1, java.lang.Object val2)
           
static NativeFunction createFunctionObject(Scriptable scope, java.lang.Class functionClass, Context cx, boolean setName)
           
static java.lang.Object delete(java.lang.Object obj, java.lang.Object id)
          The delete operator See ECMA 11.4.1 In ECMA 0.19, the description of the delete operator (11.4.1) assumes that the [[Delete]] method returns a value.
static Scriptable enterWith(java.lang.Object value, Scriptable scope)
           
static boolean eq(java.lang.Object x, java.lang.Object y)
          Equality See ECMA 11.9
static java.lang.Boolean eqB(java.lang.Object x, java.lang.Object y)
           
static java.lang.String escapeString(java.lang.String s)
          For escaping strings printed by object and array literals; not quite the same as 'escape.'
static Scriptable getBase(Scriptable scope, java.lang.String id)
           
static NativeCall getCurrentActivation(Context cx)
           
static java.lang.Object getElem(java.lang.Object obj, java.lang.Object id, Scriptable scope)
           
static java.lang.Object getElem(Scriptable obj, int index)
           
static java.lang.String getMessage(java.lang.String messageId, java.lang.Object[] arguments)
           
static java.lang.String getMessage0(java.lang.String messageId)
           
static java.lang.String getMessage1(java.lang.String messageId, java.lang.Object arg1)
           
static java.lang.String getMessage2(java.lang.String messageId, java.lang.Object arg1, java.lang.Object arg2)
           
static Scriptable getParent(java.lang.Object obj)
           
static Scriptable getParent(java.lang.Object obj, Scriptable scope)
           
static java.lang.Object getProp(java.lang.Object obj, java.lang.String id, Scriptable scope)
           
static Scriptable getProto(java.lang.Object obj, Scriptable scope)
           
static RegExpProxy getRegExpProxy(Context cx)
           
static Scriptable getThis(Scriptable base)
           
static java.lang.Object getTopLevelProp(Scriptable scope, java.lang.String id)
           
static boolean in(java.lang.Object a, java.lang.Object b, Scriptable scope)
          The in operator.
static java.util.Enumeration initEnum(java.lang.Object value, Scriptable scope)
           
static NativeFunction initFunction(NativeFunction fn, Scriptable scope, java.lang.String fnName, Context cx, boolean doSetName)
           
static Scriptable initScript(Context cx, Scriptable scope, NativeFunction funObj, Scriptable thisObj, boolean fromEvalCode)
           
static Scriptable initVarObj(Context cx, Scriptable scope, NativeFunction funObj, Scriptable thisObj, java.lang.Object[] args)
           
static boolean instanceOf(Scriptable scope, java.lang.Object a, java.lang.Object b)
          The instanceof operator.
static Scriptable leaveWith(Scriptable scope)
           
static java.lang.Class loadClassName(java.lang.String className)
           
static void main(java.lang.String scriptClassName, java.lang.String[] args)
           
static java.lang.Object name(Scriptable scopeChain, java.lang.String id)
          Looks up a name in the scope chain and returns its value.
static java.lang.Boolean neB(java.lang.Object x, java.lang.Object y)
           
static Scriptable newObject(Context cx, java.lang.Object fun, java.lang.Object[] args, Scriptable scope)
          Operator new.
static Scriptable newObject(Context cx, Scriptable scope, java.lang.String constructorName, java.lang.Object[] args)
           
static Scriptable newObjectSpecial(Context cx, java.lang.Object fun, java.lang.Object[] args, Scriptable scope)
           
static Scriptable newScope()
           
static java.lang.Object nextEnum(java.util.Enumeration enum)
           
static java.lang.String numberToString(double d, int base)
           
static java.lang.Object[] padArguments(java.lang.Object[] args, int count)
          Helper function for builtin objects that use the varargs form.
static void popActivation(Context cx)
           
static java.lang.Object postDecrement(java.lang.Object value)
           
static java.lang.Object postDecrement(java.lang.Object obj, java.lang.String id, Scriptable scope)
           
static java.lang.Object postDecrement(Scriptable scopeChain, java.lang.String id)
           
static java.lang.Object postDecrementElem(java.lang.Object obj, java.lang.Object index, Scriptable scope)
           
static java.lang.Object postIncrement(java.lang.Object value)
           
static java.lang.Object postIncrement(java.lang.Object obj, java.lang.String id, Scriptable scope)
           
static java.lang.Object postIncrement(Scriptable scopeChain, java.lang.String id)
           
static java.lang.Object postIncrementElem(java.lang.Object obj, java.lang.Object index, Scriptable scope)
           
static Scriptable runScript(Script script)
           
static java.lang.Boolean seqB(java.lang.Object x, java.lang.Object y)
           
static void setCurrentActivation(Context cx, NativeCall activation)
           
static java.lang.Object setElem(java.lang.Object obj, java.lang.Object id, java.lang.Object value, Scriptable scope)
           
static java.lang.Object setElem(Scriptable obj, int index, java.lang.Object value)
           
static java.lang.Object setName(Scriptable bound, java.lang.Object value, Scriptable scope, java.lang.String id)
           
static java.lang.Object setParent(java.lang.Object obj, java.lang.Object value, Scriptable scope)
           
static java.lang.Object setProp(java.lang.Object obj, java.lang.String id, java.lang.Object value, Scriptable scope)
           
static java.lang.Object setProto(java.lang.Object obj, java.lang.Object value, Scriptable scope)
           
static boolean shallowEq(java.lang.Object x, java.lang.Object y)
           
static java.lang.Boolean sneB(java.lang.Object x, java.lang.Object y)
           
static boolean toBoolean(java.lang.Object val)
          Convert the value to a boolean.
static boolean toBoolean(java.lang.Object[] args, int index)
           
static int toInt32(double d)
           
static int toInt32(java.lang.Object val)
          See ECMA 9.5.
static int toInt32(java.lang.Object[] args, int index)
           
static double toInteger(double d)
           
static double toInteger(java.lang.Object val)
          See ECMA 9.4.
static double toInteger(java.lang.Object[] args, int index)
           
static double toNumber(java.lang.Object val)
          Convert the value to a number.
static double toNumber(java.lang.Object[] args, int index)
           
static double toNumber(java.lang.String s)
          ToNumber applied to the String type See ECMA 9.3.1
static Scriptable toObject(Scriptable scope, java.lang.Object val)
          Convert the value to an object.
static Scriptable toObject(Scriptable scope, java.lang.Object val, java.lang.Class staticClass)
           
static java.lang.Object toPrimitive(java.lang.Object val)
           
static java.lang.String toString(double val)
          Optimized version of toString(Object) for numbers.
static java.lang.String toString(java.lang.Object val)
          Convert the value to a string.
static java.lang.String toString(java.lang.Object[] args, int index)
           
static char toUint16(java.lang.Object val)
          See ECMA 9.7.
static long toUint32(double d)
          See ECMA 9.6.
static long toUint32(java.lang.Object val)
           
static java.lang.String typeof(java.lang.Object value)
          The typeof operator
static java.lang.String typeofName(Scriptable scope, java.lang.String id)
          The typeof operator that correctly handles the undefined case
static java.lang.Object unwrapJavaScriptException(JavaScriptException jse)
          Unwrap a JavaScriptException.
static java.lang.Object unwrapWrappedException(WrappedException we)
          Check a WrappedException.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UndefinedClass

public static final java.lang.Class UndefinedClass

ScriptableClass

public static final java.lang.Class ScriptableClass

StringClass

public static final java.lang.Class StringClass

NumberClass

public static final java.lang.Class NumberClass

BooleanClass

public static final java.lang.Class BooleanClass

ByteClass

public static final java.lang.Class ByteClass

ShortClass

public static final java.lang.Class ShortClass

IntegerClass

public static final java.lang.Class IntegerClass

LongClass

public static final java.lang.Class LongClass

FloatClass

public static final java.lang.Class FloatClass

DoubleClass

public static final java.lang.Class DoubleClass

CharacterClass

public static final java.lang.Class CharacterClass

ObjectClass

public static final java.lang.Class ObjectClass

FunctionClass

public static final java.lang.Class FunctionClass

ClassClass

public static final java.lang.Class ClassClass

NaN

public static double NaN

NaNobj

public static java.lang.Double NaNobj

negativeZero

public static double negativeZero

emptyArgs

public static final java.lang.Object[] emptyArgs
Method Detail

toBoolean

public static boolean toBoolean(java.lang.Object val)
Convert the value to a boolean. See ECMA 9.2.

toBoolean

public static boolean toBoolean(java.lang.Object[] args,
                                int index)

toNumber

public static double toNumber(java.lang.Object val)
Convert the value to a number. See ECMA 9.3.

toNumber

public static double toNumber(java.lang.Object[] args,
                              int index)

toNumber

public static double toNumber(java.lang.String s)
ToNumber applied to the String type See ECMA 9.3.1

padArguments

public static java.lang.Object[] padArguments(java.lang.Object[] args,
                                              int count)
Helper function for builtin objects that use the varargs form. ECMA function formal arguments are undefined if not supplied; this function pads the argument array out to the expected length, if necessary.

escapeString

public static java.lang.String escapeString(java.lang.String s)
For escaping strings printed by object and array literals; not quite the same as 'escape.'

toString

public static java.lang.String toString(java.lang.Object val)
Convert the value to a string. See ECMA 9.8.

toString

public static java.lang.String toString(java.lang.Object[] args,
                                        int index)

toString

public static java.lang.String toString(double val)
Optimized version of toString(Object) for numbers.

numberToString

public static java.lang.String numberToString(double d,
                                              int base)

toObject

public static Scriptable toObject(Scriptable scope,
                                  java.lang.Object val)
Convert the value to an object. See ECMA 9.9.

toObject

public static Scriptable toObject(Scriptable scope,
                                  java.lang.Object val,
                                  java.lang.Class staticClass)

newObject

public static Scriptable newObject(Context cx,
                                   Scriptable scope,
                                   java.lang.String constructorName,
                                   java.lang.Object[] args)

toInteger

public static double toInteger(java.lang.Object val)
See ECMA 9.4.

toInteger

public static double toInteger(double d)

toInteger

public static double toInteger(java.lang.Object[] args,
                               int index)

toInt32

public static int toInt32(java.lang.Object val)
See ECMA 9.5.

toInt32

public static int toInt32(java.lang.Object[] args,
                          int index)

toInt32

public static int toInt32(double d)

toUint32

public static long toUint32(double d)
See ECMA 9.6.

toUint32

public static long toUint32(java.lang.Object val)

toUint16

public static char toUint16(java.lang.Object val)
See ECMA 9.7.

unwrapJavaScriptException

public static java.lang.Object unwrapJavaScriptException(JavaScriptException jse)
Unwrap a JavaScriptException. Sleight of hand so that we don't javadoc JavaScriptException.getRuntimeValue().

unwrapWrappedException

public static java.lang.Object unwrapWrappedException(WrappedException we)
Check a WrappedException. Unwrap a JavaScriptException and return the value, otherwise rethrow.

getProp

public static java.lang.Object getProp(java.lang.Object obj,
                                       java.lang.String id,
                                       Scriptable scope)

getTopLevelProp

public static java.lang.Object getTopLevelProp(Scriptable scope,
                                               java.lang.String id)

getProto

public static Scriptable getProto(java.lang.Object obj,
                                  Scriptable scope)

getParent

public static Scriptable getParent(java.lang.Object obj)

getParent

public static Scriptable getParent(java.lang.Object obj,
                                   Scriptable scope)

setProto

public static java.lang.Object setProto(java.lang.Object obj,
                                        java.lang.Object value,
                                        Scriptable scope)

setParent

public static java.lang.Object setParent(java.lang.Object obj,
                                         java.lang.Object value,
                                         Scriptable scope)

setProp

public static java.lang.Object setProp(java.lang.Object obj,
                                       java.lang.String id,
                                       java.lang.Object value,
                                       Scriptable scope)

getElem

public static java.lang.Object getElem(java.lang.Object obj,
                                       java.lang.Object id,
                                       Scriptable scope)

getElem

public static java.lang.Object getElem(Scriptable obj,
                                       int index)

setElem

public static java.lang.Object setElem(java.lang.Object obj,
                                       java.lang.Object id,
                                       java.lang.Object value,
                                       Scriptable scope)

setElem

public static java.lang.Object setElem(Scriptable obj,
                                       int index,
                                       java.lang.Object value)

delete

public static java.lang.Object delete(java.lang.Object obj,
                                      java.lang.Object id)
The delete operator See ECMA 11.4.1 In ECMA 0.19, the description of the delete operator (11.4.1) assumes that the [[Delete]] method returns a value. However, the definition of the [[Delete]] operator (8.6.2.5) does not define a return value. Here we assume that the [[Delete]] method doesn't return a value.

name

public static java.lang.Object name(Scriptable scopeChain,
                                    java.lang.String id)
Looks up a name in the scope chain and returns its value.

bind

public static Scriptable bind(Scriptable scope,
                              java.lang.String id)
Returns the object in the scope chain that has a given property. The order of evaluation of an assignment expression involves evaluating the lhs to a reference, evaluating the rhs, and then modifying the reference with the rhs value. This method is used to 'bind' the given name to an object containing that property so that the side effects of evaluating the rhs do not affect which property is modified. Typically used in conjunction with setName. See ECMA 10.1.4

getBase

public static Scriptable getBase(Scriptable scope,
                                 java.lang.String id)

getThis

public static Scriptable getThis(Scriptable base)

setName

public static java.lang.Object setName(Scriptable bound,
                                       java.lang.Object value,
                                       Scriptable scope,
                                       java.lang.String id)

initEnum

public static java.util.Enumeration initEnum(java.lang.Object value,
                                             Scriptable scope)

nextEnum

public static java.lang.Object nextEnum(java.util.Enumeration enum)

call

public static java.lang.Object call(Context cx,
                                    java.lang.Object fun,
                                    java.lang.Object thisArg,
                                    java.lang.Object[] args)
                             throws JavaScriptException

call

public static java.lang.Object call(Context cx,
                                    java.lang.Object fun,
                                    java.lang.Object thisArg,
                                    java.lang.Object[] args,
                                    Scriptable scope)
                             throws JavaScriptException

callSpecial

public static java.lang.Object callSpecial(Context cx,
                                           java.lang.Object fun,
                                           java.lang.Object thisArg,
                                           java.lang.Object[] args,
                                           Scriptable enclosingThisArg,
                                           Scriptable scope,
                                           java.lang.String filename,
                                           int lineNumber)
                                    throws JavaScriptException

newObject

public static Scriptable newObject(Context cx,
                                   java.lang.Object fun,
                                   java.lang.Object[] args,
                                   Scriptable scope)
                            throws JavaScriptException
Operator new. See ECMA 11.2.2

newObjectSpecial

public static Scriptable newObjectSpecial(Context cx,
                                          java.lang.Object fun,
                                          java.lang.Object[] args,
                                          Scriptable scope)
                                   throws JavaScriptException

typeof

public static java.lang.String typeof(java.lang.Object value)
The typeof operator

typeofName

public static java.lang.String typeofName(Scriptable scope,
                                          java.lang.String id)
The typeof operator that correctly handles the undefined case

add

public static java.lang.Object add(java.lang.Object val1,
                                   java.lang.Object val2)

postIncrement

public static java.lang.Object postIncrement(java.lang.Object value)

postIncrement

public static java.lang.Object postIncrement(Scriptable scopeChain,
                                             java.lang.String id)

postIncrement

public static java.lang.Object postIncrement(java.lang.Object obj,
                                             java.lang.String id,
                                             Scriptable scope)

postIncrementElem

public static java.lang.Object postIncrementElem(java.lang.Object obj,
                                                 java.lang.Object index,
                                                 Scriptable scope)

postDecrementElem

public static java.lang.Object postDecrementElem(java.lang.Object obj,
                                                 java.lang.Object index,
                                                 Scriptable scope)

postDecrement

public static java.lang.Object postDecrement(java.lang.Object value)

postDecrement

public static java.lang.Object postDecrement(Scriptable scopeChain,
                                             java.lang.String id)

postDecrement

public static java.lang.Object postDecrement(java.lang.Object obj,
                                             java.lang.String id,
                                             Scriptable scope)

toPrimitive

public static java.lang.Object toPrimitive(java.lang.Object val)

eq

public static boolean eq(java.lang.Object x,
                         java.lang.Object y)
Equality See ECMA 11.9

eqB

public static java.lang.Boolean eqB(java.lang.Object x,
                                    java.lang.Object y)

neB

public static java.lang.Boolean neB(java.lang.Object x,
                                    java.lang.Object y)

shallowEq

public static boolean shallowEq(java.lang.Object x,
                                java.lang.Object y)

seqB

public static java.lang.Boolean seqB(java.lang.Object x,
                                     java.lang.Object y)

sneB

public static java.lang.Boolean sneB(java.lang.Object x,
                                     java.lang.Object y)

instanceOf

public static boolean instanceOf(Scriptable scope,
                                 java.lang.Object a,
                                 java.lang.Object b)
The instanceof operator.
Returns:
a instanceof b

in

public static boolean in(java.lang.Object a,
                         java.lang.Object b,
                         Scriptable scope)
The in operator. This is a new JS 1.3 language feature. The in operator mirrors the operation of the for .. in construct, and tests whether the rhs has the property given by the lhs. It is different from the for .. in construct in that:
- it doesn't perform ToObject on the right hand side
- it returns true for DontEnum properties.
Parameters:
a - the left hand operand
b - the right hand operand
Returns:
true if property name or element number a is a property of b

cmp_LTB

public static java.lang.Boolean cmp_LTB(java.lang.Object val1,
                                        java.lang.Object val2)

cmp_LT

public static int cmp_LT(java.lang.Object val1,
                         java.lang.Object val2)

cmp_LEB

public static java.lang.Boolean cmp_LEB(java.lang.Object val1,
                                        java.lang.Object val2)

cmp_LE

public static int cmp_LE(java.lang.Object val1,
                         java.lang.Object val2)

main

public static void main(java.lang.String scriptClassName,
                        java.lang.String[] args)
                 throws JavaScriptException

initScript

public static Scriptable initScript(Context cx,
                                    Scriptable scope,
                                    NativeFunction funObj,
                                    Scriptable thisObj,
                                    boolean fromEvalCode)

runScript

public static Scriptable runScript(Script script)

initVarObj

public static Scriptable initVarObj(Context cx,
                                    Scriptable scope,
                                    NativeFunction funObj,
                                    Scriptable thisObj,
                                    java.lang.Object[] args)

popActivation

public static void popActivation(Context cx)

newScope

public static Scriptable newScope()

enterWith

public static Scriptable enterWith(java.lang.Object value,
                                   Scriptable scope)

leaveWith

public static Scriptable leaveWith(Scriptable scope)

initFunction

public static NativeFunction initFunction(NativeFunction fn,
                                          Scriptable scope,
                                          java.lang.String fnName,
                                          Context cx,
                                          boolean doSetName)

createFunctionObject

public static NativeFunction createFunctionObject(Scriptable scope,
                                                  java.lang.Class functionClass,
                                                  Context cx,
                                                  boolean setName)

getMessage0

public static java.lang.String getMessage0(java.lang.String messageId)

getMessage1

public static java.lang.String getMessage1(java.lang.String messageId,
                                           java.lang.Object arg1)

getMessage2

public static java.lang.String getMessage2(java.lang.String messageId,
                                           java.lang.Object arg1,
                                           java.lang.Object arg2)

getMessage

public static java.lang.String getMessage(java.lang.String messageId,
                                          java.lang.Object[] arguments)

getRegExpProxy

public static RegExpProxy getRegExpProxy(Context cx)

getCurrentActivation

public static NativeCall getCurrentActivation(Context cx)

setCurrentActivation

public static void setCurrentActivation(Context cx,
                                        NativeCall activation)

loadClassName

public static java.lang.Class loadClassName(java.lang.String className)
                                     throws java.lang.ClassNotFoundException