OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 | 205 |
206 class SpawnState { | 206 class SpawnState { |
207 public: | 207 public: |
208 explicit SpawnState(const Function& func) | 208 explicit SpawnState(const Function& func) |
209 : isolate_(NULL), | 209 : isolate_(NULL), |
210 script_url_(NULL), | 210 script_url_(NULL), |
211 library_url_(NULL), | 211 library_url_(NULL), |
212 function_name_(NULL) { | 212 function_name_(NULL) { |
213 script_url_ = strdup(GetRootScriptUri(Isolate::Current())); | 213 script_url_ = strdup(GetRootScriptUri(Isolate::Current())); |
214 const Class& cls = Class::Handle(func.owner()); | 214 const Class& cls = Class::Handle(func.Owner()); |
215 ASSERT(cls.IsTopLevel()); | 215 ASSERT(cls.IsTopLevel()); |
216 const Library& lib = Library::Handle(cls.library()); | 216 const Library& lib = Library::Handle(cls.library()); |
217 const String& lib_url = String::Handle(lib.url()); | 217 const String& lib_url = String::Handle(lib.url()); |
218 library_url_ = strdup(lib_url.ToCString()); | 218 library_url_ = strdup(lib_url.ToCString()); |
219 | 219 |
220 const String& func_name = String::Handle(func.name()); | 220 const String& func_name = String::Handle(func.name()); |
221 function_name_ = strdup(func_name.ToCString()); | 221 function_name_ = strdup(func_name.ToCString()); |
222 } | 222 } |
223 | 223 |
224 explicit SpawnState(const char* script_url) | 224 explicit SpawnState(const char* script_url) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Dart::thread_pool(), RunIsolate, ShutdownIsolate, | 396 Dart::thread_pool(), RunIsolate, ShutdownIsolate, |
397 reinterpret_cast<uword>(state->isolate())); | 397 reinterpret_cast<uword>(state->isolate())); |
398 | 398 |
399 arguments->SetReturn(port); | 399 arguments->SetReturn(port); |
400 } | 400 } |
401 | 401 |
402 | 402 |
403 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) { | 403 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) { |
404 GET_NATIVE_ARGUMENT(Closure, closure, arguments->At(0)); | 404 GET_NATIVE_ARGUMENT(Closure, closure, arguments->At(0)); |
405 const Function& func = Function::Handle(closure.function()); | 405 const Function& func = Function::Handle(closure.function()); |
406 const Class& cls = Class::Handle(func.owner()); | 406 const Class& cls = Class::Handle(func.Owner()); |
407 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { | 407 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { |
408 const String& msg = String::Handle(String::New( | 408 const String& msg = String::Handle(String::New( |
409 "spawnFunction expects to be passed a closure to a top-level static " | 409 "spawnFunction expects to be passed a closure to a top-level static " |
410 "function")); | 410 "function")); |
411 ThrowIllegalArgException(msg); | 411 ThrowIllegalArgException(msg); |
412 } | 412 } |
413 | 413 |
414 #if defined(DEBUG) | 414 #if defined(DEBUG) |
415 const Context& ctx = Context::Handle(closure.context()); | 415 const Context& ctx = Context::Handle(closure.context()); |
416 ASSERT(ctx.num_variables() == 0); | 416 ASSERT(ctx.num_variables() == 0); |
(...skipping 24 matching lines...) Expand all Loading... |
441 | 441 |
442 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 442 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
443 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 443 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
444 if (port.IsError()) { | 444 if (port.IsError()) { |
445 Exceptions::PropagateError(Error::Cast(port)); | 445 Exceptions::PropagateError(Error::Cast(port)); |
446 } | 446 } |
447 arguments->SetReturn(port); | 447 arguments->SetReturn(port); |
448 } | 448 } |
449 | 449 |
450 } // namespace dart | 450 } // namespace dart |
OLD | NEW |