Index: runtime/vm/dart_api_impl.cc |
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
index f6f3ab841fbf2278defc14a570a591ded15f02dd..393a9ae8f0ae96c14c1e2ddc9696f6f874238249 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -17,6 +17,7 @@ |
#include "vm/dart_api_state.h" |
#include "vm/dart_entry.h" |
#include "vm/debugger.h" |
+#include "vm/dil_reader.h" |
#include "vm/exceptions.h" |
#include "vm/flags.h" |
#include "vm/growable_array.h" |
@@ -5392,6 +5393,35 @@ DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer, |
} |
+DART_EXPORT Dart_Handle Dart_LoadKernel(const uint8_t* buffer, |
+ intptr_t buffer_len) { |
+ API_TIMELINE_DURATION; |
+ DARTSCOPE(Thread::Current()); |
+ Isolate* I = T->isolate(); |
+ StackZone zone(T); |
+ |
+ Library& library = Library::Handle(Z, I->object_store()->root_library()); |
+ if (!library.IsNull()) { |
+ const String& library_url = String::Handle(Z, library.url()); |
+ return Api::NewError("%s: A script has already been loaded from '%s'.", |
+ CURRENT_FUNC, library_url.ToCString()); |
+ } |
+ CHECK_CALLBACK_STATE(T); |
+ CHECK_COMPILATION_ALLOWED(I); |
+ |
+ // TODO(kustermann): Memory leak! |
+ dil::DilReader* reader = new dil::DilReader(buffer, buffer_len); |
+ const Object& tmp = reader->ReadProgram(); |
+ if (tmp.IsError()) { |
+ return Api::NewHandle(T, tmp.raw()); |
+ } |
+ library ^= tmp.raw(); |
+ library.set_debuggable(false); |
+ I->object_store()->set_root_library(library); |
+ return Api::NewHandle(T, library.raw()); |
+} |
+ |
+ |
DART_EXPORT Dart_Handle Dart_RootLibrary() { |
Thread* thread = Thread::Current(); |
Isolate* isolate = thread->isolate(); |