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 #include "include/dart_debugger_api.h" | 6 #include "include/dart_debugger_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 | 39 |
| 40 // TODO(turnidge): Add Map support to the dart embedding api instead | 40 // TODO(turnidge): Add Map support to the dart embedding api instead |
| 41 // of implementing it here. | 41 // of implementing it here. |
| 42 static Dart_Handle CoreLib() { | 42 static Dart_Handle CoreLib() { |
| 43 Dart_Handle core_lib_name = NewString("dart:core"); | 43 Dart_Handle core_lib_name = NewString("dart:core"); |
| 44 return Dart_LookupLibrary(core_lib_name); | 44 return Dart_LookupLibrary(core_lib_name); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 static Dart_Handle MapNew() { | 48 static Dart_Handle MapNew() { |
|
regis
2013/06/26 00:16:05
Probably not for this cl, but we could consider pa
siva
2013/06/26 21:27:14
Some or all of this is going to change as we redo
| |
| 49 // TODO(turnidge): Switch to an order-preserving map type. | 49 // TODO(turnidge): Switch to an order-preserving map type. |
| 50 Dart_Handle cls = Dart_GetClass(CoreLib(), NewString("Map")); | 50 Dart_Handle type = Dart_GetType(CoreLib(), NewString("Map"), 0, NULL); |
| 51 if (Dart_IsError(cls)) { | 51 if (Dart_IsError(type)) { |
| 52 return cls; | 52 return type; |
| 53 } | 53 } |
| 54 return Dart_New(cls, Dart_Null(), 0, NULL); | 54 return Dart_New(type, Dart_Null(), 0, NULL); |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 static Dart_Handle MapAdd(Dart_Handle map, Dart_Handle key, Dart_Handle value) { | 58 static Dart_Handle MapAdd(Dart_Handle map, Dart_Handle key, Dart_Handle value) { |
| 59 Dart_Handle args[] = { key, value }; | 59 Dart_Handle args[] = { key, value }; |
| 60 return Dart_Invoke(map, NewString("[]="), ARRAY_SIZE(args), args); | 60 return Dart_Invoke(map, NewString("[]="), ARRAY_SIZE(args), args); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 static Dart_Handle MirrorLib() { | 64 static Dart_Handle MirrorLib() { |
| 65 Dart_Handle mirror_lib_name = NewString("dart:mirrors"); | 65 Dart_Handle mirror_lib_name = NewString("dart:mirrors"); |
| 66 return Dart_LookupLibrary(mirror_lib_name); | 66 return Dart_LookupLibrary(mirror_lib_name); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 static Dart_Handle IsMirror(Dart_Handle object, bool* is_mirror) { | 70 static Dart_Handle IsMirror(Dart_Handle object, bool* is_mirror) { |
| 71 Dart_Handle cls_name = NewString("Mirror"); | 71 Dart_Handle cls_name = NewString("Mirror"); |
| 72 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 72 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 73 if (Dart_IsError(cls)) { | 73 if (Dart_IsError(type)) { |
| 74 return cls; | 74 return type; |
| 75 } | 75 } |
| 76 Dart_Handle result = Dart_ObjectIsType(object, cls, is_mirror); | 76 Dart_Handle result = Dart_ObjectIsType(object, type, is_mirror); |
| 77 if (Dart_IsError(result)) { | 77 if (Dart_IsError(result)) { |
| 78 return result; | 78 return result; |
| 79 } | 79 } |
| 80 return Dart_True(); // Indicates success. Result is in is_mirror. | 80 return Dart_True(); // Indicates success. Result is in is_mirror. |
| 81 } | 81 } |
| 82 | 82 |
| 83 static Dart_Handle IsMethodMirror(Dart_Handle object, bool* is_mirror) { | 83 static Dart_Handle IsMethodMirror(Dart_Handle object, bool* is_mirror) { |
| 84 Dart_Handle cls_name = NewString("MethodMirror"); | 84 Dart_Handle cls_name = NewString("MethodMirror"); |
| 85 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 85 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 86 if (Dart_IsError(cls)) { | 86 if (Dart_IsError(type)) { |
| 87 return cls; | 87 return type; |
| 88 } | 88 } |
| 89 Dart_Handle result = Dart_ObjectIsType(object, cls, is_mirror); | 89 Dart_Handle result = Dart_ObjectIsType(object, type, is_mirror); |
| 90 if (Dart_IsError(result)) { | 90 if (Dart_IsError(result)) { |
| 91 return result; | 91 return result; |
| 92 } | 92 } |
| 93 return Dart_True(); // Indicates success. Result is in is_mirror. | 93 return Dart_True(); // Indicates success. Result is in is_mirror. |
| 94 } | 94 } |
| 95 | 95 |
| 96 static Dart_Handle IsVariableMirror(Dart_Handle object, bool* is_mirror) { | 96 static Dart_Handle IsVariableMirror(Dart_Handle object, bool* is_mirror) { |
| 97 Dart_Handle cls_name = NewString("VariableMirror"); | 97 Dart_Handle cls_name = NewString("VariableMirror"); |
| 98 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 98 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 99 if (Dart_IsError(cls)) { | 99 if (Dart_IsError(type)) { |
| 100 return cls; | 100 return type; |
| 101 } | 101 } |
| 102 Dart_Handle result = Dart_ObjectIsType(object, cls, is_mirror); | 102 Dart_Handle result = Dart_ObjectIsType(object, type, is_mirror); |
| 103 if (Dart_IsError(result)) { | 103 if (Dart_IsError(result)) { |
| 104 return result; | 104 return result; |
| 105 } | 105 } |
| 106 return Dart_True(); // Indicates success. Result is in is_mirror. | 106 return Dart_True(); // Indicates success. Result is in is_mirror. |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 static bool IsSimpleValue(Dart_Handle object) { | 110 static bool IsSimpleValue(Dart_Handle object) { |
| 111 return (Dart_IsNull(object) || | 111 return (Dart_IsNull(object) || |
| 112 Dart_IsNumber(object) || | 112 Dart_IsNumber(object) || |
| 113 Dart_IsString(object) || | 113 Dart_IsString(object) || |
| 114 Dart_IsBoolean(object)); | 114 Dart_IsBoolean(object)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 static void FreeVMReference(Dart_WeakPersistentHandle weak_ref, void* data) { | 118 static void FreeVMReference(Dart_WeakPersistentHandle weak_ref, void* data) { |
| 119 Dart_PersistentHandle perm_handle = | 119 Dart_PersistentHandle perm_handle = |
| 120 reinterpret_cast<Dart_PersistentHandle>(data); | 120 reinterpret_cast<Dart_PersistentHandle>(data); |
| 121 Dart_DeletePersistentHandle(perm_handle); | 121 Dart_DeletePersistentHandle(perm_handle); |
| 122 Dart_DeleteWeakPersistentHandle(weak_ref); | 122 Dart_DeleteWeakPersistentHandle(weak_ref); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 static Dart_Handle CreateVMReference(Dart_Handle handle) { | 126 static Dart_Handle CreateVMReference(Dart_Handle handle) { |
| 127 // Create the VMReference object. | 127 // Create the VMReference object. |
| 128 Dart_Handle cls_name = NewString("VMReference"); | 128 Dart_Handle cls_name = NewString("VMReference"); |
| 129 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 129 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 130 if (Dart_IsError(cls)) { | 130 if (Dart_IsError(type)) { |
| 131 return cls; | 131 return type; |
| 132 } | 132 } |
| 133 Dart_Handle vm_ref = Dart_New(cls, Dart_Null(), 0, NULL); | 133 Dart_Handle vm_ref = Dart_New(type, Dart_Null(), 0, NULL); |
| 134 if (Dart_IsError(vm_ref)) { | 134 if (Dart_IsError(vm_ref)) { |
| 135 return vm_ref; | 135 return vm_ref; |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Allocate a persistent handle. | 138 // Allocate a persistent handle. |
| 139 Dart_PersistentHandle perm_handle = Dart_NewPersistentHandle(handle); | 139 Dart_PersistentHandle perm_handle = Dart_NewPersistentHandle(handle); |
| 140 ASSERT(perm_handle != NULL); | 140 ASSERT(perm_handle != NULL); |
| 141 | 141 |
| 142 // Store the persistent handle in the VMReference. | 142 // Store the persistent handle in the VMReference. |
| 143 intptr_t perm_handle_value = reinterpret_cast<intptr_t>(perm_handle); | 143 intptr_t perm_handle_value = reinterpret_cast<intptr_t>(perm_handle); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 return result; | 333 return result; |
| 334 } | 334 } |
| 335 | 335 |
| 336 int64_t param_count = fixed_param_count + opt_param_count; | 336 int64_t param_count = fixed_param_count + opt_param_count; |
| 337 Dart_Handle parameter_list = Dart_NewList(param_count); | 337 Dart_Handle parameter_list = Dart_NewList(param_count); |
| 338 if (Dart_IsError(parameter_list)) { | 338 if (Dart_IsError(parameter_list)) { |
| 339 return result; | 339 return result; |
| 340 } | 340 } |
| 341 | 341 |
| 342 Dart_Handle param_cls_name = NewString("_LocalParameterMirrorImpl"); | 342 Dart_Handle param_cls_name = NewString("_LocalParameterMirrorImpl"); |
| 343 Dart_Handle param_cls = Dart_GetClass(MirrorLib(), param_cls_name); | 343 Dart_Handle param_type = Dart_GetType(MirrorLib(), param_cls_name, 0, NULL); |
| 344 if (Dart_IsError(param_cls)) { | 344 if (Dart_IsError(param_type)) { |
| 345 return param_cls; | 345 return param_type; |
| 346 } | 346 } |
| 347 | 347 |
| 348 for (int64_t i = 0; i < param_count; i++) { | 348 for (int64_t i = 0; i < param_count; i++) { |
| 349 Dart_Handle param_type = Dart_FunctionParameterType(func, i); | 349 Dart_Handle arg_type = Dart_FunctionParameterType(func, i); |
| 350 if (Dart_IsError(param_type)) { | 350 if (Dart_IsError(arg_type)) { |
| 351 return param_type; | 351 return arg_type; |
| 352 } | 352 } |
| 353 Dart_Handle args[] = { | 353 Dart_Handle args[] = { |
| 354 CreateLazyMirror(param_type), | 354 CreateLazyMirror(arg_type), |
| 355 Dart_NewBoolean(i >= fixed_param_count), // optional param? | 355 Dart_NewBoolean(i >= fixed_param_count), // optional param? |
| 356 }; | 356 }; |
| 357 Dart_Handle param = | 357 Dart_Handle param = |
| 358 Dart_New(param_cls, Dart_Null(), ARRAY_SIZE(args), args); | 358 Dart_New(param_type, Dart_Null(), ARRAY_SIZE(args), args); |
| 359 if (Dart_IsError(param)) { | 359 if (Dart_IsError(param)) { |
| 360 return param; | 360 return param; |
| 361 } | 361 } |
| 362 result = Dart_ListSetAt(parameter_list, i, param); | 362 result = Dart_ListSetAt(parameter_list, i, param); |
| 363 if (Dart_IsError(result)) { | 363 if (Dart_IsError(result)) { |
| 364 return result; | 364 return result; |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 return parameter_list; | 367 return parameter_list; |
| 368 } | 368 } |
| 369 | 369 |
| 370 | 370 |
| 371 static Dart_Handle CreateLazyMirror(Dart_Handle target) { | 371 static Dart_Handle CreateLazyMirror(Dart_Handle target) { |
| 372 if (Dart_IsNull(target) || Dart_IsError(target)) { | 372 if (Dart_IsNull(target) || Dart_IsError(target)) { |
| 373 return target; | 373 return target; |
| 374 } | 374 } |
| 375 | 375 |
| 376 if (Dart_IsLibrary(target)) { | 376 if (Dart_IsLibrary(target)) { |
| 377 Dart_Handle cls_name = NewString("_LazyLibraryMirror"); | 377 Dart_Handle cls_name = NewString("_LazyLibraryMirror"); |
| 378 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 378 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 379 Dart_Handle args[] = { Dart_LibraryUrl(target) }; | 379 Dart_Handle args[] = { Dart_LibraryUrl(target) }; |
| 380 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 380 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 381 } | 381 } |
| 382 | 382 |
| 383 if (Dart_IsClass(target)) { | 383 if (Dart_IsClass(target)) { |
| 384 if (Dart_ClassIsFunctionType(target)) { | 384 if (Dart_ClassIsFunctionType(target)) { |
| 385 Dart_Handle cls_name = NewString("_LazyFunctionTypeMirror"); | 385 Dart_Handle cls_name = NewString("_LazyFunctionTypeMirror"); |
| 386 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 386 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 387 | 387 |
| 388 Dart_Handle sig = Dart_ClassGetFunctionTypeSignature(target); | 388 Dart_Handle sig = Dart_ClassGetFunctionTypeSignature(target); |
| 389 Dart_Handle return_type = Dart_FunctionReturnType(sig); | 389 Dart_Handle return_type = Dart_FunctionReturnType(sig); |
| 390 if (Dart_IsError(return_type)) { | 390 if (Dart_IsError(return_type)) { |
| 391 return return_type; | 391 return return_type; |
| 392 } | 392 } |
| 393 | 393 |
| 394 Dart_Handle args[] = { | 394 Dart_Handle args[] = { |
| 395 CreateLazyMirror(return_type), | 395 CreateLazyMirror(return_type), |
| 396 CreateParameterMirrorList(sig), | 396 CreateParameterMirrorList(sig), |
| 397 }; | 397 }; |
| 398 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 398 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 399 } else { | 399 } else { |
| 400 Dart_Handle cls_name = NewString("_LazyTypeMirror"); | 400 Dart_Handle cls_name = NewString("_LazyTypeMirror"); |
| 401 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 401 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 402 Dart_Handle lib = Dart_ClassGetLibrary(target); | 402 Dart_Handle lib = Dart_ClassGetLibrary(target); |
| 403 Dart_Handle lib_url; | 403 Dart_Handle lib_url; |
| 404 if (Dart_IsNull(lib)) { | 404 if (Dart_IsNull(lib)) { |
| 405 lib_url = Dart_Null(); | 405 lib_url = Dart_Null(); |
| 406 } else { | 406 } else { |
| 407 lib_url = Dart_LibraryUrl(lib); | 407 lib_url = Dart_LibraryUrl(lib); |
| 408 } | 408 } |
| 409 Dart_Handle args[] = { lib_url, Dart_ClassName(target) }; | 409 Dart_Handle args[] = { lib_url, Dart_ClassName(target) }; |
| 410 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 410 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 if (Dart_IsTypeVariable(target)) { | 414 if (Dart_IsTypeVariable(target)) { |
| 415 Dart_Handle var_name = Dart_TypeVariableName(target); | 415 Dart_Handle var_name = Dart_TypeVariableName(target); |
| 416 Dart_Handle owner = Dart_TypeVariableOwner(target); | 416 Dart_Handle owner = Dart_TypeVariableOwner(target); |
| 417 Dart_Handle owner_mirror = CreateLazyMirror(owner); | 417 Dart_Handle owner_mirror = CreateLazyMirror(owner); |
| 418 | 418 |
| 419 Dart_Handle cls_name = NewString("_LazyTypeVariableMirror"); | 419 Dart_Handle cls_name = NewString("_LazyTypeVariableMirror"); |
| 420 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 420 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 421 | 421 |
| 422 Dart_Handle args[] = { var_name, owner_mirror }; | 422 Dart_Handle args[] = { var_name, owner_mirror }; |
| 423 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 423 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 424 } | 424 } |
| 425 | 425 |
| 426 UNREACHABLE(); | 426 UNREACHABLE(); |
| 427 return Dart_Null(); | 427 return Dart_Null(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 | 430 |
| 431 static Dart_Handle CreateImplementsList(Dart_Handle intf) { | 431 static Dart_Handle CreateImplementsList(Dart_Handle intf) { |
| 432 intptr_t len = 0; | 432 intptr_t len = 0; |
| 433 Dart_Handle result = Dart_ClassGetInterfaceCount(intf, &len); | 433 Dart_Handle result = Dart_ClassGetInterfaceCount(intf, &len); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 456 } | 456 } |
| 457 return mirror_list; | 457 return mirror_list; |
| 458 } | 458 } |
| 459 | 459 |
| 460 | 460 |
| 461 static Dart_Handle CreateTypeVariableMirror(Dart_Handle type_var, | 461 static Dart_Handle CreateTypeVariableMirror(Dart_Handle type_var, |
| 462 Dart_Handle type_var_name, | 462 Dart_Handle type_var_name, |
| 463 Dart_Handle owner_mirror) { | 463 Dart_Handle owner_mirror) { |
| 464 ASSERT(Dart_IsTypeVariable(type_var)); | 464 ASSERT(Dart_IsTypeVariable(type_var)); |
| 465 Dart_Handle cls_name = NewString("_LocalTypeVariableMirrorImpl"); | 465 Dart_Handle cls_name = NewString("_LocalTypeVariableMirrorImpl"); |
| 466 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 466 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 467 if (Dart_IsError(cls)) { | 467 if (Dart_IsError(type)) { |
| 468 return cls; | 468 return type; |
| 469 } | 469 } |
| 470 | 470 |
| 471 Dart_Handle upper_bound = Dart_TypeVariableUpperBound(type_var); | 471 Dart_Handle upper_bound = Dart_TypeVariableUpperBound(type_var); |
| 472 if (Dart_IsError(upper_bound)) { | 472 if (Dart_IsError(upper_bound)) { |
| 473 return upper_bound; | 473 return upper_bound; |
| 474 } | 474 } |
| 475 | 475 |
| 476 Dart_Handle args[] = { | 476 Dart_Handle args[] = { |
| 477 type_var_name, | 477 type_var_name, |
| 478 owner_mirror, | 478 owner_mirror, |
| 479 CreateLazyMirror(upper_bound), | 479 CreateLazyMirror(upper_bound), |
| 480 }; | 480 }; |
| 481 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 481 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 482 return mirror; | 482 return mirror; |
| 483 } | 483 } |
| 484 | 484 |
| 485 | 485 |
| 486 static Dart_Handle CreateTypeVariableMap(Dart_Handle owner, | 486 static Dart_Handle CreateTypeVariableMap(Dart_Handle owner, |
| 487 Dart_Handle owner_mirror) { | 487 Dart_Handle owner_mirror) { |
| 488 ASSERT(Dart_IsClass(owner)); | 488 ASSERT(Dart_IsClass(owner)); |
| 489 // TODO(turnidge): This should be an immutable map. | 489 // TODO(turnidge): This should be an immutable map. |
| 490 Dart_Handle map = MapNew(); | 490 Dart_Handle map = MapNew(); |
| 491 if (Dart_IsError(map)) { | 491 if (Dart_IsError(map)) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 520 } | 520 } |
| 521 return map; | 521 return map; |
| 522 } | 522 } |
| 523 | 523 |
| 524 | 524 |
| 525 static Dart_Handle CreateTypedefMirror(Dart_Handle cls, | 525 static Dart_Handle CreateTypedefMirror(Dart_Handle cls, |
| 526 Dart_Handle cls_name, | 526 Dart_Handle cls_name, |
| 527 Dart_Handle owner, | 527 Dart_Handle owner, |
| 528 Dart_Handle owner_mirror) { | 528 Dart_Handle owner_mirror) { |
| 529 Dart_Handle mirror_cls_name = NewString("_LocalTypedefMirrorImpl"); | 529 Dart_Handle mirror_cls_name = NewString("_LocalTypedefMirrorImpl"); |
| 530 Dart_Handle mirror_cls = Dart_GetClass(MirrorLib(), mirror_cls_name); | 530 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); |
| 531 if (Dart_IsError(mirror_cls)) { | 531 if (Dart_IsError(mirror_type)) { |
| 532 return mirror_cls; | 532 return mirror_type; |
| 533 } | 533 } |
| 534 | 534 |
| 535 Dart_Handle referent = Dart_ClassGetTypedefReferent(cls); | 535 Dart_Handle referent = Dart_ClassGetTypedefReferent(cls); |
| 536 if (Dart_IsError(referent)) { | 536 if (Dart_IsError(referent)) { |
| 537 return referent; | 537 return referent; |
| 538 } | 538 } |
| 539 | 539 |
| 540 Dart_Handle args[] = { | 540 Dart_Handle args[] = { |
| 541 cls_name, | 541 cls_name, |
| 542 owner_mirror, | 542 owner_mirror, |
| 543 CreateLazyMirror(referent), | 543 CreateLazyMirror(referent), |
| 544 }; | 544 }; |
| 545 Dart_Handle mirror = | 545 Dart_Handle mirror = |
| 546 Dart_New(mirror_cls, Dart_Null(), ARRAY_SIZE(args), args); | 546 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); |
| 547 return mirror; | 547 return mirror; |
| 548 } | 548 } |
| 549 | 549 |
| 550 | 550 |
| 551 static Dart_Handle CreateMemberMap(Dart_Handle owner, Dart_Handle owner_mirror); | 551 static Dart_Handle CreateMemberMap(Dart_Handle owner, Dart_Handle owner_mirror); |
| 552 static Dart_Handle CreateConstructorMap(Dart_Handle owner, | 552 static Dart_Handle CreateConstructorMap(Dart_Handle owner, |
| 553 Dart_Handle owner_mirror); | 553 Dart_Handle owner_mirror); |
| 554 | 554 |
| 555 | 555 |
| 556 static Dart_Handle CreateClassMirror(Dart_Handle intf, | 556 static Dart_Handle CreateClassMirror(Dart_Handle intf, |
| 557 Dart_Handle intf_name, | 557 Dart_Handle intf_name, |
| 558 Dart_Handle lib, | 558 Dart_Handle lib, |
| 559 Dart_Handle lib_mirror) { | 559 Dart_Handle lib_mirror) { |
| 560 ASSERT(Dart_IsClass(intf)); | 560 ASSERT(Dart_IsClass(intf)); |
| 561 if (Dart_ClassIsTypedef(intf)) { | 561 if (Dart_ClassIsTypedef(intf)) { |
| 562 // This class is actually a typedef. Represent it specially in | 562 // This class is actually a typedef. Represent it specially in |
| 563 // reflection. | 563 // reflection. |
| 564 return CreateTypedefMirror(intf, intf_name, lib, lib_mirror); | 564 return CreateTypedefMirror(intf, intf_name, lib, lib_mirror); |
| 565 } | 565 } |
| 566 | 566 |
| 567 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); | 567 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); |
| 568 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 568 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 569 if (Dart_IsError(cls)) { | 569 if (Dart_IsError(type)) { |
| 570 return cls; | 570 return type; |
| 571 } | 571 } |
| 572 | 572 |
| 573 // TODO(turnidge): Why am I getting Null when I expect Object? | 573 // TODO(turnidge): Why am I getting Null when I expect Object? |
| 574 // TODO(gbracha): this is probably the root of bug 7868 | 574 // TODO(gbracha): this is probably the root of bug 7868 |
| 575 Dart_Handle super_class = Dart_GetSuperclass(intf); | 575 Dart_Handle super_class = Dart_GetSuperclass(intf); |
| 576 if (Dart_IsNull(super_class)) { | 576 if (Dart_IsNull(super_class)) { |
| 577 super_class = Dart_GetClass(CoreLib(), NewString("Object")); | 577 super_class = Dart_GetClass(CoreLib(), NewString("Object")); |
| 578 } | 578 } |
| 579 // TODO(turnidge): Simplify code, now that default classes have been removed. | 579 // TODO(turnidge): Simplify code, now that default classes have been removed. |
| 580 Dart_Handle default_class = Dart_Null(); | 580 Dart_Handle default_class = Dart_Null(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 601 intf_name, | 601 intf_name, |
| 602 Dart_NewBoolean(Dart_IsClass(intf)), | 602 Dart_NewBoolean(Dart_IsClass(intf)), |
| 603 lib_mirror, | 603 lib_mirror, |
| 604 CreateLazyMirror(super_class), | 604 CreateLazyMirror(super_class), |
| 605 CreateImplementsList(intf), | 605 CreateImplementsList(intf), |
| 606 CreateLazyMirror(default_class), | 606 CreateLazyMirror(default_class), |
| 607 member_map, | 607 member_map, |
| 608 constructor_map, | 608 constructor_map, |
| 609 type_var_map, | 609 type_var_map, |
| 610 }; | 610 }; |
| 611 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 611 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 612 return mirror; | 612 return mirror; |
| 613 } | 613 } |
| 614 | 614 |
| 615 | 615 |
| 616 static Dart_Handle CreateMethodMirror(Dart_Handle func, | 616 static Dart_Handle CreateMethodMirror(Dart_Handle func, |
| 617 Dart_Handle func_name, | 617 Dart_Handle func_name, |
| 618 Dart_Handle owner_mirror) { | 618 Dart_Handle owner_mirror) { |
| 619 ASSERT(Dart_IsFunction(func)); | 619 ASSERT(Dart_IsFunction(func)); |
| 620 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); | 620 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); |
| 621 Dart_Handle mirror_cls = Dart_GetClass(MirrorLib(), mirror_cls_name); | 621 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); |
| 622 if (Dart_IsError(mirror_cls)) { | 622 if (Dart_IsError(mirror_type)) { |
| 623 return mirror_cls; | 623 return mirror_type; |
| 624 } | 624 } |
| 625 | 625 |
| 626 bool is_static = false; | 626 bool is_static = false; |
| 627 bool is_abstract = false; | 627 bool is_abstract = false; |
| 628 bool is_getter = false; | 628 bool is_getter = false; |
| 629 bool is_setter = false; | 629 bool is_setter = false; |
| 630 bool is_constructor = false; | 630 bool is_constructor = false; |
| 631 | 631 |
| 632 Dart_Handle result = Dart_FunctionIsStatic(func, &is_static); | 632 Dart_Handle result = Dart_FunctionIsStatic(func, &is_static); |
| 633 if (Dart_IsError(result)) { | 633 if (Dart_IsError(result)) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 Dart_NewBoolean(is_abstract), | 674 Dart_NewBoolean(is_abstract), |
| 675 Dart_NewBoolean(is_getter), | 675 Dart_NewBoolean(is_getter), |
| 676 Dart_NewBoolean(is_setter), | 676 Dart_NewBoolean(is_setter), |
| 677 Dart_NewBoolean(is_constructor), | 677 Dart_NewBoolean(is_constructor), |
| 678 Dart_False(), | 678 Dart_False(), |
| 679 Dart_False(), | 679 Dart_False(), |
| 680 Dart_False(), | 680 Dart_False(), |
| 681 Dart_False(), | 681 Dart_False(), |
| 682 }; | 682 }; |
| 683 Dart_Handle mirror = | 683 Dart_Handle mirror = |
| 684 Dart_New(mirror_cls, Dart_Null(), ARRAY_SIZE(args), args); | 684 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); |
| 685 return mirror; | 685 return mirror; |
| 686 } | 686 } |
| 687 | 687 |
| 688 | 688 |
| 689 static Dart_Handle CreateVariableMirror(Dart_Handle var, | 689 static Dart_Handle CreateVariableMirror(Dart_Handle var, |
| 690 Dart_Handle var_name, | 690 Dart_Handle var_name, |
| 691 Dart_Handle lib_mirror) { | 691 Dart_Handle lib_mirror) { |
| 692 ASSERT(Dart_IsVariable(var)); | 692 ASSERT(Dart_IsVariable(var)); |
| 693 Dart_Handle cls_name = NewString("_LocalVariableMirrorImpl"); | 693 Dart_Handle cls_name = NewString("_LocalVariableMirrorImpl"); |
| 694 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 694 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 695 if (Dart_IsError(cls)) { | 695 if (Dart_IsError(type)) { |
| 696 return cls; | 696 return type; |
| 697 } | 697 } |
| 698 | 698 |
| 699 bool is_static = false; | 699 bool is_static = false; |
| 700 bool is_final = false; | 700 bool is_final = false; |
| 701 | 701 |
| 702 Dart_Handle result = Dart_VariableIsStatic(var, &is_static); | 702 Dart_Handle result = Dart_VariableIsStatic(var, &is_static); |
| 703 if (Dart_IsError(result)) { | 703 if (Dart_IsError(result)) { |
| 704 return result; | 704 return result; |
| 705 } | 705 } |
| 706 result = Dart_VariableIsFinal(var, &is_final); | 706 result = Dart_VariableIsFinal(var, &is_final); |
| 707 if (Dart_IsError(result)) { | 707 if (Dart_IsError(result)) { |
| 708 return result; | 708 return result; |
| 709 } | 709 } |
| 710 | 710 |
| 711 Dart_Handle type = Dart_VariableType(var); | 711 Dart_Handle var_type = Dart_VariableType(var); |
| 712 if (Dart_IsError(type)) { | 712 if (Dart_IsError(var_type)) { |
| 713 return type; | 713 return var_type; |
| 714 } | 714 } |
| 715 | 715 |
| 716 Dart_Handle args[] = { | 716 Dart_Handle args[] = { |
| 717 var_name, | 717 var_name, |
| 718 lib_mirror, | 718 lib_mirror, |
| 719 CreateLazyMirror(type), | 719 CreateLazyMirror(var_type), |
| 720 Dart_NewBoolean(is_static), | 720 Dart_NewBoolean(is_static), |
| 721 Dart_NewBoolean(is_final), | 721 Dart_NewBoolean(is_final), |
| 722 }; | 722 }; |
| 723 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 723 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 724 return mirror; | 724 return mirror; |
| 725 } | 725 } |
| 726 | 726 |
| 727 | 727 |
| 728 static Dart_Handle AddMemberClasses(Dart_Handle map, | 728 static Dart_Handle AddMemberClasses(Dart_Handle map, |
| 729 Dart_Handle owner, | 729 Dart_Handle owner, |
| 730 Dart_Handle owner_mirror) { | 730 Dart_Handle owner_mirror) { |
| 731 ASSERT(Dart_IsLibrary(owner)); | 731 ASSERT(Dart_IsLibrary(owner)); |
| 732 Dart_Handle result; | 732 Dart_Handle result; |
| 733 Dart_Handle names = Dart_LibraryGetClassNames(owner); | 733 Dart_Handle names = Dart_LibraryGetClassNames(owner); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 result = AddConstructors(map, owner, owner_mirror); | 917 result = AddConstructors(map, owner, owner_mirror); |
| 918 if (Dart_IsError(result)) { | 918 if (Dart_IsError(result)) { |
| 919 return result; | 919 return result; |
| 920 } | 920 } |
| 921 return map; | 921 return map; |
| 922 } | 922 } |
| 923 | 923 |
| 924 | 924 |
| 925 static Dart_Handle CreateLibraryMirror(Dart_Handle lib) { | 925 static Dart_Handle CreateLibraryMirror(Dart_Handle lib) { |
| 926 Dart_Handle cls_name = NewString("_LocalLibraryMirrorImpl"); | 926 Dart_Handle cls_name = NewString("_LocalLibraryMirrorImpl"); |
| 927 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 927 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 928 if (Dart_IsError(cls)) { | 928 if (Dart_IsError(type)) { |
| 929 return cls; | 929 return type; |
| 930 } | 930 } |
| 931 Dart_Handle lazy_lib_mirror = CreateLazyMirror(lib); | 931 Dart_Handle lazy_lib_mirror = CreateLazyMirror(lib); |
| 932 if (Dart_IsError(lazy_lib_mirror)) { | 932 if (Dart_IsError(lazy_lib_mirror)) { |
| 933 return lazy_lib_mirror; | 933 return lazy_lib_mirror; |
| 934 } | 934 } |
| 935 Dart_Handle member_map = CreateMemberMap(lib, lazy_lib_mirror); | 935 Dart_Handle member_map = CreateMemberMap(lib, lazy_lib_mirror); |
| 936 if (Dart_IsError(member_map)) { | 936 if (Dart_IsError(member_map)) { |
| 937 return member_map; | 937 return member_map; |
| 938 } | 938 } |
| 939 Dart_Handle args[] = { | 939 Dart_Handle args[] = { |
| 940 CreateVMReference(lib), | 940 CreateVMReference(lib), |
| 941 Dart_LibraryName(lib), | 941 Dart_LibraryName(lib), |
| 942 Dart_LibraryUrl(lib), | 942 Dart_LibraryUrl(lib), |
| 943 member_map, | 943 member_map, |
| 944 }; | 944 }; |
| 945 Dart_Handle lib_mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 945 Dart_Handle lib_mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 946 if (Dart_IsError(lib_mirror)) { | 946 if (Dart_IsError(lib_mirror)) { |
| 947 return lib_mirror; | 947 return lib_mirror; |
| 948 } | 948 } |
| 949 | 949 |
| 950 return lib_mirror; | 950 return lib_mirror; |
| 951 } | 951 } |
| 952 | 952 |
| 953 | 953 |
| 954 static Dart_Handle CreateLibrariesMap() { | 954 static Dart_Handle CreateLibrariesMap() { |
| 955 // TODO(turnidge): This should be an immutable map. | 955 // TODO(turnidge): This should be an immutable map. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 981 return lib_mirror; | 981 return lib_mirror; |
| 982 } | 982 } |
| 983 result = MapAdd(map, lib_url, lib_mirror); | 983 result = MapAdd(map, lib_url, lib_mirror); |
| 984 } | 984 } |
| 985 return map; | 985 return map; |
| 986 } | 986 } |
| 987 | 987 |
| 988 | 988 |
| 989 static Dart_Handle CreateIsolateMirror() { | 989 static Dart_Handle CreateIsolateMirror() { |
| 990 Dart_Handle cls_name = NewString("_LocalIsolateMirrorImpl"); | 990 Dart_Handle cls_name = NewString("_LocalIsolateMirrorImpl"); |
| 991 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 991 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 992 if (Dart_IsError(cls)) { | 992 if (Dart_IsError(type)) { |
| 993 return cls; | 993 return type; |
| 994 } | 994 } |
| 995 Dart_Handle args[] = { | 995 Dart_Handle args[] = { |
| 996 Dart_DebugName(), | 996 Dart_DebugName(), |
| 997 CreateLazyMirror(Dart_RootLibrary()), | 997 CreateLazyMirror(Dart_RootLibrary()), |
| 998 }; | 998 }; |
| 999 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 999 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 | 1002 |
| 1003 static Dart_Handle CreateMirrorSystem() { | 1003 static Dart_Handle CreateMirrorSystem() { |
| 1004 Dart_Handle cls_name = NewString("_LocalMirrorSystemImpl"); | 1004 Dart_Handle cls_name = NewString("_LocalMirrorSystemImpl"); |
| 1005 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1005 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1006 if (Dart_IsError(cls)) { | 1006 if (Dart_IsError(type)) { |
| 1007 return cls; | 1007 return type; |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 Dart_Handle libraries = CreateLibrariesMap(); | 1010 Dart_Handle libraries = CreateLibrariesMap(); |
| 1011 if (Dart_IsError(libraries)) { | 1011 if (Dart_IsError(libraries)) { |
| 1012 return libraries; | 1012 return libraries; |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 Dart_Handle args[] = { | 1015 Dart_Handle args[] = { |
| 1016 libraries, | 1016 libraries, |
| 1017 CreateIsolateMirror(), | 1017 CreateIsolateMirror(), |
| 1018 }; | 1018 }; |
| 1019 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1019 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1020 if (Dart_IsError(mirror)) { | 1020 if (Dart_IsError(mirror)) { |
| 1021 return mirror; | 1021 return mirror; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 return mirror; | 1024 return mirror; |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 | 1027 |
| 1028 static Dart_Handle CreateNullMirror() { | 1028 static Dart_Handle CreateNullMirror() { |
| 1029 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); | 1029 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); |
| 1030 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1030 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1031 if (Dart_IsError(cls)) { | 1031 if (Dart_IsError(type)) { |
| 1032 return cls; | 1032 return type; |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 // TODO(turnidge): This is wrong. The Null class is distinct from object. | 1035 // TODO(turnidge): This is wrong. The Null class is distinct from object. |
| 1036 Dart_Handle object_class = Dart_GetClass(CoreLib(), NewString("Object")); | 1036 Dart_Handle object_class = Dart_GetClass(CoreLib(), NewString("Object")); |
| 1037 | 1037 |
| 1038 Dart_Handle args[] = { | 1038 Dart_Handle args[] = { |
| 1039 CreateVMReference(Dart_Null()), | 1039 CreateVMReference(Dart_Null()), |
| 1040 CreateLazyMirror(object_class), | 1040 CreateLazyMirror(object_class), |
| 1041 Dart_Null(), | 1041 Dart_Null(), |
| 1042 }; | 1042 }; |
| 1043 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1043 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1044 return mirror; | 1044 return mirror; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 | 1047 |
| 1048 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) { | 1048 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) { |
| 1049 if (Dart_IsNull(instance)) { | 1049 if (Dart_IsNull(instance)) { |
| 1050 return CreateNullMirror(); | 1050 return CreateNullMirror(); |
| 1051 } | 1051 } |
| 1052 ASSERT(Dart_IsInstance(instance)); | 1052 ASSERT(Dart_IsInstance(instance)); |
| 1053 | 1053 |
| 1054 Dart_Handle instance_cls = Dart_InstanceGetClass(instance); | 1054 Dart_Handle instance_cls = Dart_InstanceGetClass(instance); |
| 1055 if (Dart_IsError(instance_cls)) { | 1055 if (Dart_IsError(instance_cls)) { |
| 1056 return instance_cls; | 1056 return instance_cls; |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 if (Dart_IsClosure(instance)) { | 1059 if (Dart_IsClosure(instance)) { |
| 1060 Dart_Handle cls_name = NewString("_LocalClosureMirrorImpl"); | 1060 Dart_Handle cls_name = NewString("_LocalClosureMirrorImpl"); |
| 1061 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1061 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1062 if (Dart_IsError(cls)) { | 1062 if (Dart_IsError(type)) { |
| 1063 return cls; | 1063 return type; |
| 1064 } | 1064 } |
| 1065 // We set the function field of ClosureMirrors outside of the constructor | 1065 // We set the function field of ClosureMirrors outside of the constructor |
| 1066 // to break the mutual recursion. | 1066 // to break the mutual recursion. |
| 1067 Dart_Handle func = Dart_ClosureFunction(instance); | 1067 Dart_Handle func = Dart_ClosureFunction(instance); |
| 1068 if (Dart_IsError(func)) { | 1068 if (Dart_IsError(func)) { |
| 1069 return func; | 1069 return func; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 // TODO(turnidge): Why not use the real function name here? | 1072 // TODO(turnidge): Why not use the real function name here? |
| 1073 Dart_Handle func_name = NewString("call"); | 1073 Dart_Handle func_name = NewString("call"); |
| 1074 Dart_Handle func_owner = Dart_FunctionOwner(func); | 1074 Dart_Handle func_owner = Dart_FunctionOwner(func); |
| 1075 if (Dart_IsError(func_owner)) { | 1075 if (Dart_IsError(func_owner)) { |
| 1076 return func_owner; | 1076 return func_owner; |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 // TODO(turnidge): Pass the function owner here. This will require | 1079 // TODO(turnidge): Pass the function owner here. This will require |
| 1080 // us to support functions in CreateLazyMirror. | 1080 // us to support functions in CreateLazyMirror. |
| 1081 Dart_Handle func_mirror = | 1081 Dart_Handle func_mirror = |
| 1082 CreateMethodMirror(func, func_name, Dart_Null()); | 1082 CreateMethodMirror(func, func_name, Dart_Null()); |
| 1083 if (Dart_IsError(func_mirror)) { | 1083 if (Dart_IsError(func_mirror)) { |
| 1084 return func_mirror; | 1084 return func_mirror; |
| 1085 } | 1085 } |
| 1086 Dart_Handle args[] = { | 1086 Dart_Handle args[] = { |
| 1087 CreateVMReference(instance), | 1087 CreateVMReference(instance), |
| 1088 CreateLazyMirror(instance_cls), | 1088 CreateLazyMirror(instance_cls), |
| 1089 instance, | 1089 instance, |
| 1090 func_mirror, | 1090 func_mirror, |
| 1091 }; | 1091 }; |
| 1092 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1092 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1093 | 1093 |
| 1094 } else { | 1094 } else { |
| 1095 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); | 1095 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); |
| 1096 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1096 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1097 if (Dart_IsError(cls)) { | 1097 if (Dart_IsError(type)) { |
| 1098 return cls; | 1098 return type; |
| 1099 } | 1099 } |
| 1100 Dart_Handle args[] = { | 1100 Dart_Handle args[] = { |
| 1101 CreateVMReference(instance), | 1101 CreateVMReference(instance), |
| 1102 CreateLazyMirror(instance_cls), | 1102 CreateLazyMirror(instance_cls), |
| 1103 instance, | 1103 instance, |
| 1104 }; | 1104 }; |
| 1105 return Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1105 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1106 } | 1106 } |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 | 1109 |
| 1110 static Dart_Handle CreateMirroredError(Dart_Handle error) { | 1110 static Dart_Handle CreateMirroredError(Dart_Handle error) { |
| 1111 ASSERT(Dart_IsError(error)); | 1111 ASSERT(Dart_IsError(error)); |
| 1112 if (Dart_IsUnhandledExceptionError(error)) { | 1112 if (Dart_IsUnhandledExceptionError(error)) { |
| 1113 Dart_Handle exc = Dart_ErrorGetException(error); | 1113 Dart_Handle exc = Dart_ErrorGetException(error); |
| 1114 if (Dart_IsError(exc)) { | 1114 if (Dart_IsError(exc)) { |
| 1115 return exc; | 1115 return exc; |
| 1116 } | 1116 } |
| 1117 Dart_Handle exc_string = Dart_ToString(exc); | 1117 Dart_Handle exc_string = Dart_ToString(exc); |
| 1118 if (Dart_IsError(exc_string)) { | 1118 if (Dart_IsError(exc_string)) { |
| 1119 // Only propagate fatal errors from exc.toString(). Ignore the rest. | 1119 // Only propagate fatal errors from exc.toString(). Ignore the rest. |
| 1120 if (Dart_IsFatalError(exc_string)) { | 1120 if (Dart_IsFatalError(exc_string)) { |
| 1121 return exc_string; | 1121 return exc_string; |
| 1122 } | 1122 } |
| 1123 exc_string = Dart_Null(); | 1123 exc_string = Dart_Null(); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 Dart_Handle stack = Dart_ErrorGetStacktrace(error); | 1126 Dart_Handle stack = Dart_ErrorGetStacktrace(error); |
| 1127 if (Dart_IsError(stack)) { | 1127 if (Dart_IsError(stack)) { |
| 1128 return stack; | 1128 return stack; |
| 1129 } | 1129 } |
| 1130 Dart_Handle cls_name = NewString("MirroredUncaughtExceptionError"); | 1130 Dart_Handle cls_name = NewString("MirroredUncaughtExceptionError"); |
| 1131 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1131 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1132 Dart_Handle args[] = { | 1132 Dart_Handle args[] = { |
| 1133 CreateInstanceMirror(exc), | 1133 CreateInstanceMirror(exc), |
| 1134 exc_string, | 1134 exc_string, |
| 1135 stack, | 1135 stack, |
| 1136 }; | 1136 }; |
| 1137 Dart_Handle mirrored_exc = | 1137 Dart_Handle mirrored_exc = |
| 1138 Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1138 Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1139 return Dart_NewUnhandledExceptionError(mirrored_exc); | 1139 return Dart_NewUnhandledExceptionError(mirrored_exc); |
| 1140 } else if (Dart_IsApiError(error) || | 1140 } else if (Dart_IsApiError(error) || |
| 1141 Dart_IsCompilationError(error)) { | 1141 Dart_IsCompilationError(error)) { |
| 1142 Dart_Handle cls_name = NewString("MirroredCompilationError"); | 1142 Dart_Handle cls_name = NewString("MirroredCompilationError"); |
| 1143 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 1143 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1144 Dart_Handle args[] = { NewString(Dart_GetError(error)) }; | 1144 Dart_Handle args[] = { NewString(Dart_GetError(error)) }; |
| 1145 Dart_Handle mirrored_exc = | 1145 Dart_Handle mirrored_exc = |
| 1146 Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 1146 Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1147 return Dart_NewUnhandledExceptionError(mirrored_exc); | 1147 return Dart_NewUnhandledExceptionError(mirrored_exc); |
| 1148 } else { | 1148 } else { |
| 1149 ASSERT(Dart_IsFatalError(error)); | 1149 ASSERT(Dart_IsFatalError(error)); |
| 1150 return error; | 1150 return error; |
| 1151 } | 1151 } |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 | 1154 |
| 1155 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( | 1155 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( |
| 1156 Dart_NativeArguments args) { | 1156 Dart_NativeArguments args) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1398 Dart_ExitScope(); | 1398 Dart_ExitScope(); |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 void HandleMirrorsMessage(Isolate* isolate, | 1401 void HandleMirrorsMessage(Isolate* isolate, |
| 1402 Dart_Port reply_port, | 1402 Dart_Port reply_port, |
| 1403 const Instance& message) { | 1403 const Instance& message) { |
| 1404 UNIMPLEMENTED(); | 1404 UNIMPLEMENTED(); |
| 1405 } | 1405 } |
| 1406 | 1406 |
| 1407 } // namespace dart | 1407 } // namespace dart |
| OLD | NEW |