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