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/become.h" | 10 #include "vm/become.h" |
(...skipping 8848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8859 if (kind() == RawScript::kKernelTag) { | 8859 if (kind() == RawScript::kKernelTag) { |
8860 const Array& line_starts_array = Array::Handle(line_starts()); | 8860 const Array& line_starts_array = Array::Handle(line_starts()); |
8861 if (line_starts_array.IsNull()) { | 8861 if (line_starts_array.IsNull()) { |
8862 // Scripts in the AOT snapshot do not have a line starts array. | 8862 // Scripts in the AOT snapshot do not have a line starts array. |
8863 // A well-formed line number array has a leading null. | 8863 // A well-formed line number array has a leading null. |
8864 info.Add(line_separator); // New line. | 8864 info.Add(line_separator); // New line. |
8865 return info.raw(); | 8865 return info.raw(); |
8866 } | 8866 } |
8867 intptr_t line_count = line_starts_array.Length(); | 8867 intptr_t line_count = line_starts_array.Length(); |
8868 ASSERT(line_count > 0); | 8868 ASSERT(line_count > 0); |
| 8869 const Array& debug_positions_array = Array::Handle(debug_positions()); |
| 8870 intptr_t token_count = debug_positions_array.Length(); |
| 8871 int token_index = 0; |
8869 | 8872 |
8870 for (int i = 0; i < line_count; i++) { | 8873 for (int line_index = 0; line_index < line_count; ++line_index) { |
8871 info.Add(line_separator); // New line. | 8874 value ^= line_starts_array.At(line_index); |
8872 value = Smi::New(i + 1); | 8875 intptr_t start = value.Value(); |
8873 info.Add(value); // Line number. | 8876 // Output the rest of the tokens if we have no next line. |
8874 value ^= line_starts_array.At(i); | 8877 intptr_t end = TokenPosition::kMaxSourcePos; |
8875 info.Add(value); // Token position. | 8878 if (line_index + 1 < line_count) { |
8876 value = Smi::New(1); | 8879 value ^= line_starts_array.At(line_index + 1); |
8877 info.Add(value); // Column. | 8880 end = value.Value(); |
| 8881 } |
| 8882 bool first = true; |
| 8883 while (token_index < token_count) { |
| 8884 value ^= debug_positions_array.At(token_index); |
| 8885 intptr_t debug_position = value.Value(); |
| 8886 if (debug_position >= end) break; |
| 8887 |
| 8888 if (first) { |
| 8889 info.Add(line_separator); // New line. |
| 8890 value = Smi::New(line_index + 1); // Line number. |
| 8891 info.Add(value); |
| 8892 first = false; |
| 8893 } |
| 8894 |
| 8895 value ^= debug_positions_array.At(token_index); |
| 8896 info.Add(value); // Token position. |
| 8897 value = Smi::New(debug_position - start + 1); // Column. |
| 8898 info.Add(value); |
| 8899 ++token_index; |
| 8900 } |
8878 } | 8901 } |
8879 return info.raw(); | 8902 return info.raw(); |
8880 } | 8903 } |
8881 | 8904 |
8882 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 8905 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
8883 String& tokenValue = String::Handle(zone); | 8906 String& tokenValue = String::Handle(zone); |
8884 ASSERT(!tkns.IsNull()); | 8907 ASSERT(!tkns.IsNull()); |
8885 TokenStream::Iterator tkit(zone, tkns, TokenPosition::kMinSource, | 8908 TokenStream::Iterator tkit(zone, tkns, TokenPosition::kMinSource, |
8886 TokenStream::Iterator::kAllTokens); | 8909 TokenStream::Iterator::kAllTokens); |
8887 int current_line = -1; | 8910 int current_line = -1; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8988 | 9011 |
8989 void Script::set_source(const String& value) const { | 9012 void Script::set_source(const String& value) const { |
8990 StorePointer(&raw_ptr()->source_, value.raw()); | 9013 StorePointer(&raw_ptr()->source_, value.raw()); |
8991 } | 9014 } |
8992 | 9015 |
8993 void Script::set_line_starts(const Array& value) const { | 9016 void Script::set_line_starts(const Array& value) const { |
8994 StorePointer(&raw_ptr()->line_starts_, value.raw()); | 9017 StorePointer(&raw_ptr()->line_starts_, value.raw()); |
8995 } | 9018 } |
8996 | 9019 |
8997 | 9020 |
| 9021 void Script::set_debug_positions(const Array& value) const { |
| 9022 StorePointer(&raw_ptr()->debug_positions_, value.raw()); |
| 9023 } |
| 9024 |
| 9025 void Script::set_yield_positions(const Array& value) const { |
| 9026 StorePointer(&raw_ptr()->yield_positions_, value.raw()); |
| 9027 } |
| 9028 |
8998 void Script::set_kind(RawScript::Kind value) const { | 9029 void Script::set_kind(RawScript::Kind value) const { |
8999 StoreNonPointer(&raw_ptr()->kind_, value); | 9030 StoreNonPointer(&raw_ptr()->kind_, value); |
9000 } | 9031 } |
9001 | 9032 |
9002 | 9033 |
9003 void Script::set_load_timestamp(int64_t value) const { | 9034 void Script::set_load_timestamp(int64_t value) const { |
9004 StoreNonPointer(&raw_ptr()->load_timestamp_, value); | 9035 StoreNonPointer(&raw_ptr()->load_timestamp_, value); |
9005 } | 9036 } |
9006 | 9037 |
9007 | 9038 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9078 } else { | 9109 } else { |
9079 min = midpoint; | 9110 min = midpoint; |
9080 } | 9111 } |
9081 } | 9112 } |
9082 *line = min + 1; | 9113 *line = min + 1; |
9083 smi ^= line_starts_array.At(min); | 9114 smi ^= line_starts_array.At(min); |
9084 if (column != NULL) { | 9115 if (column != NULL) { |
9085 *column = offset - smi.Value() + 1; | 9116 *column = offset - smi.Value() + 1; |
9086 } | 9117 } |
9087 if (token_len != NULL) { | 9118 if (token_len != NULL) { |
| 9119 // We don't explicitly save this data. |
| 9120 // TODO(jensj): Load the source and attempt to find it from there. |
9088 *token_len = 1; | 9121 *token_len = 1; |
9089 } | 9122 } |
9090 return; | 9123 return; |
9091 } | 9124 } |
9092 | 9125 |
9093 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 9126 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
9094 if (tkns.IsNull()) { | 9127 if (tkns.IsNull()) { |
9095 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kAppAOT)); | 9128 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kAppAOT)); |
9096 *line = -1; | 9129 *line = -1; |
9097 if (column != NULL) { | 9130 if (column != NULL) { |
(...skipping 13954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23052 return UserTag::null(); | 23085 return UserTag::null(); |
23053 } | 23086 } |
23054 | 23087 |
23055 | 23088 |
23056 const char* UserTag::ToCString() const { | 23089 const char* UserTag::ToCString() const { |
23057 const String& tag_label = String::Handle(label()); | 23090 const String& tag_label = String::Handle(label()); |
23058 return tag_label.ToCString(); | 23091 return tag_label.ToCString(); |
23059 } | 23092 } |
23060 | 23093 |
23061 } // namespace dart | 23094 } // namespace dart |
OLD | NEW |