mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Major simplification to jsconfig.h, dropping support for all ancient bug config and almost all pre-ECMA-Edition-3 feature config (325951, r=mrbkap).
This commit is contained in:
parent
bb79579615
commit
916f80bcda
@ -1969,13 +1969,8 @@ static JSClass its_class = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = {
|
JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = {
|
||||||
#if JS_HAS_DFLT_MSG_STRINGS
|
|
||||||
#define MSG_DEF(name, number, count, exception, format) \
|
#define MSG_DEF(name, number, count, exception, format) \
|
||||||
{ format, count } ,
|
{ format, count } ,
|
||||||
#else
|
|
||||||
#define MSG_DEF(name, number, count, exception, format) \
|
|
||||||
{ NULL, count } ,
|
|
||||||
#endif
|
|
||||||
#include "jsshell.msg"
|
#include "jsshell.msg"
|
||||||
#undef MSG_DEF
|
#undef MSG_DEF
|
||||||
};
|
};
|
||||||
|
@ -992,6 +992,10 @@ JS_SetVersion(JSContext *cx, JSVersion version)
|
|||||||
if (version == oldVersion)
|
if (version == oldVersion)
|
||||||
return oldVersion;
|
return oldVersion;
|
||||||
|
|
||||||
|
/* We no longer support 1.4 or below. */
|
||||||
|
if (version != JSVERSION_DEFAULT && version <= JSVERSION_1_4)
|
||||||
|
return oldVersion;
|
||||||
|
|
||||||
cx->version = (cx->version & ~JSVERSION_MASK) | version;
|
cx->version = (cx->version & ~JSVERSION_MASK) | version;
|
||||||
js_OnVersionChange(cx);
|
js_OnVersionChange(cx);
|
||||||
return oldVersion;
|
return oldVersion;
|
||||||
@ -1175,18 +1179,16 @@ out:
|
|||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
|
JSAtom *atom;
|
||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
|
|
||||||
#if JS_HAS_UNDEFINED
|
|
||||||
{
|
|
||||||
/* Define a top-level property 'undefined' with the undefined value. */
|
/* Define a top-level property 'undefined' with the undefined value. */
|
||||||
JSAtom *atom = cx->runtime->atomState.typeAtoms[JSTYPE_VOID];
|
atom = cx->runtime->atomState.typeAtoms[JSTYPE_VOID];
|
||||||
if (!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
if (!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
||||||
NULL, NULL, JSPROP_PERMANENT, NULL)) {
|
NULL, NULL, JSPROP_PERMANENT, NULL)) {
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Function and Object require cooperative bootstrapping magic. */
|
/* Function and Object require cooperative bootstrapping magic. */
|
||||||
if (!js_InitFunctionAndObjectClasses(cx, obj))
|
if (!js_InitFunctionAndObjectClasses(cx, obj))
|
||||||
@ -1195,21 +1197,15 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
|||||||
/* Initialize the rest of the standard objects and functions. */
|
/* Initialize the rest of the standard objects and functions. */
|
||||||
return js_InitArrayClass(cx, obj) &&
|
return js_InitArrayClass(cx, obj) &&
|
||||||
js_InitBooleanClass(cx, obj) &&
|
js_InitBooleanClass(cx, obj) &&
|
||||||
|
js_InitCallClass(cx, obj) &&
|
||||||
|
js_InitExceptionClasses(cx, obj) &&
|
||||||
js_InitMathClass(cx, obj) &&
|
js_InitMathClass(cx, obj) &&
|
||||||
js_InitNumberClass(cx, obj) &&
|
js_InitNumberClass(cx, obj) &&
|
||||||
js_InitStringClass(cx, obj) &&
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
js_InitCallClass(cx, obj) &&
|
|
||||||
#endif
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
js_InitRegExpClass(cx, obj) &&
|
js_InitRegExpClass(cx, obj) &&
|
||||||
#endif
|
js_InitStringClass(cx, obj) &&
|
||||||
#if JS_HAS_SCRIPT_OBJECT
|
#if JS_HAS_SCRIPT_OBJECT
|
||||||
js_InitScriptClass(cx, obj) &&
|
js_InitScriptClass(cx, obj) &&
|
||||||
#endif
|
#endif
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
js_InitExceptionClasses(cx, obj) &&
|
|
||||||
#endif
|
|
||||||
#if JS_HAS_XML_SUPPORT
|
#if JS_HAS_XML_SUPPORT
|
||||||
js_InitXMLClasses(cx, obj) &&
|
js_InitXMLClasses(cx, obj) &&
|
||||||
#endif
|
#endif
|
||||||
@ -1239,15 +1235,9 @@ static struct {
|
|||||||
{js_InitMathClass, CLASS_ATOM_OFFSET(Math)},
|
{js_InitMathClass, CLASS_ATOM_OFFSET(Math)},
|
||||||
{js_InitNumberClass, CLASS_ATOM_OFFSET(Number)},
|
{js_InitNumberClass, CLASS_ATOM_OFFSET(Number)},
|
||||||
{js_InitStringClass, CLASS_ATOM_OFFSET(String)},
|
{js_InitStringClass, CLASS_ATOM_OFFSET(String)},
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
{js_InitCallClass, CLASS_ATOM_OFFSET(Call)},
|
{js_InitCallClass, CLASS_ATOM_OFFSET(Call)},
|
||||||
#endif
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
{js_InitExceptionClasses, CLASS_ATOM_OFFSET(Error)},
|
{js_InitExceptionClasses, CLASS_ATOM_OFFSET(Error)},
|
||||||
#endif
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
{js_InitRegExpClass, CLASS_ATOM_OFFSET(RegExp)},
|
{js_InitRegExpClass, CLASS_ATOM_OFFSET(RegExp)},
|
||||||
#endif
|
|
||||||
#if JS_HAS_SCRIPT_OBJECT
|
#if JS_HAS_SCRIPT_OBJECT
|
||||||
{js_InitScriptClass, CLASS_ATOM_OFFSET(Script)},
|
{js_InitScriptClass, CLASS_ATOM_OFFSET(Script)},
|
||||||
#endif
|
#endif
|
||||||
@ -1320,7 +1310,6 @@ static JSStdName standard_class_names[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Exception constructors. */
|
/* Exception constructors. */
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(Error)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(Error)},
|
||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(InternalError)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(InternalError)},
|
||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(EvalError)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(EvalError)},
|
||||||
@ -1329,7 +1318,6 @@ static JSStdName standard_class_names[] = {
|
|||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(SyntaxError)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(SyntaxError)},
|
||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(TypeError)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(TypeError)},
|
||||||
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(URIError)},
|
{js_InitExceptionClasses, EAGERLY_PINNED_CLASS_ATOM(URIError)},
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JS_HAS_XML_SUPPORT
|
#if JS_HAS_XML_SUPPORT
|
||||||
{js_InitAnyNameClass, EAGERLY_PINNED_CLASS_ATOM(AnyName)},
|
{js_InitAnyNameClass, EAGERLY_PINNED_CLASS_ATOM(AnyName)},
|
||||||
@ -1356,11 +1344,9 @@ static JSStdName object_prototype_names[] = {
|
|||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(watch)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(watch)},
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(unwatch)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(unwatch)},
|
||||||
#endif
|
#endif
|
||||||
#if JS_HAS_NEW_OBJ_METHODS
|
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(hasOwnProperty)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(hasOwnProperty)},
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(isPrototypeOf)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(isPrototypeOf)},
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(propertyIsEnumerable)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(propertyIsEnumerable)},
|
||||||
#endif
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(defineGetter)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(defineGetter)},
|
||||||
{js_InitObjectClass, LAZILY_PINNED_ATOM(defineSetter)},
|
{js_InitObjectClass, LAZILY_PINNED_ATOM(defineSetter)},
|
||||||
@ -1392,7 +1378,6 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id,
|
|||||||
idstr = JSVAL_TO_STRING(id);
|
idstr = JSVAL_TO_STRING(id);
|
||||||
rt = cx->runtime;
|
rt = cx->runtime;
|
||||||
|
|
||||||
#if JS_HAS_UNDEFINED
|
|
||||||
/* Check whether we're resolving 'undefined', and define it if so. */
|
/* Check whether we're resolving 'undefined', and define it if so. */
|
||||||
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
||||||
if (idstr == ATOM_TO_STRING(atom)) {
|
if (idstr == ATOM_TO_STRING(atom)) {
|
||||||
@ -1400,7 +1385,6 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id,
|
|||||||
return OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
return OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
||||||
NULL, NULL, JSPROP_PERMANENT, NULL);
|
NULL, NULL, JSPROP_PERMANENT, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Try for class constructors/prototypes named by well-known atoms. */
|
/* Try for class constructors/prototypes named by well-known atoms. */
|
||||||
init = NULL;
|
init = NULL;
|
||||||
@ -1467,7 +1451,6 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj)
|
|||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
rt = cx->runtime;
|
rt = cx->runtime;
|
||||||
|
|
||||||
#if JS_HAS_UNDEFINED
|
|
||||||
/* Check whether we need to bind 'undefined' and define it if so. */
|
/* Check whether we need to bind 'undefined' and define it if so. */
|
||||||
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
||||||
if (!AlreadyHasOwnProperty(obj, atom) &&
|
if (!AlreadyHasOwnProperty(obj, atom) &&
|
||||||
@ -1475,7 +1458,6 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj)
|
|||||||
NULL, NULL, JSPROP_PERMANENT, NULL)) {
|
NULL, NULL, JSPROP_PERMANENT, NULL)) {
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize any classes that have not been resolved yet. */
|
/* Initialize any classes that have not been resolved yet. */
|
||||||
for (i = 0; standard_class_atoms[i].init; i++) {
|
for (i = 0; standard_class_atoms[i].init; i++) {
|
||||||
@ -1538,13 +1520,11 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj,
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_UNDEFINED
|
|
||||||
/* Check whether 'undefined' has been resolved and enumerate it if so. */
|
/* Check whether 'undefined' has been resolved and enumerate it if so. */
|
||||||
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
||||||
ida = EnumerateIfResolved(cx, obj, atom, ida, &i, &found);
|
ida = EnumerateIfResolved(cx, obj, atom, ida, &i, &found);
|
||||||
if (!ida)
|
if (!ida)
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enumerate only classes that *have* been resolved. */
|
/* Enumerate only classes that *have* been resolved. */
|
||||||
for (j = 0; standard_class_atoms[j].init; j++) {
|
for (j = 0; standard_class_atoms[j].init; j++) {
|
||||||
@ -2085,12 +2065,7 @@ JS_ResolveStub(JSContext *cx, JSObject *obj, jsval id)
|
|||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||||
{
|
{
|
||||||
#if JS_BUG_EAGER_TOSTRING
|
return js_TryValueOf(cx, obj, type, vp);
|
||||||
if (type == JSTYPE_STRING)
|
|
||||||
return JS_TRUE;
|
|
||||||
#endif
|
|
||||||
js_TryValueOf(cx, obj, type, vp);
|
|
||||||
return JS_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
@ -3789,15 +3764,11 @@ JS_CompileUCScript(JSContext *cx, JSObject *obj,
|
|||||||
filename, lineno);
|
filename, lineno);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
#define LAST_FRAME_EXCEPTION_CHECK(cx,result) \
|
||||||
# define LAST_FRAME_EXCEPTION_CHECK(cx,result) \
|
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
if (!(result) && !((cx)->options & JSOPTION_DONT_REPORT_UNCAUGHT)) \
|
if (!(result) && !((cx)->options & JSOPTION_DONT_REPORT_UNCAUGHT)) \
|
||||||
js_ReportUncaughtException(cx); \
|
js_ReportUncaughtException(cx); \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
#else
|
|
||||||
# define LAST_FRAME_EXCEPTION_CHECK(cx,result) /* nothing */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LAST_FRAME_CHECKS(cx,result) \
|
#define LAST_FRAME_CHECKS(cx,result) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
@ -4681,7 +4652,6 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er)
|
|||||||
JS_PUBLIC_API(JSObject *)
|
JS_PUBLIC_API(JSObject *)
|
||||||
JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags)
|
JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags)
|
||||||
{
|
{
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
jschar *chars;
|
jschar *chars;
|
||||||
JSObject *obj;
|
JSObject *obj;
|
||||||
|
|
||||||
@ -4692,22 +4662,13 @@ JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags)
|
|||||||
obj = js_NewRegExpObject(cx, NULL, chars, length, flags);
|
obj = js_NewRegExpObject(cx, NULL, chars, length, flags);
|
||||||
JS_free(cx, chars);
|
JS_free(cx, chars);
|
||||||
return obj;
|
return obj;
|
||||||
#else
|
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NO_REG_EXPS);
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSObject *)
|
JS_PUBLIC_API(JSObject *)
|
||||||
JS_NewUCRegExpObject(JSContext *cx, jschar *chars, size_t length, uintN flags)
|
JS_NewUCRegExpObject(JSContext *cx, jschar *chars, size_t length, uintN flags)
|
||||||
{
|
{
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
return js_NewRegExpObject(cx, NULL, chars, length, flags);
|
return js_NewRegExpObject(cx, NULL, chars, length, flags);
|
||||||
#else
|
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NO_REG_EXPS);
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
@ -4770,50 +4731,37 @@ JS_GetLocaleCallbacks(JSContext *cx)
|
|||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_IsExceptionPending(JSContext *cx)
|
JS_IsExceptionPending(JSContext *cx)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
return (JSBool) cx->throwing;
|
return (JSBool) cx->throwing;
|
||||||
#else
|
|
||||||
return JS_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_GetPendingException(JSContext *cx, jsval *vp)
|
JS_GetPendingException(JSContext *cx, jsval *vp)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
if (!cx->throwing)
|
if (!cx->throwing)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
*vp = cx->exception;
|
*vp = cx->exception;
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
#else
|
|
||||||
return JS_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
JS_SetPendingException(JSContext *cx, jsval v)
|
JS_SetPendingException(JSContext *cx, jsval v)
|
||||||
{
|
{
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
cx->throwing = JS_TRUE;
|
cx->throwing = JS_TRUE;
|
||||||
cx->exception = v;
|
cx->exception = v;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
JS_ClearPendingException(JSContext *cx)
|
JS_ClearPendingException(JSContext *cx)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
cx->throwing = JS_FALSE;
|
cx->throwing = JS_FALSE;
|
||||||
cx->exception = JSVAL_VOID;
|
cx->exception = JSVAL_VOID;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_ReportPendingException(JSContext *cx)
|
JS_ReportPendingException(JSContext *cx)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
JSBool save, ok;
|
JSBool save, ok;
|
||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
@ -4829,22 +4777,16 @@ JS_ReportPendingException(JSContext *cx)
|
|||||||
ok = js_ReportUncaughtException(cx);
|
ok = js_ReportUncaughtException(cx);
|
||||||
cx->creatingException = save;
|
cx->creatingException = save;
|
||||||
return ok;
|
return ok;
|
||||||
#else
|
|
||||||
return JS_TRUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
struct JSExceptionState {
|
struct JSExceptionState {
|
||||||
JSBool throwing;
|
JSBool throwing;
|
||||||
jsval exception;
|
jsval exception;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
JS_PUBLIC_API(JSExceptionState *)
|
JS_PUBLIC_API(JSExceptionState *)
|
||||||
JS_SaveExceptionState(JSContext *cx)
|
JS_SaveExceptionState(JSContext *cx)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
JSExceptionState *state;
|
JSExceptionState *state;
|
||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
@ -4855,15 +4797,11 @@ JS_SaveExceptionState(JSContext *cx)
|
|||||||
js_AddRoot(cx, &state->exception, "JSExceptionState.exception");
|
js_AddRoot(cx, &state->exception, "JSExceptionState.exception");
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state)
|
JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
if (state) {
|
if (state) {
|
||||||
if (state->throwing)
|
if (state->throwing)
|
||||||
@ -4872,31 +4810,24 @@ JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state)
|
|||||||
JS_ClearPendingException(cx);
|
JS_ClearPendingException(cx);
|
||||||
JS_DropExceptionState(cx, state);
|
JS_DropExceptionState(cx, state);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
||||||
{
|
{
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
if (state) {
|
if (state) {
|
||||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||||
JS_RemoveRoot(cx, &state->exception);
|
JS_RemoveRoot(cx, &state->exception);
|
||||||
JS_free(cx, state);
|
JS_free(cx, state);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSErrorReport *)
|
JS_PUBLIC_API(JSErrorReport *)
|
||||||
JS_ErrorFromException(JSContext *cx, jsval v)
|
JS_ErrorFromException(JSContext *cx, jsval v)
|
||||||
{
|
{
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
return js_ErrorFromException(cx, v);
|
return js_ErrorFromException(cx, v);
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
|
134
js/src/jsarray.c
134
js/src/jsarray.c
@ -331,21 +331,6 @@ array_addProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
static JSBool
|
static JSBool
|
||||||
array_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
array_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||||
{
|
{
|
||||||
jsuint length;
|
|
||||||
|
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
|
||||||
if (!js_GetLengthProperty(cx, obj, &length))
|
|
||||||
return JS_FALSE;
|
|
||||||
switch (type) {
|
|
||||||
case JSTYPE_NUMBER:
|
|
||||||
return IndexToValue(cx, length, vp);
|
|
||||||
case JSTYPE_BOOLEAN:
|
|
||||||
*vp = BOOLEAN_TO_JSVAL(length > 0);
|
|
||||||
return JS_TRUE;
|
|
||||||
default:
|
|
||||||
return JS_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return js_TryValueOf(cx, obj, type, vp);
|
return js_TryValueOf(cx, obj, type, vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,12 +466,8 @@ array_join_sub(JSContext *cx, JSObject *obj, enum ArrayToStringOp op,
|
|||||||
goto done;
|
goto done;
|
||||||
if (id == JSID_HOLE) {
|
if (id == JSID_HOLE) {
|
||||||
str = cx->runtime->emptyString;
|
str = cx->runtime->emptyString;
|
||||||
/*
|
/* For tail holes always append single "," and not ", ". */
|
||||||
* For tail holes always append single "," and not ", "
|
if (index + 1 == length)
|
||||||
* unless the version is JS1.2 where for extra compatibility
|
|
||||||
* the full ", " is added even in the tail case.
|
|
||||||
*/
|
|
||||||
if (index + 1 == length && !JS_VERSION_IS_1_2(cx))
|
|
||||||
seplen = 1;
|
seplen = 1;
|
||||||
goto got_str;
|
goto got_str;
|
||||||
}
|
}
|
||||||
@ -496,17 +477,8 @@ array_join_sub(JSContext *cx, JSObject *obj, enum ArrayToStringOp op,
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if ((op != TO_SOURCE || JS_VERSION_IS_1_2(cx)) &&
|
if (op != TO_SOURCE && (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))) {
|
||||||
(JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))) {
|
|
||||||
str = cx->runtime->emptyString;
|
str = cx->runtime->emptyString;
|
||||||
if (op == TO_SOURCE) {
|
|
||||||
/*
|
|
||||||
* JS1.2 treats null and undefined in the same way as holes.
|
|
||||||
* It requires to add terminating ", " after empty string
|
|
||||||
* representing tail null or undefined.
|
|
||||||
*/
|
|
||||||
goto got_str;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (op == TO_LOCALE_STRING) {
|
if (op == TO_LOCALE_STRING) {
|
||||||
if (!js_ValueToObject(cx, v, &obj2) ||
|
if (!js_ValueToObject(cx, v, &obj2) ||
|
||||||
@ -611,13 +583,7 @@ static JSBool
|
|||||||
array_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
array_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
jsval *rval)
|
jsval *rval)
|
||||||
{
|
{
|
||||||
/*
|
return array_join_sub(cx, obj, TO_STRING, NULL, rval);
|
||||||
* JS1.2 arrays convert to array literals, with a comma followed by a space
|
|
||||||
* between each element.
|
|
||||||
*/
|
|
||||||
return array_join_sub(cx, obj,
|
|
||||||
(JS_VERSION_IS_1_2(cx) ? TO_SOURCE : TO_STRING),
|
|
||||||
NULL, rval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
@ -668,7 +634,6 @@ InitArrayObject(JSContext *cx, JSObject *obj, jsuint length, jsval *vector)
|
|||||||
return InitArrayElements(cx, obj, length, vector);
|
return InitArrayElements(cx, obj, length, vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_SOME_PERL_FUN
|
|
||||||
/*
|
/*
|
||||||
* Perl-inspired join, reverse, and sort.
|
* Perl-inspired join, reverse, and sort.
|
||||||
*/
|
*/
|
||||||
@ -1090,9 +1055,7 @@ out:
|
|||||||
JS_free(cx, vec);
|
JS_free(cx, vec);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SOME_PERL_FUN */
|
|
||||||
|
|
||||||
#if JS_HAS_MORE_PERL_FUN
|
|
||||||
/*
|
/*
|
||||||
* Perl-inspired push, pop, shift, unshift, and splice methods.
|
* Perl-inspired push, pop, shift, unshift, and splice methods.
|
||||||
*/
|
*/
|
||||||
@ -1112,17 +1075,10 @@ array_push(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Per ECMA-262, return the new array length. */
|
||||||
* If JS1.2, follow Perl4 by returning the last thing pushed. Otherwise,
|
|
||||||
* return the new array length.
|
|
||||||
*/
|
|
||||||
length += argc;
|
length += argc;
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
if (!IndexToValue(cx, length, rval))
|
||||||
*rval = argc ? argv[argc-1] : JSVAL_VOID;
|
return JS_FALSE;
|
||||||
} else {
|
|
||||||
if (!IndexToValue(cx, length, rval))
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
return js_SetLengthProperty(cx, obj, length);
|
return js_SetLengthProperty(cx, obj, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1292,53 +1248,35 @@ array_splice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1 && JS_VERSION_IS_1_2(cx)) {
|
if (count > 0) {
|
||||||
/*
|
/*
|
||||||
* JS lacks "list context", whereby in Perl one turns the single
|
* Create a new array value to return. Our ECMA v2 proposal specs
|
||||||
* scalar that's spliced out into an array just by assigning it to
|
* that splice always returns an array value, even when given no
|
||||||
* @single instead of $single, or by using it as Perl push's first
|
* arguments. We think this is best because it eliminates the need
|
||||||
* argument, for instance.
|
* for callers to do an extra test to handle the empty splice case.
|
||||||
*
|
|
||||||
* JS1.2 emulated Perl too closely and returned a non-Array for
|
|
||||||
* the single-splice-out case, requiring callers to test and wrap
|
|
||||||
* in [] if necessary. So JS1.3, default, and other versions all
|
|
||||||
* return an array of length 1 for uniformity.
|
|
||||||
*/
|
*/
|
||||||
if (!IndexToId(cx, begin, &id))
|
obj2 = js_NewArrayObject(cx, 0, NULL);
|
||||||
|
if (!obj2)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!OBJ_GET_PROPERTY(cx, obj, id, rval))
|
*rval = OBJECT_TO_JSVAL(obj2);
|
||||||
return JS_FALSE;
|
|
||||||
} else {
|
|
||||||
if (!JS_VERSION_IS_1_2(cx) || count > 0) {
|
|
||||||
/*
|
|
||||||
* Create a new array value to return. Our ECMA v2 proposal specs
|
|
||||||
* that splice always returns an array value, even when given no
|
|
||||||
* arguments. We think this is best because it eliminates the need
|
|
||||||
* for callers to do an extra test to handle the empty splice case.
|
|
||||||
*/
|
|
||||||
obj2 = js_NewArrayObject(cx, 0, NULL);
|
|
||||||
if (!obj2)
|
|
||||||
return JS_FALSE;
|
|
||||||
*rval = OBJECT_TO_JSVAL(obj2);
|
|
||||||
|
|
||||||
/* If there are elements to remove, put them into the return value. */
|
/* If there are elements to remove, put them into the return value. */
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
for (last = begin; last < end; last++) {
|
for (last = begin; last < end; last++) {
|
||||||
if (!IndexToExistingId(cx, obj, last, &id))
|
if (!IndexToExistingId(cx, obj, last, &id))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (id == JSID_HOLE)
|
if (id == JSID_HOLE)
|
||||||
continue; /* don't fill holes in the new array */
|
continue; /* don't fill holes in the new array */
|
||||||
if (!OBJ_GET_PROPERTY(cx, obj, id, vp))
|
if (!OBJ_GET_PROPERTY(cx, obj, id, vp))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!IndexToId(cx, last - begin, &id2))
|
if (!IndexToId(cx, last - begin, &id2))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!OBJ_SET_PROPERTY(cx, obj2, id2, vp))
|
if (!OBJ_SET_PROPERTY(cx, obj2, id2, vp))
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!js_SetLengthProperty(cx, obj2, end - begin))
|
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!js_SetLengthProperty(cx, obj2, end - begin))
|
||||||
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,9 +1332,7 @@ array_splice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
/* Update length in case we deleted elements from the end. */
|
/* Update length in case we deleted elements from the end. */
|
||||||
return js_SetLengthProperty(cx, obj, length);
|
return js_SetLengthProperty(cx, obj, length);
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_MORE_PERL_FUN */
|
|
||||||
|
|
||||||
#if JS_HAS_SEQUENCE_OPS
|
|
||||||
/*
|
/*
|
||||||
* Python-esque sequence operations.
|
* Python-esque sequence operations.
|
||||||
*/
|
*/
|
||||||
@ -1538,7 +1474,6 @@ array_slice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
}
|
}
|
||||||
return js_SetLengthProperty(cx, nobj, end - begin);
|
return js_SetLengthProperty(cx, nobj, end - begin);
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SEQUENCE_OPS */
|
|
||||||
|
|
||||||
#if JS_HAS_ARRAY_EXTRAS
|
#if JS_HAS_ARRAY_EXTRAS
|
||||||
|
|
||||||
@ -1828,24 +1763,18 @@ static JSFunctionSpec array_methods[] = {
|
|||||||
{js_toLocaleString_str, array_toLocaleString, 0,0,0},
|
{js_toLocaleString_str, array_toLocaleString, 0,0,0},
|
||||||
|
|
||||||
/* Perl-ish methods. */
|
/* Perl-ish methods. */
|
||||||
#if JS_HAS_SOME_PERL_FUN
|
|
||||||
{"join", array_join, 1,JSFUN_GENERIC_NATIVE,0},
|
{"join", array_join, 1,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"reverse", array_reverse, 0,JSFUN_GENERIC_NATIVE,2},
|
{"reverse", array_reverse, 0,JSFUN_GENERIC_NATIVE,2},
|
||||||
{"sort", array_sort, 1,JSFUN_GENERIC_NATIVE,2},
|
{"sort", array_sort, 1,JSFUN_GENERIC_NATIVE,2},
|
||||||
#endif
|
|
||||||
#if JS_HAS_MORE_PERL_FUN
|
|
||||||
{"push", array_push, 1,JSFUN_GENERIC_NATIVE,0},
|
{"push", array_push, 1,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"pop", array_pop, 0,JSFUN_GENERIC_NATIVE,0},
|
{"pop", array_pop, 0,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"shift", array_shift, 0,JSFUN_GENERIC_NATIVE,1},
|
{"shift", array_shift, 0,JSFUN_GENERIC_NATIVE,1},
|
||||||
{"unshift", array_unshift, 1,JSFUN_GENERIC_NATIVE,1},
|
{"unshift", array_unshift, 1,JSFUN_GENERIC_NATIVE,1},
|
||||||
{"splice", array_splice, 2,JSFUN_GENERIC_NATIVE,1},
|
{"splice", array_splice, 2,JSFUN_GENERIC_NATIVE,1},
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Python-esque sequence methods. */
|
/* Python-esque sequence methods. */
|
||||||
#if JS_HAS_SEQUENCE_OPS
|
|
||||||
{"concat", array_concat, 1,JSFUN_GENERIC_NATIVE,1},
|
{"concat", array_concat, 1,JSFUN_GENERIC_NATIVE,1},
|
||||||
{"slice", array_slice, 2,JSFUN_GENERIC_NATIVE,1},
|
{"slice", array_slice, 2,JSFUN_GENERIC_NATIVE,1},
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JS_HAS_ARRAY_EXTRAS
|
#if JS_HAS_ARRAY_EXTRAS
|
||||||
{"indexOf", array_indexOf, 1,JSFUN_GENERIC_NATIVE,0},
|
{"indexOf", array_indexOf, 1,JSFUN_GENERIC_NATIVE,0},
|
||||||
@ -1877,9 +1806,6 @@ Array(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
length = 0;
|
length = 0;
|
||||||
vector = NULL;
|
vector = NULL;
|
||||||
} else if (JS_VERSION_IS_1_2(cx)) {
|
|
||||||
length = (jsuint) argc;
|
|
||||||
vector = argv;
|
|
||||||
} else if (argc > 1) {
|
} else if (argc > 1) {
|
||||||
length = (jsuint) argc;
|
length = (jsuint) argc;
|
||||||
vector = argv;
|
vector = argv;
|
||||||
|
@ -63,10 +63,6 @@ js_AtomToPrintableString(JSContext *cx, JSAtom *atom)
|
|||||||
return js_ValueToPrintableString(cx, ATOM_KEY(atom));
|
return js_ValueToPrintableString(cx, ATOM_KEY(atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
extern const char js_Error_str[]; /* trivial, from jsexn.h */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep this in sync with jspubtd.h -- an assertion below will insist that
|
* Keep this in sync with jspubtd.h -- an assertion below will insist that
|
||||||
* its length match the JSType enum's JSTYPE_LIMIT limit value.
|
* its length match the JSType enum's JSTYPE_LIMIT limit value.
|
||||||
|
@ -149,15 +149,11 @@ js_ClearContextThread(JSContext *cx)
|
|||||||
void
|
void
|
||||||
js_OnVersionChange(JSContext *cx)
|
js_OnVersionChange(JSContext *cx)
|
||||||
{
|
{
|
||||||
#if !JS_BUG_FALLIBLE_EQOPS
|
#ifdef DEBUG
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
JSVersion version = JSVERSION_NUMBER(cx);
|
||||||
cx->jsop_eq = JSOP_NEW_EQ;
|
|
||||||
cx->jsop_ne = JSOP_NEW_NE;
|
JS_ASSERT(version == JSVERSION_DEFAULT || version >= JSVERSION_ECMA_3);
|
||||||
} else {
|
#endif
|
||||||
cx->jsop_eq = JSOP_EQ;
|
|
||||||
cx->jsop_ne = JSOP_NE;
|
|
||||||
}
|
|
||||||
#endif /* !JS_BUG_FALLIBLE_EQOPS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -217,12 +213,10 @@ js_NewContext(JSRuntime *rt, size_t stackChunkSize)
|
|||||||
JS_InitArenaPool(&cx->stackPool, "stack", stackChunkSize, sizeof(jsval));
|
JS_InitArenaPool(&cx->stackPool, "stack", stackChunkSize, sizeof(jsval));
|
||||||
JS_InitArenaPool(&cx->tempPool, "temp", 1024, sizeof(jsdouble));
|
JS_InitArenaPool(&cx->tempPool, "temp", 1024, sizeof(jsdouble));
|
||||||
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
if (!js_InitRegExpStatics(cx, &cx->regExpStatics)) {
|
if (!js_InitRegExpStatics(cx, &cx->regExpStatics)) {
|
||||||
js_DestroyContext(cx, JS_NO_GC);
|
js_DestroyContext(cx, JS_NO_GC);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If cx is the first context on this runtime, initialize well-known atoms,
|
* If cx is the first context on this runtime, initialize well-known atoms,
|
||||||
@ -317,7 +311,6 @@ js_DestroyContext(JSContext *cx, JSGCMode gcmode)
|
|||||||
JS_ClearAllWatchPoints(cx);
|
JS_ClearAllWatchPoints(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
/*
|
/*
|
||||||
* Remove more GC roots in regExpStatics, then collect garbage.
|
* Remove more GC roots in regExpStatics, then collect garbage.
|
||||||
* XXX anti-modularity alert: we rely on the call to js_RemoveRoot within
|
* XXX anti-modularity alert: we rely on the call to js_RemoveRoot within
|
||||||
@ -325,7 +318,6 @@ js_DestroyContext(JSContext *cx, JSGCMode gcmode)
|
|||||||
* XXX case where JS_DestroyContext is called outside of a request on cx
|
* XXX case where JS_DestroyContext is called outside of a request on cx
|
||||||
*/
|
*/
|
||||||
js_FreeRegExpStatics(cx, &cx->regExpStatics);
|
js_FreeRegExpStatics(cx, &cx->regExpStatics);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef JS_THREADSAFE
|
#ifdef JS_THREADSAFE
|
||||||
/*
|
/*
|
||||||
@ -911,7 +903,6 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp)
|
|||||||
if (reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
|
if (reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
|
||||||
reportp->flags |= JSREPORT_EXCEPTION;
|
reportp->flags |= JSREPORT_EXCEPTION;
|
||||||
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
/*
|
/*
|
||||||
* Call the error reporter only if an exception wasn't raised.
|
* Call the error reporter only if an exception wasn't raised.
|
||||||
*
|
*
|
||||||
@ -928,9 +919,6 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp)
|
|||||||
if (hook)
|
if (hook)
|
||||||
hook(cx, message, reportp, cx->runtime->debugErrorHookData);
|
hook(cx, message, reportp, cx->runtime->debugErrorHookData);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
js_ReportErrorAgain(cx, message, reportp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1297,13 +1285,8 @@ void js_traceoff(JSContext *cx) { cx->tracefp = NULL; }
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
|
JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
|
||||||
#if JS_HAS_DFLT_MSG_STRINGS
|
|
||||||
#define MSG_DEF(name, number, count, exception, format) \
|
#define MSG_DEF(name, number, count, exception, format) \
|
||||||
{ format, count, exception } ,
|
{ format, count, exception } ,
|
||||||
#else
|
|
||||||
#define MSG_DEF(name, number, count, exception, format) \
|
|
||||||
{ NULL, count, exception } ,
|
|
||||||
#endif
|
|
||||||
#include "js.msg"
|
#include "js.msg"
|
||||||
#undef MSG_DEF
|
#undef MSG_DEF
|
||||||
};
|
};
|
||||||
|
@ -662,7 +662,6 @@ struct JSContext {
|
|||||||
* and masking off the XML flag and any other high order bits.
|
* and masking off the XML flag and any other high order bits.
|
||||||
*/
|
*/
|
||||||
#define JS_VERSION_IS_ECMA(cx) JSVERSION_IS_ECMA(JSVERSION_NUMBER(cx))
|
#define JS_VERSION_IS_ECMA(cx) JSVERSION_IS_ECMA(JSVERSION_NUMBER(cx))
|
||||||
#define JS_VERSION_IS_1_2(cx) (JSVERSION_NUMBER(cx) == JSVERSION_1_2)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common subroutine of JS_SetVersion and js_SetVersion, to update per-context
|
* Common subroutine of JS_SetVersion and js_SetVersion, to update per-context
|
||||||
|
@ -58,15 +58,19 @@
|
|||||||
* <= JSVERSION_1_4 to mean "before the Third Edition of ECMA-262" and version
|
* <= JSVERSION_1_4 to mean "before the Third Edition of ECMA-262" and version
|
||||||
* > JSVERSION_1_4 to mean "at or after the Third Edition".
|
* > JSVERSION_1_4 to mean "at or after the Third Edition".
|
||||||
*
|
*
|
||||||
* In the unlikely event that SpiderMonkey ever implements JavaScript 2.0, or
|
* In the (likely?) event that SpiderMonkey grows to implement JavaScript 2.0,
|
||||||
* ECMA-262 Edition 4 (JS2 without certain extensions), the version number to
|
* or ECMA-262 Edition 4 (JS2 without certain extensions), the version number
|
||||||
* use would be near 200, or greater.
|
* to use would be near 200, or greater.
|
||||||
*
|
*
|
||||||
* The JS_VERSION_ECMA_3 version is the minimal configuration conforming to
|
* The JS_VERSION_ECMA_3 version is the minimal configuration conforming to
|
||||||
* the ECMA-262 Edition 3 specification. Use it for minimal embeddings, where
|
* the ECMA-262 Edition 3 specification. Use it for minimal embeddings, where
|
||||||
* you're sure you don't need any of the extensions disabled in this version.
|
* you're sure you don't need any of the extensions disabled in this version.
|
||||||
* In order to facilitate testing, JS_HAS_OBJ_PROTO_PROP is defined as part of
|
* In order to facilitate testing, JS_HAS_OBJ_PROTO_PROP is defined as part of
|
||||||
* the JS_VERSION_ECMA_3_TEST version.
|
* the JS_VERSION_ECMA_3_TEST version.
|
||||||
|
*
|
||||||
|
* To keep things sane in the modern age, where we need exceptions in order to
|
||||||
|
* implement, e.g., iterators and generators, we are dropping support for all
|
||||||
|
* versions <= 1.4.
|
||||||
*/
|
*/
|
||||||
#define JS_VERSION_ECMA_3 148
|
#define JS_VERSION_ECMA_3 148
|
||||||
#define JS_VERSION_ECMA_3_TEST 149
|
#define JS_VERSION_ECMA_3_TEST 149
|
||||||
@ -74,59 +78,24 @@
|
|||||||
#if JS_VERSION == JS_VERSION_ECMA_3 || \
|
#if JS_VERSION == JS_VERSION_ECMA_3 || \
|
||||||
JS_VERSION == JS_VERSION_ECMA_3_TEST
|
JS_VERSION == JS_VERSION_ECMA_3_TEST
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, array.pop, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 0 /* has str.anchor, str.bold, etc. */
|
#define JS_HAS_STR_HTML_HELPERS 0 /* has str.anchor, str.bold, etc. */
|
||||||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */
|
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has fun.apply(obj, argArray) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#if JS_VERSION == JS_VERSION_ECMA_3_TEST
|
#if JS_VERSION == JS_VERSION_ECMA_3_TEST
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
||||||
#else
|
#else
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */
|
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */
|
||||||
#endif
|
#endif
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */
|
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */
|
||||||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun */
|
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun */
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */
|
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */
|
||||||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */
|
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */
|
||||||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() */
|
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() */
|
||||||
#define JS_HAS_XDR 0 /* has XDR API and internal support */
|
#define JS_HAS_XDR 0 /* has XDR API and internal support */
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
||||||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */
|
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */
|
||||||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* has error object hierarchy */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
||||||
@ -136,357 +105,26 @@
|
|||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
||||||
|
|
||||||
#elif JS_VERSION == 100
|
#elif JS_VERSION < 150
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 1 /* o[0] defaults to null, not void */
|
#error "unsupported JS_VERSION"
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 1 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 1 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 1 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 1 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 0 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 0 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 0 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 0 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 0 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 0 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 0 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
|
||||||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */
|
|
||||||
#define JS_HAS_VALUEOF_HINT 0 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 0 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 0 /* has fun.apply(obj, argArray) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */
|
|
||||||
#define JS_HAS_REGEXPS 0 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 0 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 0 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */
|
|
||||||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun */
|
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */
|
|
||||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */
|
|
||||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() */
|
|
||||||
#define JS_HAS_XDR 0 /* has XDR API and internal support */
|
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
|
||||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */
|
|
||||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
|
||||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */
|
|
||||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native item */
|
|
||||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */
|
|
||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
|
||||||
|
|
||||||
#elif JS_VERSION == 110
|
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 1 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 1 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 1 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 1 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 1 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 1 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 1 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 0 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 0 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 0 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 0 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 0 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 0 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
|
||||||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */
|
|
||||||
#define JS_HAS_VALUEOF_HINT 0 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 0 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 0 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */
|
|
||||||
#define JS_HAS_REGEXPS 0 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 0 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 0 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */
|
|
||||||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun */
|
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */
|
|
||||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */
|
|
||||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() */
|
|
||||||
#define JS_HAS_XDR 0 /* has XDR API and internal support */
|
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
|
||||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */
|
|
||||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
|
||||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */
|
|
||||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native item */
|
|
||||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */
|
|
||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
|
||||||
|
|
||||||
#elif JS_VERSION == 120
|
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 1 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
|
||||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
|
||||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
|
||||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */
|
|
||||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() */
|
|
||||||
#define JS_HAS_XDR 0 /* has XDR API and internal support */
|
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
|
||||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */
|
|
||||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
|
||||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */
|
|
||||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native item */
|
|
||||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */
|
|
||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
|
||||||
|
|
||||||
#elif JS_VERSION == 130
|
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
|
||||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
|
||||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
|
||||||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
|
||||||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
|
||||||
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
|
||||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
|
||||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
|
||||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */
|
|
||||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native item */
|
|
||||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */
|
|
||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
|
||||||
|
|
||||||
#elif JS_VERSION == 140
|
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
|
||||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
|
||||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
|
||||||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
|
||||||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
|
||||||
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
|
||||||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
|
||||||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* rt errors reflected as exceptions */
|
|
||||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */
|
|
||||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */
|
|
||||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */
|
|
||||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */
|
|
||||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native item */
|
|
||||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */
|
|
||||||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */
|
|
||||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */
|
|
||||||
|
|
||||||
#elif JS_VERSION == 150
|
#elif JS_VERSION == 150
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
||||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
||||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
||||||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
||||||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
||||||
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
||||||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
||||||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
|
||||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */
|
#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */
|
||||||
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
|
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
|
||||||
#define JS_HAS_CONST 1 /* has JS2 const as alternative var */
|
#define JS_HAS_CONST 1 /* has JS2 const as alternative var */
|
||||||
@ -498,55 +136,20 @@
|
|||||||
|
|
||||||
#elif JS_VERSION == 160
|
#elif JS_VERSION == 160
|
||||||
|
|
||||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */
|
|
||||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */
|
|
||||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */
|
|
||||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */
|
|
||||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */
|
|
||||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */
|
|
||||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */
|
|
||||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */
|
|
||||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */
|
|
||||||
|
|
||||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */
|
|
||||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */
|
|
||||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */
|
|
||||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */
|
|
||||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */
|
|
||||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */
|
|
||||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */
|
|
||||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
|
||||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
|
||||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */
|
|
||||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */
|
|
||||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */
|
|
||||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */
|
|
||||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
||||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */
|
|
||||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */
|
|
||||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */
|
|
||||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
|
||||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
|
||||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
|
||||||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */
|
|
||||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
|
||||||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */
|
|
||||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
|
||||||
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
#define JS_HAS_XDR 1 /* has XDR API and internal support */
|
||||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
|
||||||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */
|
|
||||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */
|
|
||||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
||||||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) */
|
|
||||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */
|
|
||||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
|
||||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
|
||||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */
|
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
|
||||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
|
||||||
#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */
|
#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */
|
||||||
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
|
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
|
||||||
#define JS_HAS_CONST 1 /* has JS2 const as alternative var */
|
#define JS_HAS_CONST 1 /* has JS2 const as alternative var */
|
||||||
|
@ -924,7 +924,6 @@ date_getYear(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
{
|
{
|
||||||
jsdouble *date;
|
jsdouble *date;
|
||||||
jsdouble result;
|
jsdouble result;
|
||||||
JSVersion version;
|
|
||||||
|
|
||||||
date = date_getProlog(cx, obj, argv);
|
date = date_getProlog(cx, obj, argv);
|
||||||
if (!date)
|
if (!date)
|
||||||
@ -936,25 +935,8 @@ date_getYear(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
|
|
||||||
result = YearFromTime(LocalTime(result));
|
result = YearFromTime(LocalTime(result));
|
||||||
|
|
||||||
/*
|
/* Follow ECMA-262 to the letter, contrary to IE JScript. */
|
||||||
* During the great date rewrite of 1.3, we tried to track the evolving ECMA
|
result -= 1900;
|
||||||
* standard, which then had a definition of getYear which always subtracted
|
|
||||||
* 1900. Which we implemented, not realizing that it was incompatible with
|
|
||||||
* the old behavior... now, rather than thrash the behavior yet again,
|
|
||||||
* we've decided to leave it with the - 1900 behavior and point people to
|
|
||||||
* the getFullYear method. But we try to protect existing scripts that
|
|
||||||
* have specified a version...
|
|
||||||
*/
|
|
||||||
version = cx->version & JSVERSION_MASK;
|
|
||||||
if (version == JSVERSION_1_0 ||
|
|
||||||
version == JSVERSION_1_1 ||
|
|
||||||
version == JSVERSION_1_2)
|
|
||||||
{
|
|
||||||
if (result >= 1900 && result < 2000)
|
|
||||||
result -= 1900;
|
|
||||||
} else {
|
|
||||||
result -= 1900;
|
|
||||||
}
|
|
||||||
return js_NewNumberValue(cx, result, rval);
|
return js_NewNumberValue(cx, result, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1918,7 +1900,6 @@ date_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
return date_format(cx, *date, FORMATSPEC_FULL, rval);
|
return date_format(cx, *date, FORMATSPEC_FULL, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_VALUEOF_HINT
|
|
||||||
static JSBool
|
static JSBool
|
||||||
date_valueOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
date_valueOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
jsval *rval)
|
jsval *rval)
|
||||||
@ -1945,9 +1926,6 @@ date_valueOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
}
|
}
|
||||||
return date_toString(cx, obj, argc, argv, rval);
|
return date_toString(cx, obj, argc, argv, rval);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define date_valueOf date_getTime
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -790,19 +790,15 @@ JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp)
|
|||||||
{
|
{
|
||||||
if (! fp->fun)
|
if (! fp->fun)
|
||||||
return NULL;
|
return NULL;
|
||||||
#if JS_HAS_ARGS_OBJECT
|
|
||||||
/* Force creation of argument object if not yet created */
|
/* Force creation of argument object if not yet created */
|
||||||
(void) js_GetArgsObject(cx, fp);
|
(void) js_GetArgsObject(cx, fp);
|
||||||
#endif
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/*
|
/*
|
||||||
* XXX ill-defined: null return here means error was reported, unlike a
|
* XXX ill-defined: null return here means error was reported, unlike a
|
||||||
* null returned above or in the #else
|
* null returned above or in the #else
|
||||||
*/
|
*/
|
||||||
return js_GetCallObject(cx, fp, NULL);
|
return js_GetCallObject(cx, fp, NULL);
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif /* JS_HAS_CALL_OBJECT */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1025,12 +1021,10 @@ JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
|
|||||||
pd->flags |= ((sprop->attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0)
|
pd->flags |= ((sprop->attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0)
|
||||||
| ((sprop->attrs & JSPROP_READONLY) ? JSPD_READONLY : 0)
|
| ((sprop->attrs & JSPROP_READONLY) ? JSPD_READONLY : 0)
|
||||||
| ((sprop->attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0)
|
| ((sprop->attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0)
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
| ((getter == js_GetCallVariable) ? JSPD_VARIABLE : 0)
|
| ((getter == js_GetCallVariable) ? JSPD_VARIABLE : 0)
|
||||||
#endif /* JS_HAS_CALL_OBJECT */
|
|
||||||
| ((getter == js_GetArgument) ? JSPD_ARGUMENT : 0)
|
| ((getter == js_GetArgument) ? JSPD_ARGUMENT : 0)
|
||||||
| ((getter == js_GetLocalVariable) ? JSPD_VARIABLE : 0);
|
| ((getter == js_GetLocalVariable) ? JSPD_VARIABLE : 0);
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/* for Call Object 'real' getter isn't passed in to us */
|
/* for Call Object 'real' getter isn't passed in to us */
|
||||||
if (OBJ_GET_CLASS(cx, obj) == &js_CallClass &&
|
if (OBJ_GET_CLASS(cx, obj) == &js_CallClass &&
|
||||||
getter == js_CallClass.getProperty) {
|
getter == js_CallClass.getProperty) {
|
||||||
@ -1045,7 +1039,7 @@ JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
|
|||||||
? JSPD_ARGUMENT
|
? JSPD_ARGUMENT
|
||||||
: JSPD_VARIABLE;
|
: JSPD_VARIABLE;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_CALL_OBJECT */
|
|
||||||
pd->spare = 0;
|
pd->spare = 0;
|
||||||
pd->slot = (pd->flags & (JSPD_ARGUMENT | JSPD_VARIABLE))
|
pd->slot = (pd->flags & (JSPD_ARGUMENT | JSPD_VARIABLE))
|
||||||
? sprop->shortid
|
? sprop->shortid
|
||||||
|
@ -560,7 +560,6 @@ BuildSpanDepTable(JSContext *cx, JSCodeGenerator *cg)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case JOF_TABLESWITCH:
|
case JOF_TABLESWITCH:
|
||||||
{
|
{
|
||||||
jsbytecode *pc2;
|
jsbytecode *pc2;
|
||||||
@ -608,7 +607,6 @@ BuildSpanDepTable(JSContext *cx, JSCodeGenerator *cg)
|
|||||||
len = 1 + pc2 - pc;
|
len = 1 + pc2 - pc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ASSERT(len > 0);
|
JS_ASSERT(len > 0);
|
||||||
@ -2320,7 +2318,6 @@ EmitNumberOp(JSContext *cx, jsdouble dval, JSCodeGenerator *cg)
|
|||||||
return EmitAtomIndexOp(cx, JSOP_NUMBER, ALE_INDEX(ale), cg);
|
return EmitAtomIndexOp(cx, JSOP_NUMBER, ALE_INDEX(ale), cg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
static JSBool
|
static JSBool
|
||||||
EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
||||||
JSStmtInfo *stmtInfo)
|
JSStmtInfo *stmtInfo)
|
||||||
@ -2765,7 +2762,6 @@ bad:
|
|||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
|
js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
|
||||||
@ -2922,13 +2918,11 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
atomIndex = ALE_INDEX(ale);
|
atomIndex = ALE_INDEX(ale);
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
/* Emit a bytecode pointing to the closure object in its immediate. */
|
/* Emit a bytecode pointing to the closure object in its immediate. */
|
||||||
if (pn->pn_op != JSOP_NOP) {
|
if (pn->pn_op != JSOP_NOP) {
|
||||||
EMIT_ATOM_INDEX_OP(pn->pn_op, atomIndex);
|
EMIT_ATOM_INDEX_OP(pn->pn_op, atomIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Top-level named functions need a nop for decompilation. */
|
/* Top-level named functions need a nop for decompilation. */
|
||||||
noteIndex = js_NewSrcNote2(cx, cg, SRC_FUNCDEF, (ptrdiff_t)atomIndex);
|
noteIndex = js_NewSrcNote2(cx, cg, SRC_FUNCDEF, (ptrdiff_t)atomIndex);
|
||||||
@ -2943,7 +2937,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
*/
|
*/
|
||||||
CG_SWITCH_TO_PROLOG(cg);
|
CG_SWITCH_TO_PROLOG(cg);
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
if (cg->treeContext.flags & TCF_IN_FUNCTION) {
|
if (cg->treeContext.flags & TCF_IN_FUNCTION) {
|
||||||
JSObject *obj, *pobj;
|
JSObject *obj, *pobj;
|
||||||
JSProperty *prop;
|
JSProperty *prop;
|
||||||
@ -2984,9 +2977,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
pc += VARNO_LEN;
|
pc += VARNO_LEN;
|
||||||
SET_ATOM_INDEX(pc, atomIndex);
|
SET_ATOM_INDEX(pc, atomIndex);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
EMIT_ATOM_INDEX_OP(JSOP_DEFFUN, atomIndex);
|
EMIT_ATOM_INDEX_OP(JSOP_DEFFUN, atomIndex);
|
||||||
|
}
|
||||||
|
|
||||||
CG_SWITCH_TO_MAIN(cg);
|
CG_SWITCH_TO_MAIN(cg);
|
||||||
break;
|
break;
|
||||||
@ -3107,12 +3100,10 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
ok = js_PopStatementCG(cx, cg);
|
ok = js_PopStatementCG(cx, cg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case TOK_SWITCH:
|
case TOK_SWITCH:
|
||||||
/* Out of line to avoid bloating js_EmitTree's stack frame size. */
|
/* Out of line to avoid bloating js_EmitTree's stack frame size. */
|
||||||
ok = EmitSwitch(cx, cg, pn, &stmtInfo);
|
ok = EmitSwitch(cx, cg, pn, &stmtInfo);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
case TOK_WHILE:
|
case TOK_WHILE:
|
||||||
js_PushStatement(&cg->treeContext, &stmtInfo, STMT_WHILE_LOOP, top);
|
js_PushStatement(&cg->treeContext, &stmtInfo, STMT_WHILE_LOOP, top);
|
||||||
@ -3135,7 +3126,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
ok = js_PopStatementCG(cx, cg);
|
ok = js_PopStatementCG(cx, cg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_DO_WHILE_LOOP
|
|
||||||
case TOK_DO:
|
case TOK_DO:
|
||||||
/* Emit an annotated nop so we know to decompile a 'do' keyword. */
|
/* Emit an annotated nop so we know to decompile a 'do' keyword. */
|
||||||
if (js_NewSrcNote(cx, cg, SRC_WHILE) < 0 ||
|
if (js_NewSrcNote(cx, cg, SRC_WHILE) < 0 ||
|
||||||
@ -3169,7 +3159,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
ok = js_PopStatementCG(cx, cg);
|
ok = js_PopStatementCG(cx, cg);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_DO_WHILE_LOOP */
|
|
||||||
|
|
||||||
case TOK_FOR:
|
case TOK_FOR:
|
||||||
beq = 0; /* suppress gcc warnings */
|
beq = 0; /* suppress gcc warnings */
|
||||||
@ -3511,8 +3500,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
ok = js_PopStatementCG(cx, cg);
|
ok = js_PopStatementCG(cx, cg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
|
|
||||||
case TOK_TRY:
|
case TOK_TRY:
|
||||||
{
|
{
|
||||||
ptrdiff_t start, end, catchStart, finallyCatch, catchJump;
|
ptrdiff_t start, end, catchStart, finallyCatch, catchJump;
|
||||||
@ -3813,8 +3800,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
|
||||||
case TOK_VAR:
|
case TOK_VAR:
|
||||||
off = noteIndex = -1;
|
off = noteIndex = -1;
|
||||||
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
|
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
|
||||||
@ -4305,12 +4290,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
case TOK_BITAND:
|
case TOK_BITAND:
|
||||||
case TOK_EQOP:
|
case TOK_EQOP:
|
||||||
case TOK_RELOP:
|
case TOK_RELOP:
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
case TOK_IN:
|
case TOK_IN:
|
||||||
#endif
|
|
||||||
#if JS_HAS_INSTANCEOF
|
|
||||||
case TOK_INSTANCEOF:
|
case TOK_INSTANCEOF:
|
||||||
#endif
|
|
||||||
case TOK_SHOP:
|
case TOK_SHOP:
|
||||||
case TOK_PLUS:
|
case TOK_PLUS:
|
||||||
case TOK_MINUS:
|
case TOK_MINUS:
|
||||||
@ -4349,9 +4330,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case TOK_THROW:
|
case TOK_THROW:
|
||||||
#endif
|
|
||||||
#if JS_HAS_XML_SUPPORT
|
#if JS_HAS_XML_SUPPORT
|
||||||
case TOK_AT:
|
case TOK_AT:
|
||||||
case TOK_DEFAULT:
|
case TOK_DEFAULT:
|
||||||
@ -4588,7 +4567,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
case TOK_RB:
|
case TOK_RB:
|
||||||
/*
|
/*
|
||||||
* Emit code for [a, b, c] of the form:
|
* Emit code for [a, b, c] of the form:
|
||||||
@ -4722,7 +4700,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
EMIT_UINT16_IMM_OP(JSOP_USESHARP, (jsatomid) pn->pn_num);
|
EMIT_UINT16_IMM_OP(JSOP_USESHARP, (jsatomid) pn->pn_num);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_SHARP_VARS */
|
#endif /* JS_HAS_SHARP_VARS */
|
||||||
#endif /* JS_HAS_INITIALIZERS */
|
|
||||||
|
|
||||||
case TOK_RP:
|
case TOK_RP:
|
||||||
/*
|
/*
|
||||||
|
@ -60,11 +60,6 @@
|
|||||||
#include "jsopcode.h"
|
#include "jsopcode.h"
|
||||||
#include "jsscript.h"
|
#include "jsscript.h"
|
||||||
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
#if !JS_HAS_EXCEPTIONS
|
|
||||||
# error "JS_HAS_EXCEPTIONS must be defined to use JS_HAS_ERROR_EXCEPTIONS"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* XXX consider adding rt->atomState.messageAtom */
|
/* XXX consider adding rt->atomState.messageAtom */
|
||||||
static char js_message_str[] = "message";
|
static char js_message_str[] = "message";
|
||||||
static char js_filename_str[] = "fileName";
|
static char js_filename_str[] = "fileName";
|
||||||
@ -1061,9 +1056,6 @@ out:
|
|||||||
cx->creatingException = JS_FALSE;
|
cx->creatingException = JS_FALSE;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_ERROR_EXCEPTIONS */
|
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
js_ReportUncaughtException(JSContext *cx)
|
js_ReportUncaughtException(JSContext *cx)
|
||||||
@ -1104,11 +1096,7 @@ js_ReportUncaughtException(JSContext *cx)
|
|||||||
vp[0] = exn;
|
vp[0] = exn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
reportp = js_ErrorFromException(cx, exn);
|
reportp = js_ErrorFromException(cx, exn);
|
||||||
#else
|
|
||||||
reportp = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* XXX L10N angels cry once again (see also jsemit.c, /L10N gaffes/) */
|
/* XXX L10N angels cry once again (see also jsemit.c, /L10N gaffes/) */
|
||||||
str = js_ValueToString(cx, exn);
|
str = js_ValueToString(cx, exn);
|
||||||
@ -1171,5 +1159,3 @@ out:
|
|||||||
js_FreeStack(cx, mark);
|
js_FreeStack(cx, mark);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
@ -52,18 +52,6 @@ JS_BEGIN_EXTERN_C
|
|||||||
extern JSObject *
|
extern JSObject *
|
||||||
js_InitExceptionClasses(JSContext *cx, JSObject *obj);
|
js_InitExceptionClasses(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
/*
|
|
||||||
* String constants naming the exception classes.
|
|
||||||
*/
|
|
||||||
extern const char js_Error_str[];
|
|
||||||
extern const char js_InternalError_str[];
|
|
||||||
extern const char js_EvalError_str[];
|
|
||||||
extern const char js_RangeError_str[];
|
|
||||||
extern const char js_ReferenceError_str[];
|
|
||||||
extern const char js_SyntaxError_str[];
|
|
||||||
extern const char js_TypeError_str[];
|
|
||||||
extern const char js_URIError_str[];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a JSErrorReport, check to see if there is an exception associated with
|
* Given a JSErrorReport, check to see if there is an exception associated with
|
||||||
* the error number. If there is, then create an appropriate exception object,
|
* the error number. If there is, then create an appropriate exception object,
|
||||||
|
@ -87,8 +87,6 @@ enum {
|
|||||||
#define SET_OVERRIDE_BIT(fp, tinyid) \
|
#define SET_OVERRIDE_BIT(fp, tinyid) \
|
||||||
((fp)->flags |= JS_BIT(JSFRAME_OVERRIDE_SHIFT - ((tinyid) + 1)))
|
((fp)->flags |= JS_BIT(JSFRAME_OVERRIDE_SHIFT - ((tinyid) + 1)))
|
||||||
|
|
||||||
#if JS_HAS_ARGS_OBJECT
|
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
js_GetArgsValue(JSContext *cx, JSStackFrame *fp, jsval *vp)
|
js_GetArgsValue(JSContext *cx, JSStackFrame *fp, jsval *vp)
|
||||||
{
|
{
|
||||||
@ -540,10 +538,6 @@ JSClass js_ArgumentsClass = {
|
|||||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* JS_HAS_ARGS_OBJECT */
|
|
||||||
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
|
js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
|
||||||
{
|
{
|
||||||
@ -895,7 +889,7 @@ call_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
|||||||
|
|
||||||
JSClass js_CallClass = {
|
JSClass js_CallClass = {
|
||||||
js_Call_str,
|
js_Call_str,
|
||||||
JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE |
|
JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE | JSCLASS_IS_ANONYMOUS |
|
||||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Call),
|
JSCLASS_HAS_CACHED_PROTO(JSProto_Call),
|
||||||
JS_PropertyStub, JS_PropertyStub,
|
JS_PropertyStub, JS_PropertyStub,
|
||||||
call_getProperty, call_setProperty,
|
call_getProperty, call_setProperty,
|
||||||
@ -904,8 +898,6 @@ JSClass js_CallClass = {
|
|||||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* JS_HAS_CALL_OBJECT */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ECMA-262 specifies that length is a property of function object instances,
|
* ECMA-262 specifies that length is a property of function object instances,
|
||||||
* but we can avoid that space cost by delegating to a prototype property that
|
* but we can avoid that space cost by delegating to a prototype property that
|
||||||
@ -976,7 +968,6 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
|
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case CALL_ARGUMENTS:
|
case CALL_ARGUMENTS:
|
||||||
#if JS_HAS_ARGS_OBJECT
|
|
||||||
/* Warn if strict about f.arguments or equivalent unqualified uses. */
|
/* Warn if strict about f.arguments or equivalent unqualified uses. */
|
||||||
if (!JS_ReportErrorFlagsAndNumber(cx,
|
if (!JS_ReportErrorFlagsAndNumber(cx,
|
||||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||||
@ -992,15 +983,8 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
*vp = JSVAL_NULL;
|
*vp = JSVAL_NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#else /* !JS_HAS_ARGS_OBJECT */
|
|
||||||
*vp = OBJECT_TO_JSVAL(fp ? obj : NULL);
|
|
||||||
break;
|
|
||||||
#endif /* !JS_HAS_ARGS_OBJECT */
|
|
||||||
|
|
||||||
case ARGS_LENGTH:
|
case ARGS_LENGTH:
|
||||||
if (!JS_VERSION_IS_ECMA(cx))
|
|
||||||
*vp = INT_TO_JSVAL((jsint)(fp && fp->fun ? fp->argc : fun->nargs));
|
|
||||||
else
|
|
||||||
case FUN_ARITY:
|
case FUN_ARITY:
|
||||||
*vp = INT_TO_JSVAL((jsint)fun->nargs);
|
*vp = INT_TO_JSVAL((jsint)fun->nargs);
|
||||||
break;
|
break;
|
||||||
@ -1369,8 +1353,6 @@ bad:
|
|||||||
|
|
||||||
#endif /* !JS_HAS_XDR */
|
#endif /* !JS_HAS_XDR */
|
||||||
|
|
||||||
#if JS_HAS_INSTANCEOF
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [[HasInstance]] internal method for Function objects: fetch the .prototype
|
* [[HasInstance]] internal method for Function objects: fetch the .prototype
|
||||||
* property of its 'this' parameter, and walks the prototype chain of v (only
|
* property of its 'this' parameter, and walks the prototype chain of v (only
|
||||||
@ -1405,12 +1387,6 @@ fun_hasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||||||
return js_IsDelegate(cx, JSVAL_TO_OBJECT(pval), v, bp);
|
return js_IsDelegate(cx, JSVAL_TO_OBJECT(pval), v, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !JS_HAS_INSTANCEOF */
|
|
||||||
|
|
||||||
#define fun_hasInstance NULL
|
|
||||||
|
|
||||||
#endif /* !JS_HAS_INSTANCEOF */
|
|
||||||
|
|
||||||
static uint32
|
static uint32
|
||||||
fun_mark(JSContext *cx, JSObject *obj, void *arg)
|
fun_mark(JSContext *cx, JSObject *obj, void *arg)
|
||||||
{
|
{
|
||||||
@ -1521,7 +1497,6 @@ fun_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
|
|
||||||
static const char call_str[] = "call";
|
static const char call_str[] = "call";
|
||||||
|
|
||||||
#if JS_HAS_CALL_FUNCTION
|
|
||||||
static JSBool
|
static JSBool
|
||||||
fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||||
{
|
{
|
||||||
@ -1583,9 +1558,7 @@ fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
js_FreeStack(cx, mark);
|
js_FreeStack(cx, mark);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_CALL_FUNCTION */
|
|
||||||
|
|
||||||
#if JS_HAS_APPLY_FUNCTION
|
|
||||||
static JSBool
|
static JSBool
|
||||||
fun_apply(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
fun_apply(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||||
{
|
{
|
||||||
@ -1675,7 +1648,6 @@ out:
|
|||||||
js_FreeStack(cx, mark);
|
js_FreeStack(cx, mark);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_APPLY_FUNCTION */
|
|
||||||
|
|
||||||
#ifdef NARCISSUS
|
#ifdef NARCISSUS
|
||||||
static JSBool
|
static JSBool
|
||||||
@ -1735,12 +1707,8 @@ static JSFunctionSpec function_methods[] = {
|
|||||||
{js_toSource_str, fun_toSource, 0,0,0},
|
{js_toSource_str, fun_toSource, 0,0,0},
|
||||||
#endif
|
#endif
|
||||||
{js_toString_str, fun_toString, 1,0,0},
|
{js_toString_str, fun_toString, 1,0,0},
|
||||||
#if JS_HAS_APPLY_FUNCTION
|
|
||||||
{"apply", fun_apply, 2,0,0},
|
{"apply", fun_apply, 2,0,0},
|
||||||
#endif
|
|
||||||
#if JS_HAS_CALL_FUNCTION
|
|
||||||
{call_str, fun_call, 1,0,0},
|
{call_str, fun_call, 1,0,0},
|
||||||
#endif
|
|
||||||
#ifdef NARCISSUS
|
#ifdef NARCISSUS
|
||||||
{"__applyConstructor__", fun_applyConstructor, 1,0,0},
|
{"__applyConstructor__", fun_applyConstructor, 1,0,0},
|
||||||
#endif
|
#endif
|
||||||
@ -1801,7 +1769,6 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
if (fun)
|
if (fun)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/*
|
/*
|
||||||
* NB: (new Function) is not lexically closed by its caller, it's just an
|
* NB: (new Function) is not lexically closed by its caller, it's just an
|
||||||
* anonymous function in the top-level scope that its constructor inhabits.
|
* anonymous function in the top-level scope that its constructor inhabits.
|
||||||
@ -1813,15 +1780,9 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
* top-level reachable from scopeChain (in HTML frames, e.g.).
|
* top-level reachable from scopeChain (in HTML frames, e.g.).
|
||||||
*/
|
*/
|
||||||
parent = OBJ_GET_PARENT(cx, JSVAL_TO_OBJECT(argv[-2]));
|
parent = OBJ_GET_PARENT(cx, JSVAL_TO_OBJECT(argv[-2]));
|
||||||
#else
|
|
||||||
/* Set up for dynamic parenting (see js_Invoke in jsinterp.c). */
|
|
||||||
parent = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fun = js_NewFunction(cx, obj, NULL, 0, JSFUN_LAMBDA, parent,
|
fun = js_NewFunction(cx, obj, NULL, 0, JSFUN_LAMBDA, parent,
|
||||||
JS_VERSION_IS_ECMA(cx)
|
cx->runtime->atomState.anonymousAtom);
|
||||||
? cx->runtime->atomState.anonymousAtom
|
|
||||||
: NULL);
|
|
||||||
|
|
||||||
if (!fun)
|
if (!fun)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -2068,7 +2029,6 @@ bad:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
JSObject *
|
JSObject *
|
||||||
js_InitCallClass(JSContext *cx, JSObject *obj)
|
js_InitCallClass(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
@ -2086,7 +2046,6 @@ js_InitCallClass(JSContext *cx, JSObject *obj)
|
|||||||
OBJ_SET_PROTO(cx, proto, NULL);
|
OBJ_SET_PROTO(cx, proto, NULL);
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
JSFunction *
|
JSFunction *
|
||||||
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
|
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
|
||||||
|
@ -2041,10 +2041,8 @@ restart:
|
|||||||
if (thing)
|
if (thing)
|
||||||
GC_MARK(cx, thing, "lastInternalResult");
|
GC_MARK(cx, thing, "lastInternalResult");
|
||||||
}
|
}
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
if (acx->throwing && JSVAL_IS_GCTHING(acx->exception))
|
if (acx->throwing && JSVAL_IS_GCTHING(acx->exception))
|
||||||
GC_MARK(cx, JSVAL_TO_GCTHING(acx->exception), "exception");
|
GC_MARK(cx, JSVAL_TO_GCTHING(acx->exception), "exception");
|
||||||
#endif
|
|
||||||
#if JS_HAS_LVALUE_RETURN
|
#if JS_HAS_LVALUE_RETURN
|
||||||
if (acx->rval2set && JSVAL_IS_GCTHING(acx->rval2))
|
if (acx->rval2set && JSVAL_IS_GCTHING(acx->rval2))
|
||||||
GC_MARK(cx, JSVAL_TO_GCTHING(acx->rval2), "rval2");
|
GC_MARK(cx, JSVAL_TO_GCTHING(acx->rval2), "rval2");
|
||||||
|
@ -322,31 +322,12 @@ static JSClass prop_iterator_class = {
|
|||||||
STORE_OPND(n, OBJECT_TO_JSVAL(obj)); \
|
STORE_OPND(n, OBJECT_TO_JSVAL(obj)); \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
#if JS_BUG_VOID_TOSTRING
|
|
||||||
#define CHECK_VOID_TOSTRING(cx, v) \
|
|
||||||
if (JSVAL_IS_VOID(v)) { \
|
|
||||||
JSString *str_; \
|
|
||||||
str_ = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]); \
|
|
||||||
v = STRING_TO_JSVAL(str_); \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define CHECK_VOID_TOSTRING(cx, v) ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JS_BUG_EAGER_TOSTRING
|
|
||||||
#define CHECK_EAGER_TOSTRING(hint) (hint = JSTYPE_STRING)
|
|
||||||
#else
|
|
||||||
#define CHECK_EAGER_TOSTRING(hint) ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define VALUE_TO_PRIMITIVE(cx, v, hint, vp) \
|
#define VALUE_TO_PRIMITIVE(cx, v, hint, vp) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
if (JSVAL_IS_PRIMITIVE(v)) { \
|
if (JSVAL_IS_PRIMITIVE(v)) { \
|
||||||
CHECK_VOID_TOSTRING(cx, v); \
|
|
||||||
*vp = v; \
|
*vp = v; \
|
||||||
} else { \
|
} else { \
|
||||||
SAVE_SP_AND_PC(fp); \
|
SAVE_SP_AND_PC(fp); \
|
||||||
CHECK_EAGER_TOSTRING(hint); \
|
|
||||||
ok = OBJ_DEFAULT_VALUE(cx, JSVAL_TO_OBJECT(v), hint, vp); \
|
ok = OBJ_DEFAULT_VALUE(cx, JSVAL_TO_OBJECT(v), hint, vp); \
|
||||||
if (!ok) \
|
if (!ok) \
|
||||||
goto out; \
|
goto out; \
|
||||||
@ -1071,8 +1052,7 @@ js_Invoke(JSContext *cx, uintN argc, uintN flags)
|
|||||||
* We attempt the conversion under all circumstances for 1.2, but
|
* We attempt the conversion under all circumstances for 1.2, but
|
||||||
* only if there is a call op defined otherwise.
|
* only if there is a call op defined otherwise.
|
||||||
*/
|
*/
|
||||||
if (JS_VERSION_IS_1_2(cx) ||
|
if ((ops == &js_ObjectOps) ? clasp->call : ops->call) {
|
||||||
((ops == &js_ObjectOps) ? clasp->call : ops->call)) {
|
|
||||||
ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v);
|
ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
goto out2;
|
goto out2;
|
||||||
@ -1256,16 +1236,11 @@ have_fun:
|
|||||||
/* Use parent scope so js_GetCallObject can find the right "Call". */
|
/* Use parent scope so js_GetCallObject can find the right "Call". */
|
||||||
frame.scopeChain = parent;
|
frame.scopeChain = parent;
|
||||||
if (fun->flags & JSFUN_HEAVYWEIGHT) {
|
if (fun->flags & JSFUN_HEAVYWEIGHT) {
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/* Scope with a call object parented by the callee's parent. */
|
/* Scope with a call object parented by the callee's parent. */
|
||||||
if (!js_GetCallObject(cx, &frame, parent)) {
|
if (!js_GetCallObject(cx, &frame, parent)) {
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* Bad old code used the function as a proxy for all calls to it. */
|
|
||||||
frame.scopeChain = funobj;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
ok = js_Interpret(cx, script->code, &v);
|
ok = js_Interpret(cx, script->code, &v);
|
||||||
} else {
|
} else {
|
||||||
@ -1280,16 +1255,14 @@ out:
|
|||||||
if (hook)
|
if (hook)
|
||||||
hook(cx, &frame, JS_FALSE, &ok, hookData);
|
hook(cx, &frame, JS_FALSE, &ok, hookData);
|
||||||
}
|
}
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/* If frame has a call object, sync values and clear back-pointer. */
|
/* If frame has a call object, sync values and clear back-pointer. */
|
||||||
if (frame.callobj)
|
if (frame.callobj)
|
||||||
ok &= js_PutCallObject(cx, &frame);
|
ok &= js_PutCallObject(cx, &frame);
|
||||||
#endif
|
|
||||||
#if JS_HAS_ARGS_OBJECT
|
|
||||||
/* If frame has an arguments object, sync values and clear back-pointer. */
|
/* If frame has an arguments object, sync values and clear back-pointer. */
|
||||||
if (frame.argsobj)
|
if (frame.argsobj)
|
||||||
ok &= js_PutArgsObject(cx, &frame);
|
ok &= js_PutArgsObject(cx, &frame);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Restore cx->fp now that we're done releasing frame objects. */
|
/* Restore cx->fp now that we're done releasing frame objects. */
|
||||||
cx->fp = fp;
|
cx->fp = fp;
|
||||||
@ -1796,7 +1769,7 @@ js_InvokeConstructor(JSContext *cx, jsval *vp, uintN argc)
|
|||||||
/* Check the return value and if it's primitive, force it to be obj. */
|
/* Check the return value and if it's primitive, force it to be obj. */
|
||||||
rval = *vp;
|
rval = *vp;
|
||||||
if (JSVAL_IS_PRIMITIVE(rval)) {
|
if (JSVAL_IS_PRIMITIVE(rval)) {
|
||||||
if (!fun && JS_VERSION_IS_ECMA(cx)) {
|
if (!fun) {
|
||||||
/* native [[Construct]] returning primitive is error */
|
/* native [[Construct]] returning primitive is error */
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||||
JSMSG_BAD_NEW_RESULT,
|
JSMSG_BAD_NEW_RESULT,
|
||||||
@ -1922,10 +1895,8 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result)
|
|||||||
#if JS_HAS_EXPORT_IMPORT
|
#if JS_HAS_EXPORT_IMPORT
|
||||||
JSIdArray *ida;
|
JSIdArray *ida;
|
||||||
#endif
|
#endif
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
jsint low, high, off, npairs;
|
jsint low, high, off, npairs;
|
||||||
JSBool match;
|
JSBool match;
|
||||||
#endif
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
JSPropertyOp getter, setter;
|
JSPropertyOp getter, setter;
|
||||||
#endif
|
#endif
|
||||||
@ -2081,13 +2052,11 @@ interrupt:
|
|||||||
case JSTRAP_RETURN:
|
case JSTRAP_RETURN:
|
||||||
fp->rval = rval;
|
fp->rval = rval;
|
||||||
goto out;
|
goto out;
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSTRAP_THROW:
|
case JSTRAP_THROW:
|
||||||
cx->throwing = JS_TRUE;
|
cx->throwing = JS_TRUE;
|
||||||
cx->exception = rval;
|
cx->exception = rval;
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
LOAD_INTERRUPT_HANDLER(rt);
|
LOAD_INTERRUPT_HANDLER(rt);
|
||||||
@ -2140,13 +2109,11 @@ interrupt:
|
|||||||
case JSTRAP_RETURN:
|
case JSTRAP_RETURN:
|
||||||
fp->rval = rval;
|
fp->rval = rval;
|
||||||
goto out;
|
goto out;
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSTRAP_THROW:
|
case JSTRAP_THROW:
|
||||||
cx->throwing = JS_TRUE;
|
cx->throwing = JS_TRUE;
|
||||||
cx->exception = rval;
|
cx->exception = rval;
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
LOAD_INTERRUPT_HANDLER(rt);
|
LOAD_INTERRUPT_HANDLER(rt);
|
||||||
@ -2245,7 +2212,6 @@ interrupt:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_CALL_OBJECT
|
|
||||||
/*
|
/*
|
||||||
* If frame has a call object, sync values and clear the back-
|
* If frame has a call object, sync values and clear the back-
|
||||||
* pointer. This can happen for a lightweight function if it
|
* pointer. This can happen for a lightweight function if it
|
||||||
@ -2256,13 +2222,11 @@ interrupt:
|
|||||||
SAVE_SP_AND_PC(fp);
|
SAVE_SP_AND_PC(fp);
|
||||||
ok &= js_PutCallObject(cx, fp);
|
ok &= js_PutCallObject(cx, fp);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if JS_HAS_ARGS_OBJECT
|
|
||||||
if (fp->argsobj) {
|
if (fp->argsobj) {
|
||||||
SAVE_SP_AND_PC(fp);
|
SAVE_SP_AND_PC(fp);
|
||||||
ok &= js_PutArgsObject(cx, fp);
|
ok &= js_PutArgsObject(cx, fp);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Restore context version only if callee hasn't set version. */
|
/* Restore context version only if callee hasn't set version. */
|
||||||
if (JS_LIKELY(cx->version == currentVersion)) {
|
if (JS_LIKELY(cx->version == currentVersion)) {
|
||||||
@ -2304,11 +2268,9 @@ interrupt:
|
|||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
BEGIN_CASE(JSOP_DEFAULT)
|
BEGIN_CASE(JSOP_DEFAULT)
|
||||||
(void) POP();
|
(void) POP();
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
#endif
|
|
||||||
BEGIN_CASE(JSOP_GOTO)
|
BEGIN_CASE(JSOP_GOTO)
|
||||||
len = GET_JUMP_OFFSET(pc);
|
len = GET_JUMP_OFFSET(pc);
|
||||||
CHECK_BRANCH(len);
|
CHECK_BRANCH(len);
|
||||||
@ -2350,11 +2312,9 @@ interrupt:
|
|||||||
}
|
}
|
||||||
END_CASE(JSOP_AND)
|
END_CASE(JSOP_AND)
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
BEGIN_CASE(JSOP_DEFAULTX)
|
BEGIN_CASE(JSOP_DEFAULTX)
|
||||||
(void) POP();
|
(void) POP();
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
#endif
|
|
||||||
BEGIN_CASE(JSOP_GOTOX)
|
BEGIN_CASE(JSOP_GOTOX)
|
||||||
len = GET_JUMPX_OFFSET(pc);
|
len = GET_JUMPX_OFFSET(pc);
|
||||||
CHECK_BRANCH(len);
|
CHECK_BRANCH(len);
|
||||||
@ -2428,7 +2388,6 @@ interrupt:
|
|||||||
} \
|
} \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
BEGIN_CASE(JSOP_IN)
|
BEGIN_CASE(JSOP_IN)
|
||||||
SAVE_SP_AND_PC(fp);
|
SAVE_SP_AND_PC(fp);
|
||||||
rval = FETCH_OPND(-1);
|
rval = FETCH_OPND(-1);
|
||||||
@ -2453,7 +2412,6 @@ interrupt:
|
|||||||
if (prop)
|
if (prop)
|
||||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
||||||
END_CASE(JSOP_IN)
|
END_CASE(JSOP_IN)
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
|
|
||||||
BEGIN_CASE(JSOP_FORPROP)
|
BEGIN_CASE(JSOP_FORPROP)
|
||||||
/*
|
/*
|
||||||
@ -2725,7 +2683,7 @@ interrupt:
|
|||||||
rval = STRING_TO_JSVAL(str);
|
rval = STRING_TO_JSVAL(str);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (!JS_VERSION_IS_1_2(cx)) {
|
else {
|
||||||
str = js_NumberToString(cx, (jsdouble) JSID_TO_INT(fid));
|
str = js_NumberToString(cx, (jsdouble) JSID_TO_INT(fid));
|
||||||
if (!str) {
|
if (!str) {
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
@ -2733,8 +2691,6 @@ interrupt:
|
|||||||
}
|
}
|
||||||
|
|
||||||
rval = STRING_TO_JSVAL(str);
|
rval = STRING_TO_JSVAL(str);
|
||||||
} else {
|
|
||||||
rval = INT_JSID_TO_JSVAL(fid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3096,7 +3052,6 @@ interrupt:
|
|||||||
EQUALITY_OP(!=, JS_TRUE);
|
EQUALITY_OP(!=, JS_TRUE);
|
||||||
END_CASE(JSOP_NE)
|
END_CASE(JSOP_NE)
|
||||||
|
|
||||||
#if !JS_BUG_FALLIBLE_EQOPS
|
|
||||||
#define NEW_EQUALITY_OP(OP) \
|
#define NEW_EQUALITY_OP(OP) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
rval = FETCH_OPND(-1); \
|
rval = FETCH_OPND(-1); \
|
||||||
@ -3114,7 +3069,6 @@ interrupt:
|
|||||||
NEW_EQUALITY_OP(!=);
|
NEW_EQUALITY_OP(!=);
|
||||||
END_CASE(JSOP_NEW_NE)
|
END_CASE(JSOP_NEW_NE)
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
BEGIN_CASE(JSOP_CASE)
|
BEGIN_CASE(JSOP_CASE)
|
||||||
NEW_EQUALITY_OP(==);
|
NEW_EQUALITY_OP(==);
|
||||||
(void) POP();
|
(void) POP();
|
||||||
@ -3136,9 +3090,6 @@ interrupt:
|
|||||||
}
|
}
|
||||||
PUSH(lval);
|
PUSH(lval);
|
||||||
END_CASE(JSOP_CASEX)
|
END_CASE(JSOP_CASEX)
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !JS_BUG_FALLIBLE_EQOPS */
|
|
||||||
|
|
||||||
BEGIN_CASE(JSOP_LT)
|
BEGIN_CASE(JSOP_LT)
|
||||||
RELATIONAL_OP(<);
|
RELATIONAL_OP(<);
|
||||||
@ -3358,9 +3309,7 @@ interrupt:
|
|||||||
/* Get immediate argc and find the constructor function. */
|
/* Get immediate argc and find the constructor function. */
|
||||||
argc = GET_ARGC(pc);
|
argc = GET_ARGC(pc);
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
do_new:
|
do_new:
|
||||||
#endif
|
|
||||||
SAVE_SP_AND_PC(fp);
|
SAVE_SP_AND_PC(fp);
|
||||||
vp = sp - (2 + argc);
|
vp = sp - (2 + argc);
|
||||||
JS_ASSERT(vp >= fp->spbase);
|
JS_ASSERT(vp >= fp->spbase);
|
||||||
@ -4270,26 +4219,19 @@ interrupt:
|
|||||||
obj = NULL;
|
obj = NULL;
|
||||||
END_CASE(JSOP_TRUE)
|
END_CASE(JSOP_TRUE)
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
BEGIN_CASE(JSOP_TABLESWITCH)
|
BEGIN_CASE(JSOP_TABLESWITCH)
|
||||||
pc2 = pc;
|
pc2 = pc;
|
||||||
len = GET_JUMP_OFFSET(pc2);
|
len = GET_JUMP_OFFSET(pc2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ECMAv2 forbids conversion of discriminant, so we will skip to
|
* ECMAv2+ forbids conversion of discriminant, so we will skip to
|
||||||
* the default case if the discriminant isn't already an int jsval.
|
* the default case if the discriminant isn't already an int jsval.
|
||||||
* (This opcode is emitted only for dense jsint-domain switches.)
|
* (This opcode is emitted only for dense jsint-domain switches.)
|
||||||
*/
|
*/
|
||||||
if ((cx->version & JSVERSION_MASK) == JSVERSION_DEFAULT ||
|
rval = POP_OPND();
|
||||||
(cx->version & JSVERSION_MASK) >= JSVERSION_1_4) {
|
if (!JSVAL_IS_INT(rval))
|
||||||
rval = POP_OPND();
|
DO_NEXT_OP(len);
|
||||||
if (!JSVAL_IS_INT(rval))
|
i = JSVAL_TO_INT(rval);
|
||||||
DO_NEXT_OP(len);
|
|
||||||
i = JSVAL_TO_INT(rval);
|
|
||||||
} else {
|
|
||||||
FETCH_INT(cx, -1, i);
|
|
||||||
sp--;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc2 += JUMP_OFFSET_LEN;
|
pc2 += JUMP_OFFSET_LEN;
|
||||||
low = GET_JUMP_OFFSET(pc2);
|
low = GET_JUMP_OFFSET(pc2);
|
||||||
@ -4359,20 +4301,14 @@ interrupt:
|
|||||||
len = GET_JUMPX_OFFSET(pc2);
|
len = GET_JUMPX_OFFSET(pc2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ECMAv2 forbids conversion of discriminant, so we will skip to
|
* ECMAv2+ forbids conversion of discriminant, so we will skip to
|
||||||
* the default case if the discriminant isn't already an int jsval.
|
* the default case if the discriminant isn't already an int jsval.
|
||||||
* (This opcode is emitted only for dense jsint-domain switches.)
|
* (This opcode is emitted only for dense jsint-domain switches.)
|
||||||
*/
|
*/
|
||||||
if ((cx->version & JSVERSION_MASK) == JSVERSION_DEFAULT ||
|
rval = POP_OPND();
|
||||||
(cx->version & JSVERSION_MASK) >= JSVERSION_1_4) {
|
if (!JSVAL_IS_INT(rval))
|
||||||
rval = POP_OPND();
|
DO_NEXT_OP(len);
|
||||||
if (!JSVAL_IS_INT(rval))
|
i = JSVAL_TO_INT(rval);
|
||||||
DO_NEXT_OP(len);
|
|
||||||
i = JSVAL_TO_INT(rval);
|
|
||||||
} else {
|
|
||||||
FETCH_INT(cx, -1, i);
|
|
||||||
sp--;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc2 += JUMPX_OFFSET_LEN;
|
pc2 += JUMPX_OFFSET_LEN;
|
||||||
low = GET_JUMP_OFFSET(pc2);
|
low = GET_JUMP_OFFSET(pc2);
|
||||||
@ -4439,8 +4375,6 @@ interrupt:
|
|||||||
|
|
||||||
EMPTY_CASE(JSOP_CONDSWITCH)
|
EMPTY_CASE(JSOP_CONDSWITCH)
|
||||||
|
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
#if JS_HAS_EXPORT_IMPORT
|
#if JS_HAS_EXPORT_IMPORT
|
||||||
BEGIN_CASE(JSOP_EXPORTALL)
|
BEGIN_CASE(JSOP_EXPORTALL)
|
||||||
obj = fp->varobj;
|
obj = fp->varobj;
|
||||||
@ -4526,13 +4460,11 @@ interrupt:
|
|||||||
case JSTRAP_RETURN:
|
case JSTRAP_RETURN:
|
||||||
fp->rval = rval;
|
fp->rval = rval;
|
||||||
goto out;
|
goto out;
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSTRAP_THROW:
|
case JSTRAP_THROW:
|
||||||
cx->throwing = JS_TRUE;
|
cx->throwing = JS_TRUE;
|
||||||
cx->exception = rval;
|
cx->exception = rval;
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
LOAD_INTERRUPT_HANDLER(rt);
|
LOAD_INTERRUPT_HANDLER(rt);
|
||||||
@ -4827,7 +4759,6 @@ interrupt:
|
|||||||
}
|
}
|
||||||
END_LITOPX_CASE(JSOP_DEFFUN)
|
END_LITOPX_CASE(JSOP_DEFFUN)
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
BEGIN_LITOPX_CASE(JSOP_DEFLOCALFUN, VARNO_LEN)
|
BEGIN_LITOPX_CASE(JSOP_DEFLOCALFUN, VARNO_LEN)
|
||||||
/*
|
/*
|
||||||
* Define a local function (i.e., one nested at the top level of
|
* Define a local function (i.e., one nested at the top level of
|
||||||
@ -5040,7 +4971,6 @@ interrupt:
|
|||||||
#endif
|
#endif
|
||||||
OBJ_DROP_PROPERTY(cx, parent, prop);
|
OBJ_DROP_PROPERTY(cx, parent, prop);
|
||||||
END_LITOPX_CASE(JSOP_CLOSURE)
|
END_LITOPX_CASE(JSOP_CLOSURE)
|
||||||
#endif /* JS_HAS_LEXICAL_CLOSURE */
|
|
||||||
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
BEGIN_CASE(JSOP_GETTER)
|
BEGIN_CASE(JSOP_GETTER)
|
||||||
@ -5063,7 +4993,6 @@ interrupt:
|
|||||||
FETCH_OBJECT(cx, i - 1, lval, obj);
|
FETCH_OBJECT(cx, i - 1, lval, obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
case JSOP_INITPROP:
|
case JSOP_INITPROP:
|
||||||
JS_ASSERT(sp - fp->spbase >= 2);
|
JS_ASSERT(sp - fp->spbase >= 2);
|
||||||
rval = FETCH_OPND(-1);
|
rval = FETCH_OPND(-1);
|
||||||
@ -5082,7 +5011,6 @@ interrupt:
|
|||||||
JS_ASSERT(JSVAL_IS_OBJECT(lval));
|
JS_ASSERT(JSVAL_IS_OBJECT(lval));
|
||||||
obj = JSVAL_TO_OBJECT(lval);
|
obj = JSVAL_TO_OBJECT(lval);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_INITIALIZERS */
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
JS_ASSERT(0);
|
JS_ASSERT(0);
|
||||||
@ -5139,7 +5067,6 @@ interrupt:
|
|||||||
DO_NEXT_OP(len);
|
DO_NEXT_OP(len);
|
||||||
#endif /* JS_HAS_GETTER_SETTER */
|
#endif /* JS_HAS_GETTER_SETTER */
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
BEGIN_CASE(JSOP_NEWINIT)
|
BEGIN_CASE(JSOP_NEWINIT)
|
||||||
argc = 0;
|
argc = 0;
|
||||||
fp->sharpDepth++;
|
fp->sharpDepth++;
|
||||||
@ -5245,9 +5172,7 @@ interrupt:
|
|||||||
PUSH_OPND(rval);
|
PUSH_OPND(rval);
|
||||||
END_CASE(JSOP_USESHARP)
|
END_CASE(JSOP_USESHARP)
|
||||||
#endif /* JS_HAS_SHARP_VARS */
|
#endif /* JS_HAS_SHARP_VARS */
|
||||||
#endif /* JS_HAS_INITIALIZERS */
|
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
/* No-ops for ease of decompilation and jit'ing. */
|
/* No-ops for ease of decompilation and jit'ing. */
|
||||||
EMPTY_CASE(JSOP_TRY)
|
EMPTY_CASE(JSOP_TRY)
|
||||||
EMPTY_CASE(JSOP_FINALLY)
|
EMPTY_CASE(JSOP_FINALLY)
|
||||||
@ -5320,9 +5245,7 @@ interrupt:
|
|||||||
/* Now that we're done with rval, pop it. */
|
/* Now that we're done with rval, pop it. */
|
||||||
sp--;
|
sp--;
|
||||||
END_LITOPX_CASE(JSOP_INITCATCHVAR)
|
END_LITOPX_CASE(JSOP_INITCATCHVAR)
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
|
||||||
#if JS_HAS_INSTANCEOF
|
|
||||||
BEGIN_CASE(JSOP_INSTANCEOF)
|
BEGIN_CASE(JSOP_INSTANCEOF)
|
||||||
SAVE_SP_AND_PC(fp);
|
SAVE_SP_AND_PC(fp);
|
||||||
rval = FETCH_OPND(-1);
|
rval = FETCH_OPND(-1);
|
||||||
@ -5345,7 +5268,6 @@ interrupt:
|
|||||||
sp--;
|
sp--;
|
||||||
STORE_OPND(-1, BOOLEAN_TO_JSVAL(cond));
|
STORE_OPND(-1, BOOLEAN_TO_JSVAL(cond));
|
||||||
END_CASE(JSOP_INSTANCEOF)
|
END_CASE(JSOP_INSTANCEOF)
|
||||||
#endif /* JS_HAS_INSTANCEOF */
|
|
||||||
|
|
||||||
#if JS_HAS_DEBUGGER_KEYWORD
|
#if JS_HAS_DEBUGGER_KEYWORD
|
||||||
BEGIN_CASE(JSOP_DEBUGGER)
|
BEGIN_CASE(JSOP_DEBUGGER)
|
||||||
@ -5363,13 +5285,11 @@ interrupt:
|
|||||||
case JSTRAP_RETURN:
|
case JSTRAP_RETURN:
|
||||||
fp->rval = rval;
|
fp->rval = rval;
|
||||||
goto out;
|
goto out;
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSTRAP_THROW:
|
case JSTRAP_THROW:
|
||||||
cx->throwing = JS_TRUE;
|
cx->throwing = JS_TRUE;
|
||||||
cx->exception = rval;
|
cx->exception = rval;
|
||||||
ok = JS_FALSE;
|
ok = JS_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
LOAD_INTERRUPT_HANDLER(rt);
|
LOAD_INTERRUPT_HANDLER(rt);
|
||||||
@ -5745,7 +5665,6 @@ interrupt:
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
/*
|
/*
|
||||||
* Has an exception been raised? Also insist that we are in the
|
* Has an exception been raised? Also insist that we are in the
|
||||||
@ -5813,7 +5732,6 @@ out:
|
|||||||
}
|
}
|
||||||
no_catch:;
|
no_catch:;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check whether control fell off the end of a lightweight function, or an
|
* Check whether control fell off the end of a lightweight function, or an
|
||||||
|
@ -392,7 +392,6 @@ num_valueOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if JS_HAS_NUMBER_FORMATS
|
|
||||||
#define MAX_PRECISION 100
|
#define MAX_PRECISION 100
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
@ -459,8 +458,6 @@ num_toPrecision(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||||||
/* We allow a larger range of precision than ECMA requires; this is permitted by ECMA. */
|
/* We allow a larger range of precision than ECMA requires; this is permitted by ECMA. */
|
||||||
return num_to(cx, obj, argc, argv, rval, DTOSTR_STANDARD, DTOSTR_PRECISION, 1, MAX_PRECISION, 0);
|
return num_to(cx, obj, argc, argv, rval, DTOSTR_STANDARD, DTOSTR_PRECISION, 1, MAX_PRECISION, 0);
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_NUMBER_FORMATS */
|
|
||||||
|
|
||||||
|
|
||||||
static JSFunctionSpec number_methods[] = {
|
static JSFunctionSpec number_methods[] = {
|
||||||
#if JS_HAS_TOSOURCE
|
#if JS_HAS_TOSOURCE
|
||||||
@ -469,11 +466,9 @@ static JSFunctionSpec number_methods[] = {
|
|||||||
{js_toString_str, num_toString, 0,0,0},
|
{js_toString_str, num_toString, 0,0,0},
|
||||||
{js_toLocaleString_str, num_toLocaleString, 0,0,0},
|
{js_toLocaleString_str, num_toLocaleString, 0,0,0},
|
||||||
{js_valueOf_str, num_valueOf, 0,0,0},
|
{js_valueOf_str, num_valueOf, 0,0,0},
|
||||||
#if JS_HAS_NUMBER_FORMATS
|
|
||||||
{"toFixed", num_toFixed, 1,0,0},
|
{"toFixed", num_toFixed, 1,0,0},
|
||||||
{"toExponential", num_toExponential, 1,0,0},
|
{"toExponential", num_toExponential, 1,0,0},
|
||||||
{"toPrecision", num_toPrecision, 1,0,0},
|
{"toPrecision", num_toPrecision, 1,0,0},
|
||||||
#endif
|
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -746,19 +741,8 @@ js_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp)
|
|||||||
} else if (JSVAL_IS_BOOLEAN(v)) {
|
} else if (JSVAL_IS_BOOLEAN(v)) {
|
||||||
*dp = JSVAL_TO_BOOLEAN(v) ? 1 : 0;
|
*dp = JSVAL_TO_BOOLEAN(v) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
#if JS_BUG_FALLIBLE_TONUM
|
|
||||||
str = js_DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NULL);
|
|
||||||
badstr:
|
|
||||||
if (str) {
|
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NAN,
|
|
||||||
JS_GetStringBytes(str));
|
|
||||||
|
|
||||||
}
|
|
||||||
return JS_FALSE;
|
|
||||||
#else
|
|
||||||
badstr:
|
badstr:
|
||||||
*dp = *cx->runtime->jsNaN;
|
*dp = *cx->runtime->jsNaN;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
100
js/src/jsobj.c
100
js/src/jsobj.c
@ -645,7 +645,7 @@ js_LeaveSharpObject(JSContext *cx, JSIdArray **idap)
|
|||||||
|
|
||||||
#define OBJ_TOSTRING_EXTRA 4 /* for 4 local GC roots */
|
#define OBJ_TOSTRING_EXTRA 4 /* for 4 local GC roots */
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS || JS_HAS_TOSOURCE
|
#if JS_HAS_TOSOURCE
|
||||||
JSBool
|
JSBool
|
||||||
js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
jsval *rval)
|
jsval *rval)
|
||||||
@ -675,11 +675,8 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* If outermost, we need parentheses to be an expression, not a block. */
|
||||||
* obj_toString for 1.2 calls toSource, and doesn't want the extra parens
|
outermost = (cx->sharpObjectMap.depth == 0);
|
||||||
* on the outside.
|
|
||||||
*/
|
|
||||||
outermost = !JS_VERSION_IS_1_2(cx) && cx->sharpObjectMap.depth == 0;
|
|
||||||
he = js_EnterSharpObject(cx, obj, &ida, &chars);
|
he = js_EnterSharpObject(cx, obj, &ida, &chars);
|
||||||
if (!he)
|
if (!he)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -1000,7 +997,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
*rval = STRING_TO_JSVAL(str);
|
*rval = STRING_TO_JSVAL(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_INITIALIZERS || JS_HAS_TOSOURCE */
|
#endif /* JS_HAS_TOSOURCE */
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
@ -1011,11 +1008,6 @@ js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
const char *clazz, *prefix;
|
const char *clazz, *prefix;
|
||||||
JSString *str;
|
JSString *str;
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
if (JS_VERSION_IS_1_2(cx))
|
|
||||||
return js_obj_toSource(cx, obj, argc, argv, rval);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clazz = OBJ_GET_CLASS(cx, obj)->name;
|
clazz = OBJ_GET_CLASS(cx, obj)->name;
|
||||||
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
||||||
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar));
|
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar));
|
||||||
@ -1150,8 +1142,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
JS_ASSERT(!caller || caller->pc);
|
JS_ASSERT(!caller || caller->pc);
|
||||||
indirectCall = (caller && *caller->pc != JSOP_EVAL);
|
indirectCall = (caller && *caller->pc != JSOP_EVAL);
|
||||||
|
|
||||||
if (JS_VERSION_IS_ECMA(cx) &&
|
if (indirectCall &&
|
||||||
indirectCall &&
|
|
||||||
!JS_ReportErrorFlagsAndNumber(cx,
|
!JS_ReportErrorFlagsAndNumber(cx,
|
||||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||||
js_GetErrorMessage, NULL,
|
js_GetErrorMessage, NULL,
|
||||||
@ -1222,14 +1213,9 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
/* From here on, control must exit through label out with ok set. */
|
/* From here on, control must exit through label out with ok set. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if JS_BUG_EVAL_THIS_SCOPE
|
|
||||||
/* An old version used the object in which eval was found for scope. */
|
|
||||||
scopeobj = obj;
|
|
||||||
#else
|
|
||||||
/* Compile using caller's current scope object. */
|
/* Compile using caller's current scope object. */
|
||||||
if (caller)
|
if (caller)
|
||||||
scopeobj = caller->scopeChain;
|
scopeobj = caller->scopeChain;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure we compile this eval with the right object in the scope chain. */
|
/* Ensure we compile this eval with the right object in the scope chain. */
|
||||||
@ -1269,7 +1255,6 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !JS_BUG_EVAL_THIS_SCOPE
|
|
||||||
#if JS_HAS_SCRIPT_OBJECT
|
#if JS_HAS_SCRIPT_OBJECT
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
#endif
|
#endif
|
||||||
@ -1278,7 +1263,6 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
if (caller)
|
if (caller)
|
||||||
scopeobj = caller->scopeChain;
|
scopeobj = caller->scopeChain;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Belt-and-braces: check that the lesser of eval's principals and the
|
* Belt-and-braces: check that the lesser of eval's principals and the
|
||||||
@ -1365,7 +1349,6 @@ obj_unwatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
|
|
||||||
#endif /* JS_HAS_OBJ_WATCHPOINT */
|
#endif /* JS_HAS_OBJ_WATCHPOINT */
|
||||||
|
|
||||||
#if JS_HAS_NEW_OBJ_METHODS
|
|
||||||
/*
|
/*
|
||||||
* Prototype and property query methods, to complement the 'in' and
|
* Prototype and property query methods, to complement the 'in' and
|
||||||
* 'instanceof' operators.
|
* 'instanceof' operators.
|
||||||
@ -1495,7 +1478,6 @@ obj_propertyIsEnumerable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
*rval = BOOLEAN_TO_JSVAL((attrs & JSPROP_ENUMERATE) != 0);
|
*rval = BOOLEAN_TO_JSVAL((attrs & JSPROP_ENUMERATE) != 0);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_NEW_OBJ_METHODS */
|
|
||||||
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
static JSBool
|
static JSBool
|
||||||
@ -1615,11 +1597,9 @@ obj_lookupSetter(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
const char js_watch_str[] = "watch";
|
const char js_watch_str[] = "watch";
|
||||||
const char js_unwatch_str[] = "unwatch";
|
const char js_unwatch_str[] = "unwatch";
|
||||||
#endif
|
#endif
|
||||||
#if JS_HAS_NEW_OBJ_METHODS
|
|
||||||
const char js_hasOwnProperty_str[] = "hasOwnProperty";
|
const char js_hasOwnProperty_str[] = "hasOwnProperty";
|
||||||
const char js_isPrototypeOf_str[] = "isPrototypeOf";
|
const char js_isPrototypeOf_str[] = "isPrototypeOf";
|
||||||
const char js_propertyIsEnumerable_str[] = "propertyIsEnumerable";
|
const char js_propertyIsEnumerable_str[] = "propertyIsEnumerable";
|
||||||
#endif
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
const char js_defineGetter_str[] = "__defineGetter__";
|
const char js_defineGetter_str[] = "__defineGetter__";
|
||||||
const char js_defineSetter_str[] = "__defineSetter__";
|
const char js_defineSetter_str[] = "__defineSetter__";
|
||||||
@ -1639,11 +1619,9 @@ static JSFunctionSpec object_methods[] = {
|
|||||||
{js_watch_str, obj_watch, 2,0,0},
|
{js_watch_str, obj_watch, 2,0,0},
|
||||||
{js_unwatch_str, obj_unwatch, 1,0,0},
|
{js_unwatch_str, obj_unwatch, 1,0,0},
|
||||||
#endif
|
#endif
|
||||||
#if JS_HAS_NEW_OBJ_METHODS
|
|
||||||
{js_hasOwnProperty_str, obj_hasOwnProperty, 1,0,0},
|
{js_hasOwnProperty_str, obj_hasOwnProperty, 1,0,0},
|
||||||
{js_isPrototypeOf_str, obj_isPrototypeOf, 1,0,0},
|
{js_isPrototypeOf_str, obj_isPrototypeOf, 1,0,0},
|
||||||
{js_propertyIsEnumerable_str, obj_propertyIsEnumerable, 1,0,0},
|
{js_propertyIsEnumerable_str, obj_propertyIsEnumerable, 1,0,0},
|
||||||
#endif
|
|
||||||
#if JS_HAS_GETTER_SETTER
|
#if JS_HAS_GETTER_SETTER
|
||||||
{js_defineGetter_str, obj_defineGetter, 2,0,0},
|
{js_defineGetter_str, obj_defineGetter, 2,0,0},
|
||||||
{js_defineSetter_str, obj_defineSetter, 2,0,0},
|
{js_defineSetter_str, obj_defineSetter, 2,0,0},
|
||||||
@ -2316,16 +2294,6 @@ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_BUG_EMPTY_INDEX_ZERO
|
|
||||||
#define CHECK_FOR_EMPTY_INDEX(id) \
|
|
||||||
JS_BEGIN_MACRO \
|
|
||||||
if (JSSTRING_LENGTH(str_) == 0) \
|
|
||||||
id = JSVAL_ZERO; \
|
|
||||||
JS_END_MACRO
|
|
||||||
#else
|
|
||||||
#define CHECK_FOR_EMPTY_INDEX(id) /* nothing */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* JSVAL_INT_MAX as a string */
|
/* JSVAL_INT_MAX as a string */
|
||||||
#define JSVAL_INT_MAX_STRING "1073741823"
|
#define JSVAL_INT_MAX_STRING "1073741823"
|
||||||
|
|
||||||
@ -2340,8 +2308,6 @@ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot)
|
|||||||
if (JS7_ISDEC(*cp_) && \
|
if (JS7_ISDEC(*cp_) && \
|
||||||
str_->length - negative_ <= sizeof(JSVAL_INT_MAX_STRING)-1) { \
|
str_->length - negative_ <= sizeof(JSVAL_INT_MAX_STRING)-1) { \
|
||||||
id = CheckForStringIndex(id, cp_, negative_); \
|
id = CheckForStringIndex(id, cp_, negative_); \
|
||||||
} else { \
|
|
||||||
CHECK_FOR_EMPTY_INDEX(id); \
|
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
@ -2954,18 +2920,9 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||||||
if (!js_LookupProperty(cx, obj, id, &obj2, &prop))
|
if (!js_LookupProperty(cx, obj, id, &obj2, &prop))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
jsval default_val;
|
|
||||||
jsbytecode *pc;
|
jsbytecode *pc;
|
||||||
|
|
||||||
#if JS_BUG_NULL_INDEX_PROPS
|
*vp = JSVAL_VOID;
|
||||||
/* Indexed properties defaulted to null in old versions. */
|
|
||||||
default_val = (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0)
|
|
||||||
? JSVAL_NULL
|
|
||||||
: JSVAL_VOID;
|
|
||||||
#else
|
|
||||||
default_val = JSVAL_VOID;
|
|
||||||
#endif
|
|
||||||
*vp = default_val;
|
|
||||||
|
|
||||||
if (!OBJ_GET_CLASS(cx, obj)->getProperty(cx, obj, ID_TO_VALUE(id), vp))
|
if (!OBJ_GET_CLASS(cx, obj)->getProperty(cx, obj, ID_TO_VALUE(id), vp))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -2974,7 +2931,7 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||||||
* Give a strict warning if foo.bar is evaluated by a script for an
|
* Give a strict warning if foo.bar is evaluated by a script for an
|
||||||
* object foo with no property named 'bar'.
|
* object foo with no property named 'bar'.
|
||||||
*/
|
*/
|
||||||
if (*vp == default_val && cx->fp && (pc = cx->fp->pc)) {
|
if (JSVAL_IS_VOID(*vp) && cx->fp && (pc = cx->fp->pc)) {
|
||||||
JSOp op;
|
JSOp op;
|
||||||
uintN flags;
|
uintN flags;
|
||||||
JSString *str;
|
JSString *str;
|
||||||
@ -3312,8 +3269,6 @@ js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
|
|||||||
JSBool
|
JSBool
|
||||||
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
||||||
{
|
{
|
||||||
#if JS_HAS_PROP_DELETE
|
|
||||||
|
|
||||||
JSObject *proto;
|
JSObject *proto;
|
||||||
JSProperty *prop;
|
JSProperty *prop;
|
||||||
JSScopeProperty *sprop;
|
JSScopeProperty *sprop;
|
||||||
@ -3321,7 +3276,7 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
|||||||
JSScope *scope;
|
JSScope *scope;
|
||||||
JSBool ok;
|
JSBool ok;
|
||||||
|
|
||||||
*rval = JS_VERSION_IS_ECMA(cx) ? JSVAL_TRUE : JSVAL_VOID;
|
*rval = JSVAL_TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle old bug that took empty string as zero index. Also convert
|
* Handle old bug that took empty string as zero index. Also convert
|
||||||
@ -3389,15 +3344,6 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
|||||||
ok = js_RemoveScopeProperty(cx, scope, id);
|
ok = js_RemoveScopeProperty(cx, scope, id);
|
||||||
OBJ_DROP_PROPERTY(cx, obj, prop);
|
OBJ_DROP_PROPERTY(cx, obj, prop);
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
#else /* !JS_HAS_PROP_DELETE */
|
|
||||||
|
|
||||||
jsval null = JSVAL_NULL;
|
|
||||||
|
|
||||||
*rval = JSVAL_VOID;
|
|
||||||
return js_SetProperty(cx, obj, id, &null);
|
|
||||||
|
|
||||||
#endif /* !JS_HAS_PROP_DELETE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
@ -3421,25 +3367,6 @@ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
|
|||||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||||
if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))
|
if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
/*
|
|
||||||
* JS1.2 never failed (except for malloc failure) to convert an
|
|
||||||
* object to a string. ECMA requires an error if both toString
|
|
||||||
* and valueOf fail to produce a primitive value.
|
|
||||||
*/
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(v) && JS_VERSION_IS_1_2(cx)) {
|
|
||||||
char *bytes = JS_smprintf("[object %s]",
|
|
||||||
OBJ_GET_CLASS(cx, obj)->name);
|
|
||||||
if (!bytes)
|
|
||||||
return JS_FALSE;
|
|
||||||
str = JS_NewString(cx, bytes, strlen(bytes));
|
|
||||||
if (!str) {
|
|
||||||
free(bytes);
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
v = STRING_TO_JSVAL(str);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3452,12 +3379,10 @@ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
|
|||||||
(type == JSTYPE_FUNCTION && hint == JSTYPE_OBJECT)) {
|
(type == JSTYPE_FUNCTION && hint == JSTYPE_OBJECT)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* Don't convert to string (source object literal) for JS1.2. */
|
|
||||||
if (JS_VERSION_IS_1_2(cx) && hint == JSTYPE_BOOLEAN)
|
|
||||||
goto out;
|
|
||||||
if (!js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0,
|
if (!js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0,
|
||||||
NULL, &v))
|
NULL, &v)) {
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4057,16 +3982,11 @@ js_ValueToNonNullObject(JSContext *cx, jsval v)
|
|||||||
JSBool
|
JSBool
|
||||||
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval)
|
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval)
|
||||||
{
|
{
|
||||||
#if JS_HAS_VALUEOF_HINT
|
|
||||||
jsval argv[1];
|
jsval argv[1];
|
||||||
|
|
||||||
argv[0] = ATOM_KEY(cx->runtime->atomState.typeAtoms[type]);
|
argv[0] = ATOM_KEY(cx->runtime->atomState.typeAtoms[type]);
|
||||||
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv,
|
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv,
|
||||||
rval);
|
rval);
|
||||||
#else
|
|
||||||
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 0, NULL,
|
|
||||||
rval);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
|
@ -183,7 +183,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc,
|
|||||||
fprintf(fp, " %u", GET_ARGC(pc));
|
fprintf(fp, " %u", GET_ARGC(pc));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case JOF_TABLESWITCH:
|
case JOF_TABLESWITCH:
|
||||||
case JOF_TABLESWITCHX:
|
case JOF_TABLESWITCHX:
|
||||||
{
|
{
|
||||||
@ -238,7 +237,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc,
|
|||||||
len = 1 + pc2 - pc;
|
len = 1 + pc2 - pc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
case JOF_QARG:
|
case JOF_QARG:
|
||||||
fprintf(fp, " %u", GET_ARGNO(pc));
|
fprintf(fp, " %u", GET_ARGNO(pc));
|
||||||
@ -248,7 +246,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc,
|
|||||||
fprintf(fp, " %u", GET_VARNO(pc));
|
fprintf(fp, " %u", GET_VARNO(pc));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
case JOF_INDEXCONST:
|
case JOF_INDEXCONST:
|
||||||
fprintf(fp, " %u", GET_VARNO(pc));
|
fprintf(fp, " %u", GET_VARNO(pc));
|
||||||
pc += VARNO_LEN;
|
pc += VARNO_LEN;
|
||||||
@ -258,7 +255,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc,
|
|||||||
return 0;
|
return 0;
|
||||||
fprintf(fp, " %s", JS_GetStringBytes(str));
|
fprintf(fp, " %s", JS_GetStringBytes(str));
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
case JOF_UINT24:
|
case JOF_UINT24:
|
||||||
if (op == JSOP_FINDNAME) {
|
if (op == JSOP_FINDNAME) {
|
||||||
@ -289,10 +285,8 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc,
|
|||||||
op = *pc;
|
op = *pc;
|
||||||
cs = &js_CodeSpec[op];
|
cs = &js_CodeSpec[op];
|
||||||
fprintf(fp, " %s op %s", JS_GetStringBytes(str), cs->name);
|
fprintf(fp, " %s op %s", JS_GetStringBytes(str), cs->name);
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
if ((cs->format & JOF_TYPEMASK) == JOF_INDEXCONST)
|
if ((cs->format & JOF_TYPEMASK) == JOF_INDEXCONST)
|
||||||
fprintf(fp, " %u", GET_VARNO(pc));
|
fprintf(fp, " %u", GET_VARNO(pc));
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set len to advance pc to skip op and any other immediates (namely,
|
* Set len to advance pc to skip op and any other immediates (namely,
|
||||||
@ -699,7 +693,6 @@ PopOff(SprintStack *ss, JSOp op)
|
|||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
typedef struct TableEntry {
|
typedef struct TableEntry {
|
||||||
jsval key;
|
jsval key;
|
||||||
ptrdiff_t offset;
|
ptrdiff_t offset;
|
||||||
@ -831,7 +824,6 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
|
|||||||
js_printf(jp, "\t}\n");
|
js_printf(jp, "\t}\n");
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static JSAtom *
|
static JSAtom *
|
||||||
GetSlotAtom(JSPrinter *jp, JSPropertyOp getter, uintN slot)
|
GetSlotAtom(JSPrinter *jp, JSPropertyOp getter, uintN slot)
|
||||||
@ -1034,12 +1026,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
sn = js_GetSrcNote(jp->script, pc);
|
sn = js_GetSrcNote(jp->script, pc);
|
||||||
todo = -2;
|
todo = -2;
|
||||||
switch (sn ? SN_TYPE(sn) : SRC_NULL) {
|
switch (sn ? SN_TYPE(sn) : SRC_NULL) {
|
||||||
#if JS_HAS_DO_WHILE_LOOP
|
|
||||||
case SRC_WHILE:
|
case SRC_WHILE:
|
||||||
js_printf(jp, "\tdo {\n");
|
js_printf(jp, "\tdo {\n");
|
||||||
jp->indent += 4;
|
jp->indent += 4;
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_DO_WHILE_LOOP */
|
|
||||||
|
|
||||||
case SRC_FOR:
|
case SRC_FOR:
|
||||||
rval = "";
|
rval = "";
|
||||||
@ -1214,7 +1204,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
todo = Sprint(&ss->sprinter, "");
|
todo = Sprint(&ss->sprinter, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSOP_TRY:
|
case JSOP_TRY:
|
||||||
js_printf(jp, "\ttry {\n");
|
js_printf(jp, "\ttry {\n");
|
||||||
jp->indent += 4;
|
jp->indent += 4;
|
||||||
@ -1284,7 +1273,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_HIDDEN);
|
LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_HIDDEN);
|
||||||
todo = -2;
|
todo = -2;
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
|
||||||
case JSOP_POP:
|
case JSOP_POP:
|
||||||
case JSOP_POPV:
|
case JSOP_POPV:
|
||||||
@ -1375,7 +1363,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
todo = -2;
|
todo = -2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case JSOP_THROW:
|
case JSOP_THROW:
|
||||||
sn = js_GetSrcNote(jp->script, pc);
|
sn = js_GetSrcNote(jp->script, pc);
|
||||||
todo = -2;
|
todo = -2;
|
||||||
@ -1384,7 +1371,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
rval = POP_STR();
|
rval = POP_STR();
|
||||||
js_printf(jp, "\t%s %s;\n", cs->name, rval);
|
js_printf(jp, "\t%s %s;\n", cs->name, rval);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
|
||||||
case JSOP_GOTO:
|
case JSOP_GOTO:
|
||||||
case JSOP_GOTOX:
|
case JSOP_GOTOX:
|
||||||
@ -1491,14 +1477,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
|
|
||||||
case JSOP_IFNE:
|
case JSOP_IFNE:
|
||||||
case JSOP_IFNEX:
|
case JSOP_IFNEX:
|
||||||
#if JS_HAS_DO_WHILE_LOOP
|
|
||||||
/* Currently, this must be a do-while loop's upward branch. */
|
/* Currently, this must be a do-while loop's upward branch. */
|
||||||
jp->indent -= 4;
|
jp->indent -= 4;
|
||||||
js_printf(jp, "\t} while (%s);\n", POP_STR());
|
js_printf(jp, "\t} while (%s);\n", POP_STR());
|
||||||
todo = -2;
|
todo = -2;
|
||||||
#else
|
|
||||||
JS_ASSERT(0);
|
|
||||||
#endif /* JS_HAS_DO_WHILE_LOOP */
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JSOP_OR:
|
case JSOP_OR:
|
||||||
@ -2199,7 +2181,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
JSSTRING_LENGTH(str));
|
JSSTRING_LENGTH(str));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case JSOP_TABLESWITCH:
|
case JSOP_TABLESWITCH:
|
||||||
case JSOP_TABLESWITCHX:
|
case JSOP_TABLESWITCHX:
|
||||||
{
|
{
|
||||||
@ -2398,31 +2379,19 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
#if !JS_BUG_FALLIBLE_EQOPS
|
|
||||||
case JSOP_NEW_EQ:
|
case JSOP_NEW_EQ:
|
||||||
case JSOP_NEW_NE:
|
case JSOP_NEW_NE:
|
||||||
rval = POP_STR();
|
rval = POP_STR();
|
||||||
lval = POP_STR();
|
lval = POP_STR();
|
||||||
todo = Sprint(&ss->sprinter, "%s %c%s %s",
|
todo = Sprint(&ss->sprinter, "%s %c== %s",
|
||||||
lval,
|
lval, (op == JSOP_NEW_EQ) ? '=' : '!', rval);
|
||||||
(op == JSOP_NEW_EQ) ? '=' : '!',
|
|
||||||
#if JS_HAS_TRIPLE_EQOPS
|
|
||||||
JS_VERSION_IS_ECMA(cx) ? "==" :
|
|
||||||
#endif
|
|
||||||
"=",
|
|
||||||
rval);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
BEGIN_LITOPX_CASE(JSOP_CLOSURE)
|
BEGIN_LITOPX_CASE(JSOP_CLOSURE)
|
||||||
JS_ASSERT(ATOM_IS_OBJECT(atom));
|
JS_ASSERT(ATOM_IS_OBJECT(atom));
|
||||||
todo = -2;
|
todo = -2;
|
||||||
goto do_function;
|
goto do_function;
|
||||||
END_LITOPX_CASE
|
END_LITOPX_CASE
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JS_HAS_EXPORT_IMPORT
|
#if JS_HAS_EXPORT_IMPORT
|
||||||
case JSOP_EXPORTALL:
|
case JSOP_EXPORTALL:
|
||||||
@ -2477,7 +2446,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
todo = -2;
|
todo = -2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
case JSOP_NEWINIT:
|
case JSOP_NEWINIT:
|
||||||
LOCAL_ASSERT(ss->top >= 2);
|
LOCAL_ASSERT(ss->top >= 2);
|
||||||
(void) PopOff(ss, op);
|
(void) PopOff(ss, op);
|
||||||
@ -2575,7 +2543,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
|||||||
todo = Sprint(&ss->sprinter, "#%u#", (unsigned) i);
|
todo = Sprint(&ss->sprinter, "#%u#", (unsigned) i);
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_SHARP_VARS */
|
#endif /* JS_HAS_SHARP_VARS */
|
||||||
#endif /* JS_HAS_INITIALIZERS */
|
|
||||||
|
|
||||||
#if JS_HAS_DEBUGGER_KEYWORD
|
#if JS_HAS_DEBUGGER_KEYWORD
|
||||||
case JSOP_DEBUGGER:
|
case JSOP_DEBUGGER:
|
||||||
|
@ -94,9 +94,7 @@ JSMemberParser(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
JSBool allowCallSyntax);
|
JSBool allowCallSyntax);
|
||||||
|
|
||||||
static JSParser FunctionStmt;
|
static JSParser FunctionStmt;
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
static JSParser FunctionExpr;
|
static JSParser FunctionExpr;
|
||||||
#endif
|
|
||||||
static JSParser Statements;
|
static JSParser Statements;
|
||||||
static JSParser Statement;
|
static JSParser Statement;
|
||||||
static JSParser Variables;
|
static JSParser Variables;
|
||||||
@ -560,7 +558,6 @@ HasFinalReturn(JSParseNode *pn)
|
|||||||
return ENDS_IN_OTHER;
|
return ENDS_IN_OTHER;
|
||||||
return HasFinalReturn(pn->pn_kid2) & HasFinalReturn(pn->pn_kid3);
|
return HasFinalReturn(pn->pn_kid2) & HasFinalReturn(pn->pn_kid3);
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case TOK_SWITCH:
|
case TOK_SWITCH:
|
||||||
rv = ENDS_IN_RETURN;
|
rv = ENDS_IN_RETURN;
|
||||||
hasDefault = ENDS_IN_OTHER;
|
hasDefault = ENDS_IN_OTHER;
|
||||||
@ -580,7 +577,6 @@ HasFinalReturn(JSParseNode *pn)
|
|||||||
/* If a final switch has no default case, we judge it harshly. */
|
/* If a final switch has no default case, we judge it harshly. */
|
||||||
rv &= hasDefault;
|
rv &= hasDefault;
|
||||||
return rv;
|
return rv;
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
case TOK_BREAK:
|
case TOK_BREAK:
|
||||||
return ENDS_IN_BREAK;
|
return ENDS_IN_BREAK;
|
||||||
@ -594,7 +590,6 @@ HasFinalReturn(JSParseNode *pn)
|
|||||||
case TOK_COLON:
|
case TOK_COLON:
|
||||||
return HasFinalReturn(pn->pn_expr);
|
return HasFinalReturn(pn->pn_expr);
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case TOK_THROW:
|
case TOK_THROW:
|
||||||
return ENDS_IN_RETURN;
|
return ENDS_IN_RETURN;
|
||||||
|
|
||||||
@ -618,7 +613,6 @@ HasFinalReturn(JSParseNode *pn)
|
|||||||
for (pn2 = pn->pn_kid2; pn2; pn2 = pn2->pn_kid2)
|
for (pn2 = pn->pn_kid2; pn2; pn2 = pn2->pn_kid2)
|
||||||
rv &= HasFinalReturn(pn2->pn_kid3);
|
rv &= HasFinalReturn(pn2->pn_kid3);
|
||||||
return rv;
|
return rv;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ENDS_IN_OTHER;
|
return ENDS_IN_OTHER;
|
||||||
@ -795,13 +789,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
|
|
||||||
/* Scan the optional function name into funAtom. */
|
/* Scan the optional function name into funAtom. */
|
||||||
funAtom = js_MatchToken(cx, ts, TOK_NAME) ? CURRENT_TOKEN(ts).t_atom : NULL;
|
funAtom = js_MatchToken(cx, ts, TOK_NAME) ? CURRENT_TOKEN(ts).t_atom : NULL;
|
||||||
#if !JS_HAS_LEXICAL_CLOSURE
|
|
||||||
if (!funAtom && !lambda) {
|
|
||||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_TS | JSREPORT_ERROR,
|
|
||||||
JSMSG_SYNTAX_ERROR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Find the nearest variable-declaring scope and use it as our parent. */
|
/* Find the nearest variable-declaring scope and use it as our parent. */
|
||||||
fp = cx->fp;
|
fp = cx->fp;
|
||||||
@ -844,7 +831,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
}
|
}
|
||||||
ALE_SET_JSOP(ale, tc->topStmt ? JSOP_CLOSURE : JSOP_DEFFUN);
|
ALE_SET_JSOP(ale, tc->topStmt ? JSOP_CLOSURE : JSOP_DEFFUN);
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
/*
|
/*
|
||||||
* A function nested at top level inside another's body needs only a
|
* A function nested at top level inside another's body needs only a
|
||||||
* local variable to bind its name to its value, and not an activation
|
* local variable to bind its name to its value, and not an activation
|
||||||
@ -886,7 +872,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
fp->fun->u.i.nvars++;
|
fp->fun->u.i.nvars++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun = js_NewFunction(cx, NULL, NULL, 0, lambda ? JSFUN_LAMBDA : 0, varobj,
|
fun = js_NewFunction(cx, NULL, NULL, 0, lambda ? JSFUN_LAMBDA : 0, varobj,
|
||||||
@ -988,7 +973,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_BODY);
|
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_BODY);
|
||||||
pn->pn_pos.end = CURRENT_TOKEN(ts).pos.end;
|
pn->pn_pos.end = CURRENT_TOKEN(ts).pos.end;
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
/*
|
/*
|
||||||
* If we collected flags that indicate nested heavyweight functions, or
|
* If we collected flags that indicate nested heavyweight functions, or
|
||||||
* this function contains heavyweight-making statements (references to
|
* this function contains heavyweight-making statements (references to
|
||||||
@ -1011,10 +995,8 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
tc->flags |= TCF_FUN_HEAVYWEIGHT;
|
tc->flags |= TCF_FUN_HEAVYWEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
result = pn;
|
result = pn;
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
if (lambda) {
|
if (lambda) {
|
||||||
/*
|
/*
|
||||||
* ECMA ed. 3 standard: function expression, possibly anonymous.
|
* ECMA ed. 3 standard: function expression, possibly anonymous.
|
||||||
@ -1042,9 +1024,9 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||||||
* sub-statement.
|
* sub-statement.
|
||||||
*/
|
*/
|
||||||
op = JSOP_CLOSURE;
|
op = JSOP_CLOSURE;
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
op = JSOP_NOP;
|
op = JSOP_NOP;
|
||||||
|
}
|
||||||
|
|
||||||
pn->pn_funAtom = objAtom;
|
pn->pn_funAtom = objAtom;
|
||||||
pn->pn_op = op;
|
pn->pn_op = op;
|
||||||
@ -1061,13 +1043,11 @@ FunctionStmt(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
return FunctionDef(cx, ts, tc, JS_FALSE);
|
return FunctionDef(cx, ts, tc, JS_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_LEXICAL_CLOSURE
|
|
||||||
static JSParseNode *
|
static JSParseNode *
|
||||||
FunctionExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
FunctionExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||||
{
|
{
|
||||||
return FunctionDef(cx, ts, tc, JS_TRUE);
|
return FunctionDef(cx, ts, tc, JS_TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the statements in a block, creating a TOK_LC node that lists the
|
* Parse the statements in a block, creating a TOK_LC node that lists the
|
||||||
@ -1196,7 +1176,6 @@ static JSBool
|
|||||||
MatchLabel(JSContext *cx, JSTokenStream *ts, JSParseNode *pn)
|
MatchLabel(JSContext *cx, JSTokenStream *ts, JSParseNode *pn)
|
||||||
{
|
{
|
||||||
JSAtom *label;
|
JSAtom *label;
|
||||||
#if JS_HAS_LABEL_STATEMENT
|
|
||||||
JSTokenType tt;
|
JSTokenType tt;
|
||||||
|
|
||||||
tt = js_PeekTokenSameLine(cx, ts);
|
tt = js_PeekTokenSameLine(cx, ts);
|
||||||
@ -1208,9 +1187,6 @@ MatchLabel(JSContext *cx, JSTokenStream *ts, JSParseNode *pn)
|
|||||||
} else {
|
} else {
|
||||||
label = NULL;
|
label = NULL;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
label = NULL;
|
|
||||||
#endif
|
|
||||||
pn->pn_atom = label;
|
pn->pn_atom = label;
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -1398,7 +1374,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
pn->pn_kid3 = pn3;
|
pn->pn_kid3 = pn3;
|
||||||
return pn;
|
return pn;
|
||||||
|
|
||||||
#if JS_HAS_SWITCH_STATEMENT
|
|
||||||
case TOK_SWITCH:
|
case TOK_SWITCH:
|
||||||
{
|
{
|
||||||
JSParseNode *pn5;
|
JSParseNode *pn5;
|
||||||
@ -1502,7 +1477,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
pn->pn_kid2 = pn2;
|
pn->pn_kid2 = pn2;
|
||||||
return pn;
|
return pn;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SWITCH_STATEMENT */
|
|
||||||
|
|
||||||
case TOK_WHILE:
|
case TOK_WHILE:
|
||||||
pn = NewParseNode(cx, ts, PN_BINARY, tc);
|
pn = NewParseNode(cx, ts, PN_BINARY, tc);
|
||||||
@ -1521,7 +1495,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
pn->pn_right = pn2;
|
pn->pn_right = pn2;
|
||||||
return pn;
|
return pn;
|
||||||
|
|
||||||
#if JS_HAS_DO_WHILE_LOOP
|
|
||||||
case TOK_DO:
|
case TOK_DO:
|
||||||
pn = NewParseNode(cx, ts, PN_BINARY, tc);
|
pn = NewParseNode(cx, ts, PN_BINARY, tc);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
@ -1548,7 +1521,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
return pn;
|
return pn;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_DO_WHILE_LOOP */
|
|
||||||
|
|
||||||
case TOK_FOR:
|
case TOK_FOR:
|
||||||
/* A FOR node is binary, left is loop control and right is the body. */
|
/* A FOR node is binary, left is loop control and right is the body. */
|
||||||
@ -1581,7 +1553,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
pn1 = NULL;
|
pn1 = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* Set pn1 to a var list or an initializing expression. */
|
/* Set pn1 to a var list or an initializing expression. */
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
/*
|
/*
|
||||||
* Set the TCF_IN_FOR_INIT flag during parsing of the first clause
|
* Set the TCF_IN_FOR_INIT flag during parsing of the first clause
|
||||||
* of the for statement. This flag will be used by the RelExpr
|
* of the for statement. This flag will be used by the RelExpr
|
||||||
@ -1592,16 +1563,13 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
* are illegal in the init clause of an ordinary for loop.
|
* are illegal in the init clause of an ordinary for loop.
|
||||||
*/
|
*/
|
||||||
tc->flags |= TCF_IN_FOR_INIT;
|
tc->flags |= TCF_IN_FOR_INIT;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
if (tt == TOK_VAR) {
|
if (tt == TOK_VAR) {
|
||||||
(void) js_GetToken(cx, ts);
|
(void) js_GetToken(cx, ts);
|
||||||
pn1 = Variables(cx, ts, tc);
|
pn1 = Variables(cx, ts, tc);
|
||||||
} else {
|
} else {
|
||||||
pn1 = Expr(cx, ts, tc);
|
pn1 = Expr(cx, ts, tc);
|
||||||
}
|
}
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
tc->flags &= ~TCF_IN_FOR_INIT;
|
tc->flags &= ~TCF_IN_FOR_INIT;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
if (!pn1)
|
if (!pn1)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1732,7 +1700,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if JS_HAS_EXCEPTIONS
|
|
||||||
case TOK_TRY: {
|
case TOK_TRY: {
|
||||||
JSParseNode *catchtail = NULL;
|
JSParseNode *catchtail = NULL;
|
||||||
/*
|
/*
|
||||||
@ -1885,8 +1852,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
JSMSG_FINALLY_WITHOUT_TRY);
|
JSMSG_FINALLY_WITHOUT_TRY);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#endif /* JS_HAS_EXCEPTIONS */
|
|
||||||
|
|
||||||
case TOK_BREAK:
|
case TOK_BREAK:
|
||||||
pn = NewParseNode(cx, ts, PN_NULLARY, tc);
|
pn = NewParseNode(cx, ts, PN_NULLARY, tc);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
@ -2498,9 +2463,7 @@ static JSParseNode *
|
|||||||
CondExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
CondExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||||
{
|
{
|
||||||
JSParseNode *pn, *pn1, *pn2, *pn3;
|
JSParseNode *pn, *pn1, *pn2, *pn3;
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
uintN oldflags;
|
uintN oldflags;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
|
|
||||||
pn = OrExpr(cx, ts, tc);
|
pn = OrExpr(cx, ts, tc);
|
||||||
if (pn && js_MatchToken(cx, ts, TOK_HOOK)) {
|
if (pn && js_MatchToken(cx, ts, TOK_HOOK)) {
|
||||||
@ -2508,7 +2471,6 @@ CondExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
pn = NewParseNode(cx, ts, PN_TERNARY, tc);
|
pn = NewParseNode(cx, ts, PN_TERNARY, tc);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
return NULL;
|
return NULL;
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
/*
|
/*
|
||||||
* Always accept the 'in' operator in the middle clause of a ternary,
|
* Always accept the 'in' operator in the middle clause of a ternary,
|
||||||
* where it's unambiguous, even if we might be parsing the init of a
|
* where it's unambiguous, even if we might be parsing the init of a
|
||||||
@ -2516,11 +2478,8 @@ CondExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
*/
|
*/
|
||||||
oldflags = tc->flags;
|
oldflags = tc->flags;
|
||||||
tc->flags &= ~TCF_IN_FOR_INIT;
|
tc->flags &= ~TCF_IN_FOR_INIT;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
pn2 = AssignExpr(cx, ts, tc);
|
pn2 = AssignExpr(cx, ts, tc);
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
tc->flags = oldflags | (tc->flags & TCF_FUN_FLAGS);
|
tc->flags = oldflags | (tc->flags & TCF_FUN_FLAGS);
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
|
|
||||||
if (!pn2)
|
if (!pn2)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2616,7 +2575,6 @@ RelExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
JSParseNode *pn;
|
JSParseNode *pn;
|
||||||
JSTokenType tt;
|
JSTokenType tt;
|
||||||
JSOp op;
|
JSOp op;
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
uintN inForInitFlag = tc->flags & TCF_IN_FOR_INIT;
|
uintN inForInitFlag = tc->flags & TCF_IN_FOR_INIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2624,30 +2582,22 @@ RelExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
* so unset the flag that prohibits recognizing it.
|
* so unset the flag that prohibits recognizing it.
|
||||||
*/
|
*/
|
||||||
tc->flags &= ~TCF_IN_FOR_INIT;
|
tc->flags &= ~TCF_IN_FOR_INIT;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
|
|
||||||
pn = ShiftExpr(cx, ts, tc);
|
pn = ShiftExpr(cx, ts, tc);
|
||||||
while (pn &&
|
while (pn &&
|
||||||
(js_MatchToken(cx, ts, TOK_RELOP)
|
(js_MatchToken(cx, ts, TOK_RELOP) ||
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
/*
|
/*
|
||||||
* Recognize the 'in' token as an operator only if we're not
|
* Recognize the 'in' token as an operator only if we're not
|
||||||
* currently in the init expr of a for loop.
|
* currently in the init expr of a for loop.
|
||||||
*/
|
*/
|
||||||
|| (inForInitFlag == 0 && js_MatchToken(cx, ts, TOK_IN))
|
(inForInitFlag == 0 && js_MatchToken(cx, ts, TOK_IN)) ||
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
js_MatchToken(cx, ts, TOK_INSTANCEOF))) {
|
||||||
#if JS_HAS_INSTANCEOF
|
|
||||||
|| js_MatchToken(cx, ts, TOK_INSTANCEOF)
|
|
||||||
#endif /* JS_HAS_INSTANCEOF */
|
|
||||||
)) {
|
|
||||||
tt = CURRENT_TOKEN(ts).type;
|
tt = CURRENT_TOKEN(ts).type;
|
||||||
op = CURRENT_TOKEN(ts).t_op;
|
op = CURRENT_TOKEN(ts).t_op;
|
||||||
pn = NewBinary(cx, tt, op, pn, ShiftExpr(cx, ts, tc), tc);
|
pn = NewBinary(cx, tt, op, pn, ShiftExpr(cx, ts, tc), tc);
|
||||||
}
|
}
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
/* Restore previous state of inForInit flag. */
|
/* Restore previous state of inForInit flag. */
|
||||||
tc->flags |= inForInitFlag;
|
tc->flags |= inForInitFlag;
|
||||||
#endif /* JS_HAS_IN_OPERATOR */
|
|
||||||
|
|
||||||
return pn;
|
return pn;
|
||||||
}
|
}
|
||||||
@ -3086,7 +3036,6 @@ BracketedExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
uintN oldflags;
|
uintN oldflags;
|
||||||
JSParseNode *pn;
|
JSParseNode *pn;
|
||||||
|
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
/*
|
/*
|
||||||
* Always accept the 'in' operator in a parenthesized expression,
|
* Always accept the 'in' operator in a parenthesized expression,
|
||||||
* where it's unambiguous, even if we might be parsing the init of a
|
* where it's unambiguous, even if we might be parsing the init of a
|
||||||
@ -3094,11 +3043,8 @@ BracketedExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
*/
|
*/
|
||||||
oldflags = tc->flags;
|
oldflags = tc->flags;
|
||||||
tc->flags &= ~TCF_IN_FOR_INIT;
|
tc->flags &= ~TCF_IN_FOR_INIT;
|
||||||
#endif
|
|
||||||
pn = Expr(cx, ts, tc);
|
pn = Expr(cx, ts, tc);
|
||||||
#if JS_HAS_IN_OPERATOR
|
|
||||||
tc->flags = oldflags | (tc->flags & TCF_FUN_FLAGS);
|
tc->flags = oldflags | (tc->flags & TCF_FUN_FLAGS);
|
||||||
#endif
|
|
||||||
return pn;
|
return pn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3799,9 +3745,8 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (tt) {
|
switch (tt) {
|
||||||
#if JS_HAS_LEXICAL_CLOSURE || JS_HAS_XML_SUPPORT
|
|
||||||
case TOK_FUNCTION:
|
|
||||||
#if JS_HAS_XML_SUPPORT
|
#if JS_HAS_XML_SUPPORT
|
||||||
|
case TOK_FUNCTION:
|
||||||
if (js_MatchToken(cx, ts, TOK_DBLCOLON)) {
|
if (js_MatchToken(cx, ts, TOK_DBLCOLON)) {
|
||||||
pn2 = NewParseNode(cx, ts, PN_NULLARY, tc);
|
pn2 = NewParseNode(cx, ts, PN_NULLARY, tc);
|
||||||
if (!pn2)
|
if (!pn2)
|
||||||
@ -3812,14 +3757,12 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pn = FunctionExpr(cx, ts, tc);
|
pn = FunctionExpr(cx, ts, tc);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if JS_HAS_INITIALIZERS
|
|
||||||
case TOK_LB:
|
case TOK_LB:
|
||||||
{
|
{
|
||||||
JSBool matched;
|
JSBool matched;
|
||||||
@ -4005,7 +3948,6 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||||||
notsharp = JS_TRUE;
|
notsharp = JS_TRUE;
|
||||||
break;
|
break;
|
||||||
#endif /* JS_HAS_SHARP_VARS */
|
#endif /* JS_HAS_SHARP_VARS */
|
||||||
#endif /* JS_HAS_INITIALIZERS */
|
|
||||||
|
|
||||||
case TOK_LP:
|
case TOK_LP:
|
||||||
pn = NewParseNode(cx, ts, PN_UNARY, tc);
|
pn = NewParseNode(cx, ts, PN_UNARY, tc);
|
||||||
|
@ -63,8 +63,6 @@
|
|||||||
#include "jsscan.h"
|
#include "jsscan.h"
|
||||||
#include "jsstr.h"
|
#include "jsstr.h"
|
||||||
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
|
|
||||||
/* Note : contiguity of 'simple opcodes' is important for SimpleMatch() */
|
/* Note : contiguity of 'simple opcodes' is important for SimpleMatch() */
|
||||||
typedef enum REOp {
|
typedef enum REOp {
|
||||||
REOP_EMPTY = 0, /* match rest of input against rest of r.e. */
|
REOP_EMPTY = 0, /* match rest of input against rest of r.e. */
|
||||||
@ -3427,28 +3425,14 @@ js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp,
|
|||||||
|
|
||||||
res->lastMatch.chars = cp;
|
res->lastMatch.chars = cp;
|
||||||
res->lastMatch.length = matchlen;
|
res->lastMatch.length = matchlen;
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
|
||||||
/*
|
/*
|
||||||
* JS1.2 emulated Perl4.0.1.8 (patch level 36) for global regexps used
|
* For JS1.3 and ECMAv2, emulate Perl5 exactly:
|
||||||
* in scalar contexts, and unintentionally for the string.match "list"
|
*
|
||||||
* pseudo-context. On "hi there bye", the following would result:
|
* js1.3 "hi", "hi there" "hihitherehi therebye"
|
||||||
*
|
*/
|
||||||
* Language while(/ /g){print("$`");} s/ /$`/g
|
res->leftContext.chars = JSSTRING_CHARS(str);
|
||||||
* perl4.036 "hi", "there" "hihitherehi therebye"
|
res->leftContext.length = start + gData.skipped;
|
||||||
* perl5 "hi", "hi there" "hihitherehi therebye"
|
|
||||||
* js1.2 "hi", "there" "hihitheretherebye"
|
|
||||||
*/
|
|
||||||
res->leftContext.chars = JSSTRING_CHARS(str) + start;
|
|
||||||
res->leftContext.length = gData.skipped;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* For JS1.3 and ECMAv2, emulate Perl5 exactly:
|
|
||||||
*
|
|
||||||
* js1.3 "hi", "hi there" "hihitherehi therebye"
|
|
||||||
*/
|
|
||||||
res->leftContext.chars = JSSTRING_CHARS(str);
|
|
||||||
res->leftContext.length = start + gData.skipped;
|
|
||||||
}
|
|
||||||
res->rightContext.chars = ep;
|
res->rightContext.chars = ep;
|
||||||
res->rightContext.length = gData.cpend - ep;
|
res->rightContext.length = gData.cpend - ep;
|
||||||
|
|
||||||
@ -4173,5 +4157,3 @@ js_SetLastIndex(JSContext *cx, JSObject *obj, jsdouble lastIndex)
|
|||||||
return js_NewNumberValue(cx, lastIndex, &v) &&
|
return js_NewNumberValue(cx, lastIndex, &v) &&
|
||||||
JS_SetReservedSlot(cx, obj, 0, v);
|
JS_SetReservedSlot(cx, obj, 0, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* JS_HAS_REGEXPS */
|
|
||||||
|
@ -618,7 +618,6 @@ ReportCompileErrorNumber(JSContext *cx, void *handle, uintN flags,
|
|||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#if JS_HAS_ERROR_EXCEPTIONS
|
|
||||||
/*
|
/*
|
||||||
* If there's a runtime exception type associated with this error
|
* If there's a runtime exception type associated with this error
|
||||||
* number, set that as the pending exception. For errors occuring at
|
* number, set that as the pending exception. For errors occuring at
|
||||||
@ -654,7 +653,7 @@ ReportCompileErrorNumber(JSContext *cx, void *handle, uintN flags,
|
|||||||
*/
|
*/
|
||||||
if (cx->interpLevel != 0 && !JSREPORT_IS_WARNING(flags))
|
if (cx->interpLevel != 0 && !JSREPORT_IS_WARNING(flags))
|
||||||
onError = NULL;
|
onError = NULL;
|
||||||
#endif
|
|
||||||
if (onError) {
|
if (onError) {
|
||||||
JSDebugErrorHook hook = cx->runtime->debugErrorHook;
|
JSDebugErrorHook hook = cx->runtime->debugErrorHook;
|
||||||
|
|
||||||
@ -1288,9 +1287,12 @@ retry:
|
|||||||
if (kw->tokentype == TOK_RESERVED) {
|
if (kw->tokentype == TOK_RESERVED) {
|
||||||
char buf[MAX_KEYWORD_LENGTH + 1];
|
char buf[MAX_KEYWORD_LENGTH + 1];
|
||||||
size_t buflen = sizeof(buf) - 1;
|
size_t buflen = sizeof(buf) - 1;
|
||||||
if (!js_DeflateStringToBuffer(cx, TOKENBUF_BASE(), TOKENBUF_LENGTH(),
|
if (!js_DeflateStringToBuffer(cx,
|
||||||
buf, &buflen))
|
TOKENBUF_BASE(),
|
||||||
|
TOKENBUF_LENGTH(),
|
||||||
|
buf, &buflen)) {
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
buf [buflen] = 0;
|
buf [buflen] = 0;
|
||||||
if (!js_ReportCompileErrorNumber(cx, ts,
|
if (!js_ReportCompileErrorNumber(cx, ts,
|
||||||
JSREPORT_TS |
|
JSREPORT_TS |
|
||||||
@ -1558,11 +1560,7 @@ retry:
|
|||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
if (MatchChar(ts, c)) {
|
if (MatchChar(ts, c)) {
|
||||||
#if JS_HAS_TRIPLE_EQOPS
|
|
||||||
tp->t_op = MatchChar(ts, c) ? JSOP_NEW_EQ : (JSOp)cx->jsop_eq;
|
tp->t_op = MatchChar(ts, c) ? JSOP_NEW_EQ : (JSOp)cx->jsop_eq;
|
||||||
#else
|
|
||||||
tp->t_op = cx->jsop_eq;
|
|
||||||
#endif
|
|
||||||
tt = TOK_EQOP;
|
tt = TOK_EQOP;
|
||||||
} else {
|
} else {
|
||||||
tp->t_op = JSOP_NOP;
|
tp->t_op = JSOP_NOP;
|
||||||
@ -1859,7 +1857,6 @@ skipline:
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
if (ts->flags & TSF_OPERAND) {
|
if (ts->flags & TSF_OPERAND) {
|
||||||
JSObject *obj;
|
JSObject *obj;
|
||||||
uintN flags;
|
uintN flags;
|
||||||
@ -1933,7 +1930,6 @@ skipline:
|
|||||||
tt = TOK_OBJECT;
|
tt = TOK_OBJECT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_REGEXPS */
|
|
||||||
|
|
||||||
tp->t_op = JSOP_DIV;
|
tp->t_op = JSOP_DIV;
|
||||||
tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
|
tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
|
||||||
|
183
js/src/jsstr.c
183
js/src/jsstr.c
@ -70,10 +70,6 @@
|
|||||||
#include "jsregexp.h"
|
#include "jsregexp.h"
|
||||||
#include "jsstr.h"
|
#include "jsstr.h"
|
||||||
|
|
||||||
#if JS_HAS_REPLACE_LAMBDA
|
|
||||||
#include "jsinterp.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define JSSTRDEP_RECURSION_LIMIT 100
|
#define JSSTRDEP_RECURSION_LIMIT 100
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@ -554,10 +550,6 @@ str_enumerate(JSContext *cx, JSObject *obj)
|
|||||||
JSString *str, *str1;
|
JSString *str, *str1;
|
||||||
size_t i, length;
|
size_t i, length;
|
||||||
|
|
||||||
/* Avoid infinite recursion via js_obj_toSource (see bug 271477). */
|
|
||||||
if (JS_VERSION_IS_1_2(cx))
|
|
||||||
return JS_TRUE;
|
|
||||||
|
|
||||||
v = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
|
v = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
|
||||||
JS_ASSERT(JSVAL_IS_STRING(v));
|
JS_ASSERT(JSVAL_IS_STRING(v));
|
||||||
str = JSVAL_TO_STRING(v);
|
str = JSVAL_TO_STRING(v);
|
||||||
@ -740,14 +732,10 @@ str_substring(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
else if (end > length)
|
else if (end > length)
|
||||||
end = length;
|
end = length;
|
||||||
if (end < begin) {
|
if (end < begin) {
|
||||||
if (!JS_VERSION_IS_1_2(cx)) {
|
/* ECMA emulates old JDK1.0 java.lang.String.substring. */
|
||||||
/* XXX emulate old JDK1.0 java.lang.String.substring. */
|
jsdouble tmp = begin;
|
||||||
jsdouble tmp = begin;
|
begin = end;
|
||||||
begin = end;
|
end = tmp;
|
||||||
end = tmp;
|
|
||||||
} else {
|
|
||||||
end = begin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,7 +1098,6 @@ str_lastIndexOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
/*
|
/*
|
||||||
* Perl-inspired string functions.
|
* Perl-inspired string functions.
|
||||||
*/
|
*/
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
typedef struct GlobData {
|
typedef struct GlobData {
|
||||||
uintN flags; /* inout: mode and flag bits, see below */
|
uintN flags; /* inout: mode and flag bits, see below */
|
||||||
uintN optarg; /* in: index of optional flags argument */
|
uintN optarg; /* in: index of optional flags argument */
|
||||||
@ -1332,24 +1319,12 @@ static JSSubString *
|
|||||||
interpret_dollar(JSContext *cx, jschar *dp, jschar *ep, ReplaceData *rdata,
|
interpret_dollar(JSContext *cx, jschar *dp, jschar *ep, ReplaceData *rdata,
|
||||||
size_t *skip)
|
size_t *skip)
|
||||||
{
|
{
|
||||||
JSVersion version;
|
|
||||||
JSRegExpStatics *res;
|
JSRegExpStatics *res;
|
||||||
jschar dc, *cp;
|
jschar dc, *cp;
|
||||||
uintN num, tmp;
|
uintN num, tmp;
|
||||||
JSString *str;
|
|
||||||
|
|
||||||
JS_ASSERT(*dp == '$');
|
JS_ASSERT(*dp == '$');
|
||||||
|
|
||||||
/*
|
|
||||||
* Allow a real backslash (literal "\\" before "$1") to escape "$1", e.g.
|
|
||||||
* Do this only for versions strictly less than ECMAv3.
|
|
||||||
*/
|
|
||||||
version = cx->version & JSVERSION_MASK;
|
|
||||||
if (version != JSVERSION_DEFAULT && version <= JSVERSION_1_4) {
|
|
||||||
if (dp > JSSTRING_CHARS(rdata->repstr) && dp[-1] == '\\')
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there is only a dollar, bail now */
|
/* If there is only a dollar, bail now */
|
||||||
if (dp + 1 >= ep)
|
if (dp + 1 >= ep)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1358,35 +1333,22 @@ interpret_dollar(JSContext *cx, jschar *dp, jschar *ep, ReplaceData *rdata,
|
|||||||
res = &cx->regExpStatics;
|
res = &cx->regExpStatics;
|
||||||
dc = dp[1];
|
dc = dp[1];
|
||||||
if (JS7_ISDEC(dc)) {
|
if (JS7_ISDEC(dc)) {
|
||||||
if (version != JSVERSION_DEFAULT && version <= JSVERSION_1_4) {
|
/* ECMA-262 Edition 3: 1-9 or 01-99 */
|
||||||
if (dc == '0')
|
num = JS7_UNDEC(dc);
|
||||||
return NULL;
|
if (num > res->parenCount)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Check for overflow to avoid gobbling arbitrary decimal digits. */
|
cp = dp + 2;
|
||||||
num = 0;
|
if (cp < ep && (dc = *cp, JS7_ISDEC(dc))) {
|
||||||
cp = dp;
|
tmp = 10 * num + JS7_UNDEC(dc);
|
||||||
while (++cp < ep && (dc = *cp, JS7_ISDEC(dc))) {
|
if (tmp <= res->parenCount) {
|
||||||
tmp = 10 * num + JS7_UNDEC(dc);
|
cp++;
|
||||||
if (tmp < num)
|
|
||||||
break;
|
|
||||||
num = tmp;
|
num = tmp;
|
||||||
}
|
}
|
||||||
} else { /* ECMA 3, 1-9 or 01-99 */
|
|
||||||
num = JS7_UNDEC(dc);
|
|
||||||
if (num > res->parenCount)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
cp = dp + 2;
|
|
||||||
if (cp < ep && (dc = *cp, JS7_ISDEC(dc))) {
|
|
||||||
tmp = 10 * num + JS7_UNDEC(dc);
|
|
||||||
if (tmp <= res->parenCount) {
|
|
||||||
cp++;
|
|
||||||
num = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (num == 0)
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
if (num == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Adjust num from 1 $n-origin to 0 array-index-origin. */
|
/* Adjust num from 1 $n-origin to 0 array-index-origin. */
|
||||||
num--;
|
num--;
|
||||||
*skip = cp - dp;
|
*skip = cp - dp;
|
||||||
@ -1404,19 +1366,6 @@ interpret_dollar(JSContext *cx, jschar *dp, jschar *ep, ReplaceData *rdata,
|
|||||||
case '+':
|
case '+':
|
||||||
return &res->lastParen;
|
return &res->lastParen;
|
||||||
case '`':
|
case '`':
|
||||||
if (version == JSVERSION_1_2) {
|
|
||||||
/*
|
|
||||||
* JS1.2 imitated the Perl4 bug where left context at each step
|
|
||||||
* in an iterative use of a global regexp started from last match,
|
|
||||||
* not from the start of the target string. But Perl4 does start
|
|
||||||
* $` at the beginning of the target string when it is used in a
|
|
||||||
* substitution, so we emulate that special case here.
|
|
||||||
*/
|
|
||||||
str = rdata->base.str;
|
|
||||||
res->leftContext.chars = JSSTRING_CHARS(str);
|
|
||||||
res->leftContext.length = res->lastMatch.chars
|
|
||||||
- JSSTRING_CHARS(str);
|
|
||||||
}
|
|
||||||
return &res->leftContext;
|
return &res->leftContext;
|
||||||
case '\'':
|
case '\'':
|
||||||
return &res->rightContext;
|
return &res->rightContext;
|
||||||
@ -1431,7 +1380,6 @@ find_replen(JSContext *cx, ReplaceData *rdata, size_t *sizep)
|
|||||||
size_t replen, skip;
|
size_t replen, skip;
|
||||||
jschar *dp, *ep;
|
jschar *dp, *ep;
|
||||||
JSSubString *sub;
|
JSSubString *sub;
|
||||||
#if JS_HAS_REPLACE_LAMBDA
|
|
||||||
JSObject *lambda;
|
JSObject *lambda;
|
||||||
|
|
||||||
lambda = rdata->lambda;
|
lambda = rdata->lambda;
|
||||||
@ -1540,7 +1488,6 @@ find_replen(JSContext *cx, ReplaceData *rdata, size_t *sizep)
|
|||||||
cx->regExpStatics = save;
|
cx->regExpStatics = save;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_REPLACE_LAMBDA */
|
|
||||||
|
|
||||||
repstr = rdata->repstr;
|
repstr = rdata->repstr;
|
||||||
replen = JSSTRING_LENGTH(repstr);
|
replen = JSSTRING_LENGTH(repstr);
|
||||||
@ -1633,18 +1580,14 @@ str_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
JSObject *lambda;
|
JSObject *lambda;
|
||||||
JSString *repstr, *str;
|
JSString *repstr, *str;
|
||||||
ReplaceData rdata;
|
ReplaceData rdata;
|
||||||
JSVersion version;
|
|
||||||
JSBool ok;
|
JSBool ok;
|
||||||
jschar *chars;
|
jschar *chars;
|
||||||
size_t leftlen, rightlen, length;
|
size_t leftlen, rightlen, length;
|
||||||
|
|
||||||
#if JS_HAS_REPLACE_LAMBDA
|
|
||||||
if (JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) {
|
if (JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) {
|
||||||
lambda = JSVAL_TO_OBJECT(argv[1]);
|
lambda = JSVAL_TO_OBJECT(argv[1]);
|
||||||
repstr = NULL;
|
repstr = NULL;
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!JS_ConvertValue(cx, argv[1], JSTYPE_STRING, &argv[1]))
|
if (!JS_ConvertValue(cx, argv[1], JSTYPE_STRING, &argv[1]))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
repstr = JSVAL_TO_STRING(argv[1]);
|
repstr = JSVAL_TO_STRING(argv[1]);
|
||||||
@ -1656,10 +1599,7 @@ str_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
* to match in a "flat" sense (without regular expression metachars having
|
* to match in a "flat" sense (without regular expression metachars having
|
||||||
* special meanings) UNLESS the first arg is a RegExp object.
|
* special meanings) UNLESS the first arg is a RegExp object.
|
||||||
*/
|
*/
|
||||||
rdata.base.flags = MODE_REPLACE | KEEP_REGEXP;
|
rdata.base.flags = MODE_REPLACE | KEEP_REGEXP | FORCE_FLAT;
|
||||||
version = cx->version & JSVERSION_MASK;
|
|
||||||
if (version == JSVERSION_DEFAULT || version > JSVERSION_1_4)
|
|
||||||
rdata.base.flags |= FORCE_FLAT;
|
|
||||||
rdata.base.optarg = 2;
|
rdata.base.optarg = 2;
|
||||||
|
|
||||||
rdata.lambda = lambda;
|
rdata.lambda = lambda;
|
||||||
@ -1729,7 +1669,6 @@ out:
|
|||||||
js_DestroyRegExp(cx, rdata.base.regexp);
|
js_DestroyRegExp(cx, rdata.base.regexp);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_REGEXPS */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subroutine used by str_split to find the next split point in str, starting
|
* Subroutine used by str_split to find the next split point in str, starting
|
||||||
@ -1745,8 +1684,8 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
JSSubString *sep)
|
JSSubString *sep)
|
||||||
{
|
{
|
||||||
jsint i, j, k;
|
jsint i, j, k;
|
||||||
jschar *chars;
|
|
||||||
size_t length;
|
size_t length;
|
||||||
|
jschar *chars;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop if past end of string. If at end of string, we will compare the
|
* Stop if past end of string. If at end of string, we will compare the
|
||||||
@ -1760,48 +1699,12 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
* limit argument (see str_split).
|
* limit argument (see str_split).
|
||||||
*/
|
*/
|
||||||
i = *ip;
|
i = *ip;
|
||||||
if ((size_t)i > JSSTRING_LENGTH(str))
|
length = JSSTRING_LENGTH(str);
|
||||||
|
if ((size_t)i > length)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
|
||||||
* Perl4 special case for str.split(' '), only if the user has selected
|
|
||||||
* JavaScript1.2 explicitly. Split on whitespace, and skip leading w/s.
|
|
||||||
* Strange but true, apparently modeled after awk.
|
|
||||||
*
|
|
||||||
* NB: we set sep->length to the length of the w/s run, so we must test
|
|
||||||
* sep->chars[1] == 0 to make sure sep is just one space.
|
|
||||||
*/
|
|
||||||
chars = JSSTRING_CHARS(str);
|
chars = JSSTRING_CHARS(str);
|
||||||
length = JSSTRING_LENGTH(str);
|
|
||||||
if (JS_VERSION_IS_1_2(cx) &&
|
|
||||||
!re && *sep->chars == ' ' && sep->chars[1] == 0) {
|
|
||||||
|
|
||||||
/* Skip leading whitespace if at front of str. */
|
|
||||||
if (i == 0) {
|
|
||||||
while (JS_ISSPACE(chars[i]))
|
|
||||||
i++;
|
|
||||||
*ip = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Don't delimit whitespace at end of string. */
|
|
||||||
if ((size_t)i == length)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Skip over the non-whitespace chars. */
|
|
||||||
while ((size_t)i < length && !JS_ISSPACE(chars[i]))
|
|
||||||
i++;
|
|
||||||
|
|
||||||
/* Now skip the next run of whitespace. */
|
|
||||||
j = i;
|
|
||||||
while ((size_t)j < length && JS_ISSPACE(chars[j]))
|
|
||||||
j++;
|
|
||||||
|
|
||||||
/* Update sep->length to count delimiter chars. */
|
|
||||||
sep->length = (size_t)(j - i);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
/*
|
/*
|
||||||
* Match a regular expression against the separator at or above index i.
|
* Match a regular expression against the separator at or above index i.
|
||||||
* Call js_ExecuteRegExp with true for the test argument. On successful
|
* Call js_ExecuteRegExp with true for the test argument. On successful
|
||||||
@ -1835,13 +1738,8 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
* bump past end of string -- our caller must do that by adding
|
* bump past end of string -- our caller must do that by adding
|
||||||
* sep->length to our return value.
|
* sep->length to our return value.
|
||||||
*/
|
*/
|
||||||
if ((size_t)i == length) {
|
if ((size_t)i == length)
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
|
||||||
sep->length = 1;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -1857,7 +1755,6 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
JS_ASSERT((size_t)i >= sep->length);
|
JS_ASSERT((size_t)i >= sep->length);
|
||||||
return i - sep->length;
|
return i - sep->length;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_REGEXPS */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deviate from ECMA by never splitting an empty string by any separator
|
* Deviate from ECMA by never splitting an empty string by any separator
|
||||||
@ -1871,21 +1768,9 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
* Special case: if sep is the empty string, split str into one character
|
* Special case: if sep is the empty string, split str into one character
|
||||||
* substrings. Let our caller worry about whether to split once at end of
|
* substrings. Let our caller worry about whether to split once at end of
|
||||||
* string into an empty substring.
|
* string into an empty substring.
|
||||||
*
|
|
||||||
* For 1.2 compatibility, at the end of the string, we return the length as
|
|
||||||
* the result, and set the separator length to 1 -- this allows the caller
|
|
||||||
* to include an additional null string at the end of the substring list.
|
|
||||||
*/
|
*/
|
||||||
if (sep->length == 0) {
|
if (sep->length == 0)
|
||||||
if (JS_VERSION_IS_1_2(cx)) {
|
|
||||||
if ((size_t)i == length) {
|
|
||||||
sep->length = 1;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
return ((size_t)i == length) ? -1 : i + 1;
|
return ((size_t)i == length) ? -1 : i + 1;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now that we know sep is non-empty, search starting at i in str for an
|
* Now that we know sep is non-empty, search starting at i in str for an
|
||||||
@ -1932,16 +1817,13 @@ str_split(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
v = STRING_TO_JSVAL(str);
|
v = STRING_TO_JSVAL(str);
|
||||||
ok = JS_SetElement(cx, arrayobj, 0, &v);
|
ok = JS_SetElement(cx, arrayobj, 0, &v);
|
||||||
} else {
|
} else {
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
if (JSVAL_IS_REGEXP(cx, argv[0])) {
|
if (JSVAL_IS_REGEXP(cx, argv[0])) {
|
||||||
re = (JSRegExp *) JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
|
re = (JSRegExp *) JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||||
sep = &tmp;
|
sep = &tmp;
|
||||||
|
|
||||||
/* Set a magic value so we can detect a successful re match. */
|
/* Set a magic value so we can detect a successful re match. */
|
||||||
sep->chars = NULL;
|
sep->chars = NULL;
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
JSString *str2 = js_ValueToString(cx, argv[0]);
|
JSString *str2 = js_ValueToString(cx, argv[0]);
|
||||||
if (!str2)
|
if (!str2)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -1982,7 +1864,7 @@ str_split(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
if (!JS_SetElement(cx, arrayobj, len, &v))
|
if (!JS_SetElement(cx, arrayobj, len, &v))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
len++;
|
len++;
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
/*
|
/*
|
||||||
* Imitate perl's feature of including parenthesized substrings
|
* Imitate perl's feature of including parenthesized substrings
|
||||||
* that matched part of the delimiter in the new array, after the
|
* that matched part of the delimiter in the new array, after the
|
||||||
@ -2007,7 +1889,7 @@ str_split(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
}
|
}
|
||||||
sep->chars = NULL;
|
sep->chars = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
i = j + sep->length;
|
i = j + sep->length;
|
||||||
if (!JS_VERSION_IS_ECMA(cx)) {
|
if (!JS_VERSION_IS_ECMA(cx)) {
|
||||||
/*
|
/*
|
||||||
@ -2072,7 +1954,6 @@ str_substr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
}
|
}
|
||||||
#endif /* JS_HAS_PERL_SUBSTR */
|
#endif /* JS_HAS_PERL_SUBSTR */
|
||||||
|
|
||||||
#if JS_HAS_SEQUENCE_OPS
|
|
||||||
/*
|
/*
|
||||||
* Python-esque sequence operations.
|
* Python-esque sequence operations.
|
||||||
*/
|
*/
|
||||||
@ -2152,7 +2033,6 @@ str_slice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
*rval = STRING_TO_JSVAL(str);
|
*rval = STRING_TO_JSVAL(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_SEQUENCE_OPS */
|
|
||||||
|
|
||||||
#if JS_HAS_STR_HTML_HELPERS
|
#if JS_HAS_STR_HTML_HELPERS
|
||||||
/*
|
/*
|
||||||
@ -2336,21 +2216,17 @@ static JSFunctionSpec string_methods[] = {
|
|||||||
{"localeCompare", str_localeCompare, 1,JSFUN_GENERIC_NATIVE,0},
|
{"localeCompare", str_localeCompare, 1,JSFUN_GENERIC_NATIVE,0},
|
||||||
|
|
||||||
/* Perl-ish methods (search is actually Python-esque). */
|
/* Perl-ish methods (search is actually Python-esque). */
|
||||||
#if JS_HAS_REGEXPS
|
|
||||||
{"match", str_match, 1,JSFUN_GENERIC_NATIVE,2},
|
{"match", str_match, 1,JSFUN_GENERIC_NATIVE,2},
|
||||||
{"search", str_search, 1,JSFUN_GENERIC_NATIVE,0},
|
{"search", str_search, 1,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"replace", str_replace, 2,JSFUN_GENERIC_NATIVE,0},
|
{"replace", str_replace, 2,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"split", str_split, 2,JSFUN_GENERIC_NATIVE,0},
|
{"split", str_split, 2,JSFUN_GENERIC_NATIVE,0},
|
||||||
#endif
|
|
||||||
#if JS_HAS_PERL_SUBSTR
|
#if JS_HAS_PERL_SUBSTR
|
||||||
{"substr", str_substr, 2,JSFUN_GENERIC_NATIVE,0},
|
{"substr", str_substr, 2,JSFUN_GENERIC_NATIVE,0},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Python-esque sequence methods. */
|
/* Python-esque sequence methods. */
|
||||||
#if JS_HAS_SEQUENCE_OPS
|
|
||||||
{"concat", str_concat, 0,JSFUN_GENERIC_NATIVE,0},
|
{"concat", str_concat, 0,JSFUN_GENERIC_NATIVE,0},
|
||||||
{"slice", str_slice, 0,JSFUN_GENERIC_NATIVE,0},
|
{"slice", str_slice, 0,JSFUN_GENERIC_NATIVE,0},
|
||||||
#endif
|
|
||||||
|
|
||||||
/* HTML string methods. */
|
/* HTML string methods. */
|
||||||
#if JS_HAS_STR_HTML_HELPERS
|
#if JS_HAS_STR_HTML_HELPERS
|
||||||
@ -2402,6 +2278,7 @@ str_fromCharCode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
uint16 code;
|
uint16 code;
|
||||||
JSString *str;
|
JSString *str;
|
||||||
|
|
||||||
|
JS_ASSERT(argc < ARGC_LIMIT);
|
||||||
chars = (jschar *) JS_malloc(cx, (argc + 1) * sizeof(jschar));
|
chars = (jschar *) JS_malloc(cx, (argc + 1) * sizeof(jschar));
|
||||||
if (!chars)
|
if (!chars)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -3145,8 +3022,10 @@ js_DeflateStringToBuffer(JSContext* cx, const jschar *chars, size_t length, char
|
|||||||
if (length > *bytesLength) {
|
if (length > *bytesLength) {
|
||||||
for (i = 0; i < *bytesLength; i++)
|
for (i = 0; i < *bytesLength; i++)
|
||||||
bytes[i] = (char) chars[i];
|
bytes[i] = (char) chars[i];
|
||||||
if (cx)
|
if (cx) {
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BUFFER_TOO_SMALL);
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||||
|
JSMSG_BUFFER_TOO_SMALL);
|
||||||
|
}
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user