Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: src/parser.cc

Issue 1309303006: Propagate switch statement value for 'eval' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix AST tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-ast-expression-visitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 3f635c70df275ea837606aa81354f6daea36a882..048216ca7a323a69185a66f252b837a34fe8a6c0 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2990,7 +2990,7 @@ Statement* Parser::ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
// }
Block* switch_block =
- factory()->NewBlock(NULL, 2, true, RelocInfo::kNoPosition);
+ factory()->NewBlock(NULL, 2, false, RelocInfo::kNoPosition);
int switch_pos = peek_position();
Expect(Token::SWITCH, CHECK_OK);
@@ -3007,8 +3007,17 @@ Statement* Parser::ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
factory()->NewExpressionStatement(tag_assign, RelocInfo::kNoPosition);
switch_block->AddStatement(tag_statement, zone());
+ // make statement: undefined;
+ // This is needed so the tag isn't returned as the value, in case the switch
+ // statements don't have a value.
+ switch_block->AddStatement(
+ factory()->NewExpressionStatement(
+ factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
+ RelocInfo::kNoPosition),
+ zone());
+
Block* cases_block =
- factory()->NewBlock(NULL, 1, true, RelocInfo::kNoPosition);
+ factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition);
Scope* cases_scope = NewScope(scope_, BLOCK_SCOPE);
SwitchStatement* switch_statement =
« no previous file with comments | « no previous file | test/cctest/test-ast-expression-visitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698