| Index: runtime/vm/flow_graph_builder_test.cc
|
| diff --git a/runtime/vm/flow_graph_builder_test.cc b/runtime/vm/flow_graph_builder_test.cc
|
| index 2213d0bf9531320fb813730eba1b50f7d4523746..f16395410044374584d39451d999f0852d62f51d 100644
|
| --- a/runtime/vm/flow_graph_builder_test.cc
|
| +++ b/runtime/vm/flow_graph_builder_test.cc
|
| @@ -166,29 +166,29 @@ class SourcePositionTest : public ValueObject {
|
| }
|
| }
|
|
|
| - // Fails if any of the IR nodes has a token position of Token::kNoSourcePos.
|
| + // Fails if any of the IR nodes has a token position of
|
| + // TokenDescriptor::kNoSourcePos.
|
| void EnsureSourcePositions() {
|
| for (intptr_t i = 0; i < blocks_->length(); i++) {
|
| BlockEntryInstr* entry = (*blocks_)[i];
|
| - DUMP_ASSERT(entry->token_pos() != Token::kNoSourcePos);
|
| + DUMP_ASSERT(entry->token_pos() != TokenDescriptor::kNoSource);
|
| for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
|
| Instruction* instr = it.Current();
|
| - DUMP_ASSERT(instr->token_pos() != Token::kNoSourcePos);
|
| + DUMP_ASSERT(instr->token_pos() != TokenDescriptor::kNoSource);
|
| }
|
| }
|
| }
|
|
|
| private:
|
| void DumpInstruction(Instruction* instr) {
|
| - intptr_t token_pos = instr->token_pos();
|
| + TokenDescriptor token_pos = instr->token_pos();
|
| bool synthetic = false;
|
| - if (Token::IsSynthetic(token_pos)) {
|
| + if (token_pos.IsSynthetic()) {
|
| synthetic = true;
|
| - token_pos = Token::FromSynthetic(token_pos);
|
| + token_pos = TokenDescriptor::FromSynthetic(token_pos);
|
| }
|
| - if (token_pos < 0) {
|
| - const char* token_pos_string =
|
| - ClassifyingTokenPositions::ToCString(token_pos);
|
| + if (token_pos.IsClassifying()) {
|
| + const char* token_pos_string = token_pos.ToCString();
|
| THR_Print("%12s -- %s\n", token_pos_string, instr->ToCString());
|
| return;
|
| }
|
| @@ -228,11 +228,11 @@ class SourcePositionTest : public ValueObject {
|
| BlockEntryInstr* entry = (*blocks_)[i];
|
| for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
|
| Instruction* instr = it.Current();
|
| - intptr_t token_pos = instr->token_pos();
|
| - if (Token::IsSynthetic(token_pos)) {
|
| - token_pos = Token::FromSynthetic(token_pos);
|
| + TokenDescriptor token_pos = instr->token_pos();
|
| + if (token_pos.IsSynthetic()) {
|
| + token_pos = TokenDescriptor::FromSynthetic(token_pos);
|
| }
|
| - if (token_pos < 0) {
|
| + if (!token_pos.IsReal()) {
|
| continue;
|
| }
|
| intptr_t token_line = -1;
|
| @@ -258,7 +258,7 @@ class SourcePositionTest : public ValueObject {
|
| BlockEntryInstr* entry = (*blocks_)[i];
|
| for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
|
| Instruction* instr = it.Current();
|
| - if (instr->token_pos() == token_pos) {
|
| + if (instr->token_pos().value() == token_pos) {
|
| instructions->Add(instr);
|
| }
|
| }
|
| @@ -780,26 +780,29 @@ TEST_CASE(SourcePosition_Async) {
|
| }
|
|
|
|
|
| -static bool SyntheticRoundTripTest(intptr_t token_pos) {
|
| - return Token::FromSynthetic(Token::ToSynthetic(token_pos)) == token_pos;
|
| +static bool SyntheticRoundTripTest(TokenDescriptor token_pos) {
|
| + const TokenDescriptor synthetic_token_pos =
|
| + TokenDescriptor::ToSynthetic(token_pos);
|
| + return TokenDescriptor::FromSynthetic(synthetic_token_pos) == token_pos;
|
| }
|
|
|
|
|
| UNIT_TEST_CASE(SourcePosition_SyntheticTokens) {
|
| - EXPECT(Token::kNoSourcePos == -1);
|
| - EXPECT(Token::kMinSourcePos == 0);
|
| - EXPECT(Token::kMaxSourcePos > 0);
|
| -
|
| - EXPECT(!Token::IsSynthetic(0));
|
| - EXPECT(Token::IsSynthetic(Token::ToSynthetic(0)));
|
| - EXPECT(Token::IsSynthetic(Token::ToSynthetic(9)));
|
| - EXPECT(!Token::IsSynthetic(Token::FromSynthetic(-1)));
|
| - EXPECT(!Token::IsSynthetic(ClassifyingTokenPositions::kPrivate));
|
| - EXPECT(!Token::IsSynthetic(ClassifyingTokenPositions::kLast));
|
| -
|
| - EXPECT(SyntheticRoundTripTest(0));
|
| - EXPECT(SyntheticRoundTripTest(Token::kMaxSourcePos));
|
| - EXPECT(SyntheticRoundTripTest(Token::kMinSourcePos));
|
| + EXPECT(TokenDescriptor::kNoSourcePos == -1);
|
| + EXPECT(TokenDescriptor::kMinSourcePos == 0);
|
| + EXPECT(TokenDescriptor::kMaxSourcePos > 0);
|
| + EXPECT(TokenDescriptor::kMaxSourcePos > TokenDescriptor::kMinSourcePos);
|
| + EXPECT(TokenDescriptor::kMinSource.value() == TokenDescriptor::kMinSourcePos);
|
| + EXPECT(TokenDescriptor::kMaxSource.value() == TokenDescriptor::kMaxSourcePos);
|
| + EXPECT(!TokenDescriptor(0).IsSynthetic());
|
| + EXPECT(TokenDescriptor::ToSynthetic(TokenDescriptor(0)).IsSynthetic());
|
| + EXPECT(TokenDescriptor::ToSynthetic(TokenDescriptor(9)).IsSynthetic());
|
| + EXPECT(!TokenDescriptor::FromSynthetic(TokenDescriptor(-1)).IsSynthetic());
|
| + EXPECT(!TokenDescriptor::kNoSource.IsSynthetic());
|
| + EXPECT(!TokenDescriptor::kLast.IsSynthetic());
|
| + EXPECT(SyntheticRoundTripTest(TokenDescriptor(0)));
|
| + EXPECT(SyntheticRoundTripTest(TokenDescriptor::kMaxSource));
|
| + EXPECT(SyntheticRoundTripTest(TokenDescriptor::kMinSource));
|
| }
|
|
|
| } // namespace dart
|
|
|