Support ref()++ etc. for native ref (75688) and fix exn_toSource (96284); sr=shaver&jband.

git-svn-id: svn://10.0.0.236/trunk@101627 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org 2001-08-22 04:59:28 +00:00
parent b4e046129c
commit 97dea81da0
3 changed files with 48 additions and 5 deletions

View File

@ -2481,6 +2481,19 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (!EmitElemOp(cx, pn2, op, cg))
return JS_FALSE;
break;
#if JS_HAS_LVALUE_RETURN
case TOK_LP:
if (!js_EmitTree(cx, cg, pn2))
return JS_FALSE;
if (js_NewSrcNote2(cx, cg, SRC_PCBASE,
(ptrdiff_t)(CG_OFFSET(cg) - pn2->pn_offset))
< 0) {
return JS_FALSE;
}
if (js_Emit1(cx, cg, op) < 0)
return JS_FALSE;
break;
#endif
default:
JS_ASSERT(0);
}

View File

@ -549,6 +549,9 @@ exn_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_FALSE;
}
result = js_QuoteString(cx, result, '"');
if (!result)
return JS_FALSE;
*rval = STRING_TO_JSVAL(result);
return JS_TRUE;
}
@ -700,12 +703,32 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp)
/*
* Try to get an appropriate prototype by looking up the corresponding
* exception constructor name in the current context. If the constructor
* has been deleted or overwritten, this may fail or return NULL, and
* js_NewObject will fall back to using Object.prototype.
* exception constructor name in the scope chain of the current context's
* top stack frame, or in the global object if no frame is active.
*
* XXXbe hack around JSCLASS_NEW_RESOLVE code in js_LookupProperty that
* checks cx->fp, cx->fp->pc, and js_CodeSpec[*cx->fp->pc] in order
* to compute resolve flags such as JSRESOLVE_ASSIGNING. The bug
* is that this "internal" js_GetClassPrototype call may trigger a
* resolve of exceptions[exn].name if the global object uses a lazy
* standard class resolver (see JS_ResolveStandardClass), but the
* current frame and bytecode end up affecting the resolve flags.
*/
if (!js_GetClassPrototype(cx, exceptions[exn].name, &errProto))
errProto = NULL;
{
JSStackFrame *fp = cx->fp;
jsbytecode *pc = NULL;
JSBool ok;
if (fp) {
pc = fp->pc;
fp->pc = NULL;
}
ok = js_GetClassPrototype(cx, exceptions[exn].name, &errProto);
if (pc)
fp->pc = pc;
if (!ok)
return JS_FALSE;
}
/*
* Use js_NewObject instead of js_ConstructObject, because

View File

@ -2381,6 +2381,9 @@ SetLvalKid(JSContext *cx, JSTokenStream *ts, JSParseNode *pn, JSParseNode *kid,
kid = kid->pn_kid;
if (kid->pn_type != TOK_NAME &&
kid->pn_type != TOK_DOT &&
#if JS_HAS_LVALUE_RETURN
(kid->pn_type != TOK_LP || kid->pn_op != JSOP_CALL) &&
#endif
kid->pn_type != TOK_LB) {
js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
JSMSG_BAD_OPERAND, name);
@ -2418,6 +2421,10 @@ SetIncOpKid(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
break;
case TOK_LB:
#if JS_HAS_LVALUE_RETURN
case TOK_LP:
kid->pn_op = JSOP_SETCALL;
#endif
op = (tt == TOK_INC)
? (preorder ? JSOP_INCELEM : JSOP_ELEMINC)
: (preorder ? JSOP_DECELEM : JSOP_ELEMDEC);