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

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

Issue 23484020: Update handling of ambiguous name references (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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/debugger.cc ('k') | runtime/vm/find_code_object_test.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/exceptions.h" 5 #include "vm/exceptions.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 static RawField* LookupStacktraceField(const Instance& instance) { 316 static RawField* LookupStacktraceField(const Instance& instance) {
317 if (instance.GetClassId() < kNumPredefinedCids) { 317 if (instance.GetClassId() < kNumPredefinedCids) {
318 // 'class Error' is not a predefined class. 318 // 'class Error' is not a predefined class.
319 return Field::null(); 319 return Field::null();
320 } 320 }
321 Isolate* isolate = Isolate::Current(); 321 Isolate* isolate = Isolate::Current();
322 Class& error_class = Class::Handle(isolate, 322 Class& error_class = Class::Handle(isolate,
323 isolate->object_store()->error_class()); 323 isolate->object_store()->error_class());
324 if (error_class.IsNull()) { 324 if (error_class.IsNull()) {
325 const Library& core_lib = Library::Handle(isolate, Library::CoreLibrary()); 325 const Library& core_lib = Library::Handle(isolate, Library::CoreLibrary());
326 error_class = core_lib.LookupClass(Symbols::Error(), NULL); 326 error_class = core_lib.LookupClass(Symbols::Error());
327 ASSERT(!error_class.IsNull()); 327 ASSERT(!error_class.IsNull());
328 isolate->object_store()->set_error_class(error_class); 328 isolate->object_store()->set_error_class(error_class);
329 } 329 }
330 // If instance class extends 'class Error' return '_stackTrace' field. 330 // If instance class extends 'class Error' return '_stackTrace' field.
331 Class& test_class = Class::Handle(isolate, instance.clazz()); 331 Class& test_class = Class::Handle(isolate, instance.clazz());
332 AbstractType& type = AbstractType::Handle(isolate, AbstractType::null()); 332 AbstractType& type = AbstractType::Handle(isolate, AbstractType::null());
333 while (true) { 333 while (true) {
334 if (test_class.raw() == error_class.raw()) { 334 if (test_class.raw() == error_class.raw()) {
335 return error_class.LookupInstanceField(Symbols::_stackTrace()); 335 return error_class.LookupInstanceField(Symbols::_stackTrace());
336 } 336 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 476 }
477 477
478 478
479 // Allocate a new instance of the given class name. 479 // Allocate a new instance of the given class name.
480 // TODO(hausner): Rename this NewCoreInstance to call out the fact that 480 // TODO(hausner): Rename this NewCoreInstance to call out the fact that
481 // the class name is resolved in the core library implicitly? 481 // the class name is resolved in the core library implicitly?
482 RawInstance* Exceptions::NewInstance(const char* class_name) { 482 RawInstance* Exceptions::NewInstance(const char* class_name) {
483 const String& cls_name = String::Handle(Symbols::New(class_name)); 483 const String& cls_name = String::Handle(Symbols::New(class_name));
484 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 484 const Library& core_lib = Library::Handle(Library::CoreLibrary());
485 // No ambiguity error expected: passing NULL. 485 // No ambiguity error expected: passing NULL.
486 Class& cls = Class::Handle(core_lib.LookupClass(cls_name, NULL)); 486 Class& cls = Class::Handle(core_lib.LookupClass(cls_name));
487 ASSERT(!cls.IsNull()); 487 ASSERT(!cls.IsNull());
488 // There are no parameterized error types, so no need to set type arguments. 488 // There are no parameterized error types, so no need to set type arguments.
489 return Instance::New(cls); 489 return Instance::New(cls);
490 } 490 }
491 491
492 492
493 // Allocate, initialize, and throw a TypeError or CastError. 493 // Allocate, initialize, and throw a TypeError or CastError.
494 void Exceptions::CreateAndThrowTypeError(intptr_t location, 494 void Exceptions::CreateAndThrowTypeError(intptr_t location,
495 const String& src_type_name, 495 const String& src_type_name,
496 const String& dst_type_name, 496 const String& dst_type_name,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 break; 695 break;
696 } 696 }
697 697
698 return DartLibraryCalls::InstanceCreate(library, 698 return DartLibraryCalls::InstanceCreate(library,
699 *class_name, 699 *class_name,
700 *constructor_name, 700 *constructor_name,
701 arguments); 701 arguments);
702 } 702 }
703 703
704 } // namespace dart 704 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/find_code_object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698