'With' statement fixes.
git-svn-id: svn://10.0.0.236/trunk@138552 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a3f633551a
commit
2dc237657b
@ -503,6 +503,8 @@ namespace MetaData {
|
||||
{ eReturnVoid, "ReturnVoid", 0 },
|
||||
{ ePushFrame, "PushFrame", FRAME_INDEX }, // <frame index:u16>
|
||||
{ ePopFrame, "PopFrame", 0 },
|
||||
{ eWithin, "With", 0 },
|
||||
{ eWithout, "EndWith", 0 },
|
||||
{ eBranchFalse, "BranchFalse", BRANCH_OFFSET }, // <branch displacement:s32> XXX save space with short and long versions instead ?
|
||||
{ eBranchTrue, "BranchTrue", BRANCH_OFFSET }, // <branch displacement:s32>
|
||||
{ eBranch, "Branch", BRANCH_OFFSET }, // <branch displacement:s32>
|
||||
@ -746,6 +748,11 @@ namespace MetaData {
|
||||
case ePopFrame: // ...not the exec stack
|
||||
return 0;
|
||||
|
||||
case eWithin:
|
||||
return -1; // pop with'd object
|
||||
case eWithout:
|
||||
return 0; // frame stack pop only
|
||||
|
||||
case eBranchFalse:
|
||||
case eBranchTrue:
|
||||
return -1; // pop the boolean condition
|
||||
|
||||
@ -124,6 +124,8 @@ enum JS2Op {
|
||||
eReturnVoid,
|
||||
ePushFrame, // <frame index:u16>
|
||||
ePopFrame,
|
||||
eWithin,
|
||||
eWithout,
|
||||
eBranchFalse, // <branch displacement:s32> XXX save space with short and long versions instead ?
|
||||
eBranchTrue, // <branch displacement:s32>
|
||||
eBranch, // <branch displacement:s32>
|
||||
|
||||
@ -105,9 +105,8 @@ namespace MetaData {
|
||||
|
||||
JS2Object::RootIterator ri = JS2Object::addRoot(&result);
|
||||
Frame *curTopFrame = env->getTopFrame();
|
||||
|
||||
CompilationData *oldData = startCompilationUnit(fnDef->fWrap->bCon, bCon->mSource, bCon->mSourceLocation);
|
||||
try {
|
||||
CompilationData *oldData = startCompilationUnit(fnDef->fWrap->bCon, bCon->mSource, bCon->mSourceLocation);
|
||||
env->addFrame(compileFrame);
|
||||
VariableBinding *pb = fnDef->parameters;
|
||||
if (pb) {
|
||||
@ -134,13 +133,14 @@ namespace MetaData {
|
||||
}
|
||||
ValidateStmt(cxt, env, Plural, fnDef->body);
|
||||
env->removeTopFrame();
|
||||
restoreCompilationUnit(oldData);
|
||||
}
|
||||
catch (Exception x) {
|
||||
restoreCompilationUnit(oldData);
|
||||
env->setTopFrame(curTopFrame);
|
||||
JS2Object::removeRoot(ri);
|
||||
throw x;
|
||||
}
|
||||
restoreCompilationUnit(oldData);
|
||||
JS2Object::removeRoot(ri);
|
||||
return result;
|
||||
}
|
||||
@ -635,8 +635,17 @@ namespace MetaData {
|
||||
c->complete = true;
|
||||
}
|
||||
break;
|
||||
case StmtNode::With:
|
||||
{
|
||||
UnaryStmtNode *w = checked_cast<UnaryStmtNode *>(p);
|
||||
ValidateExpression(cxt, env, w->expr);
|
||||
ValidateStmt(cxt, env, pl, w->stmt);
|
||||
}
|
||||
break;
|
||||
case StmtNode::empty:
|
||||
break;
|
||||
default:
|
||||
NOT_REACHED("Not Yet Implemented");
|
||||
} // switch (p->getKind())
|
||||
}
|
||||
catch (Exception x) {
|
||||
@ -1228,6 +1237,16 @@ namespace MetaData {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StmtNode::With:
|
||||
{
|
||||
UnaryStmtNode *w = checked_cast<UnaryStmtNode *>(p);
|
||||
Reference *r = SetupExprNode(env, phase, w->expr, &exprType);
|
||||
if (r) r->emitReadBytecode(bCon, p->pos);
|
||||
bCon->emitOp(eWithin, p->pos);
|
||||
SetupStmt(env, phase, w->stmt);
|
||||
bCon->emitOp(eWithout, p->pos);
|
||||
}
|
||||
break;
|
||||
case StmtNode::empty:
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -105,6 +105,7 @@ enum ObjectKind {
|
||||
MethodClosureKind,
|
||||
AlienInstanceKind,
|
||||
ForIteratorKind,
|
||||
WithFrameKind,
|
||||
|
||||
EnvironmentKind, // Not an available JS2 runtime kind
|
||||
MetaDataKind
|
||||
@ -488,6 +489,15 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class WithFrame : public Frame {
|
||||
public:
|
||||
WithFrame(JS2Object *b) : Frame(WithFrameKind), obj(b) { }
|
||||
virtual ~WithFrame() { }
|
||||
|
||||
virtual void markChildren() { GCMARKOBJECT(obj); }
|
||||
|
||||
JS2Object *obj;
|
||||
};
|
||||
|
||||
class JS2Class : public Frame {
|
||||
public:
|
||||
|
||||
@ -236,7 +236,16 @@
|
||||
}
|
||||
break;
|
||||
|
||||
case eWithin:
|
||||
{
|
||||
a = pop();
|
||||
a = meta->toObject(a);
|
||||
meta->env->addFrame(new WithFrame(JS2VAL_TO_OBJECT(a)));
|
||||
}
|
||||
break;
|
||||
|
||||
case ePopFrame:
|
||||
case eWithout:
|
||||
{
|
||||
meta->env->removeTopFrame();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user