Bug 697322 - Add easier to use reset method to CallReceiver; r=luke

All users of InvokeArgsGuard that use calleeHasBeenReset use it before
setting a new callee/this in a loop.  We should make it easier to use
by combining the reset with the setup with the setting of the new
callee.
This commit is contained in:
Terrence Cole 2011-11-08 10:17:25 -08:00
Родитель 4f068f0945
Коммит 5ae078453d
3 изменённых файлов: 8 добавлений и 13 удалений

Просмотреть файл

@ -2151,8 +2151,7 @@ sort_compare(void *arg, const void *a, const void *b, int *result)
if (!ag.pushed() && !cx->stack.pushInvokeArgs(cx, 2, &ag))
return JS_FALSE;
ag.calleeHasBeenReset();
ag.calleev() = ca->fval;
ag.setCallee(ca->fval);
ag.thisv() = UndefinedValue();
ag[0] = *av;
ag[1] = *bv;
@ -3360,8 +3359,7 @@ array_readonlyCommon(JSContext *cx, CallArgs &args)
if (!kNotPresent) {
if (!ag.pushed() && !cx->stack.pushInvokeArgs(cx, 3, &ag))
return false;
ag.calleeHasBeenReset();
ag.calleev() = ObjectValue(*callable);
ag.setCallee(ObjectValue(*callable));
ag.thisv() = thisv;
ag[0] = kValue;
ag[1] = NumberValue(k);
@ -3462,8 +3460,7 @@ array_map(JSContext *cx, uintN argc, Value *vp)
if (!kNotPresent) {
if (!ag.pushed() && !cx->stack.pushInvokeArgs(cx, 3, &ag))
return false;
ag.calleeHasBeenReset();
ag.calleev() = ObjectValue(*callable);
ag.setCallee(ObjectValue(*callable));
ag.thisv() = thisv;
ag[0] = kValue;
ag[1] = NumberValue(k);
@ -3542,8 +3539,7 @@ array_filter(JSContext *cx, uintN argc, Value *vp)
if (!kNotPresent) {
if (!ag.pushed() && !cx->stack.pushInvokeArgs(cx, 3, &ag))
return false;
ag.calleeHasBeenReset();
ag.calleev() = ObjectValue(*callable);
ag.setCallee(ObjectValue(*callable));
ag.thisv() = thisv;
ag[0] = kValue;
ag[1] = NumberValue(k);
@ -3661,8 +3657,7 @@ array_reduceCommon(JSContext *cx, CallArgs &args)
if (!kNotPresent) {
if (!ag.pushed() && !cx->stack.pushInvokeArgs(cx, 4, &ag))
return false;
ag.calleeHasBeenReset();
ag.calleev() = ObjectValue(*callable);
ag.setCallee(ObjectValue(*callable));
ag.thisv() = UndefinedValue();
ag[0] = accumulator;
ag[1] = kValue;

Просмотреть файл

@ -1791,8 +1791,7 @@ FindReplaceLength(JSContext *cx, RegExpStatics *res, ReplaceData &rdata, size_t
if (!args.pushed() && !cx->stack.pushInvokeArgs(cx, argc, &args))
return false;
args.calleeHasBeenReset();
args.calleev() = ObjectValue(*lambda);
args.setCallee(ObjectValue(*lambda));
args.thisv() = UndefinedValue();
/* Push $&, $1, $2, ... */

Просмотреть файл

@ -208,8 +208,9 @@ class CallReceiver
return argv_ - 1;
}
void calleeHasBeenReset() const {
void setCallee(Value calleev) {
clearUsedRval();
this->calleev() = calleev;
}
};