| 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 8355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8366 | 8366 |
| 8367 // Setup for next iteration. | 8367 // Setup for next iteration. |
| 8368 prev = curr; | 8368 prev = curr; |
| 8369 curr = next; | 8369 curr = next; |
| 8370 } | 8370 } |
| 8371 const Array& source = Array::Handle(Array::MakeArray(literals)); | 8371 const Array& source = Array::Handle(Array::MakeArray(literals)); |
| 8372 return String::ConcatAll(source); | 8372 return String::ConcatAll(source); |
| 8373 } | 8373 } |
| 8374 | 8374 |
| 8375 | 8375 |
| 8376 TokenPosition TokenStream::ComputeSourcePosition( | 8376 intptr_t TokenStream::ComputeSourcePosition(TokenPosition tok_pos) const { |
| 8377 TokenPosition tok_pos) const { | |
| 8378 Zone* zone = Thread::Current()->zone(); | 8377 Zone* zone = Thread::Current()->zone(); |
| 8379 Iterator iterator(zone, | 8378 Iterator iterator(zone, |
| 8380 *this, | 8379 *this, |
| 8381 TokenPosition::kMinSource, | 8380 TokenPosition::kMinSource, |
| 8382 Iterator::kAllTokens); | 8381 Iterator::kAllTokens); |
| 8383 TokenPosition src_pos = TokenPosition::kMinSource; | 8382 intptr_t src_pos = 0; |
| 8384 Token::Kind kind = iterator.CurrentTokenKind(); | 8383 Token::Kind kind = iterator.CurrentTokenKind(); |
| 8385 while ((iterator.CurrentPosition() < tok_pos) && (kind != Token::kEOS)) { | 8384 while ((iterator.CurrentPosition() < tok_pos) && (kind != Token::kEOS)) { |
| 8386 iterator.Advance(); | 8385 iterator.Advance(); |
| 8387 kind = iterator.CurrentTokenKind(); | 8386 kind = iterator.CurrentTokenKind(); |
| 8388 src_pos.Next(); | 8387 src_pos++; |
| 8389 } | 8388 } |
| 8390 return src_pos; | 8389 return src_pos; |
| 8391 } | 8390 } |
| 8392 | 8391 |
| 8393 | 8392 |
| 8394 RawTokenStream* TokenStream::New() { | 8393 RawTokenStream* TokenStream::New() { |
| 8395 ASSERT(Object::token_stream_class() != Class::null()); | 8394 ASSERT(Object::token_stream_class() != Class::null()); |
| 8396 RawObject* raw = Object::Allocate(TokenStream::kClassId, | 8395 RawObject* raw = Object::Allocate(TokenStream::kClassId, |
| 8397 TokenStream::InstanceSize(), | 8396 TokenStream::InstanceSize(), |
| 8398 Heap::kOld); | 8397 Heap::kOld); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8987 while ((tkit.CurrentPosition() < token_pos) && | 8986 while ((tkit.CurrentPosition() < token_pos) && |
| 8988 (tkit.CurrentTokenKind() != Token::kEOS)) { | 8987 (tkit.CurrentTokenKind() != Token::kEOS)) { |
| 8989 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8988 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
| 8990 cur_line++; | 8989 cur_line++; |
| 8991 } | 8990 } |
| 8992 tkit.Advance(); | 8991 tkit.Advance(); |
| 8993 } | 8992 } |
| 8994 *line = cur_line; | 8993 *line = cur_line; |
| 8995 } else { | 8994 } else { |
| 8996 const String& src = String::Handle(zone, Source()); | 8995 const String& src = String::Handle(zone, Source()); |
| 8997 TokenPosition src_pos = tkns.ComputeSourcePosition(token_pos); | 8996 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); |
| 8998 Scanner scanner(src, Symbols::Empty()); | 8997 Scanner scanner(src, Symbols::Empty()); |
| 8999 scanner.ScanTo(src_pos); | 8998 scanner.ScanTo(src_pos); |
| 9000 intptr_t relative_line = scanner.CurrentPosition().line; | 8999 intptr_t relative_line = scanner.CurrentPosition().line; |
| 9001 *line = relative_line + line_offset(); | 9000 *line = relative_line + line_offset(); |
| 9002 *column = scanner.CurrentPosition().column; | 9001 *column = scanner.CurrentPosition().column; |
| 9003 if (token_len != NULL) { | 9002 if (token_len != NULL) { |
| 9004 if (scanner.current_token().literal != NULL) { | 9003 if (scanner.current_token().literal != NULL) { |
| 9005 *token_len = scanner.current_token().literal->Length(); | 9004 *token_len = scanner.current_token().literal->Length(); |
| 9006 } else { | 9005 } else { |
| 9007 *token_len = 1; | 9006 *token_len = 1; |
| (...skipping 13447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22455 return UserTag::null(); | 22454 return UserTag::null(); |
| 22456 } | 22455 } |
| 22457 | 22456 |
| 22458 | 22457 |
| 22459 const char* UserTag::ToCString() const { | 22458 const char* UserTag::ToCString() const { |
| 22460 const String& tag_label = String::Handle(label()); | 22459 const String& tag_label = String::Handle(label()); |
| 22461 return tag_label.ToCString(); | 22460 return tag_label.ToCString(); |
| 22462 } | 22461 } |
| 22463 | 22462 |
| 22464 } // namespace dart | 22463 } // namespace dart |
| OLD | NEW |