| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Lookup the target class by name, create an instance and call the run | 156 // Lookup the target class by name, create an instance and call the run |
| 157 // method. | 157 // method. |
| 158 const String& lib_name = String::Handle(String::NewSymbol(library_url)); | 158 const String& lib_name = String::Handle(String::NewSymbol(library_url)); |
| 159 const Library& lib = Library::Handle(Library::LookupLibrary(lib_name)); | 159 const Library& lib = Library::Handle(Library::LookupLibrary(lib_name)); |
| 160 ASSERT(!lib.IsNull()); | 160 ASSERT(!lib.IsNull()); |
| 161 const String& cls_name = String::Handle(String::NewSymbol(class_name)); | 161 const String& cls_name = String::Handle(String::NewSymbol(class_name)); |
| 162 const Class& target_class = Class::Handle(lib.LookupClass(cls_name)); | 162 const Class& target_class = Class::Handle(lib.LookupClass(cls_name)); |
| 163 // TODO(iposva): Deserialize or call the constructor after allocating. | 163 // TODO(iposva): Deserialize or call the constructor after allocating. |
| 164 // For now, we only support a non-parameterized or raw target class. | 164 // For now, we only support a non-parameterized or raw target class. |
| 165 const Instance& target = Instance::Handle(Instance::New(target_class)); | 165 const Instance& target = Instance::Handle(Instance::New(target_class)); |
| 166 Instance& result = Instance::Handle(); | 166 Object& result = Object::Handle(); |
| 167 | 167 |
| 168 // Invoke the default constructor. | 168 // Invoke the default constructor. |
| 169 const String& period = String::Handle(String::New(".")); | 169 const String& period = String::Handle(String::New(".")); |
| 170 String& constructor_name = String::Handle(String::Concat(cls_name, period)); | 170 String& constructor_name = String::Handle(String::Concat(cls_name, period)); |
| 171 const Function& default_constructor = | 171 const Function& default_constructor = |
| 172 Function::Handle(target_class.LookupConstructor(constructor_name)); | 172 Function::Handle(target_class.LookupConstructor(constructor_name)); |
| 173 if (!default_constructor.IsNull()) { | 173 if (!default_constructor.IsNull()) { |
| 174 GrowableArray<const Object*> arguments(1); | 174 GrowableArray<const Object*> arguments(1); |
| 175 arguments.Add(&target); | 175 arguments.Add(&target); |
| 176 arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); | 176 arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 200 target_function, | 200 target_function, |
| 201 arguments, | 201 arguments, |
| 202 kNoArgumentNames); | 202 kNoArgumentNames); |
| 203 if (result.IsUnhandledException()) { | 203 if (result.IsUnhandledException()) { |
| 204 UnhandledException& uhe = UnhandledException::Handle(); | 204 UnhandledException& uhe = UnhandledException::Handle(); |
| 205 uhe ^= result.raw(); | 205 uhe ^= result.raw(); |
| 206 ProcessUnhandledException(uhe); | 206 ProcessUnhandledException(uhe); |
| 207 } | 207 } |
| 208 ASSERT(result.IsNull()); | 208 ASSERT(result.IsNull()); |
| 209 free(class_name); | 209 free(class_name); |
| 210 isolate->StandardRunLoop(); | 210 result = isolate->StandardRunLoop(); |
| 211 if (result.IsUnhandledException()) { |
| 212 UnhandledException& uhe = UnhandledException::Handle(); |
| 213 uhe ^= result.raw(); |
| 214 ProcessUnhandledException(uhe); |
| 215 } |
| 216 ASSERT(result.IsNull()); |
| 211 | 217 |
| 212 } else { | 218 } else { |
| 213 Zone zone(isolate); | 219 Zone zone(isolate); |
| 214 HandleScope handle_scope(isolate); | 220 HandleScope handle_scope(isolate); |
| 215 const String& error = String::Handle( | 221 const String& error = String::Handle( |
| 216 Isolate::Current()->object_store()->sticky_error()); | 222 Isolate::Current()->object_store()->sticky_error()); |
| 217 const char* errmsg = error.ToCString(); | 223 const char* errmsg = error.ToCString(); |
| 218 fprintf(stderr, "%s\n", errmsg); | 224 fprintf(stderr, "%s\n", errmsg); |
| 219 exit(255); | 225 exit(255); |
| 220 } | 226 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); | 345 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 340 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 346 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 341 // TODO(iposva): Allow for arbitrary messages to be sent. | 347 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 342 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 348 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); |
| 343 | 349 |
| 344 // TODO(turnidge): Throw an exception when the return value is false? | 350 // TODO(turnidge): Throw an exception when the return value is false? |
| 345 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); | 351 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); |
| 346 } | 352 } |
| 347 | 353 |
| 348 } // namespace dart | 354 } // namespace dart |
| OLD | NEW |