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

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

Issue 11099049: Report error in APIs if type is malformed instead of crashing. Example: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | no next file » | 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 "include/dart_api.h" 5 #include "include/dart_api.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/dart.h" 10 #include "vm/dart.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 return false; 283 return false;
284 } 284 }
285 285
286 286
287 // When we want to return a handle to a type to the user, we handle 287 // When we want to return a handle to a type to the user, we handle
288 // class-types differently than some other types. 288 // class-types differently than some other types.
289 static Dart_Handle TypeToHandle(Isolate* isolate, 289 static Dart_Handle TypeToHandle(Isolate* isolate,
290 const char* function_name, 290 const char* function_name,
291 const AbstractType& type) { 291 const AbstractType& type) {
292 if (type.HasResolvedTypeClass()) { 292 if (type.IsMalformed()) {
293 const Error& error = Error::Handle(type.malformed_error());
294 return Api::NewError("%s: malformed type encountered: %s.",
295 function_name, error.ToErrorCString());
296 } else if (type.HasResolvedTypeClass()) {
293 const Class& cls = Class::Handle(isolate, type.type_class()); 297 const Class& cls = Class::Handle(isolate, type.type_class());
294 #if defined(DEBUG) 298 #if defined(DEBUG)
295 const Library& lib = Library::Handle(cls.library()); 299 const Library& lib = Library::Handle(cls.library());
296 if (lib.IsNull()) { 300 if (lib.IsNull()) {
297 ASSERT(cls.IsDynamicClass() || cls.IsVoidClass()); 301 ASSERT(cls.IsDynamicClass() || cls.IsVoidClass());
298 } 302 }
299 #endif 303 #endif
300 return Api::NewHandle(isolate, cls.raw()); 304 return Api::NewHandle(isolate, cls.raw());
301 } else if (type.IsTypeParameter()) { 305 } else if (type.IsTypeParameter()) {
302 return Api::NewHandle(isolate, type.raw()); 306 return Api::NewHandle(isolate, type.raw());
(...skipping 4188 matching lines...) Expand 10 before | Expand all | Expand 10 after
4491 } 4495 }
4492 { 4496 {
4493 NoGCScope no_gc; 4497 NoGCScope no_gc;
4494 RawObject* raw_obj = obj.raw(); 4498 RawObject* raw_obj = obj.raw();
4495 isolate->heap()->SetPeer(raw_obj, peer); 4499 isolate->heap()->SetPeer(raw_obj, peer);
4496 } 4500 }
4497 return Api::Success(isolate); 4501 return Api::Success(isolate);
4498 } 4502 }
4499 4503
4500 } // namespace dart 4504 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698