This is the class that implements the runtime.
add
public static Object add(Object val1,
Object val2,
Context cx)
applyOrCall
public static Object applyOrCall(boolean isApply,
Context cx,
Scriptable scope,
Scriptable thisObj,
Object[] args)
Function.prototype.apply and Function.prototype.call
See Ecma 15.3.4.[34]
bind
public static Scriptable bind(Context cx,
Scriptable scope,
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
call
public static Object call(Context cx,
Object fun,
Object thisArg,
Object[] args,
Scriptable scope)
The method is only present for compatibility.
callRef
public static Ref callRef(Callable function,
Scriptable thisObj,
Object[] args,
Context cx)
Perform function call in reference context. Should always
return value that can be passed to
refGet(Object)
or @link #refSet(Object, Object)}
arbitrary number of times.
The args array reference should not be stored in any object that is
can be GC-reachable after this method returns. If this is necessary,
store args.clone(), not args array itself.
cmp_LE
public static boolean cmp_LE(Object val1,
Object val2)
cmp_LT
public static boolean cmp_LT(Object val1,
Object val2)
constructError
public static EcmaError constructError(String error,
String message)
constructError
public static EcmaError constructError(String error,
String message,
String sourceName,
int lineNumber,
String lineSource,
int columnNumber)
delete
public static Object delete(Object obj,
Object id,
Context cx)
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.
deleteObjectElem
public static boolean deleteObjectElem(Scriptable target,
Object elem,
Context cx)
elemIncrDecr
public static Object elemIncrDecr(Object obj,
Object index,
Context cx,
int incrDecrMask)
enterActivationFunction
public static void enterActivationFunction(Context cx,
Scriptable activation)
enumId
public static Object enumId(Object enumObj,
Context cx)
enumInit
public static Object enumInit(Object value,
Context cx,
boolean enumValues)
enumNext
public static Boolean enumNext(Object enumObj)
eq
public static boolean eq(Object x,
Object y)
Equality
See ECMA 11.9
escapeAttributeValue
public static String escapeAttributeValue(Object value,
Context cx)
Escapes the reserved characters in a value of an attribute
escapeString
public static String escapeString(String s)
escapeString
public static String escapeString(String s,
char escapeQuote)
For escaping strings printed by object and array literals; not quite
the same as 'escape.'
escapeTextValue
public static String escapeTextValue(Object value,
Context cx)
Escapes the reserved characters in a value of a text node
evalSpecial
public static Object evalSpecial(Context cx,
Scriptable scope,
Object thisArg,
Object[] args,
String filename,
int lineNumber)
The eval function property of the global object.
See ECMA 15.1.2.1
exitActivationFunction
public static void exitActivationFunction(Context cx)
getArrayElements
public static Object[] getArrayElements(Scriptable object)
getElemFunctionAndThis
public static Callable getElemFunctionAndThis(Object obj,
Object elem,
Context cx)
Prepare for calling obj[id](...): return function corresponding to
obj[id] and make obj properly converted to Scriptable available
as ScriptRuntime.lastStoredScriptable() for consumption as thisObj.
The caller must call ScriptRuntime.lastStoredScriptable() immediately
after calling this method.
getMessage
public static String getMessage(String messageId,
Object[] arguments)
getMessage0
public static String getMessage0(String messageId)
getMessage1
public static String getMessage1(String messageId,
Object arg1)
getMessage2
public static String getMessage2(String messageId,
Object arg1,
Object arg2)
getMessage3
public static String getMessage3(String messageId,
Object arg1,
Object arg2,
Object arg3)
getMessage4
public static String getMessage4(String messageId,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
getNameFunctionAndThis
public static Callable getNameFunctionAndThis(String name,
Context cx,
Scriptable scope)
Prepare for calling name(...): return function corresponding to
name and make current top scope available
as ScriptRuntime.lastStoredScriptable() for consumption as thisObj.
The caller must call ScriptRuntime.lastStoredScriptable() immediately
after calling this method.
getObjectElem
public static Object getObjectElem(Object obj,
Object elem,
Context cx)
Call obj.[[Get]](id)
getObjectElem
public static Object getObjectElem(Scriptable obj,
Object elem,
Context cx)
getObjectIndex
public static Object getObjectIndex(Object obj,
double dblIndex,
Context cx)
getObjectIndex
public static Object getObjectIndex(Scriptable obj,
int index,
Context cx)
getObjectProp
public static Object getObjectProp(Object obj,
String property,
Context cx)
Version of getObjectElem when elem is a valid JS identifier name.
getObjectProp
public static Object getObjectProp(Scriptable obj,
String property,
Context cx)
getPropFunctionAndThis
public static Callable getPropFunctionAndThis(Object obj,
String property,
Context cx)
Prepare for calling obj.property(...): return function corresponding to
obj.property and make obj properly converted to Scriptable available
as ScriptRuntime.lastStoredScriptable() for consumption as thisObj.
The caller must call ScriptRuntime.lastStoredScriptable() immediately
after calling this method.
getTopLevelProp
public static Object getTopLevelProp(Scriptable scope,
String id)
getValueFunctionAndThis
public static Callable getValueFunctionAndThis(Object value,
Context cx)
Prepare for calling (...): return function corresponding to
and make parent scope of the function available
as ScriptRuntime.lastStoredScriptable() for consumption as thisObj.
The caller must call ScriptRuntime.lastStoredScriptable() immediately
after calling this method.
hasObjectElem
public static boolean hasObjectElem(Scriptable target,
Object elem,
Context cx)
hasTopCall
public static boolean hasTopCall(Context cx)
in
public static boolean in(Object a,
Object b,
Context cx)
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.
a
- the left hand operandb
- the right hand operand
- true if property name or element number a is a property of b
instanceOf
public static boolean instanceOf(Object a,
Object b,
Context cx)
The instanceof operator.
isArrayObject
public static boolean isArrayObject(Object obj)
isJSLineTerminator
public static boolean isJSLineTerminator(int c)
isRhinoRuntimeType
public static boolean isRhinoRuntimeType(Class cl)
jsDelegatesTo
protected static boolean jsDelegatesTo(Scriptable lhs,
Scriptable rhs)
Delegates to
- true iff rhs appears in lhs' proto chain
lastUint32Result
public static long lastUint32Result(Context cx)
memberRef
public static Ref memberRef(Object obj,
Object namespace,
Object elem,
Context cx,
int memberTypeFlags)
memberRef
public static Ref memberRef(Object obj,
Object elem,
Context cx,
int memberTypeFlags)
name
public static Object name(Context cx,
Scriptable scope,
String name)
Looks up a name in the scope chain and returns its value.
nameIncrDecr
public static Object nameIncrDecr(Scriptable scopeChain,
String id,
int incrDecrMask)
nameRef
public static Ref nameRef(Object namespace,
Object name,
Context cx,
Scriptable scope,
int memberTypeFlags)
newSpecial
public static Object newSpecial(Context cx,
Object fun,
Object[] args,
Scriptable scope,
int callType)
notFoundError
public static RuntimeException notFoundError(Scriptable object,
String property)
notFunctionError
public static RuntimeException notFunctionError(Object value)
notFunctionError
public static RuntimeException notFunctionError(Object value,
Object messageHelper)
numberToString
public static String numberToString(double d,
int base)
padArguments
public static Object[] padArguments(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.
propIncrDecr
public static Object propIncrDecr(Object obj,
String id,
Context cx,
int incrDecrMask)
refDel
public static Object refDel(Ref ref,
Context cx)
refGet
public static Object refGet(Ref ref,
Context cx)
refIncrDecr
public static Object refIncrDecr(Ref ref,
Context cx,
int incrDecrMask)
refSet
public static Object refSet(Ref ref,
Object value,
Context cx)
searchDefaultNamespace
public static Object searchDefaultNamespace(Context cx)
setDefaultNamespace
public static Object setDefaultNamespace(Object namespace,
Context cx)
setObjectElem
public static Object setObjectElem(Object obj,
Object elem,
Object value,
Context cx)
setObjectElem
public static Object setObjectElem(Scriptable obj,
Object elem,
Object value,
Context cx)
setObjectIndex
public static Object setObjectIndex(Object obj,
double dblIndex,
Object value,
Context cx)
setObjectIndex
public static Object setObjectIndex(Scriptable obj,
int index,
Object value,
Context cx)
setObjectProp
public static Object setObjectProp(Object obj,
String property,
Object value,
Context cx)
Version of setObjectElem when elem is a valid JS identifier name.
setObjectProp
public static Object setObjectProp(Scriptable obj,
String property,
Object value,
Context cx)
shallowEq
public static boolean shallowEq(Object x,
Object y)
specialRef
public static Ref specialRef(Object obj,
String specialProperty,
Context cx)
storeUint32Result
public static void storeUint32Result(Context cx,
long value)
testUint32String
public static long testUint32String(String str)
If str is a decimal presentation of Uint32 value, return it as long.
Othewise return -1L;
toBoolean
public static boolean toBoolean(Object val)
Convert the value to a boolean.
See ECMA 9.2.
toBoolean
public static boolean toBoolean(Object[] args,
int index)
toInt32
public static int toInt32(Object val)
See ECMA 9.5.
toInt32
public static int toInt32(Object[] args,
int index)
toInt32
public static int toInt32(double d)
toInteger
public static double toInteger(Object val)
See ECMA 9.4.
toInteger
public static double toInteger(Object[] args,
int index)
toInteger
public static double toInteger(double d)
toNumber
public static double toNumber(Object val)
Convert the value to a number.
See ECMA 9.3.
toNumber
public static double toNumber(Object[] args,
int index)
toNumber
public static double toNumber(String s)
ToNumber applied to the String type
See ECMA 9.3.1
toString
public static String toString(Object val)
Convert the value to a string.
See ECMA 9.8.
toString
public static String toString(Object[] args,
int index)
toString
public static String toString(double val)
Optimized version of toString(Object) for numbers.
toUint16
public static char toUint16(Object val)
See ECMA 9.7.
toUint32
public static long toUint32(Object val)
toUint32
public static long toUint32(double d)
See ECMA 9.6.
- long value representing 32 bits unsigned integer
typeError
public static EcmaError typeError(String message)
typeError0
public static EcmaError typeError0(String messageId)
typeError1
public static EcmaError typeError1(String messageId,
String arg1)
typeError2
public static EcmaError typeError2(String messageId,
String arg1,
String arg2)
typeError3
public static EcmaError typeError3(String messageId,
String arg1,
String arg2,
String arg3)
typeof
public static String typeof(Object value)
The typeof operator
typeofName
public static String typeofName(Scriptable scope,
String id)
The typeof operator that correctly handles the undefined case
undefCallError
public static RuntimeException undefCallError(Object object,
Object id)
undefReadError
public static RuntimeException undefReadError(Object object,
Object id)
undefWriteError
public static RuntimeException undefWriteError(Object object,
Object id,
Object value)
updateDotQuery
public static Object updateDotQuery(boolean value,
Scriptable scope)
wrapBoolean
public static Boolean wrapBoolean(boolean b)
wrapInt
public static Integer wrapInt(int i)
wrapNumber
public static Number wrapNumber(double x)