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

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

Issue 10823396: Implement import scope (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/dart_api_impl_test.cc ('k') | runtime/vm/parser.h » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 5599 matching lines...) Expand 10 before | Expand all | Expand 10 after
5610 // Remember the new dictionary now. 5610 // Remember the new dictionary now.
5611 StorePointer(&raw_ptr()->dictionary_, new_dict.raw()); 5611 StorePointer(&raw_ptr()->dictionary_, new_dict.raw());
5612 } 5612 }
5613 5613
5614 5614
5615 void Library::AddObject(const Object& obj, const String& name) const { 5615 void Library::AddObject(const Object& obj, const String& name) const {
5616 ASSERT(obj.IsClass() || 5616 ASSERT(obj.IsClass() ||
5617 obj.IsFunction() || 5617 obj.IsFunction() ||
5618 obj.IsField() || 5618 obj.IsField() ||
5619 obj.IsLibraryPrefix()); 5619 obj.IsLibraryPrefix());
5620 ASSERT((LookupObject(name) == Object::null()) || 5620 ASSERT((LookupLocalObject(name) == Object::null()) ||
5621 ((obj.IsLibraryPrefix() || 5621 ((obj.IsLibraryPrefix() ||
5622 (obj.IsClass() && 5622 (obj.IsClass() &&
5623 Class::CheckedHandle(obj.raw()).IsCanonicalSignatureClass())) && 5623 Class::CheckedHandle(obj.raw()).IsCanonicalSignatureClass())) &&
5624 (LookupLocalObject(name) == Object::null()))); 5624 (LookupLocalObject(name) == Object::null())));
5625 const Array& dict = Array::Handle(dictionary()); 5625 const Array& dict = Array::Handle(dictionary());
5626 intptr_t dict_size = dict.Length() - 1; 5626 intptr_t dict_size = dict.Length() - 1;
5627 intptr_t index = name.Hash() % dict_size; 5627 intptr_t index = name.Hash() % dict_size;
5628 5628
5629 Object& entry = Object::Handle(); 5629 Object& entry = Object::Handle();
5630 entry = dict.At(index); 5630 entry = dict.At(index);
(...skipping 23 matching lines...) Expand all
5654 } 5654 }
5655 5655
5656 5656
5657 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const { 5657 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const {
5658 Isolate* isolate = Isolate::Current(); 5658 Isolate* isolate = Isolate::Current();
5659 const Array& dict = Array::Handle(isolate, dictionary()); 5659 const Array& dict = Array::Handle(isolate, dictionary());
5660 intptr_t dict_size = dict.Length() - 1; 5660 intptr_t dict_size = dict.Length() - 1;
5661 *index = name.Hash() % dict_size; 5661 *index = name.Hash() % dict_size;
5662 5662
5663 Object& entry = Object::Handle(isolate); 5663 Object& entry = Object::Handle(isolate);
5664 Class& cls = Class::Handle(isolate);
5665 Function& func = Function::Handle(isolate);
5666 Field& field = Field::Handle(isolate);
5667 LibraryPrefix& library_prefix = LibraryPrefix::Handle(isolate);
5668 String& entry_name = String::Handle(isolate); 5664 String& entry_name = String::Handle(isolate);
5669 entry = dict.At(*index); 5665 entry = dict.At(*index);
5670 // Search the entry in the hash set. 5666 // Search the entry in the hash set.
5671 while (!entry.IsNull()) { 5667 while (!entry.IsNull()) {
5672 // TODO(hausner): find a better way to handle this polymorphism.
5673 // Either introduce a common base class for Class, Function, Field
5674 // and LibraryPrefix or make the name() function virtual in Object.
5675 if (entry.IsClass()) { 5668 if (entry.IsClass()) {
5676 cls ^= entry.raw(); 5669 entry_name = Class::Cast(entry).Name();
5677 entry_name = cls.Name();
5678 } else if (entry.IsFunction()) { 5670 } else if (entry.IsFunction()) {
5679 func ^= entry.raw(); 5671 entry_name = Function::Cast(entry).name();
5680 entry_name = func.name();
5681 } else if (entry.IsField()) { 5672 } else if (entry.IsField()) {
5682 field ^= entry.raw(); 5673 entry_name = Field::Cast(entry).name();
5683 entry_name = field.name();
5684 } else if (entry.IsLibraryPrefix()) { 5674 } else if (entry.IsLibraryPrefix()) {
5685 library_prefix ^= entry.raw(); 5675 entry_name = LibraryPrefix::Cast(entry).name();
5686 entry_name = library_prefix.name();
5687 } else { 5676 } else {
5688 UNREACHABLE(); 5677 UNREACHABLE();
5689 } 5678 }
5690 if (entry_name.Equals(name)) { 5679 if (entry_name.Equals(name)) {
5691 return entry.raw(); 5680 return entry.raw();
5692 } 5681 }
5693 *index = (*index + 1) % dict_size; 5682 *index = (*index + 1) % dict_size;
5694 entry = dict.At(*index); 5683 entry = dict.At(*index);
5695 } 5684 }
5696 return Object::null(); 5685 return Object::null();
(...skipping 5645 matching lines...) Expand 10 before | Expand all | Expand 10 after
11342 } 11331 }
11343 return result.raw(); 11332 return result.raw();
11344 } 11333 }
11345 11334
11346 11335
11347 const char* WeakProperty::ToCString() const { 11336 const char* WeakProperty::ToCString() const {
11348 return "WeakProperty"; 11337 return "WeakProperty";
11349 } 11338 }
11350 11339
11351 } // namespace dart 11340 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698