| OLD | NEW |
| 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 5767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5778 return obj.raw(); | 5778 return obj.raw(); |
| 5779 } | 5779 } |
| 5780 } | 5780 } |
| 5781 return Object::null(); | 5781 return Object::null(); |
| 5782 } | 5782 } |
| 5783 | 5783 |
| 5784 | 5784 |
| 5785 RawClass* Library::LookupClass(const String& name) const { | 5785 RawClass* Library::LookupClass(const String& name) const { |
| 5786 Object& obj = Object::Handle(LookupObject(name)); | 5786 Object& obj = Object::Handle(LookupObject(name)); |
| 5787 if (!obj.IsNull() && obj.IsClass()) { | 5787 if (!obj.IsNull() && obj.IsClass()) { |
| 5788 return Class::CheckedHandle(obj.raw()).raw(); | 5788 return Class::Cast(obj).raw(); |
| 5789 } | 5789 } |
| 5790 return Class::null(); | 5790 return Class::null(); |
| 5791 } | 5791 } |
| 5792 | 5792 |
| 5793 | 5793 |
| 5794 RawClass* Library::LookupLocalClass(const String& name) const { | 5794 RawClass* Library::LookupLocalClass(const String& name) const { |
| 5795 Object& obj = Object::Handle(LookupLocalObject(name)); | 5795 Object& obj = Object::Handle(LookupLocalObject(name)); |
| 5796 if (!obj.IsNull() && obj.IsClass()) { | 5796 if (!obj.IsNull() && obj.IsClass()) { |
| 5797 return Class::CheckedHandle(obj.raw()).raw(); | 5797 return Class::Cast(obj).raw(); |
| 5798 } | 5798 } |
| 5799 return Class::null(); | 5799 return Class::null(); |
| 5800 } | 5800 } |
| 5801 | 5801 |
| 5802 | 5802 |
| 5803 RawClass* Library::LookupClassAllowPrivate(const String& name) const { | 5803 RawClass* Library::LookupClassAllowPrivate(const String& name) const { |
| 5804 // See if the class is available in this library or in the top level | 5804 // See if the class is available in this library or in the top level |
| 5805 // scope of any imported library. | 5805 // scope of any imported library. |
| 5806 Isolate* isolate = Isolate::Current(); | 5806 Isolate* isolate = Isolate::Current(); |
| 5807 const Class& cls = Class::Handle(isolate, LookupClass(name)); | 5807 const Class& cls = Class::Handle(isolate, LookupClass(name)); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6239 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 6239 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; |
| 6240 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6240 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6241 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 6241 OS::SNPrint(chars, len, kFormat, name.ToCString()); |
| 6242 return chars; | 6242 return chars; |
| 6243 } | 6243 } |
| 6244 | 6244 |
| 6245 | 6245 |
| 6246 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 6246 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
| 6247 if ((index >= 0) || (index < num_imports())) { | 6247 if ((index >= 0) || (index < num_imports())) { |
| 6248 const Array& imports = Array::Handle(this->imports()); | 6248 const Array& imports = Array::Handle(this->imports()); |
| 6249 const Namespace& import = Namespace::CheckedHandle(imports.At(index)); | 6249 Namespace& import = Namespace::Handle(); |
| 6250 import ^= imports.At(index); |
| 6250 return import.library(); | 6251 return import.library(); |
| 6251 } | 6252 } |
| 6252 return Library::null(); | 6253 return Library::null(); |
| 6253 } | 6254 } |
| 6254 | 6255 |
| 6255 | 6256 |
| 6256 bool LibraryPrefix::ContainsLibrary(const Library& library) const { | 6257 bool LibraryPrefix::ContainsLibrary(const Library& library) const { |
| 6257 intptr_t num_current_imports = num_imports(); | 6258 intptr_t num_current_imports = num_imports(); |
| 6258 if (num_current_imports > 0) { | 6259 if (num_current_imports > 0) { |
| 6259 Library& lib = Library::Handle(); | 6260 Library& lib = Library::Handle(); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6771 chars[index] = '\0'; | 6772 chars[index] = '\0'; |
| 6772 return chars; | 6773 return chars; |
| 6773 } | 6774 } |
| 6774 } | 6775 } |
| 6775 | 6776 |
| 6776 | 6777 |
| 6777 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { | 6778 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { |
| 6778 ASSERT(var_index < Length()); | 6779 ASSERT(var_index < Length()); |
| 6779 const Array& names = Array::Handle(raw_ptr()->names_); | 6780 const Array& names = Array::Handle(raw_ptr()->names_); |
| 6780 ASSERT(Length() == names.Length()); | 6781 ASSERT(Length() == names.Length()); |
| 6781 const String& name = String::CheckedHandle(names.At(var_index)); | 6782 String& name = String::Handle(); |
| 6783 name ^= names.At(var_index); |
| 6782 return name.raw(); | 6784 return name.raw(); |
| 6783 } | 6785 } |
| 6784 | 6786 |
| 6785 | 6787 |
| 6786 void LocalVarDescriptors::SetVar(intptr_t var_index, | 6788 void LocalVarDescriptors::SetVar(intptr_t var_index, |
| 6787 const String& name, | 6789 const String& name, |
| 6788 RawLocalVarDescriptors::VarInfo* info) const { | 6790 RawLocalVarDescriptors::VarInfo* info) const { |
| 6789 ASSERT(var_index < Length()); | 6791 ASSERT(var_index < Length()); |
| 6790 const Array& names = Array::Handle(raw_ptr()->names_); | 6792 const Array& names = Array::Handle(raw_ptr()->names_); |
| 6791 ASSERT(Length() == names.Length()); | 6793 ASSERT(Length() == names.Length()); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7048 | 7050 |
| 7049 intptr_t Code::Comments::Length() const { | 7051 intptr_t Code::Comments::Length() const { |
| 7050 if (comments_.IsNull()) { | 7052 if (comments_.IsNull()) { |
| 7051 return 0; | 7053 return 0; |
| 7052 } | 7054 } |
| 7053 return comments_.Length() / kNumberOfEntries; | 7055 return comments_.Length() / kNumberOfEntries; |
| 7054 } | 7056 } |
| 7055 | 7057 |
| 7056 | 7058 |
| 7057 intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const { | 7059 intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const { |
| 7058 return Smi::CheckedHandle( | 7060 Smi& result = Smi::Handle(); |
| 7059 comments_.At(idx * kNumberOfEntries + kPCOffsetEntry)).Value(); | 7061 result ^= comments_.At(idx * kNumberOfEntries + kPCOffsetEntry); |
| 7062 return result.Value(); |
| 7060 } | 7063 } |
| 7061 | 7064 |
| 7062 | 7065 |
| 7063 void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) { | 7066 void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) { |
| 7064 comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry, | 7067 comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry, |
| 7065 Smi::Handle(Smi::New(pc))); | 7068 Smi::Handle(Smi::New(pc))); |
| 7066 } | 7069 } |
| 7067 | 7070 |
| 7068 | 7071 |
| 7069 const String& Code::Comments::CommentAt(intptr_t idx) const { | 7072 RawString* Code::Comments::CommentAt(intptr_t idx) const { |
| 7070 return String::CheckedHandle( | 7073 String& result = String::Handle(); |
| 7071 comments_.At(idx * kNumberOfEntries + kCommentEntry)); | 7074 result ^= comments_.At(idx * kNumberOfEntries + kCommentEntry); |
| 7075 return result.raw(); |
| 7072 } | 7076 } |
| 7073 | 7077 |
| 7074 | 7078 |
| 7075 void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) { | 7079 void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) { |
| 7076 comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment); | 7080 comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment); |
| 7077 } | 7081 } |
| 7078 | 7082 |
| 7079 | 7083 |
| 7080 Code::Comments::Comments(const Array& comments) | 7084 Code::Comments::Comments(const Array& comments) |
| 7081 : comments_(comments) { | 7085 : comments_(comments) { |
| (...skipping 5340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12422 } | 12426 } |
| 12423 return result.raw(); | 12427 return result.raw(); |
| 12424 } | 12428 } |
| 12425 | 12429 |
| 12426 | 12430 |
| 12427 const char* WeakProperty::ToCString() const { | 12431 const char* WeakProperty::ToCString() const { |
| 12428 return "_WeakProperty"; | 12432 return "_WeakProperty"; |
| 12429 } | 12433 } |
| 12430 | 12434 |
| 12431 } // namespace dart | 12435 } // namespace dart |
| OLD | NEW |