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