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

Side by Side Diff: runtime/vm/parser.cc

Issue 2825843003: Fix VM crash when encountering an assignment expression in a case expression. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/language/case_expression_with_assignment_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 11454 matching lines...) Expand 10 before | Expand all | Expand 10 after
11465 expr = LiteralIfStaticConst(Z, expr); 11465 expr = LiteralIfStaticConst(Z, expr);
11466 } 11466 }
11467 return expr; 11467 return expr;
11468 } 11468 }
11469 // Assignment expressions. 11469 // Assignment expressions.
11470 if (!IsLegalAssignableSyntax(expr, TokenPos())) { 11470 if (!IsLegalAssignableSyntax(expr, TokenPos())) {
11471 ReportError(expr_pos, "expression is not assignable"); 11471 ReportError(expr_pos, "expression is not assignable");
11472 } 11472 }
11473 const Token::Kind assignment_op = CurrentToken(); 11473 const Token::Kind assignment_op = CurrentToken();
11474 const TokenPosition assignment_pos = TokenPos(); 11474 const TokenPosition assignment_pos = TokenPos();
11475 ConsumeToken(); 11475 if (require_compiletime_const) {
11476 const TokenPosition right_expr_pos = TokenPos(); 11476 ReportError(assignment_pos,
11477 if (require_compiletime_const && (assignment_op != Token::kASSIGN)) {
11478 ReportError(right_expr_pos,
11479 "expression is not a valid compile-time constant"); 11477 "expression is not a valid compile-time constant");
11480 } 11478 }
11479 ConsumeToken();
11481 AstNode* right_expr = ParseExpr(require_compiletime_const, consume_cascades); 11480 AstNode* right_expr = ParseExpr(require_compiletime_const, consume_cascades);
11482 if (assignment_op != Token::kASSIGN) { 11481 if (assignment_op != Token::kASSIGN) {
11483 // Compound assignment: store inputs with side effects into temp. locals. 11482 // Compound assignment: store inputs with side effects into temp. locals.
11484 LetNode* let_expr = PrepareCompoundAssignmentNodes(&expr); 11483 LetNode* let_expr = PrepareCompoundAssignmentNodes(&expr);
11485 AstNode* assigned_value = 11484 AstNode* assigned_value =
11486 ExpandAssignableOp(assignment_pos, assignment_op, expr, right_expr); 11485 ExpandAssignableOp(assignment_pos, assignment_op, expr, right_expr);
11487 AstNode* assign_expr = 11486 AstNode* assign_expr =
11488 CreateAssignmentNode(expr, assigned_value, expr_ident, expr_pos, true); 11487 CreateAssignmentNode(expr, assigned_value, expr_ident, expr_pos, true);
11489 ASSERT(assign_expr != NULL); 11488 ASSERT(assign_expr != NULL);
11490 let_expr->AddNode(assign_expr); 11489 let_expr->AddNode(assign_expr);
(...skipping 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after
15163 const ArgumentListNode& function_args, 15162 const ArgumentListNode& function_args,
15164 const LocalVariable* temp_for_last_arg, 15163 const LocalVariable* temp_for_last_arg,
15165 bool is_super_invocation) { 15164 bool is_super_invocation) {
15166 UNREACHABLE(); 15165 UNREACHABLE();
15167 return NULL; 15166 return NULL;
15168 } 15167 }
15169 15168
15170 } // namespace dart 15169 } // namespace dart
15171 15170
15172 #endif // DART_PRECOMPILED_RUNTIME 15171 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | tests/language/case_expression_with_assignment_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698