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

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

Issue 183743015: Fix type checks with malformed types (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/is_malformed_type_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 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 7592 matching lines...) Expand 10 before | Expand all | Expand 10 after
7603 CaptureInstantiator(); 7603 CaptureInstantiator();
7604 } 7604 }
7605 right_operand = new TypeNode(type_pos, type); 7605 right_operand = new TypeNode(type_pos, type);
7606 // In production mode, the type may be malformed. 7606 // In production mode, the type may be malformed.
7607 // In checked mode, the type may be malformed or malbounded. 7607 // In checked mode, the type may be malformed or malbounded.
7608 if (((op_kind == Token::kIS) || (op_kind == Token::kISNOT) || 7608 if (((op_kind == Token::kIS) || (op_kind == Token::kISNOT) ||
7609 (op_kind == Token::kAS)) && 7609 (op_kind == Token::kAS)) &&
7610 type.IsMalformedOrMalbounded()) { 7610 type.IsMalformedOrMalbounded()) {
7611 // Note that a type error is thrown even if the tested value is null 7611 // Note that a type error is thrown even if the tested value is null
7612 // in a type test or in a type cast. 7612 // in a type test or in a type cast.
7613 return ThrowTypeError(type_pos, type); 7613 // TODO(hausner): We drop the left operand. We need to
7614 // evaluate it in case there are side effects.
7615 left_operand = ThrowTypeError(type_pos, type);
Florian Schneider 2014/03/04 09:48:24 I think you can use LetNode as a light-weight sequ
7616 break; // Type checks and casts can't be chained.
7614 } 7617 }
7615 } 7618 }
7616 if (Token::IsRelationalOperator(op_kind) 7619 if (Token::IsRelationalOperator(op_kind)
7617 || Token::IsTypeTestOperator(op_kind) 7620 || Token::IsTypeTestOperator(op_kind)
7618 || Token::IsTypeCastOperator(op_kind) 7621 || Token::IsTypeCastOperator(op_kind)
7619 || Token::IsEqualityOperator(op_kind)) { 7622 || Token::IsEqualityOperator(op_kind)) {
7620 if (Token::IsTypeTestOperator(op_kind) || 7623 if (Token::IsTypeTestOperator(op_kind) ||
7621 Token::IsTypeCastOperator(op_kind)) { 7624 Token::IsTypeCastOperator(op_kind)) {
7622 if (!right_operand->AsTypeNode()->type().IsInstantiated()) { 7625 if (!right_operand->AsTypeNode()->type().IsInstantiated()) {
7623 EnsureExpressionTemp(); 7626 EnsureExpressionTemp();
(...skipping 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after
10786 void Parser::SkipQualIdent() { 10789 void Parser::SkipQualIdent() {
10787 ASSERT(IsIdentifier()); 10790 ASSERT(IsIdentifier());
10788 ConsumeToken(); 10791 ConsumeToken();
10789 if (CurrentToken() == Token::kPERIOD) { 10792 if (CurrentToken() == Token::kPERIOD) {
10790 ConsumeToken(); // Consume the kPERIOD token. 10793 ConsumeToken(); // Consume the kPERIOD token.
10791 ExpectIdentifier("identifier expected after '.'"); 10794 ExpectIdentifier("identifier expected after '.'");
10792 } 10795 }
10793 } 10796 }
10794 10797
10795 } // namespace dart 10798 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/is_malformed_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698