mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 20:51:50 +00:00
0f8861e3ba
In the codebase, we have several different interfaces for instance methods that return a hash: - uword Hash() const; - intptr_t Hash() const; - uint32_t Hash() const; - intptr_t Hashcode() const; This CL standardizes on `uword Hash() const` and adjusts any related functions to match. TEST=Existing test suites, as this is an internal refactoring. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try Change-Id: If2cbce57f3fae0f0d24031b6e324f0323c965f41 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195067 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/token_position.h"
|
|
|
|
#include "vm/object.h"
|
|
#include "vm/zone_text_buffer.h"
|
|
|
|
namespace dart {
|
|
|
|
uword TokenPosition::Hash() const {
|
|
return Utils::WordHash(value_);
|
|
}
|
|
|
|
TokenPosition TokenPosition::Deserialize(int32_t value) {
|
|
return TokenPosition(value);
|
|
}
|
|
|
|
int32_t TokenPosition::Serialize() const {
|
|
return static_cast<int32_t>(value_);
|
|
}
|
|
|
|
#define DEFINE_VALUES(name, value) \
|
|
const TokenPosition TokenPosition::k##name(value);
|
|
SENTINEL_TOKEN_DESCRIPTORS(DEFINE_VALUES);
|
|
#undef DEFINE_VALUES
|
|
const TokenPosition TokenPosition::kMinSource(kMinSourcePos);
|
|
const TokenPosition TokenPosition::kMaxSource(kMaxSourcePos);
|
|
|
|
const char* TokenPosition::ToCString() const {
|
|
switch (value_) {
|
|
#define DEFINE_CASE(name, value) \
|
|
case value: \
|
|
return #name;
|
|
SENTINEL_TOKEN_DESCRIPTORS(DEFINE_CASE);
|
|
#undef DEFINE_CASE
|
|
default:
|
|
break;
|
|
}
|
|
ASSERT(IsReal() || IsSynthetic());
|
|
ZoneTextBuffer buffer(Thread::Current()->zone());
|
|
if (IsSynthetic()) {
|
|
buffer.AddString("syn:");
|
|
}
|
|
buffer.Printf("%" Pd32 "", value_);
|
|
return buffer.buffer();
|
|
}
|
|
|
|
} // namespace dart
|