Fixed E3 bugs throughout. Added /Op to build for bug in numerics.cpp code

inherited from SpiderMonkey.


git-svn-id: svn://10.0.0.236/trunk@142342 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
2003-05-12 21:33:18 +00:00
parent 22c581e6eb
commit 022516fe63
5 changed files with 40 additions and 15 deletions

View File

@@ -468,6 +468,9 @@ namespace MetaData {
INIT_STRINGATOM(length),
INIT_STRINGATOM(toString),
INIT_STRINGATOM(valueOf),
packageFrame(NULL),
parameterFrame(NULL),
localFrame(NULL),
traceInstructions(false)
{
for (int i = 0; i < 256; i++)

View File

@@ -78,22 +78,16 @@ namespace MetaData {
ASSERT(fnExpr); // otherwise, an exception would have been thrown out of here
fnExpr->obj = NULL;
DEFINE_ROOTKEEPER(rk, fnExpr->obj);
// JS2Class *exprType;
meta->ValidateExpression(&meta->cxt, meta->env, fnExpr);
Arena *oldArena = meta->referenceArena;
meta->referenceArena = new Arena;
try {
// meta->SetupExprNode(meta->env, RunPhase, fnExpr, &exprType);
CompilationData *oldData = meta->startCompilationUnit(fnExpr->function.fWrap->bCon, *bodyStr, srcLoc);
meta->env->addFrame(fnExpr->function.fWrap->compileFrame);
meta->SetupStmt(meta->env, RunPhase, fnExpr->function.body);
fnExpr->function.fWrap->bCon->emitOp(eReturnVoid, meta->engine->errorPos());
meta->env->removeTopFrame();
meta->restoreCompilationUnit(oldData);
}
catch (Exception &x) {
meta->referenceArena->clear();
@@ -113,6 +107,8 @@ namespace MetaData {
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);
if (meta->cxt.E3compatibility)
meta->createDynamicProperty(fnInst, &meta->world.identifiers["arguments"], JS2VAL_NULL, ReadAccess, true, false);
return thatValue;
}
}

View File

@@ -134,7 +134,18 @@ static js2val Math_exp(JS2Metadata *meta, const js2val /*thisValue*/, js2val *ar
{
if (argc == 0)
return meta->engine->nanValue;
return meta->engine->allocNumber(fd::exp(meta->toFloat64(argv[0])));
float64 x = meta->toFloat64(argv[0]);
#ifdef _WIN32
if (!JSDOUBLE_IS_NaN(x)) {
if (x == positiveInfinity) {
return meta->engine->posInfValue;
}
if (x == negativeInfinity) {
return JS2VAL_ZERO;
}
}
#endif
return meta->engine->allocNumber(fd::exp(x));
}
static js2val Math_floor(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
{

View File

@@ -478,8 +478,10 @@ namespace MetaData {
break;
case StmtNode::Return:
{
Frame *regionalFrame = *env->getRegionalFrame();
if (regionalFrame->kind != ParameterFrameKind)
ParameterFrame *pFrame = env->getEnclosingParameterFrame();
// If there isn't a parameter frame, or the parameter frame is
// only a runtime frame (for eval), then it's an orphan return
if ((pFrame->kind != ParameterFrameKind) || pFrame->pluralFrame)
reportError(Exception::syntaxError, "Return statement not in function", p->pos);
ExprStmtNode *e = checked_cast<ExprStmtNode *>(p);
if (e->expr) {
@@ -3875,7 +3877,8 @@ bool nullClass_BracketDelete(JS2Metadata *meta, js2val base, JS2Class *limit, js
// A 'forbidden' member, used to mark hidden bindings
forbiddenMember = new LocalMember(Member::ForbiddenMember, true);
FunctionInstance *fInst;
Variable *v;
// XXX Built-in Attributes... XXX
@@ -3908,6 +3911,8 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
env->addFrame(objectClass);
v = new Variable(objectClass, OBJECT_TO_JS2VAL(objectClass->prototype), true);
defineLocalMember(env, engine->prototype_StringAtom, NULL, Attribute::NoOverride, false, ReadWriteAccess, v, 0, false);
v = new Variable(objectClass, INT_TO_JS2VAL(1), true);
defineLocalMember(env, engine->length_StringAtom, NULL, Attribute::NoOverride, false, ReadWriteAccess, v, 0, false);
env->removeTopFrame();
/*** ECMA 3 Function Class ***/
@@ -3930,7 +3935,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
// Add __proto__ as a getter/setter instance member to Object & class
Multiname mn(&world.identifiers["__proto__"], publicNamespace);
FunctionInstance *fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), class_underbarProtoGet, env);
fInst->fWrap->length = 0;
InstanceGetter *g = new InstanceGetter(&mn, fInst, objectClass, true, true);
@@ -3965,6 +3970,13 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
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);
// and 'constructor'
fInst = new FunctionInstance(this, functionClass->prototype, functionClass);
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_INACCESSIBLE, true), Object_Constructor, env);
fInst->fWrap->length = 0;
createDynamicProperty(JS2VAL_TO_OBJECT(objectClass->prototype), &world.identifiers["constructor"], OBJECT_TO_JS2VAL(fInst), ReadWriteAccess, false, false);
createDynamicProperty(fInst, engine->length_StringAtom, INT_TO_JS2VAL(1), ReadAccess, true, false);
/*** ECMA 4 Integer Class ***/
v = new Variable(classClass, OBJECT_TO_JS2VAL(integerClass), true);
@@ -4928,8 +4940,8 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
FunctionInstance::~FunctionInstance()
{
// if (fWrap)
// delete fWrap;
if (fWrap)
delete fWrap;
}
/************************************************************************************

View File

@@ -137,7 +137,7 @@
push(a);
}
else {
if (length || fInst->isMethodClosure) {
if (length || fInst->isMethodClosure || fWrap->compileFrame->buildArguments) {
pFrame = new ParameterFrame(fWrap->compileFrame);
pFrame->instantiate(meta->env);
pFrame->thisObject = a;
@@ -155,7 +155,10 @@
// XXX constructing a parameterFrame only for the purpose of holding the 'this'
// need to find a more efficient way of stashing 'this'
// used to be : "meta->env->addFrame(fWrap->compileFrame->prototype);"
meta->env->addFrame(new ParameterFrame(a, fWrap->compileFrame->prototype));
// Still need to mark the frame as a runtime frame (see stmtnode::return in validate)
pFrame = new ParameterFrame(a, fWrap->compileFrame->prototype);
pFrame->pluralFrame = fWrap->compileFrame;
meta->env->addFrame(pFrame);
}
}
}