Fix continue statements within for-in loops.

R=titzer@chromium.org
TEST=cctest/test-run-jsbranches/ForInContinueStatement
BUG=v8:3522
LOG=N

Review URL: https://codereview.chromium.org/502043002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23369 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ab57ca86
......@@ -744,13 +744,13 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
// Bind value and do loop body.
VisitForInAssignment(stmt->each(), value);
VisitIterationBody(stmt, &for_loop, 5);
for_loop.EndBody();
// Inc counter and continue.
Node* index_inc =
NewNode(javascript()->Add(), index, jsgraph()->OneConstant());
// TODO(jarin): provide real bailout id.
PrepareFrameState(index_inc, BailoutId::None());
environment()->Poke(0, index_inc);
for_loop.EndBody();
for_loop.EndLoop();
environment()->Drop(5);
// PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
......
......@@ -148,6 +148,26 @@ TEST(ForInStatement) {
}
TEST(ForInContinueStatement) {
const char* src =
"(function(a,b) {"
" var r = '-';"
" for (var x in a) {"
" r += 'A-';"
" if (b) continue;"
" r += 'B-';"
" }"
" return r;"
"})";
FunctionTester T(src);
T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value());
T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value());
T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value());
T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value());
}
TEST(SwitchStatement) {
const char* src =
"(function(a,b) {"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment