mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 09:19:28 +00:00
E3 test fixes.
This commit is contained in:
parent
d9200c8666
commit
88a279c007
@ -394,6 +394,14 @@ namespace MetaData {
|
||||
if (obj->kind == ClassKind) // therefore, not an E3 object, so just return
|
||||
return engine->typeofString(x); // the 'typeof' string
|
||||
|
||||
if (hint == NoHint) {
|
||||
if ((obj->kind == SimpleInstanceKind)
|
||||
&& ((checked_cast<SimpleInstance *>(obj))->type == dateClass))
|
||||
hint = StringHint;
|
||||
else
|
||||
hint = NumberHint;
|
||||
}
|
||||
|
||||
if (hint == StringHint) {
|
||||
js2val result;
|
||||
if (invokeFunctionOnObject(x, engine->toString_StringAtom, result)) {
|
||||
|
@ -110,6 +110,7 @@ namespace MetaData {
|
||||
FunctionInstance *fnInst = checked_cast<FunctionInstance *>(JS2VAL_TO_OBJECT(thatValue));
|
||||
DEFINE_ROOTKEEPER(rk, fnInst);
|
||||
fnInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), meta->env);
|
||||
fnInst->fWrap->length = 0;
|
||||
fnInst->fWrap->bCon->emitOp(eReturnVoid, meta->engine->errorPos());
|
||||
meta->createDynamicProperty(fnInst, meta->engine->length_StringAtom, INT_TO_JS2VAL(0), ReadAccess, true, false);
|
||||
return thatValue;
|
||||
@ -148,6 +149,7 @@ namespace MetaData {
|
||||
FunctionInstance *fnInst = new FunctionInstance(meta, meta->objectClass->prototype, meta->functionClass);
|
||||
DEFINE_ROOTKEEPER(rk, fnInst);
|
||||
fnInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), meta->env);
|
||||
fnInst->fWrap->length = 0;
|
||||
fnInst->fWrap->bCon->emitOp(eReturnVoid, 0);
|
||||
|
||||
meta->initBuiltinClass(meta->functionClass, NULL, Function_Constructor, Function_Constructor);
|
||||
|
@ -338,6 +338,7 @@ void initMathObject(JS2Metadata *meta, SimpleInstance *mathObject)
|
||||
while (pf->name) {
|
||||
FunctionInstance *callInst = new FunctionInstance(meta, meta->functionClass->prototype, meta->functionClass);
|
||||
callInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code, meta->env);
|
||||
callInst->fWrap->length = pf->length;
|
||||
|
||||
meta->createDynamicProperty(mathObject, &meta->world.identifiers[pf->name], OBJECT_TO_JS2VAL(callInst), ReadAccess, true, false);
|
||||
|
||||
|
@ -108,6 +108,7 @@ namespace MetaData {
|
||||
}
|
||||
if (prototype)
|
||||
createDynamicProperty(result, engine->length_StringAtom, INT_TO_JS2VAL(pCount), ReadAccess, true, false);
|
||||
result->fWrap->length = pCount;
|
||||
pb = fnDef->parameters;
|
||||
while (pb) {
|
||||
// XXX define a static binding for each parameter
|
||||
@ -429,7 +430,8 @@ namespace MetaData {
|
||||
for (TargetListReverseIterator si = targetList.rbegin(), end = targetList.rend();
|
||||
((g->tgtID == -1) && (si != end)); si++) {
|
||||
// only some non-label statements will do
|
||||
switch ((*si)->getKind()) {
|
||||
StmtNode *s = *si;
|
||||
switch (s->getKind()) {
|
||||
case StmtNode::block:
|
||||
g->blockCount++;
|
||||
break;
|
||||
@ -1006,7 +1008,6 @@ namespace MetaData {
|
||||
|
||||
bCon->setLabel(loopTop);
|
||||
|
||||
targetList.push_back(p);
|
||||
bCon->emitOp(eForValue, p->pos);
|
||||
|
||||
Reference *v = NULL;
|
||||
@ -3699,6 +3700,7 @@ static const uint8 urlCharType[256] =
|
||||
{
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), code, env);
|
||||
fInst->fWrap->length = length;
|
||||
createDynamicProperty(glob, &world.identifiers[name], OBJECT_TO_JS2VAL(fInst), ReadWriteAccess, false, true);
|
||||
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(length), ReadAccess, true, false);
|
||||
}
|
||||
@ -3852,11 +3854,13 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
||||
// Adding 'toString' to the Object.prototype XXX Or make this a static class member?
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), Object_toString, env);
|
||||
fInst->fWrap->length = 0;
|
||||
createDynamicProperty(JS2VAL_TO_OBJECT(objectClass->prototype), engine->toString_StringAtom, OBJECT_TO_JS2VAL(fInst), ReadAccess, true, false);
|
||||
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(0), ReadAccess, true, false);
|
||||
// and 'valueOf'
|
||||
fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), Object_valueOf, env);
|
||||
fInst->fWrap->length = 0;
|
||||
createDynamicProperty(JS2VAL_TO_OBJECT(objectClass->prototype), engine->valueOf_StringAtom, OBJECT_TO_JS2VAL(fInst), ReadAccess, true, false);
|
||||
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(0), ReadAccess, true, false);
|
||||
|
||||
@ -4438,6 +4442,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(1), ReadAccess, true, false);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), builtinClass->construct, env);
|
||||
fInst->fWrap->length = 0;
|
||||
ASSERT(JS2VAL_IS_OBJECT(builtinClass->prototype));
|
||||
createDynamicProperty(JS2VAL_TO_OBJECT(builtinClass->prototype), &world.identifiers["constructor"], OBJECT_TO_JS2VAL(fInst), ReadWriteAccess, false, false);
|
||||
|
||||
@ -4447,12 +4452,14 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
||||
/*
|
||||
SimpleInstance *callInst = new SimpleInstance(this, functionClass->prototype, functionClass);
|
||||
callInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code, env);
|
||||
callInst->fWrap->length = pf->length;
|
||||
Multiname *mn = new Multiname(&world.identifiers[pf->name], publicNamespace);
|
||||
InstanceMember *m = new InstanceMethod(mn, callInst, true, false);
|
||||
defineInstanceMember(builtinClass, &cxt, mn->name, *mn->nsList, Attribute::NoOverride, false, m, 0);
|
||||
*/
|
||||
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code, env);
|
||||
fInst->fWrap->length = pf->length;
|
||||
createDynamicProperty(JS2VAL_TO_OBJECT(builtinClass->prototype), &world.identifiers[pf->name], OBJECT_TO_JS2VAL(fInst), ReadWriteAccess, false, false);
|
||||
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(pf->length), ReadAccess, true, false);
|
||||
pf++;
|
||||
@ -4478,6 +4485,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
|
||||
while (pf->name) {
|
||||
FunctionInstance *callInst = new FunctionInstance(this, functionClass->prototype, functionClass);
|
||||
callInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), pf->code, env);
|
||||
callInst->fWrap->length = pf->length;
|
||||
v = new Variable(functionClass, OBJECT_TO_JS2VAL(callInst), true);
|
||||
defineLocalMember(env, &world.identifiers[pf->name], NULL, Attribute::NoOverride, false, ReadWriteAccess, v, 0, false);
|
||||
createDynamicProperty(callInst, engine->length_StringAtom, INT_TO_JS2VAL(pf->length), ReadAccess, true, false);
|
||||
|
@ -805,9 +805,9 @@ class ParameterFrame;
|
||||
class FunctionWrapper {
|
||||
public:
|
||||
FunctionWrapper(bool unchecked, ParameterFrame *compileFrame, Environment *env)
|
||||
: bCon(new BytecodeContainer()), code(NULL), unchecked(unchecked), compileFrame(compileFrame), env(new Environment(env)) { }
|
||||
: bCon(new BytecodeContainer()), code(NULL), unchecked(unchecked), compileFrame(compileFrame), env(new Environment(env)), length(0) { }
|
||||
FunctionWrapper(bool unchecked, ParameterFrame *compileFrame, NativeCode *code, Environment *env)
|
||||
: bCon(NULL), code(code), unchecked(unchecked), compileFrame(compileFrame), env(new Environment(env)) { }
|
||||
: bCon(NULL), code(code), unchecked(unchecked), compileFrame(compileFrame), env(new Environment(env)), length(0) { }
|
||||
|
||||
virtual ~FunctionWrapper() { if (bCon) delete bCon; }
|
||||
|
||||
@ -816,6 +816,7 @@ public:
|
||||
bool unchecked; // true if the function is untyped, non-method, normal
|
||||
ParameterFrame *compileFrame;
|
||||
Environment *env;
|
||||
uint32 length;
|
||||
};
|
||||
|
||||
|
||||
|
@ -329,8 +329,8 @@
|
||||
{
|
||||
b = pop();
|
||||
a = pop();
|
||||
a = meta->toPrimitive(a, NumberHint);
|
||||
b = meta->toPrimitive(b, NumberHint);
|
||||
a = meta->toPrimitive(a, NoHint);
|
||||
b = meta->toPrimitive(b, NoHint);
|
||||
if (JS2VAL_IS_STRING(a) || JS2VAL_IS_STRING(b)) {
|
||||
astr = meta->toString(a);
|
||||
bstr = meta->toString(b);
|
||||
@ -697,8 +697,11 @@
|
||||
bool rval;
|
||||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) < *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = meta->toFloat64(a) < meta->toFloat64(b);
|
||||
else {
|
||||
float64 x = meta->toFloat64(a);
|
||||
float64 y = meta->toFloat64(b);
|
||||
rval = (!JSDOUBLE_IS_NaN(x) && !JSDOUBLE_IS_NaN(y) && (x < y));
|
||||
}
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
@ -712,8 +715,11 @@
|
||||
bool rval;
|
||||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) <= *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = meta->toFloat64(a) <= meta->toFloat64(b);
|
||||
else {
|
||||
float64 x = meta->toFloat64(a);
|
||||
float64 y = meta->toFloat64(b);
|
||||
rval = (!JSDOUBLE_IS_NaN(x) && !JSDOUBLE_IS_NaN(y) && (x <= y));
|
||||
}
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
@ -727,8 +733,11 @@
|
||||
bool rval;
|
||||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) > *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = meta->toFloat64(a) > meta->toFloat64(b);
|
||||
else {
|
||||
float64 x = meta->toFloat64(a);
|
||||
float64 y = meta->toFloat64(b);
|
||||
rval = (!JSDOUBLE_IS_NaN(x) && !JSDOUBLE_IS_NaN(y) && (x > y));
|
||||
}
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
@ -742,8 +751,11 @@
|
||||
bool rval;
|
||||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) >= *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = meta->toFloat64(a) >= meta->toFloat64(b);
|
||||
else {
|
||||
float64 x = meta->toFloat64(a);
|
||||
float64 y = meta->toFloat64(b);
|
||||
rval = (!JSDOUBLE_IS_NaN(x) && !JSDOUBLE_IS_NaN(y) && (x >= y));
|
||||
}
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
|
@ -73,7 +73,7 @@
|
||||
if (!JS2VAL_IS_OBJECT(protoVal))
|
||||
meta->reportError(Exception::badValueError, "Non-object prototype value", errorPos());
|
||||
}
|
||||
uint32 length = getLength(meta, obj);
|
||||
uint32 length = fWrap->length;
|
||||
if (fWrap->code) { // native code, pass pointer to argument base
|
||||
while (argCount < length) {
|
||||
push(JS2VAL_UNDEFINED);
|
||||
@ -127,7 +127,7 @@
|
||||
}
|
||||
}
|
||||
// XXX ok to not use getLength(meta, fObj) ?
|
||||
uint32 length = (fWrap->compileFrame->slots) ? fWrap->compileFrame->slots->size() : 0;
|
||||
uint32 length = fWrap->length;
|
||||
if (fWrap->code) { // native code
|
||||
uint16 argc = argCount;
|
||||
while (argCount < length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user