OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 8574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8585 intptr_t col_offset) const { | 8585 intptr_t col_offset) const { |
8586 ASSERT(line_offset >= 0); | 8586 ASSERT(line_offset >= 0); |
8587 ASSERT(col_offset >= 0); | 8587 ASSERT(col_offset >= 0); |
8588 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); | 8588 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); |
8589 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); | 8589 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); |
8590 } | 8590 } |
8591 | 8591 |
8592 | 8592 |
8593 void Script::GetTokenLocation(intptr_t token_pos, | 8593 void Script::GetTokenLocation(intptr_t token_pos, |
8594 intptr_t* line, | 8594 intptr_t* line, |
8595 intptr_t* column) const { | 8595 intptr_t* column, |
8596 intptr_t* token_len) const { | |
8596 ASSERT(line != NULL); | 8597 ASSERT(line != NULL); |
8597 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8598 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8598 if (column == NULL) { | 8599 if (column == NULL) { |
8599 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8600 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
8600 intptr_t cur_line = line_offset() + 1; | 8601 intptr_t cur_line = line_offset() + 1; |
8601 while (tkit.CurrentPosition() < token_pos && | 8602 while (tkit.CurrentPosition() < token_pos && |
8602 tkit.CurrentTokenKind() != Token::kEOS) { | 8603 tkit.CurrentTokenKind() != Token::kEOS) { |
8603 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8604 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8604 cur_line++; | 8605 cur_line++; |
8605 } | 8606 } |
8606 tkit.Advance(); | 8607 tkit.Advance(); |
8607 } | 8608 } |
8608 *line = cur_line; | 8609 *line = cur_line; |
8609 } else { | 8610 } else { |
8610 const String& src = String::Handle(Source()); | 8611 const String& src = String::Handle(Source()); |
8611 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); | 8612 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); |
8612 Scanner scanner(src, Symbols::Empty()); | 8613 Scanner scanner(src, Symbols::Empty()); |
8613 scanner.ScanTo(src_pos); | 8614 scanner.ScanTo(src_pos); |
8614 intptr_t relative_line = scanner.CurrentPosition().line; | 8615 intptr_t relative_line = scanner.CurrentPosition().line; |
8615 *line = relative_line + line_offset(); | 8616 *line = relative_line + line_offset(); |
8616 *column = scanner.CurrentPosition().column; | 8617 *column = scanner.CurrentPosition().column; |
8618 if (token_len != NULL) { | |
8619 if (scanner.current_token().literal != NULL) { | |
8620 *token_len = scanner.current_token().literal->Length(); | |
8621 } else { | |
8622 *token_len = 1; | |
rmacnak
2015/09/03 00:55:19
Maybe otherwise keyword length?
turnidge
2015/09/04 18:05:29
My hope was that the literal pointed to the keywor
| |
8623 } | |
8624 } | |
8617 // On the first line of the script we must add the column offset. | 8625 // On the first line of the script we must add the column offset. |
8618 if (relative_line == 1) { | 8626 if (relative_line == 1) { |
8619 *column += col_offset(); | 8627 *column += col_offset(); |
8620 } | 8628 } |
8621 } | 8629 } |
8622 } | 8630 } |
8623 | 8631 |
8624 | 8632 |
8625 void Script::TokenRangeAtLine(intptr_t line_number, | 8633 void Script::TokenRangeAtLine(intptr_t line_number, |
8626 intptr_t* first_token_index, | 8634 intptr_t* first_token_index, |
(...skipping 12879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21506 return tag_label.ToCString(); | 21514 return tag_label.ToCString(); |
21507 } | 21515 } |
21508 | 21516 |
21509 | 21517 |
21510 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21518 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21511 Instance::PrintJSONImpl(stream, ref); | 21519 Instance::PrintJSONImpl(stream, ref); |
21512 } | 21520 } |
21513 | 21521 |
21514 | 21522 |
21515 } // namespace dart | 21523 } // namespace dart |
OLD | NEW |