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

Side by Side Diff: runtime/vm/token_position.cc

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/token_position.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 #include "vm/token_position.h"
6
7 #include "vm/object.h"
8
9 namespace dart {
10
11
12 TokenPosition TokenPosition::SnapshotDecode(int32_t value) {
13 return TokenPosition(static_cast<intptr_t>(value));
14 }
15
16
17 int32_t TokenPosition::SnapshotEncode() {
18 return static_cast<int32_t>(value_);
19 }
20
21
22 bool TokenPosition::IsSynthetic() const {
23 if (value_ >= kMinSourcePos) {
24 return false;
25 }
26 if (value_ < kLast.value()) {
27 return true;
28 }
29 return false;
30 }
31
32
33 #define DEFINE_VALUES(name, value) \
34 const TokenPosition TokenPosition::k##name = TokenPosition(value);
35 SENTINEL_TOKEN_DESCRIPTORS(DEFINE_VALUES);
36 #undef DEFINE_VALUES
37 const TokenPosition TokenPosition::kMinSource =
38 TokenPosition(kMinSourcePos);
39
40 const TokenPosition TokenPosition::kMaxSource =
41 TokenPosition(kMaxSourcePos);
42
43
44 const char* TokenPosition::ToCString() const {
45 switch (value_) {
46 #define DEFINE_CASE(name, value) \
47 case value: return #name;
48 SENTINEL_TOKEN_DESCRIPTORS(DEFINE_CASE);
49 #undef DEFINE_CASE
50 default: {
51 Zone* zone = Thread::Current()->zone();
52 ASSERT(zone != NULL);
53 if (IsSynthetic()) {
54 // TODO(johnmccutchan): Print synthetic positions differently.
55 return FromSynthetic().ToCString();
56 } else {
57 return OS::SCreate(zone, "%d", value_);
58 }
59 }
60 }
61 }
62
63 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/token_position.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698