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

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

Issue 10035058: Throw a type error in production mode when the type of the type test is not (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/co19/co19-runtime.status » ('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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 3148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3159 Error* malformed_error, 3159 Error* malformed_error,
3160 ClassFinalizer::FinalizationKind finalization) { 3160 ClassFinalizer::FinalizationKind finalization) {
3161 TRACE_PARSER("ParseTypeArguments"); 3161 TRACE_PARSER("ParseTypeArguments");
3162 if (CurrentToken() == Token::kLT) { 3162 if (CurrentToken() == Token::kLT) {
3163 const GrowableObjectArray& types = 3163 const GrowableObjectArray& types =
3164 GrowableObjectArray::Handle(GrowableObjectArray::New()); 3164 GrowableObjectArray::Handle(GrowableObjectArray::New());
3165 AbstractType& type = AbstractType::Handle(); 3165 AbstractType& type = AbstractType::Handle();
3166 do { 3166 do {
3167 ConsumeToken(); 3167 ConsumeToken();
3168 type = ParseType(finalization); 3168 type = ParseType(finalization);
3169 types.Add(type);
3170 // Only keep the error for the first malformed type argument. 3169 // Only keep the error for the first malformed type argument.
3171 if (malformed_error->IsNull() && type.IsMalformed()) { 3170 if (malformed_error->IsNull() && type.IsMalformed()) {
3172 *malformed_error = type.malformed_error(); 3171 *malformed_error = type.malformed_error();
3173 } 3172 }
3173 // Map a malformed type argument to Dynamic, so that malformed types with
3174 // a resolved type class are handled properly in production mode.
3175 if (type.IsMalformed()) {
3176 type = Type::DynamicType();
3177 }
3178 types.Add(type);
3174 } while (CurrentToken() == Token::kCOMMA); 3179 } while (CurrentToken() == Token::kCOMMA);
3175 Token::Kind token = CurrentToken(); 3180 Token::Kind token = CurrentToken();
3176 if ((token == Token::kGT) || (token == Token::kSHR)) { 3181 if ((token == Token::kGT) || (token == Token::kSHR)) {
3177 ConsumeRightAngleBracket(); 3182 ConsumeRightAngleBracket();
3178 } else { 3183 } else {
3179 ErrorMsg("right angle bracket expected"); 3184 ErrorMsg("right angle bracket expected");
3180 } 3185 }
3181 if (finalization != ClassFinalizer::kIgnore) { 3186 if (finalization != ClassFinalizer::kIgnore) {
3182 return NewTypeArguments(types); 3187 return NewTypeArguments(types);
3183 } 3188 }
(...skipping 4026 matching lines...) Expand 10 before | Expand all | Expand 10 after
7210 } 7215 }
7211 Error& malformed_error = Error::Handle(); 7216 Error& malformed_error = Error::Handle();
7212 AbstractTypeArguments& type_arguments = 7217 AbstractTypeArguments& type_arguments =
7213 AbstractTypeArguments::Handle(ParseTypeArguments(&malformed_error, 7218 AbstractTypeArguments::Handle(ParseTypeArguments(&malformed_error,
7214 finalization)); 7219 finalization));
7215 if (finalization == ClassFinalizer::kIgnore) { 7220 if (finalization == ClassFinalizer::kIgnore) {
7216 return Type::DynamicType(); 7221 return Type::DynamicType();
7217 } 7222 }
7218 AbstractType& type = AbstractType::Handle( 7223 AbstractType& type = AbstractType::Handle(
7219 Type::New(type_class, type_arguments, type_name.ident_pos)); 7224 Type::New(type_class, type_arguments, type_name.ident_pos));
7220 if (!malformed_error.IsNull()) { 7225 // In production mode, malformed type arguments are mapped to Dynamic.
7226 // In checked mode, a type with malformed type arguments is malformed.
7227 if (FLAG_enable_type_checks && !malformed_error.IsNull()) {
7221 Type& parameterized_type = Type::Handle(); 7228 Type& parameterized_type = Type::Handle();
7222 parameterized_type ^= type.raw(); 7229 parameterized_type ^= type.raw();
7223 parameterized_type.set_type_class(Class::Handle(Object::dynamic_class())); 7230 parameterized_type.set_type_class(Class::Handle(Object::dynamic_class()));
7224 parameterized_type.set_arguments(AbstractTypeArguments::Handle()); 7231 parameterized_type.set_arguments(AbstractTypeArguments::Handle());
7225 parameterized_type.set_malformed_error(malformed_error); 7232 parameterized_type.set_malformed_error(malformed_error);
7226 } 7233 }
7227 if (finalization >= ClassFinalizer::kTryResolve) { 7234 if (finalization >= ClassFinalizer::kTryResolve) {
7228 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); 7235 const Class& scope_class = Class::Handle(TypeParametersScopeClass());
7229 ResolveTypeFromClass(scope_class, finalization, &type); 7236 ResolveTypeFromClass(scope_class, finalization, &type);
7230 if (finalization >= ClassFinalizer::kFinalize) { 7237 if (finalization >= ClassFinalizer::kFinalize) {
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
8404 void Parser::SkipQualIdent() { 8411 void Parser::SkipQualIdent() {
8405 ASSERT(IsIdentifier()); 8412 ASSERT(IsIdentifier());
8406 ConsumeToken(); 8413 ConsumeToken();
8407 if (CurrentToken() == Token::kPERIOD) { 8414 if (CurrentToken() == Token::kPERIOD) {
8408 ConsumeToken(); // Consume the kPERIOD token. 8415 ConsumeToken(); // Consume the kPERIOD token.
8409 ExpectIdentifier("identifier expected after '.'"); 8416 ExpectIdentifier("identifier expected after '.'");
8410 } 8417 }
8411 } 8418 }
8412 8419
8413 } // namespace dart 8420 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698