| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 intptr_t len = (length); \ | 72 intptr_t len = (length); \ |
| 73 intptr_t max = (max_elements); \ | 73 intptr_t max = (max_elements); \ |
| 74 if (len < 0 || len > max) { \ | 74 if (len < 0 || len > max) { \ |
| 75 return Api::NewError( \ | 75 return Api::NewError( \ |
| 76 "%s expects argument '%s' to be in the range [0..%"Pd"].", \ | 76 "%s expects argument '%s' to be in the range [0..%"Pd"].", \ |
| 77 CURRENT_FUNC, #length, max); \ | 77 CURRENT_FUNC, #length, max); \ |
| 78 } \ | 78 } \ |
| 79 } while (0) | 79 } while (0) |
| 80 | 80 |
| 81 | 81 |
| 82 // Return error if isolate is in an inconsistent state. |
| 83 // Return NULL when no error condition exists. |
| 84 // |
| 85 // TODO(turnidge): Make this function return an error handle directly |
| 86 // rather than returning an error string. The current behavior can |
| 87 // cause compilation errors to appear to be api errors. |
| 88 const char* CheckIsolateState(Isolate* isolate) { |
| 89 if (ClassFinalizer::FinalizePendingClasses() && |
| 90 isolate->object_store()->PreallocateObjects()) { |
| 91 // Success. |
| 92 return NULL; |
| 93 } |
| 94 // Make a copy of the error message as the original message string |
| 95 // may get deallocated when we return back from the Dart API call. |
| 96 const Error& err = Error::Handle(isolate->object_store()->sticky_error()); |
| 97 const char* errmsg = err.ToErrorCString(); |
| 98 intptr_t errlen = strlen(errmsg) + 1; |
| 99 char* msg = Api::TopScope(isolate)->zone()->Alloc<char>(errlen); |
| 100 OS::SNPrint(msg, errlen, "%s", errmsg); |
| 101 return msg; |
| 102 } |
| 103 |
| 104 |
| 82 void SetupErrorResult(Isolate* isolate, Dart_Handle* handle) { | 105 void SetupErrorResult(Isolate* isolate, Dart_Handle* handle) { |
| 83 *handle = Api::NewHandle( | 106 *handle = Api::NewHandle( |
| 84 isolate, Isolate::Current()->object_store()->sticky_error()); | 107 isolate, Isolate::Current()->object_store()->sticky_error()); |
| 85 } | 108 } |
| 86 | 109 |
| 87 | 110 |
| 88 Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) { | 111 Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) { |
| 89 LocalHandles* local_handles = Api::TopScope(isolate)->local_handles(); | 112 LocalHandles* local_handles = Api::TopScope(isolate)->local_handles(); |
| 90 ASSERT(local_handles != NULL); | 113 ASSERT(local_handles != NULL); |
| 91 LocalHandle* ref = local_handles->AllocateHandle(); | 114 LocalHandle* ref = local_handles->AllocateHandle(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 169 |
| 147 | 170 |
| 148 FinalizablePersistentHandle* Api::UnwrapAsPrologueWeakPersistentHandle( | 171 FinalizablePersistentHandle* Api::UnwrapAsPrologueWeakPersistentHandle( |
| 149 const ApiState& state, | 172 const ApiState& state, |
| 150 Dart_Handle object) { | 173 Dart_Handle object) { |
| 151 ASSERT(state.IsValidPrologueWeakPersistentHandle(object)); | 174 ASSERT(state.IsValidPrologueWeakPersistentHandle(object)); |
| 152 return reinterpret_cast<FinalizablePersistentHandle*>(object); | 175 return reinterpret_cast<FinalizablePersistentHandle*>(object); |
| 153 } | 176 } |
| 154 | 177 |
| 155 | 178 |
| 156 Dart_Handle Api::CheckIsolateState(Isolate* isolate) { | |
| 157 if (ClassFinalizer::FinalizePendingClasses() && | |
| 158 isolate->object_store()->PreallocateObjects()) { | |
| 159 return Api::Success(isolate); | |
| 160 } | |
| 161 const Object& obj = Object::Handle(isolate->object_store()->sticky_error()); | |
| 162 ASSERT(obj.IsError()); | |
| 163 return Api::NewHandle(isolate, obj.raw()); | |
| 164 } | |
| 165 | |
| 166 | |
| 167 Dart_Isolate Api::CastIsolate(Isolate* isolate) { | 179 Dart_Isolate Api::CastIsolate(Isolate* isolate) { |
| 168 return reinterpret_cast<Dart_Isolate>(isolate); | 180 return reinterpret_cast<Dart_Isolate>(isolate); |
| 169 } | 181 } |
| 170 | 182 |
| 171 | 183 |
| 172 Dart_Handle Api::Success(Isolate* isolate) { | 184 Dart_Handle Api::Success(Isolate* isolate) { |
| 173 ASSERT(isolate != NULL); | 185 ASSERT(isolate != NULL); |
| 174 ApiState* state = isolate->api_state(); | 186 ApiState* state = isolate->api_state(); |
| 175 ASSERT(state != NULL); | 187 ASSERT(state != NULL); |
| 176 PersistentHandle* true_handle = state->True(); | 188 PersistentHandle* true_handle = state->True(); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 intptr_t* size) { | 898 intptr_t* size) { |
| 887 Isolate* isolate = Isolate::Current(); | 899 Isolate* isolate = Isolate::Current(); |
| 888 DARTSCOPE(isolate); | 900 DARTSCOPE(isolate); |
| 889 TIMERSCOPE(time_creating_snapshot); | 901 TIMERSCOPE(time_creating_snapshot); |
| 890 if (buffer == NULL) { | 902 if (buffer == NULL) { |
| 891 RETURN_NULL_ERROR(buffer); | 903 RETURN_NULL_ERROR(buffer); |
| 892 } | 904 } |
| 893 if (size == NULL) { | 905 if (size == NULL) { |
| 894 RETURN_NULL_ERROR(size); | 906 RETURN_NULL_ERROR(size); |
| 895 } | 907 } |
| 896 Dart_Handle state = Api::CheckIsolateState(isolate); | 908 const char* msg = CheckIsolateState(isolate); |
| 897 if (Dart_IsError(state)) { | 909 if (msg != NULL) { |
| 898 return state; | 910 return Api::NewError("%s", msg); |
| 899 } | 911 } |
| 900 // Since this is only a snapshot the root library should not be set. | 912 // Since this is only a snapshot the root library should not be set. |
| 901 isolate->object_store()->set_root_library(Library::Handle(isolate)); | 913 isolate->object_store()->set_root_library(Library::Handle(isolate)); |
| 902 FullSnapshotWriter writer(buffer, ApiReallocate); | 914 FullSnapshotWriter writer(buffer, ApiReallocate); |
| 903 writer.WriteFullSnapshot(); | 915 writer.WriteFullSnapshot(); |
| 904 *size = writer.BytesWritten(); | 916 *size = writer.BytesWritten(); |
| 905 return Api::Success(isolate); | 917 return Api::Success(isolate); |
| 906 } | 918 } |
| 907 | 919 |
| 908 | 920 |
| 909 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, | 921 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
| 910 intptr_t* size) { | 922 intptr_t* size) { |
| 911 Isolate* isolate = Isolate::Current(); | 923 Isolate* isolate = Isolate::Current(); |
| 912 DARTSCOPE(isolate); | 924 DARTSCOPE(isolate); |
| 913 TIMERSCOPE(time_creating_snapshot); | 925 TIMERSCOPE(time_creating_snapshot); |
| 914 if (buffer == NULL) { | 926 if (buffer == NULL) { |
| 915 RETURN_NULL_ERROR(buffer); | 927 RETURN_NULL_ERROR(buffer); |
| 916 } | 928 } |
| 917 if (size == NULL) { | 929 if (size == NULL) { |
| 918 RETURN_NULL_ERROR(size); | 930 RETURN_NULL_ERROR(size); |
| 919 } | 931 } |
| 920 Dart_Handle state = Api::CheckIsolateState(isolate); | 932 const char* msg = CheckIsolateState(isolate); |
| 921 if (Dart_IsError(state)) { | 933 if (msg != NULL) { |
| 922 return state; | 934 return Api::NewError("%s", msg); |
| 923 } | 935 } |
| 924 Library& library = | 936 Library& library = |
| 925 Library::Handle(isolate, isolate->object_store()->root_library()); | 937 Library::Handle(isolate, isolate->object_store()->root_library()); |
| 926 if (library.IsNull()) { | 938 if (library.IsNull()) { |
| 927 return | 939 return |
| 928 Api::NewError("%s expects the isolate to have a script loaded in it.", | 940 Api::NewError("%s expects the isolate to have a script loaded in it.", |
| 929 CURRENT_FUNC); | 941 CURRENT_FUNC); |
| 930 } | 942 } |
| 931 ScriptSnapshotWriter writer(buffer, ApiReallocate); | 943 ScriptSnapshotWriter writer(buffer, ApiReallocate); |
| 932 writer.WriteScriptSnapshot(library); | 944 writer.WriteScriptSnapshot(library); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 } | 1248 } |
| 1237 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 1249 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
| 1238 if (obj.IsError()) { | 1250 if (obj.IsError()) { |
| 1239 return object; | 1251 return object; |
| 1240 } else if (!obj.IsNull() && !obj.IsInstance()) { | 1252 } else if (!obj.IsNull() && !obj.IsInstance()) { |
| 1241 return Api::NewError( | 1253 return Api::NewError( |
| 1242 "%s expects argument 'object' to be an instance of Object.", | 1254 "%s expects argument 'object' to be an instance of Object.", |
| 1243 CURRENT_FUNC); | 1255 CURRENT_FUNC); |
| 1244 } | 1256 } |
| 1245 // Finalize all classes. | 1257 // Finalize all classes. |
| 1246 Dart_Handle state = Api::CheckIsolateState(isolate); | 1258 const char* msg = CheckIsolateState(isolate); |
| 1247 if (Dart_IsError(state)) { | 1259 if (msg != NULL) { |
| 1248 return state; | 1260 return Api::NewError("%s", msg); |
| 1249 } | 1261 } |
| 1250 if (obj.IsInstance()) { | 1262 if (obj.IsInstance()) { |
| 1251 CHECK_CALLBACK_STATE(isolate); | 1263 CHECK_CALLBACK_STATE(isolate); |
| 1252 const Type& type = Type::Handle(isolate, | 1264 const Type& type = Type::Handle(isolate, |
| 1253 Type::NewNonParameterizedType(cls)); | 1265 Type::NewNonParameterizedType(cls)); |
| 1254 Error& malformed_type_error = Error::Handle(isolate); | 1266 Error& malformed_type_error = Error::Handle(isolate); |
| 1255 *value = Instance::Cast(obj).IsInstanceOf(type, | 1267 *value = Instance::Cast(obj).IsInstanceOf(type, |
| 1256 TypeArguments::Handle(isolate), | 1268 TypeArguments::Handle(isolate), |
| 1257 &malformed_type_error); | 1269 &malformed_type_error); |
| 1258 ASSERT(malformed_type_error.IsNull()); // Type was created from a class. | 1270 ASSERT(malformed_type_error.IsNull()); // Type was created from a class. |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, | 2523 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, |
| 2512 intptr_t index) { | 2524 intptr_t index) { |
| 2513 Isolate* isolate = Isolate::Current(); | 2525 Isolate* isolate = Isolate::Current(); |
| 2514 DARTSCOPE(isolate); | 2526 DARTSCOPE(isolate); |
| 2515 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | 2527 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); |
| 2516 if (cls.IsNull()) { | 2528 if (cls.IsNull()) { |
| 2517 RETURN_TYPE_ERROR(isolate, clazz, Class); | 2529 RETURN_TYPE_ERROR(isolate, clazz, Class); |
| 2518 } | 2530 } |
| 2519 | 2531 |
| 2520 // Finalize all classes. | 2532 // Finalize all classes. |
| 2521 Dart_Handle state = Api::CheckIsolateState(isolate); | 2533 const char* msg = CheckIsolateState(isolate); |
| 2522 if (Dart_IsError(state)) { | 2534 if (msg != NULL) { |
| 2523 return state; | 2535 return Api::NewError("%s", msg); |
| 2524 } | 2536 } |
| 2525 | 2537 |
| 2526 const Array& interface_types = Array::Handle(isolate, cls.interfaces()); | 2538 const Array& interface_types = Array::Handle(isolate, cls.interfaces()); |
| 2527 if (index < 0 || index >= interface_types.Length()) { | 2539 if (index < 0 || index >= interface_types.Length()) { |
| 2528 return Api::NewError("%s: argument 'index' out of bounds.", CURRENT_FUNC); | 2540 return Api::NewError("%s: argument 'index' out of bounds.", CURRENT_FUNC); |
| 2529 } | 2541 } |
| 2530 Type& interface_type = Type::Handle(isolate); | 2542 Type& interface_type = Type::Handle(isolate); |
| 2531 interface_type ^= interface_types.At(index); | 2543 interface_type ^= interface_types.At(index); |
| 2532 if (interface_type.HasResolvedTypeClass()) { | 2544 if (interface_type.HasResolvedTypeClass()) { |
| 2533 return Api::NewHandle(isolate, interface_type.type_class()); | 2545 return Api::NewHandle(isolate, interface_type.type_class()); |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 String& dot_name = String::Handle(isolate); | 3289 String& dot_name = String::Handle(isolate); |
| 3278 const Object& name_obj = | 3290 const Object& name_obj = |
| 3279 Object::Handle(isolate, Api::UnwrapHandle(constructor_name)); | 3291 Object::Handle(isolate, Api::UnwrapHandle(constructor_name)); |
| 3280 if (name_obj.IsNull()) { | 3292 if (name_obj.IsNull()) { |
| 3281 dot_name = Symbols::Dot().raw(); | 3293 dot_name = Symbols::Dot().raw(); |
| 3282 } else if (name_obj.IsString()) { | 3294 } else if (name_obj.IsString()) { |
| 3283 dot_name = String::Concat(Symbols::Dot(), String::Cast(name_obj)); | 3295 dot_name = String::Concat(Symbols::Dot(), String::Cast(name_obj)); |
| 3284 } else { | 3296 } else { |
| 3285 RETURN_TYPE_ERROR(isolate, constructor_name, String); | 3297 RETURN_TYPE_ERROR(isolate, constructor_name, String); |
| 3286 } | 3298 } |
| 3287 Dart_Handle state = Api::CheckIsolateState(isolate); | 3299 const char* msg = CheckIsolateState(isolate); |
| 3288 if (Dart_IsError(state)) { | 3300 if (msg != NULL) { |
| 3289 return state; | 3301 return Api::NewError("%s", msg); |
| 3290 } | 3302 } |
| 3291 | 3303 |
| 3292 // Resolve the constructor. | 3304 // Resolve the constructor. |
| 3293 result = ResolveConstructor( | 3305 result = ResolveConstructor( |
| 3294 "Dart_New", cls, base_constructor_name, dot_name, number_of_arguments); | 3306 "Dart_New", cls, base_constructor_name, dot_name, number_of_arguments); |
| 3295 if (result.IsError()) { | 3307 if (result.IsError()) { |
| 3296 return Api::NewHandle(isolate, result.raw()); | 3308 return Api::NewHandle(isolate, result.raw()); |
| 3297 } | 3309 } |
| 3298 // TODO(turnidge): Support redirecting factories. | 3310 // TODO(turnidge): Support redirecting factories. |
| 3299 ASSERT(result.IsFunction()); | 3311 ASSERT(result.IsFunction()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 return Api::NewError("%s: did not find instance method '%s.%s'.", | 3419 return Api::NewError("%s: did not find instance method '%s.%s'.", |
| 3408 CURRENT_FUNC, | 3420 CURRENT_FUNC, |
| 3409 cls_name.ToCString(), | 3421 cls_name.ToCString(), |
| 3410 function_name.ToCString()); | 3422 function_name.ToCString()); |
| 3411 } | 3423 } |
| 3412 args.SetAt(0, instance); | 3424 args.SetAt(0, instance); |
| 3413 return Api::NewHandle(isolate, DartEntry::InvokeDynamic(function, args)); | 3425 return Api::NewHandle(isolate, DartEntry::InvokeDynamic(function, args)); |
| 3414 | 3426 |
| 3415 } else if (obj.IsClass()) { | 3427 } else if (obj.IsClass()) { |
| 3416 // Finalize all classes. | 3428 // Finalize all classes. |
| 3417 Dart_Handle state = Api::CheckIsolateState(isolate); | 3429 const char* msg = CheckIsolateState(isolate); |
| 3418 if (Dart_IsError(state)) { | 3430 if (msg != NULL) { |
| 3419 return state; | 3431 return Api::NewError("%s", msg); |
| 3420 } | 3432 } |
| 3421 | 3433 |
| 3422 const Class& cls = Class::Cast(obj); | 3434 const Class& cls = Class::Cast(obj); |
| 3423 const Function& function = Function::Handle( | 3435 const Function& function = Function::Handle( |
| 3424 isolate, | 3436 isolate, |
| 3425 Resolver::ResolveStatic(cls, | 3437 Resolver::ResolveStatic(cls, |
| 3426 function_name, | 3438 function_name, |
| 3427 number_of_arguments, | 3439 number_of_arguments, |
| 3428 Object::empty_array(), | 3440 Object::empty_array(), |
| 3429 Resolver::kIsQualified)); | 3441 Resolver::kIsQualified)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3444 // When calling functions in the dart:builtin library do not finalize as it | 3456 // When calling functions in the dart:builtin library do not finalize as it |
| 3445 // should have been prefinalized. | 3457 // should have been prefinalized. |
| 3446 Library& builtin = | 3458 Library& builtin = |
| 3447 Library::Handle(isolate, isolate->object_store()->builtin_library()); | 3459 Library::Handle(isolate, isolate->object_store()->builtin_library()); |
| 3448 if (builtin.raw() == lib.raw()) { | 3460 if (builtin.raw() == lib.raw()) { |
| 3449 finalize_classes = false; | 3461 finalize_classes = false; |
| 3450 } | 3462 } |
| 3451 | 3463 |
| 3452 // Finalize all classes if needed. | 3464 // Finalize all classes if needed. |
| 3453 if (finalize_classes) { | 3465 if (finalize_classes) { |
| 3454 Dart_Handle state = Api::CheckIsolateState(isolate); | 3466 const char* msg = CheckIsolateState(isolate); |
| 3455 if (Dart_IsError(state)) { | 3467 if (msg != NULL) { |
| 3456 return state; | 3468 return Api::NewError("%s", msg); |
| 3457 } | 3469 } |
| 3458 } | 3470 } |
| 3459 | 3471 |
| 3460 Function& function = Function::Handle(isolate); | 3472 Function& function = Function::Handle(isolate); |
| 3461 function = lib.LookupFunctionAllowPrivate(function_name); | 3473 function = lib.LookupFunctionAllowPrivate(function_name); |
| 3462 if (function.IsNull()) { | 3474 if (function.IsNull()) { |
| 3463 return Api::NewError("%s: did not find top-level function '%s'.", | 3475 return Api::NewError("%s: did not find top-level function '%s'.", |
| 3464 CURRENT_FUNC, | 3476 CURRENT_FUNC, |
| 3465 function_name.ToCString()); | 3477 function_name.ToCString()); |
| 3466 } | 3478 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3536 } | 3548 } |
| 3537 | 3549 |
| 3538 // Invoke the getter and return the result. | 3550 // Invoke the getter and return the result. |
| 3539 const int kNumArgs = 1; | 3551 const int kNumArgs = 1; |
| 3540 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); | 3552 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); |
| 3541 args.SetAt(0, instance); | 3553 args.SetAt(0, instance); |
| 3542 return Api::NewHandle(isolate, DartEntry::InvokeDynamic(getter, args)); | 3554 return Api::NewHandle(isolate, DartEntry::InvokeDynamic(getter, args)); |
| 3543 | 3555 |
| 3544 } else if (obj.IsClass()) { | 3556 } else if (obj.IsClass()) { |
| 3545 // Finalize all classes. | 3557 // Finalize all classes. |
| 3546 Dart_Handle state = Api::CheckIsolateState(isolate); | 3558 const char* msg = CheckIsolateState(isolate); |
| 3547 if (Dart_IsError(state)) { | 3559 if (msg != NULL) { |
| 3548 return state; | 3560 return Api::NewError("%s", msg); |
| 3549 } | 3561 } |
| 3550 // To access a static field we may need to use the Field or the | 3562 // To access a static field we may need to use the Field or the |
| 3551 // getter Function. | 3563 // getter Function. |
| 3552 const Class& cls = Class::Cast(obj); | 3564 const Class& cls = Class::Cast(obj); |
| 3553 field = cls.LookupStaticField(field_name); | 3565 field = cls.LookupStaticField(field_name); |
| 3554 if (field.IsNull() || FieldIsUninitialized(isolate, field)) { | 3566 if (field.IsNull() || FieldIsUninitialized(isolate, field)) { |
| 3555 const String& getter_name = | 3567 const String& getter_name = |
| 3556 String::Handle(isolate, Field::GetterName(field_name)); | 3568 String::Handle(isolate, Field::GetterName(field_name)); |
| 3557 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 3569 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
| 3558 } | 3570 } |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4121 *result = Api::Success(isolate); | 4133 *result = Api::Success(isolate); |
| 4122 } else { | 4134 } else { |
| 4123 *result = Api::NewHandle(isolate, error.raw()); | 4135 *result = Api::NewHandle(isolate, error.raw()); |
| 4124 } | 4136 } |
| 4125 } | 4137 } |
| 4126 | 4138 |
| 4127 | 4139 |
| 4128 DART_EXPORT Dart_Handle Dart_CompileAll() { | 4140 DART_EXPORT Dart_Handle Dart_CompileAll() { |
| 4129 Isolate* isolate = Isolate::Current(); | 4141 Isolate* isolate = Isolate::Current(); |
| 4130 DARTSCOPE(isolate); | 4142 DARTSCOPE(isolate); |
| 4131 Dart_Handle result = Api::CheckIsolateState(isolate); | 4143 Dart_Handle result; |
| 4132 if (Dart_IsError(result)) { | 4144 const char* msg = CheckIsolateState(isolate); |
| 4133 return result; | 4145 if (msg != NULL) { |
| 4146 return Api::NewError("%s", msg); |
| 4134 } | 4147 } |
| 4135 CHECK_CALLBACK_STATE(isolate); | 4148 CHECK_CALLBACK_STATE(isolate); |
| 4136 CompileAll(isolate, &result); | 4149 CompileAll(isolate, &result); |
| 4137 return result; | 4150 return result; |
| 4138 } | 4151 } |
| 4139 | 4152 |
| 4140 | 4153 |
| 4141 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { | 4154 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { |
| 4142 return Api::ClassId(object) == kLibraryCid; | 4155 return Api::ClassId(object) == kLibraryCid; |
| 4143 } | 4156 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4273 Dart_Handle result; | 4286 Dart_Handle result; |
| 4274 CompileSource(isolate, library, script, &result); | 4287 CompileSource(isolate, library, script, &result); |
| 4275 // Propagate the error out right now. | 4288 // Propagate the error out right now. |
| 4276 if (::Dart_IsError(result)) { | 4289 if (::Dart_IsError(result)) { |
| 4277 return result; | 4290 return result; |
| 4278 } | 4291 } |
| 4279 | 4292 |
| 4280 // If this is the dart:builtin library, register it with the VM. | 4293 // If this is the dart:builtin library, register it with the VM. |
| 4281 if (url_str.Equals("dart:builtin")) { | 4294 if (url_str.Equals("dart:builtin")) { |
| 4282 isolate->object_store()->set_builtin_library(library); | 4295 isolate->object_store()->set_builtin_library(library); |
| 4283 Dart_Handle state = Api::CheckIsolateState(isolate); | 4296 const char* msg = CheckIsolateState(isolate); |
| 4284 if (Dart_IsError(state)) { | 4297 if (msg != NULL) { |
| 4285 return state; | 4298 return Api::NewError("%s", msg); |
| 4286 } | 4299 } |
| 4287 } | 4300 } |
| 4288 return result; | 4301 return result; |
| 4289 } | 4302 } |
| 4290 | 4303 |
| 4291 | 4304 |
| 4292 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, | 4305 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, |
| 4293 Dart_Handle import, | 4306 Dart_Handle import, |
| 4294 Dart_Handle prefix) { | 4307 Dart_Handle prefix) { |
| 4295 Isolate* isolate = Isolate::Current(); | 4308 Isolate* isolate = Isolate::Current(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4450 } | 4463 } |
| 4451 { | 4464 { |
| 4452 NoGCScope no_gc; | 4465 NoGCScope no_gc; |
| 4453 RawObject* raw_obj = obj.raw(); | 4466 RawObject* raw_obj = obj.raw(); |
| 4454 isolate->heap()->SetPeer(raw_obj, peer); | 4467 isolate->heap()->SetPeer(raw_obj, peer); |
| 4455 } | 4468 } |
| 4456 return Api::Success(isolate); | 4469 return Api::Success(isolate); |
| 4457 } | 4470 } |
| 4458 | 4471 |
| 4459 } // namespace dart | 4472 } // namespace dart |
| OLD | NEW |