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

Side by Side Diff: runtime/vm/class_finalizer.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/bin/builtin.dart ('k') | runtime/vm/parser.cc » ('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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1263
1264 1264
1265 void ClassFinalizer::FinalizeMalformedType(const Error& prev_error, 1265 void ClassFinalizer::FinalizeMalformedType(const Error& prev_error,
1266 const Class& cls, 1266 const Class& cls,
1267 const Type& type, 1267 const Type& type,
1268 FinalizationKind finalization, 1268 FinalizationKind finalization,
1269 const char* format, ...) { 1269 const char* format, ...) {
1270 va_list args; 1270 va_list args;
1271 va_start(args, format); 1271 va_start(args, format);
1272 LanguageError& error = LanguageError::Handle(); 1272 LanguageError& error = LanguageError::Handle();
1273 if ((finalization == kFinalizeWellFormed) || FLAG_enable_type_checks) { 1273 if (FLAG_enable_type_checks ||
1274 !type.HasResolvedTypeClass() ||
1275 (finalization == kFinalizeWellFormed)) {
1274 const Script& script = Script::Handle(cls.script()); 1276 const Script& script = Script::Handle(cls.script());
1275 if (prev_error.IsNull()) { 1277 if (prev_error.IsNull()) {
1276 error ^= Parser::FormatError( 1278 error ^= Parser::FormatError(
1277 script, type.token_index(), "Error", format, args); 1279 script, type.token_index(), "Error", format, args);
1278 } else { 1280 } else {
1279 error ^= Parser::FormatErrorWithAppend( 1281 error ^= Parser::FormatErrorWithAppend(
1280 prev_error, script, type.token_index(), "Error", format, args); 1282 prev_error, script, type.token_index(), "Error", format, args);
1281 } 1283 }
1282 if (finalization == kFinalizeWellFormed) { 1284 if (finalization == kFinalizeWellFormed) {
1283 ReportError(error); 1285 ReportError(error);
1284 } 1286 }
1285 } 1287 }
1286 if (FLAG_enable_type_checks) { 1288 if (FLAG_enable_type_checks || !type.HasResolvedTypeClass()) {
1287 // In checked mode, mark type as malformed. 1289 // In check mode, always mark the type as malformed.
1290 // In production mode, mark the type as malformed only if its type class is
1291 // not resolved.
1288 type.set_malformed_error(error); 1292 type.set_malformed_error(error);
1289 } else { 1293 } else {
1290 // In production mode, replace malformed type with Dynamic type. 1294 // In production mode, do not mark the type with a resolved type class as
1291 type.set_type_class(Class::Handle(Object::dynamic_class())); 1295 // malformed, but make it raw.
1296 ASSERT(type.HasResolvedTypeClass());
1292 type.set_arguments(AbstractTypeArguments::Handle()); 1297 type.set_arguments(AbstractTypeArguments::Handle());
1293 } 1298 }
1294 if (!type.IsFinalized()) { 1299 if (!type.IsFinalized()) {
1295 type.set_is_finalized(); 1300 type.set_is_finalized();
1296 // Do not canonicalize malformed types, since they may not be resolved. 1301 // Do not canonicalize malformed types, since they may not be resolved.
1297 } else { 1302 } else {
1298 // The only case where the malformed type was already finalized is when its 1303 // The only case where the malformed type was already finalized is when its
1299 // type arguments are not within bounds. In that case, we have a prev_error. 1304 // type arguments are not within bounds. In that case, we have a prev_error.
1300 ASSERT(!prev_error.IsNull()); 1305 ASSERT(!prev_error.IsNull());
1301 } 1306 }
(...skipping 20 matching lines...) Expand all
1322 void ClassFinalizer::ReportError(const char* format, ...) { 1327 void ClassFinalizer::ReportError(const char* format, ...) {
1323 va_list args; 1328 va_list args;
1324 va_start(args, format); 1329 va_start(args, format);
1325 const Error& error = Error::Handle( 1330 const Error& error = Error::Handle(
1326 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1331 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1327 va_end(args); 1332 va_end(args);
1328 ReportError(error); 1333 ReportError(error);
1329 } 1334 }
1330 1335
1331 } // namespace dart 1336 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/builtin.dart ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698