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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 intptr_t Hash() const { return name_.Hash(); } | 2080 intptr_t Hash() const { return name_.Hash(); } |
2081 private: | 2081 private: |
2082 const String& name_; | 2082 const String& name_; |
2083 String* tmp_string_; | 2083 String* tmp_string_; |
2084 }; | 2084 }; |
2085 | 2085 |
2086 | 2086 |
2087 // Traits for looking up Functions by name. | 2087 // Traits for looking up Functions by name. |
2088 class ClassFunctionsTraits { | 2088 class ClassFunctionsTraits { |
2089 public: | 2089 public: |
| 2090 static const char* Name() { return "ClassFunctionsTraits"; } |
| 2091 |
2090 // Called when growing the table. | 2092 // Called when growing the table. |
2091 static bool IsMatch(const Object& a, const Object& b) { | 2093 static bool IsMatch(const Object& a, const Object& b) { |
2092 ASSERT(a.IsFunction() && b.IsFunction()); | 2094 ASSERT(a.IsFunction() && b.IsFunction()); |
2093 // Function objects are always canonical. | 2095 // Function objects are always canonical. |
2094 return a.raw() == b.raw(); | 2096 return a.raw() == b.raw(); |
2095 } | 2097 } |
2096 static bool IsMatch(const FunctionName& name, const Object& obj) { | 2098 static bool IsMatch(const FunctionName& name, const Object& obj) { |
2097 return name.Matches(Function::Cast(obj)); | 2099 return name.Matches(Function::Cast(obj)); |
2098 } | 2100 } |
2099 static uword Hash(const Object& key) { | 2101 static uword Hash(const Object& key) { |
(...skipping 6203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8303 const TokenStream& result = TokenStream::Handle(zone, TokenStream::New()); | 8305 const TokenStream& result = TokenStream::Handle(zone, TokenStream::New()); |
8304 result.SetStream(stream); | 8306 result.SetStream(stream); |
8305 return result.raw(); | 8307 return result.raw(); |
8306 } | 8308 } |
8307 | 8309 |
8308 | 8310 |
8309 // CompressedTokenMap maps String and LiteralToken keys to Smi values. | 8311 // CompressedTokenMap maps String and LiteralToken keys to Smi values. |
8310 // It also supports lookup by TokenDescriptor. | 8312 // It also supports lookup by TokenDescriptor. |
8311 class CompressedTokenTraits { | 8313 class CompressedTokenTraits { |
8312 public: | 8314 public: |
| 8315 static const char* Name() { return "CompressedTokenTraits"; } |
| 8316 |
8313 static bool IsMatch(const Scanner::TokenDescriptor& descriptor, | 8317 static bool IsMatch(const Scanner::TokenDescriptor& descriptor, |
8314 const Object& key) { | 8318 const Object& key) { |
8315 if (!key.IsLiteralToken()) { | 8319 if (!key.IsLiteralToken()) { |
8316 return false; | 8320 return false; |
8317 } | 8321 } |
8318 const LiteralToken& token = LiteralToken::Cast(key); | 8322 const LiteralToken& token = LiteralToken::Cast(key); |
8319 return (token.literal() == descriptor.literal->raw()) && | 8323 return (token.literal() == descriptor.literal->raw()) && |
8320 (token.kind() == descriptor.kind); | 8324 (token.kind() == descriptor.kind); |
8321 } | 8325 } |
8322 | 8326 |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9232 // Should not be already successfully loaded or just allocated. | 9236 // Should not be already successfully loaded or just allocated. |
9233 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); | 9237 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); |
9234 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadError); | 9238 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadError); |
9235 StorePointer(&raw_ptr()->load_error_, error.raw()); | 9239 StorePointer(&raw_ptr()->load_error_, error.raw()); |
9236 } | 9240 } |
9237 | 9241 |
9238 | 9242 |
9239 // Traits for looking up Libraries by url in a hash set. | 9243 // Traits for looking up Libraries by url in a hash set. |
9240 class LibraryUrlTraits { | 9244 class LibraryUrlTraits { |
9241 public: | 9245 public: |
| 9246 static const char* Name() { return "LibraryUrlTraits"; } |
| 9247 |
9242 // Called when growing the table. | 9248 // Called when growing the table. |
9243 static bool IsMatch(const Object& a, const Object& b) { | 9249 static bool IsMatch(const Object& a, const Object& b) { |
9244 ASSERT(a.IsLibrary() && b.IsLibrary()); | 9250 ASSERT(a.IsLibrary() && b.IsLibrary()); |
9245 // Library objects are always canonical. | 9251 // Library objects are always canonical. |
9246 return a.raw() == b.raw(); | 9252 return a.raw() == b.raw(); |
9247 } | 9253 } |
9248 static uword Hash(const Object& key) { | 9254 static uword Hash(const Object& key) { |
9249 return Library::Cast(key).UrlHash(); | 9255 return Library::Cast(key).UrlHash(); |
9250 } | 9256 } |
9251 }; | 9257 }; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9522 obj = LookupImportedObject(name); | 9528 obj = LookupImportedObject(name); |
9523 } | 9529 } |
9524 } | 9530 } |
9525 AddToResolvedNamesCache(name, obj); | 9531 AddToResolvedNamesCache(name, obj); |
9526 return obj.raw(); | 9532 return obj.raw(); |
9527 } | 9533 } |
9528 | 9534 |
9529 | 9535 |
9530 class StringEqualsTraits { | 9536 class StringEqualsTraits { |
9531 public: | 9537 public: |
| 9538 static const char* Name() { return "StringEqualsTraits"; } |
| 9539 |
9532 static bool IsMatch(const Object& a, const Object& b) { | 9540 static bool IsMatch(const Object& a, const Object& b) { |
9533 return String::Cast(a).Equals(String::Cast(b)); | 9541 return String::Cast(a).Equals(String::Cast(b)); |
9534 } | 9542 } |
9535 static uword Hash(const Object& obj) { | 9543 static uword Hash(const Object& obj) { |
9536 return String::Cast(obj).Hash(); | 9544 return String::Cast(obj).Hash(); |
9537 } | 9545 } |
9538 }; | 9546 }; |
9539 typedef UnorderedHashMap<StringEqualsTraits> ResolvedNamesMap; | 9547 typedef UnorderedHashMap<StringEqualsTraits> ResolvedNamesMap; |
9540 | 9548 |
9541 | 9549 |
(...skipping 12414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21956 return UserTag::null(); | 21964 return UserTag::null(); |
21957 } | 21965 } |
21958 | 21966 |
21959 | 21967 |
21960 const char* UserTag::ToCString() const { | 21968 const char* UserTag::ToCString() const { |
21961 const String& tag_label = String::Handle(label()); | 21969 const String& tag_label = String::Handle(label()); |
21962 return tag_label.ToCString(); | 21970 return tag_label.ToCString(); |
21963 } | 21971 } |
21964 | 21972 |
21965 } // namespace dart | 21973 } // namespace dart |
OLD | NEW |