Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Changes based on feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/kernel_reader.cc
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index d11e931e529e27a84b6c13ab68a19e5910b13921..955b88b7c5b66e8bda013ed7f1251de77446fdb1 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -103,7 +103,7 @@ KernelReader::KernelReader(Program* program)
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/false) {
- intptr_t source_file_count = program_->line_starting_table().size();
+ intptr_t source_file_count = program_->source_table().size();
scripts_ = Array::New(source_file_count, Heap::kOld);
}
@@ -158,7 +158,8 @@ void KernelReader::ReadLibrary(Library* kernel_library) {
}
// Setup toplevel class (which contains library fields/procedures).
- Script& script = ScriptAt(kernel_library->source_uri_index());
+ Script& script = ScriptAt(kernel_library->source_uri_index(),
+ kernel_library->import_uri());
dart::Class& toplevel_class = dart::Class::Handle(
Z, dart::Class::New(library, Symbols::TopLevel(), script,
TokenPosition::kNoSource));
@@ -322,7 +323,8 @@ dart::Class& KernelReader::ReadClass(const dart::Library& library,
false, // is_abstract
kernel_constructor->IsExternal(),
false, // is_native
- klass, TokenPosition::kNoSource));
+ klass, TokenPosition::kMinSource));
+ function.set_end_token_pos(TokenPosition::kMinSource);
klass.AddFunction(function);
function.set_kernel_function(kernel_constructor);
function.set_result_type(T.ReceiverType(klass));
@@ -399,7 +401,8 @@ void KernelReader::ReadProcedure(const dart::Library& library,
false, // is_const
is_abstract, is_external,
native_name != NULL, // is_native
- script_class, TokenPosition::kNoSource));
+ script_class, TokenPosition::kMinSource));
+ function.set_end_token_pos(TokenPosition::kMinSource);
Cutch 2016/12/21 00:27:12 Observatory relies on knowing start / end token po
owner.AddFunction(function);
function.set_kernel_function(kernel_procedure);
function.set_is_debuggable(false);
@@ -430,21 +433,30 @@ const Object& KernelReader::ClassForScriptAt(const dart::Class& klass,
return klass;
}
-Script& KernelReader::ScriptAt(intptr_t source_uri_index) {
+Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) {
Script& script = Script::ZoneHandle(Z);
script ^= scripts_.At(source_uri_index);
if (script.IsNull()) {
+ // Create script with correct uri(s).
String* uri = program_->source_uri_table().strings()[source_uri_index];
- script = Script::New(H.DartString(uri, Heap::kOld),
- dart::String::ZoneHandle(Z), RawScript::kKernelTag);
+ dart::String& uri_string = H.DartString(uri, Heap::kOld);
+ dart::String& import_uri_string =
+ import_uri == NULL ? uri_string : H.DartString(import_uri, Heap::kOld);
+ dart::String& source_code = H.DartString(
+ program_->source_table().SourceFor(source_uri_index), Heap::kOld);
+ script = Script::New(import_uri_string, uri_string, source_code,
+ RawScript::kKernelTag);
scripts_.SetAt(source_uri_index, script);
+
+ // Create line_starts array for the script.
intptr_t* line_starts =
- program_->line_starting_table().valuesFor(source_uri_index);
- intptr_t line_count = line_starts[0];
+ program_->source_table().LineStartsFor(source_uri_index);
+ intptr_t line_count =
+ program_->source_table().LineCountFor(source_uri_index);
Array& array_object = Array::Handle(Z, Array::New(line_count, Heap::kOld));
Smi& value = Smi::Handle(Z);
for (intptr_t i = 0; i < line_count; ++i) {
- value = Smi::New(line_starts[i + 1]);
+ value = Smi::New(line_starts[i]);
array_object.SetAt(i, value);
}
script.set_line_starts(array_object);
« no previous file with comments | « runtime/vm/kernel_reader.h ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698