| 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_
|
|
|