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

Unified Diff: runtime/vm/token_descriptor.cc

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/token_descriptor.cc
diff --git a/runtime/vm/token_descriptor.cc b/runtime/vm/token_descriptor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..543104095f58742f1573f9b2d9fd1195fa488730
--- /dev/null
+++ b/runtime/vm/token_descriptor.cc
@@ -0,0 +1,55 @@
+// 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_descriptor.h"
+
+#include "vm/object.h"
+
+namespace dart {
+
+
+TokenDescriptor TokenDescriptor::SnapshotDecode(int32_t value) {
+ return TokenDescriptor(static_cast<intptr_t>(value));
+}
+
+
+int32_t TokenDescriptor::SnapshotEncode() {
+ return static_cast<int32_t>(value_);
+}
+
+
+bool TokenDescriptor::IsSynthetic() const {
+ if (value_ >= kMinSourcePos) {
+ return false;
+ }
+ if (value_ < kLast.value()) {
+ return true;
+ }
+ return false;
+}
+
+
+#define DEFINE_VALUES(name, value) \
+const TokenDescriptor TokenDescriptor::k##name = TokenDescriptor(value);
+ SENTINEL_TOKEN_DESCRIPTORS(DEFINE_VALUES);
+#undef DEFINE_VALUES
+const TokenDescriptor TokenDescriptor::kMinSource =
+ TokenDescriptor(kMinSourcePos);
+
+const TokenDescriptor TokenDescriptor::kMaxSource =
+ TokenDescriptor(kMaxSourcePos);
+
+
+const char* TokenDescriptor::ToCString() const {
+ switch (value_) {
+#define DEFINE_CASE(name, value) \
+ case value: return #name;
+ SENTINEL_TOKEN_DESCRIPTORS(DEFINE_CASE);
+#undef DEFINE_CASE
+ default:
+ return "Non-Classifying token position";
+ }
+}
+
+} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698