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

Unified Diff: runtime/vm/token.h

Issue 1589643002: Source positions for constructors and lots of async machinery (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
« runtime/vm/flow_graph_builder_test.cc ('K') | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/token.h
diff --git a/runtime/vm/token.h b/runtime/vm/token.h
index a1018f83c5692a73b168c65104ec6012dd106455..0cd852a7120e91bf545ac54a18f6607b14008e3f 100644
--- a/runtime/vm/token.h
+++ b/runtime/vm/token.h
@@ -6,6 +6,7 @@
#define VM_TOKEN_H_
#include "platform/assert.h"
+#include "vm/allocation.h"
namespace dart {
@@ -216,6 +217,8 @@ class Token {
static const Kind kLastKeyword = kWITH;
static const int kNumKeywords = kLastKeyword - kFirstKeyword + 1;
+ static const intptr_t kNoSourcePos = -1;
+
static bool IsAssignmentOperator(Kind tok) {
return kASSIGN <= tok && tok <= kASSIGN_COND;
}
@@ -329,6 +332,48 @@ class Token {
};
+// These token positions are used to classify instructions that can't be
+// directly tied to an actual source position.
+#define CLASSIFYING_TOKEN_POSITIONS(V) \
+ V(Private, -2) \
+ V(Box, -3) \
+ V(ParallelMove, -4) \
+ V(TempMove, -5) \
+ V(Constant, -6) \
+ V(PushArgument, -7) \
+ V(ControlFlow, -8) \
+ V(Context, -9) \
+ V(MethodExtractor, -10)
+
+// COMPILE_ASSERT that all CLASSIFYING_TOKEN_POSITIONS are less than
+// Token::kNoSourcePos.
+#define SANITY_CHECK_VALUES(name, value) \
+ COMPILE_ASSERT(value < Token::kNoSourcePos);
+ CLASSIFYING_TOKEN_POSITIONS(SANITY_CHECK_VALUES);
+#undef SANITY_CHECK_VALUES
+
+class ClassifyingTokenPositions : public AllStatic {
+ public:
+#define DEFINE_VALUES(name, value) \
+ static const intptr_t k##name = value;
+ CLASSIFYING_TOKEN_POSITIONS(DEFINE_VALUES);
+#undef DEFINE_VALUES
+
+ static const char* ToCString(intptr_t token_pos) {
+ ASSERT(token_pos < 0);
+ switch (token_pos) {
+ case Token::kNoSourcePos: return "NoSource";
+#define DEFINE_CASE(name, value) \
+ case value: return #name;
+ CLASSIFYING_TOKEN_POSITIONS(DEFINE_CASE);
+#undef DEFINE_CASE
+ default:
+ UNIMPLEMENTED();
+ return NULL;
+ }
+ }
+};
+
} // namespace dart
#endif // VM_TOKEN_H_
« runtime/vm/flow_graph_builder_test.cc ('K') | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698