Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 52c92e2face95c1fb801fa3d09b2d09cd3cd95a8..cb9bbeadbc51d8631a8fc3180958b87ca5ea549b 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -9140,7 +9140,12 @@ RawString* TokenStream::Iterator::MakeLiteralToken(const Object& obj) const { |
bool Script::HasSource() const { |
+#if !defined(DART_PRECOMPILED_RUNTIME) |
+ return kind() == RawScript::kKernelTag || |
+ raw_ptr()->source_ != String::null(); |
+#else // !defined(DART_PRECOMPILED_RUNTIME) |
return raw_ptr()->source_ != String::null(); |
+#endif // !defined(DART_PRECOMPILED_RUNTIME) |
} |
@@ -9154,10 +9159,16 @@ RawString* Script::Source() const { |
RawString* Script::GenerateSource() const { |
+#if !defined(DART_PRECOMPILED_RUNTIME) |
if (kind() == RawScript::kKernelTag) { |
- // In kernel it's embedded. |
+ String& source = String::Handle(raw_ptr()->source_); |
+ if (source.IsNull()) { |
+ // This is created lazily. Now we need it. |
+ set_source(kernel::GetSourceFor(*this)); |
+ } |
return raw_ptr()->source_; |
} |
+#endif // !defined(DART_PRECOMPILED_RUNTIME) |
const TokenStream& token_stream = TokenStream::Handle(tokens()); |
if (token_stream.IsNull()) { |
@@ -9183,6 +9194,11 @@ void Script::set_kernel_data_size(const intptr_t kernel_data_size) const { |
} |
+void Script::set_kernel_script_index(const intptr_t kernel_script_index) const { |
+ StoreNonPointer(&raw_ptr()->kernel_script_index_, kernel_script_index); |
+} |
+ |
+ |
void Script::set_kernel_string_offsets(const TypedData& offsets) const { |
StorePointer(&raw_ptr()->kernel_string_offsets_, offsets.raw()); |
} |
@@ -9377,6 +9393,41 @@ void Script::set_yield_positions(const Array& value) const { |
StorePointer(&raw_ptr()->yield_positions_, value.raw()); |
} |
+RawArray* Script::yield_positions() const { |
+#if !defined(DART_PRECOMPILED_RUNTIME) |
+ Array& yields = Array::Handle(raw_ptr()->yield_positions_); |
+ if (yields.IsNull() && kind() == RawScript::kKernelTag) { |
+ // This is created lazily. Now we need it. |
+ kernel::CollectTokenPositionsFor(*this); |
+ } |
+#endif // !defined(DART_PRECOMPILED_RUNTIME) |
+ return raw_ptr()->yield_positions_; |
+} |
+ |
+ |
+RawArray* Script::line_starts() const { |
+#if !defined(DART_PRECOMPILED_RUNTIME) |
+ const Array& line_starts_array = Array::Handle(raw_ptr()->line_starts_); |
+ if (line_starts_array.IsNull() && kind() == RawScript::kKernelTag) { |
+ // This is created lazily. Now we need it. |
+ set_line_starts(kernel::GetLineStartsFor(*this)); |
+ } |
+#endif // !defined(DART_PRECOMPILED_RUNTIME) |
+ return raw_ptr()->line_starts_; |
+} |
+ |
+ |
+RawArray* Script::debug_positions() const { |
+#if !defined(DART_PRECOMPILED_RUNTIME) |
+ Array& debug_positions_array = Array::Handle(raw_ptr()->debug_positions_); |
+ if (debug_positions_array.IsNull() && kind() == RawScript::kKernelTag) { |
+ // This is created lazily. Now we need it. |
+ kernel::CollectTokenPositionsFor(*this); |
+ } |
+#endif // !defined(DART_PRECOMPILED_RUNTIME) |
+ return raw_ptr()->debug_positions_; |
+} |
+ |
void Script::set_kind(RawScript::Kind value) const { |
StoreNonPointer(&raw_ptr()->kind_, value); |
} |