| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 5057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5068 } | 5068 } |
| 5069 if (line_offset < 0) { | 5069 if (line_offset < 0) { |
| 5070 return Api::NewError("%s: argument 'line_offset' must be positive number", | 5070 return Api::NewError("%s: argument 'line_offset' must be positive number", |
| 5071 CURRENT_FUNC); | 5071 CURRENT_FUNC); |
| 5072 } | 5072 } |
| 5073 if (column_offset < 0) { | 5073 if (column_offset < 0) { |
| 5074 return Api::NewError("%s: argument 'column_offset' must be positive number", | 5074 return Api::NewError("%s: argument 'column_offset' must be positive number", |
| 5075 CURRENT_FUNC); | 5075 CURRENT_FUNC); |
| 5076 } | 5076 } |
| 5077 CHECK_CALLBACK_STATE(I); | 5077 CHECK_CALLBACK_STATE(I); |
| 5078 CHECK_COMPILATION_ALLOWED(I); |
| 5078 | 5079 |
| 5079 NoHeapGrowthControlScope no_growth_control; | 5080 NoHeapGrowthControlScope no_growth_control; |
| 5080 | 5081 |
| 5081 library = Library::New(url_str); | 5082 library = Library::New(url_str); |
| 5082 library.set_debuggable(true); | 5083 library.set_debuggable(true); |
| 5083 library.Register(); | 5084 library.Register(); |
| 5084 I->object_store()->set_root_library(library); | 5085 I->object_store()->set_root_library(library); |
| 5085 | 5086 |
| 5086 const Script& script = Script::Handle(Z, | 5087 const Script& script = Script::Handle(Z, |
| 5087 Script::New(url_str, source_str, RawScript::kScriptTag)); | 5088 Script::New(url_str, source_str, RawScript::kScriptTag)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5111 " which is the expected length in the snapshot.", | 5112 " which is the expected length in the snapshot.", |
| 5112 CURRENT_FUNC, buffer_len, snapshot->length()); | 5113 CURRENT_FUNC, buffer_len, snapshot->length()); |
| 5113 } | 5114 } |
| 5114 Library& library = Library::Handle(Z, I->object_store()->root_library()); | 5115 Library& library = Library::Handle(Z, I->object_store()->root_library()); |
| 5115 if (!library.IsNull()) { | 5116 if (!library.IsNull()) { |
| 5116 const String& library_url = String::Handle(Z, library.url()); | 5117 const String& library_url = String::Handle(Z, library.url()); |
| 5117 return Api::NewError("%s: A script has already been loaded from '%s'.", | 5118 return Api::NewError("%s: A script has already been loaded from '%s'.", |
| 5118 CURRENT_FUNC, library_url.ToCString()); | 5119 CURRENT_FUNC, library_url.ToCString()); |
| 5119 } | 5120 } |
| 5120 CHECK_CALLBACK_STATE(I); | 5121 CHECK_CALLBACK_STATE(I); |
| 5122 CHECK_COMPILATION_ALLOWED(I); |
| 5121 | 5123 |
| 5122 ASSERT(snapshot->kind() == Snapshot::kScript); | 5124 ASSERT(snapshot->kind() == Snapshot::kScript); |
| 5123 ScriptSnapshotReader reader(snapshot->content(), snapshot->length(), T); | 5125 ScriptSnapshotReader reader(snapshot->content(), snapshot->length(), T); |
| 5124 const Object& tmp = Object::Handle(Z, reader.ReadScriptSnapshot()); | 5126 const Object& tmp = Object::Handle(Z, reader.ReadScriptSnapshot()); |
| 5125 if (tmp.IsError()) { | 5127 if (tmp.IsError()) { |
| 5126 return Api::NewHandle(I, tmp.raw()); | 5128 return Api::NewHandle(I, tmp.raw()); |
| 5127 } | 5129 } |
| 5128 library ^= tmp.raw(); | 5130 library ^= tmp.raw(); |
| 5129 library.set_debuggable(true); | 5131 library.set_debuggable(true); |
| 5130 I->object_store()->set_root_library(library); | 5132 I->object_store()->set_root_library(library); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5304 } | 5306 } |
| 5305 if (line_offset < 0) { | 5307 if (line_offset < 0) { |
| 5306 return Api::NewError("%s: argument 'line_offset' must be positive number", | 5308 return Api::NewError("%s: argument 'line_offset' must be positive number", |
| 5307 CURRENT_FUNC); | 5309 CURRENT_FUNC); |
| 5308 } | 5310 } |
| 5309 if (column_offset < 0) { | 5311 if (column_offset < 0) { |
| 5310 return Api::NewError("%s: argument 'column_offset' must be positive number", | 5312 return Api::NewError("%s: argument 'column_offset' must be positive number", |
| 5311 CURRENT_FUNC); | 5313 CURRENT_FUNC); |
| 5312 } | 5314 } |
| 5313 CHECK_CALLBACK_STATE(I); | 5315 CHECK_CALLBACK_STATE(I); |
| 5316 CHECK_COMPILATION_ALLOWED(I); |
| 5314 | 5317 |
| 5315 NoHeapGrowthControlScope no_growth_control; | 5318 NoHeapGrowthControlScope no_growth_control; |
| 5316 | 5319 |
| 5317 Library& library = Library::Handle(Z, Library::LookupLibrary(url_str)); | 5320 Library& library = Library::Handle(Z, Library::LookupLibrary(url_str)); |
| 5318 if (library.IsNull()) { | 5321 if (library.IsNull()) { |
| 5319 library = Library::New(url_str); | 5322 library = Library::New(url_str); |
| 5320 library.Register(); | 5323 library.Register(); |
| 5321 } else if (library.LoadInProgress() || | 5324 } else if (library.LoadInProgress() || |
| 5322 library.Loaded() || | 5325 library.Loaded() || |
| 5323 library.LoadFailed()) { | 5326 library.LoadFailed()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 RETURN_TYPE_ERROR(I, import, Library); | 5364 RETURN_TYPE_ERROR(I, import, Library); |
| 5362 } | 5365 } |
| 5363 const Object& prefix_object = Object::Handle(Z, Api::UnwrapHandle(prefix)); | 5366 const Object& prefix_object = Object::Handle(Z, Api::UnwrapHandle(prefix)); |
| 5364 const String& prefix_vm = prefix_object.IsNull() | 5367 const String& prefix_vm = prefix_object.IsNull() |
| 5365 ? Symbols::Empty() | 5368 ? Symbols::Empty() |
| 5366 : String::Cast(prefix_object); | 5369 : String::Cast(prefix_object); |
| 5367 if (prefix_vm.IsNull()) { | 5370 if (prefix_vm.IsNull()) { |
| 5368 RETURN_TYPE_ERROR(I, prefix, String); | 5371 RETURN_TYPE_ERROR(I, prefix, String); |
| 5369 } | 5372 } |
| 5370 CHECK_CALLBACK_STATE(I); | 5373 CHECK_CALLBACK_STATE(I); |
| 5374 CHECK_COMPILATION_ALLOWED(I); |
| 5371 | 5375 |
| 5372 const String& prefix_symbol = String::Handle(Z, Symbols::New(prefix_vm)); | 5376 const String& prefix_symbol = String::Handle(Z, Symbols::New(prefix_vm)); |
| 5373 const Namespace& import_ns = Namespace::Handle(Z, | 5377 const Namespace& import_ns = Namespace::Handle(Z, |
| 5374 Namespace::New(import_vm, Object::null_array(), Object::null_array())); | 5378 Namespace::New(import_vm, Object::null_array(), Object::null_array())); |
| 5375 if (prefix_vm.Length() == 0) { | 5379 if (prefix_vm.Length() == 0) { |
| 5376 library_vm.AddImport(import_ns); | 5380 library_vm.AddImport(import_ns); |
| 5377 } else { | 5381 } else { |
| 5378 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); | 5382 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); |
| 5379 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol); | 5383 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol); |
| 5380 if (!library_prefix.IsNull()) { | 5384 if (!library_prefix.IsNull()) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5409 } | 5413 } |
| 5410 if (line_offset < 0) { | 5414 if (line_offset < 0) { |
| 5411 return Api::NewError("%s: argument 'line_offset' must be positive number", | 5415 return Api::NewError("%s: argument 'line_offset' must be positive number", |
| 5412 CURRENT_FUNC); | 5416 CURRENT_FUNC); |
| 5413 } | 5417 } |
| 5414 if (column_offset < 0) { | 5418 if (column_offset < 0) { |
| 5415 return Api::NewError("%s: argument 'column_offset' must be positive number", | 5419 return Api::NewError("%s: argument 'column_offset' must be positive number", |
| 5416 CURRENT_FUNC); | 5420 CURRENT_FUNC); |
| 5417 } | 5421 } |
| 5418 CHECK_CALLBACK_STATE(I); | 5422 CHECK_CALLBACK_STATE(I); |
| 5423 CHECK_COMPILATION_ALLOWED(I); |
| 5419 | 5424 |
| 5420 NoHeapGrowthControlScope no_growth_control; | 5425 NoHeapGrowthControlScope no_growth_control; |
| 5421 | 5426 |
| 5422 const Script& script = Script::Handle(Z, | 5427 const Script& script = Script::Handle(Z, |
| 5423 Script::New(url_str, source_str, RawScript::kSourceTag)); | 5428 Script::New(url_str, source_str, RawScript::kSourceTag)); |
| 5424 script.SetLocationOffset(line_offset, column_offset); | 5429 script.SetLocationOffset(line_offset, column_offset); |
| 5425 Dart_Handle result; | 5430 Dart_Handle result; |
| 5426 CompileSource(I, lib, script, &result); | 5431 CompileSource(I, lib, script, &result); |
| 5427 return result; | 5432 return result; |
| 5428 } | 5433 } |
| 5429 | 5434 |
| 5430 | 5435 |
| 5431 DART_EXPORT Dart_Handle Dart_LibraryLoadPatch(Dart_Handle library, | 5436 DART_EXPORT Dart_Handle Dart_LibraryLoadPatch(Dart_Handle library, |
| 5432 Dart_Handle url, | 5437 Dart_Handle url, |
| 5433 Dart_Handle patch_source) { | 5438 Dart_Handle patch_source) { |
| 5434 DARTSCOPE(Thread::Current()); | 5439 DARTSCOPE(Thread::Current()); |
| 5435 const Library& lib = Api::UnwrapLibraryHandle(I, library); | 5440 const Library& lib = Api::UnwrapLibraryHandle(I, library); |
| 5436 if (lib.IsNull()) { | 5441 if (lib.IsNull()) { |
| 5437 RETURN_TYPE_ERROR(I, library, Library); | 5442 RETURN_TYPE_ERROR(I, library, Library); |
| 5438 } | 5443 } |
| 5439 const String& url_str = Api::UnwrapStringHandle(I, url); | 5444 const String& url_str = Api::UnwrapStringHandle(I, url); |
| 5440 if (url_str.IsNull()) { | 5445 if (url_str.IsNull()) { |
| 5441 RETURN_TYPE_ERROR(I, url, String); | 5446 RETURN_TYPE_ERROR(I, url, String); |
| 5442 } | 5447 } |
| 5443 const String& source_str = Api::UnwrapStringHandle(I, patch_source); | 5448 const String& source_str = Api::UnwrapStringHandle(I, patch_source); |
| 5444 if (source_str.IsNull()) { | 5449 if (source_str.IsNull()) { |
| 5445 RETURN_TYPE_ERROR(I, patch_source, String); | 5450 RETURN_TYPE_ERROR(I, patch_source, String); |
| 5446 } | 5451 } |
| 5447 CHECK_CALLBACK_STATE(I); | 5452 CHECK_CALLBACK_STATE(I); |
| 5453 CHECK_COMPILATION_ALLOWED(I); |
| 5448 | 5454 |
| 5449 NoHeapGrowthControlScope no_growth_control; | 5455 NoHeapGrowthControlScope no_growth_control; |
| 5450 | 5456 |
| 5451 const Script& script = Script::Handle(Z, | 5457 const Script& script = Script::Handle(Z, |
| 5452 Script::New(url_str, source_str, RawScript::kPatchTag)); | 5458 Script::New(url_str, source_str, RawScript::kPatchTag)); |
| 5453 Dart_Handle result; | 5459 Dart_Handle result; |
| 5454 CompileSource(I, lib, script, &result); | 5460 CompileSource(I, lib, script, &result); |
| 5455 return result; | 5461 return result; |
| 5456 } | 5462 } |
| 5457 | 5463 |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6055 ApiReallocate); | 6061 ApiReallocate); |
| 6056 writer.WriteFullSnapshot(); | 6062 writer.WriteFullSnapshot(); |
| 6057 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6063 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 6058 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6064 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 6059 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 6065 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 6060 | 6066 |
| 6061 return Api::Success(); | 6067 return Api::Success(); |
| 6062 } | 6068 } |
| 6063 | 6069 |
| 6064 } // namespace dart | 6070 } // namespace dart |
| OLD | NEW |