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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 static char* String2UTF8(const String& str) { | 226 static char* String2UTF8(const String& str) { |
227 intptr_t len = Utf8::Length(str); | 227 intptr_t len = Utf8::Length(str); |
228 char* result = new char[len + 1]; | 228 char* result = new char[len + 1]; |
229 str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); | 229 str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); |
230 result[len] = 0; | 230 result[len] = 0; |
231 | 231 |
232 return result; | 232 return result; |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 static char* CanonicalizeUri(Isolate* isolate, | 236 static char* CanonicalizeUri(Thread* thread, |
237 const Library& library, | 237 const Library& library, |
238 const String& uri, | 238 const String& uri, |
239 char** error) { | 239 char** error) { |
240 char* result = NULL; | 240 char* result = NULL; |
241 Zone* zone = isolate->current_zone(); | 241 Zone* zone = thread->zone(); |
| 242 Isolate* isolate = thread->isolate(); |
242 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); | 243 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); |
243 if (handler != NULL) { | 244 if (handler != NULL) { |
244 Dart_EnterScope(); | 245 Dart_EnterScope(); |
245 Dart_Handle handle = handler(Dart_kCanonicalizeUrl, | 246 Dart_Handle handle = handler(Dart_kCanonicalizeUrl, |
246 Api::NewHandle(isolate, library.raw()), | 247 Api::NewHandle(isolate, library.raw()), |
247 Api::NewHandle(isolate, uri.raw())); | 248 Api::NewHandle(isolate, uri.raw())); |
248 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); | 249 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
249 if (obj.IsString()) { | 250 if (obj.IsString()) { |
250 result = String2UTF8(String::Cast(obj)); | 251 result = String2UTF8(String::Cast(obj)); |
251 } else if (obj.IsError()) { | 252 } else if (obj.IsError()) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 GET_NATIVE_ARGUMENT(Array, environment, arguments->NativeArgAt(9)); | 286 GET_NATIVE_ARGUMENT(Array, environment, arguments->NativeArgAt(9)); |
286 | 287 |
287 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(10)); | 288 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(10)); |
288 GET_NATIVE_ARGUMENT(Array, packages, arguments->NativeArgAt(11)); | 289 GET_NATIVE_ARGUMENT(Array, packages, arguments->NativeArgAt(11)); |
289 | 290 |
290 | 291 |
291 // Canonicalize the uri with respect to the current isolate. | 292 // Canonicalize the uri with respect to the current isolate. |
292 const Library& root_lib = | 293 const Library& root_lib = |
293 Library::Handle(isolate->object_store()->root_library()); | 294 Library::Handle(isolate->object_store()->root_library()); |
294 char* error = NULL; | 295 char* error = NULL; |
295 char* canonical_uri = CanonicalizeUri(isolate, root_lib, uri, &error); | 296 char* canonical_uri = CanonicalizeUri(thread, root_lib, uri, &error); |
296 if (canonical_uri == NULL) { | 297 if (canonical_uri == NULL) { |
297 const String& msg = String::Handle(String::New(error)); | 298 const String& msg = String::Handle(String::New(error)); |
298 ThrowIsolateSpawnException(msg); | 299 ThrowIsolateSpawnException(msg); |
299 } | 300 } |
300 | 301 |
301 char* utf8_package_root = | 302 char* utf8_package_root = |
302 package_root.IsNull() ? NULL : String2UTF8(package_root); | 303 package_root.IsNull() ? NULL : String2UTF8(package_root); |
303 | 304 |
304 char** utf8_package_map = NULL; | 305 char** utf8_package_map = NULL; |
305 if (!packages.IsNull()) { | 306 if (!packages.IsNull()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 MessageWriter writer(&data, &allocator, false); | 369 MessageWriter writer(&data, &allocator, false); |
369 writer.WriteMessage(msg); | 370 writer.WriteMessage(msg); |
370 | 371 |
371 PortMap::PostMessage(new Message(port.Id(), | 372 PortMap::PostMessage(new Message(port.Id(), |
372 data, writer.BytesWritten(), | 373 data, writer.BytesWritten(), |
373 Message::kOOBPriority)); | 374 Message::kOOBPriority)); |
374 return Object::null(); | 375 return Object::null(); |
375 } | 376 } |
376 | 377 |
377 } // namespace dart | 378 } // namespace dart |
OLD | NEW |