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 9122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9133 return Symbols::Token(kind).raw(); | 9133 return Symbols::Token(kind).raw(); |
9134 } else { | 9134 } else { |
9135 ASSERT(obj.IsLiteralToken()); // Must be a literal token. | 9135 ASSERT(obj.IsLiteralToken()); // Must be a literal token. |
9136 const LiteralToken& literal_token = LiteralToken::Cast(obj); | 9136 const LiteralToken& literal_token = LiteralToken::Cast(obj); |
9137 return literal_token.literal(); | 9137 return literal_token.literal(); |
9138 } | 9138 } |
9139 } | 9139 } |
9140 | 9140 |
9141 | 9141 |
9142 bool Script::HasSource() const { | 9142 bool Script::HasSource() const { |
| 9143 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9144 return kind() == RawScript::kKernelTag || |
| 9145 raw_ptr()->source_ != String::null(); |
| 9146 #else // !defined(DART_PRECOMPILED_RUNTIME) |
9143 return raw_ptr()->source_ != String::null(); | 9147 return raw_ptr()->source_ != String::null(); |
| 9148 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
9144 } | 9149 } |
9145 | 9150 |
9146 | 9151 |
9147 RawString* Script::Source() const { | 9152 RawString* Script::Source() const { |
9148 String& source = String::Handle(raw_ptr()->source_); | 9153 String& source = String::Handle(raw_ptr()->source_); |
9149 if (source.IsNull()) { | 9154 if (source.IsNull()) { |
9150 return GenerateSource(); | 9155 return GenerateSource(); |
9151 } | 9156 } |
9152 return raw_ptr()->source_; | 9157 return raw_ptr()->source_; |
9153 } | 9158 } |
9154 | 9159 |
9155 | 9160 |
9156 RawString* Script::GenerateSource() const { | 9161 RawString* Script::GenerateSource() const { |
| 9162 #if !defined(DART_PRECOMPILED_RUNTIME) |
9157 if (kind() == RawScript::kKernelTag) { | 9163 if (kind() == RawScript::kKernelTag) { |
9158 // In kernel it's embedded. | 9164 String& source = String::Handle(raw_ptr()->source_); |
| 9165 if (source.IsNull()) { |
| 9166 // This is created lazily. Now we need it. |
| 9167 set_source(kernel::GetSourceFor(*this)); |
| 9168 } |
9159 return raw_ptr()->source_; | 9169 return raw_ptr()->source_; |
9160 } | 9170 } |
| 9171 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
9161 | 9172 |
9162 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 9173 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
9163 if (token_stream.IsNull()) { | 9174 if (token_stream.IsNull()) { |
9164 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); | 9175 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
9165 return String::null(); | 9176 return String::null(); |
9166 } | 9177 } |
9167 return token_stream.GenerateSource(); | 9178 return token_stream.GenerateSource(); |
9168 } | 9179 } |
9169 | 9180 |
9170 | 9181 |
9171 void Script::set_compile_time_constants(const Array& value) const { | 9182 void Script::set_compile_time_constants(const Array& value) const { |
9172 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); | 9183 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); |
9173 } | 9184 } |
9174 | 9185 |
9175 | 9186 |
9176 void Script::set_kernel_data(const uint8_t* kernel_data) const { | 9187 void Script::set_kernel_data(const uint8_t* kernel_data) const { |
9177 StoreNonPointer(&raw_ptr()->kernel_data_, kernel_data); | 9188 StoreNonPointer(&raw_ptr()->kernel_data_, kernel_data); |
9178 } | 9189 } |
9179 | 9190 |
9180 | 9191 |
9181 void Script::set_kernel_data_size(const intptr_t kernel_data_size) const { | 9192 void Script::set_kernel_data_size(const intptr_t kernel_data_size) const { |
9182 StoreNonPointer(&raw_ptr()->kernel_data_size_, kernel_data_size); | 9193 StoreNonPointer(&raw_ptr()->kernel_data_size_, kernel_data_size); |
9183 } | 9194 } |
9184 | 9195 |
9185 | 9196 |
| 9197 void Script::set_kernel_script_index(const intptr_t kernel_script_index) const { |
| 9198 StoreNonPointer(&raw_ptr()->kernel_script_index_, kernel_script_index); |
| 9199 } |
| 9200 |
| 9201 |
9186 void Script::set_kernel_string_offsets(const TypedData& offsets) const { | 9202 void Script::set_kernel_string_offsets(const TypedData& offsets) const { |
9187 StorePointer(&raw_ptr()->kernel_string_offsets_, offsets.raw()); | 9203 StorePointer(&raw_ptr()->kernel_string_offsets_, offsets.raw()); |
9188 } | 9204 } |
9189 | 9205 |
9190 | 9206 |
9191 void Script::set_kernel_string_data(const TypedData& data) const { | 9207 void Script::set_kernel_string_data(const TypedData& data) const { |
9192 StorePointer(&raw_ptr()->kernel_string_data_, data.raw()); | 9208 StorePointer(&raw_ptr()->kernel_string_data_, data.raw()); |
9193 } | 9209 } |
9194 | 9210 |
9195 | 9211 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9370 | 9386 |
9371 | 9387 |
9372 void Script::set_debug_positions(const Array& value) const { | 9388 void Script::set_debug_positions(const Array& value) const { |
9373 StorePointer(&raw_ptr()->debug_positions_, value.raw()); | 9389 StorePointer(&raw_ptr()->debug_positions_, value.raw()); |
9374 } | 9390 } |
9375 | 9391 |
9376 void Script::set_yield_positions(const Array& value) const { | 9392 void Script::set_yield_positions(const Array& value) const { |
9377 StorePointer(&raw_ptr()->yield_positions_, value.raw()); | 9393 StorePointer(&raw_ptr()->yield_positions_, value.raw()); |
9378 } | 9394 } |
9379 | 9395 |
| 9396 RawArray* Script::yield_positions() const { |
| 9397 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9398 Array& yields = Array::Handle(raw_ptr()->yield_positions_); |
| 9399 if (yields.IsNull() && kind() == RawScript::kKernelTag) { |
| 9400 // This is created lazily. Now we need it. |
| 9401 kernel::CollectTokenPositionsFor(*this); |
| 9402 } |
| 9403 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 9404 return raw_ptr()->yield_positions_; |
| 9405 } |
| 9406 |
| 9407 |
| 9408 RawArray* Script::line_starts() const { |
| 9409 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9410 const Array& line_starts_array = Array::Handle(raw_ptr()->line_starts_); |
| 9411 if (line_starts_array.IsNull() && kind() == RawScript::kKernelTag) { |
| 9412 // This is created lazily. Now we need it. |
| 9413 set_line_starts(kernel::GetLineStartsFor(*this)); |
| 9414 } |
| 9415 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 9416 return raw_ptr()->line_starts_; |
| 9417 } |
| 9418 |
| 9419 |
| 9420 RawArray* Script::debug_positions() const { |
| 9421 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9422 Array& debug_positions_array = Array::Handle(raw_ptr()->debug_positions_); |
| 9423 if (debug_positions_array.IsNull() && kind() == RawScript::kKernelTag) { |
| 9424 // This is created lazily. Now we need it. |
| 9425 kernel::CollectTokenPositionsFor(*this); |
| 9426 } |
| 9427 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 9428 return raw_ptr()->debug_positions_; |
| 9429 } |
| 9430 |
9380 void Script::set_kind(RawScript::Kind value) const { | 9431 void Script::set_kind(RawScript::Kind value) const { |
9381 StoreNonPointer(&raw_ptr()->kind_, value); | 9432 StoreNonPointer(&raw_ptr()->kind_, value); |
9382 } | 9433 } |
9383 | 9434 |
9384 | 9435 |
9385 void Script::set_load_timestamp(int64_t value) const { | 9436 void Script::set_load_timestamp(int64_t value) const { |
9386 StoreNonPointer(&raw_ptr()->load_timestamp_, value); | 9437 StoreNonPointer(&raw_ptr()->load_timestamp_, value); |
9387 } | 9438 } |
9388 | 9439 |
9389 | 9440 |
(...skipping 14112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23502 return UserTag::null(); | 23553 return UserTag::null(); |
23503 } | 23554 } |
23504 | 23555 |
23505 | 23556 |
23506 const char* UserTag::ToCString() const { | 23557 const char* UserTag::ToCString() const { |
23507 const String& tag_label = String::Handle(label()); | 23558 const String& tag_label = String::Handle(label()); |
23508 return tag_label.ToCString(); | 23559 return tag_label.ToCString(); |
23509 } | 23560 } |
23510 | 23561 |
23511 } // namespace dart | 23562 } // namespace dart |
OLD | NEW |