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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 | 1418 |
1419 | 1419 |
1420 DART_EXPORT Dart_Handle Dart_CreateSnapshot( | 1420 DART_EXPORT Dart_Handle Dart_CreateSnapshot( |
1421 uint8_t** vm_isolate_snapshot_buffer, | 1421 uint8_t** vm_isolate_snapshot_buffer, |
1422 intptr_t* vm_isolate_snapshot_size, | 1422 intptr_t* vm_isolate_snapshot_size, |
1423 uint8_t** isolate_snapshot_buffer, | 1423 uint8_t** isolate_snapshot_buffer, |
1424 intptr_t* isolate_snapshot_size) { | 1424 intptr_t* isolate_snapshot_size) { |
1425 Isolate* isolate = Isolate::Current(); | 1425 Isolate* isolate = Isolate::Current(); |
1426 DARTSCOPE(isolate); | 1426 DARTSCOPE(isolate); |
1427 TIMERSCOPE(isolate, time_creating_snapshot); | 1427 TIMERSCOPE(isolate, time_creating_snapshot); |
1428 if (vm_isolate_snapshot_buffer == NULL) { | 1428 if (vm_isolate_snapshot_buffer != NULL && |
1429 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); | 1429 vm_isolate_snapshot_size == NULL) { |
1430 } | |
1431 if (vm_isolate_snapshot_size == NULL) { | |
1432 RETURN_NULL_ERROR(vm_isolate_snapshot_size); | 1430 RETURN_NULL_ERROR(vm_isolate_snapshot_size); |
1433 } | 1431 } |
1434 if (isolate_snapshot_buffer == NULL) { | 1432 if (isolate_snapshot_buffer == NULL) { |
1435 RETURN_NULL_ERROR(isolate_snapshot_buffer); | 1433 RETURN_NULL_ERROR(isolate_snapshot_buffer); |
1436 } | 1434 } |
1437 if (isolate_snapshot_size == NULL) { | 1435 if (isolate_snapshot_size == NULL) { |
1438 RETURN_NULL_ERROR(isolate_snapshot_size); | 1436 RETURN_NULL_ERROR(isolate_snapshot_size); |
1439 } | 1437 } |
1440 // Finalize all classes if needed. | 1438 // Finalize all classes if needed. |
1441 Dart_Handle state = Api::CheckAndFinalizePendingClasses(isolate); | 1439 Dart_Handle state = Api::CheckAndFinalizePendingClasses(isolate); |
(...skipping 3627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5069 } | 5067 } |
5070 Library& library = | 5068 Library& library = |
5071 Library::Handle(isolate, isolate->object_store()->root_library()); | 5069 Library::Handle(isolate, isolate->object_store()->root_library()); |
5072 if (!library.IsNull()) { | 5070 if (!library.IsNull()) { |
5073 const String& library_url = String::Handle(isolate, library.url()); | 5071 const String& library_url = String::Handle(isolate, library.url()); |
5074 return Api::NewError("%s: A script has already been loaded from '%s'.", | 5072 return Api::NewError("%s: A script has already been loaded from '%s'.", |
5075 CURRENT_FUNC, library_url.ToCString()); | 5073 CURRENT_FUNC, library_url.ToCString()); |
5076 } | 5074 } |
5077 CHECK_CALLBACK_STATE(isolate); | 5075 CHECK_CALLBACK_STATE(isolate); |
5078 | 5076 |
5079 SnapshotReader reader(snapshot->content(), | 5077 ASSERT(snapshot->kind() == Snapshot::kScript); |
5080 snapshot->length(), | 5078 ScriptSnapshotReader reader(snapshot->content(), |
5081 snapshot->kind(), | 5079 snapshot->length(), |
5082 isolate, | 5080 isolate, |
5083 zone.GetZone()); | 5081 zone.GetZone()); |
5084 const Object& tmp = Object::Handle(isolate, reader.ReadScriptSnapshot()); | 5082 const Object& tmp = Object::Handle(isolate, reader.ReadScriptSnapshot()); |
5085 if (tmp.IsError()) { | 5083 if (tmp.IsError()) { |
5086 return Api::NewHandle(isolate, tmp.raw()); | 5084 return Api::NewHandle(isolate, tmp.raw()); |
5087 } | 5085 } |
5088 library ^= tmp.raw(); | 5086 library ^= tmp.raw(); |
5089 library.set_debuggable(true); | 5087 library.set_debuggable(true); |
5090 isolate->object_store()->set_root_library(library); | 5088 isolate->object_store()->set_root_library(library); |
5091 return Api::NewHandle(isolate, library.raw()); | 5089 return Api::NewHandle(isolate, library.raw()); |
5092 } | 5090 } |
5093 | 5091 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5570 | 5568 |
5571 | 5569 |
5572 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5570 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
5573 const char* name, | 5571 const char* name, |
5574 Dart_ServiceRequestCallback callback, | 5572 Dart_ServiceRequestCallback callback, |
5575 void* user_data) { | 5573 void* user_data) { |
5576 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5574 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
5577 } | 5575 } |
5578 | 5576 |
5579 } // namespace dart | 5577 } // namespace dart |
OLD | NEW |