| 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 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4190 } | 4190 } |
| 4191 suffix = Symbols::Dot(); | 4191 suffix = Symbols::Dot(); |
| 4192 tmp = String::Concat(tmp, suffix); | 4192 tmp = String::Concat(tmp, suffix); |
| 4193 suffix = UserVisibleName(); | 4193 suffix = UserVisibleName(); |
| 4194 return String::Concat(tmp, suffix); | 4194 return String::Concat(tmp, suffix); |
| 4195 } | 4195 } |
| 4196 | 4196 |
| 4197 | 4197 |
| 4198 // Construct fingerprint from token stream. The token stream contains also | 4198 // Construct fingerprint from token stream. The token stream contains also |
| 4199 // arguments. | 4199 // arguments. |
| 4200 intptr_t Function::SourceFingerprint() const { | 4200 int32_t Function::SourceFingerprint() const { |
| 4201 intptr_t result = String::Handle(Signature()).Hash(); | 4201 int32_t result = String::Handle(Signature()).Hash(); |
| 4202 TokenStream::Iterator tokens_iterator(TokenStream::Handle( | 4202 TokenStream::Iterator tokens_iterator(TokenStream::Handle( |
| 4203 Script::Handle(script()).tokens()), token_pos()); | 4203 Script::Handle(script()).tokens()), token_pos()); |
| 4204 Object& obj = Object::Handle(); | 4204 Object& obj = Object::Handle(); |
| 4205 String& literal = String::Handle(); | 4205 String& literal = String::Handle(); |
| 4206 while (tokens_iterator.CurrentPosition() < end_token_pos()) { | 4206 while (tokens_iterator.CurrentPosition() < end_token_pos()) { |
| 4207 intptr_t val = 0; | 4207 int32_t val = 0; |
| 4208 obj = tokens_iterator.CurrentToken(); | 4208 obj = tokens_iterator.CurrentToken(); |
| 4209 if (obj.IsSmi()) { | 4209 if (obj.IsSmi()) { |
| 4210 val = Smi::Cast(obj).Value(); | 4210 val = Smi::Cast(obj).Value(); |
| 4211 } else { | 4211 } else { |
| 4212 literal = tokens_iterator.MakeLiteralToken(obj); | 4212 literal = tokens_iterator.MakeLiteralToken(obj); |
| 4213 val = literal.Hash(); | 4213 val = literal.Hash(); |
| 4214 } | 4214 } |
| 4215 result = 31 * result + val; | 4215 result = 31 * result + val; |
| 4216 tokens_iterator.Advance(); | 4216 tokens_iterator.Advance(); |
| 4217 } | 4217 } |
| (...skipping 5728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9946 intptr_t Finalize(int bits) { | 9946 intptr_t Finalize(int bits) { |
| 9947 ASSERT(1 <= bits && bits <= (kBitsPerWord - 1)); | 9947 ASSERT(1 <= bits && bits <= (kBitsPerWord - 1)); |
| 9948 hash_ += hash_ << 3; | 9948 hash_ += hash_ << 3; |
| 9949 hash_ ^= hash_ >> 11; | 9949 hash_ ^= hash_ >> 11; |
| 9950 hash_ += hash_ << 15; | 9950 hash_ += hash_ << 15; |
| 9951 hash_ = hash_ & ((static_cast<intptr_t>(1) << bits) - 1); | 9951 hash_ = hash_ & ((static_cast<intptr_t>(1) << bits) - 1); |
| 9952 ASSERT(hash_ >= 0); | 9952 ASSERT(hash_ >= 0); |
| 9953 return hash_ == 0 ? 1 : hash_; | 9953 return hash_ == 0 ? 1 : hash_; |
| 9954 } | 9954 } |
| 9955 private: | 9955 private: |
| 9956 intptr_t hash_; | 9956 int32_t hash_; |
| 9957 }; | 9957 }; |
| 9958 | 9958 |
| 9959 | 9959 |
| 9960 intptr_t String::Hash() const { | 9960 intptr_t String::Hash() const { |
| 9961 intptr_t result = Smi::Value(raw_ptr()->hash_); | 9961 intptr_t result = Smi::Value(raw_ptr()->hash_); |
| 9962 if (result != 0) { | 9962 if (result != 0) { |
| 9963 return result; | 9963 return result; |
| 9964 } | 9964 } |
| 9965 result = String::Hash(*this, 0, this->Length()); | 9965 result = String::Hash(*this, 0, this->Length()); |
| 9966 this->SetHash(result); | 9966 this->SetHash(result); |
| (...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12190 } | 12190 } |
| 12191 return result.raw(); | 12191 return result.raw(); |
| 12192 } | 12192 } |
| 12193 | 12193 |
| 12194 | 12194 |
| 12195 const char* WeakProperty::ToCString() const { | 12195 const char* WeakProperty::ToCString() const { |
| 12196 return "_WeakProperty"; | 12196 return "_WeakProperty"; |
| 12197 } | 12197 } |
| 12198 | 12198 |
| 12199 } // namespace dart | 12199 } // namespace dart |
| OLD | NEW |