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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "include/dart_debugger_api.h" | 9 #include "include/dart_debugger_api.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 321 } |
| 322 result = Dart_FunctionIsSetter(func, &is_setter); | 322 result = Dart_FunctionIsSetter(func, &is_setter); |
| 323 if (Dart_IsError(result)) { | 323 if (Dart_IsError(result)) { |
| 324 return result; | 324 return result; |
| 325 } | 325 } |
| 326 result = Dart_FunctionIsConstructor(func, &is_constructor); | 326 result = Dart_FunctionIsConstructor(func, &is_constructor); |
| 327 if (Dart_IsError(result)) { | 327 if (Dart_IsError(result)) { |
| 328 return result; | 328 return result; |
| 329 } | 329 } |
| 330 | 330 |
| 331 int64_t fixed_param_count, opt_param_count; | |
|
turnidge
2012/07/13 23:37:12
We declare only one variable per line.
| |
| 332 result = Dart_FunctionParameterCounts( | |
| 333 func, | |
| 334 &fixed_param_count, | |
| 335 &opt_param_count); | |
|
turnidge
2012/07/13 23:37:12
Since parameters are short, reindent like this:
r
| |
| 336 if (Dart_IsError(result)) { | |
| 337 return result; | |
| 338 } | |
| 339 | |
| 340 Dart_Handle parameter_mirrors = | |
| 341 Dart_NewList(fixed_param_count + opt_param_count); | |
| 342 if (Dart_IsError(parameter_mirrors)) { | |
| 343 return result; | |
| 344 } | |
| 345 | |
| 346 Dart_Handle param_cls_name = Dart_NewString("_LocalParameterMirrorImpl"); | |
| 347 Dart_Handle param_cls = Dart_GetClass(MirrorLib(), param_cls_name); | |
| 348 if (Dart_IsError(param_cls)) { | |
| 349 return param_cls; | |
| 350 } | |
| 351 | |
| 352 // TODO(rmacnak): Fill parameter mirrors will more than whether they're opt. | |
|
turnidge
2012/07/13 23:37:12
Comment reads funny. Is there a typo?
| |
| 353 for (int i = 0; i < fixed_param_count; i++) { | |
| 354 Dart_Handle args[] = { | |
| 355 Dart_False() | |
| 356 }; | |
|
turnidge
2012/07/13 23:37:12
Since there's only one arg, put the initializer an
rmacnak
2012/07/16 17:36:39
I did that initially, but the linter complained. I
| |
| 357 Dart_Handle fixed_param = | |
| 358 Dart_New(param_cls, Dart_Null(), ARRAY_SIZE(args), args); | |
| 359 if (Dart_IsError(fixed_param)) { | |
| 360 return fixed_param; | |
| 361 } | |
| 362 result = Dart_ListSetAt(parameter_mirrors, i, fixed_param); | |
| 363 if (Dart_IsError(result)) { | |
| 364 return result; | |
| 365 } | |
| 366 } | |
| 367 | |
| 368 for (int i = 0; i < opt_param_count; i++) { | |
| 369 Dart_Handle args[] = { | |
| 370 Dart_True() | |
| 371 }; | |
| 372 Dart_Handle opt_param = | |
| 373 Dart_New(param_cls, Dart_Null(), ARRAY_SIZE(args), args); | |
| 374 if (Dart_IsError(opt_param)) { | |
| 375 return opt_param; | |
| 376 } | |
| 377 result = Dart_ListSetAt(parameter_mirrors, i+fixed_param_count, opt_param); | |
| 378 if (Dart_IsError(result)) { | |
| 379 return result; | |
| 380 } | |
| 381 } | |
| 382 | |
| 331 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). | 383 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). |
| 332 Dart_Handle args[] = { | 384 Dart_Handle args[] = { |
| 333 func_name, | 385 func_name, |
| 334 lib_mirror, | 386 lib_mirror, |
| 387 parameter_mirrors, | |
| 335 Dart_NewBoolean(is_static), | 388 Dart_NewBoolean(is_static), |
| 336 Dart_NewBoolean(is_abstract), | 389 Dart_NewBoolean(is_abstract), |
| 337 Dart_NewBoolean(is_getter), | 390 Dart_NewBoolean(is_getter), |
| 338 Dart_NewBoolean(is_setter), | 391 Dart_NewBoolean(is_setter), |
| 339 Dart_NewBoolean(is_constructor), | 392 Dart_NewBoolean(is_constructor), |
| 340 Dart_False(), | 393 Dart_False(), |
| 341 Dart_False(), | 394 Dart_False(), |
| 342 Dart_False(), | 395 Dart_False(), |
| 343 Dart_False(), | 396 Dart_False(), |
| 344 }; | 397 }; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 if (Dart_IsError(cls)) { | 671 if (Dart_IsError(cls)) { |
| 619 return cls; | 672 return cls; |
| 620 } | 673 } |
| 621 | 674 |
| 622 // TODO(turnidge): This is wrong. The Null class is distinct from object. | 675 // TODO(turnidge): This is wrong. The Null class is distinct from object. |
| 623 Dart_Handle object_class = Dart_GetClass(CoreLib(), Dart_NewString("Object")); | 676 Dart_Handle object_class = Dart_GetClass(CoreLib(), Dart_NewString("Object")); |
| 624 | 677 |
| 625 Dart_Handle args[] = { | 678 Dart_Handle args[] = { |
| 626 CreateVMReference(Dart_Null()), | 679 CreateVMReference(Dart_Null()), |
| 627 CreateLazyMirror(object_class), | 680 CreateLazyMirror(object_class), |
| 628 Dart_True(), | |
| 629 Dart_Null(), | 681 Dart_Null(), |
| 630 }; | 682 }; |
| 631 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 683 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); |
| 632 return mirror; | 684 return mirror; |
| 633 } | 685 } |
| 634 | 686 |
| 635 | 687 |
| 636 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) { | 688 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) { |
| 637 if (Dart_IsNull(instance)) { | 689 if (Dart_IsNull(instance)) { |
| 638 return CreateNullMirror(); | 690 return CreateNullMirror(); |
| 639 } | 691 } |
| 640 ASSERT(Dart_IsInstance(instance)); | 692 ASSERT(Dart_IsInstance(instance)); |
| 641 Dart_Handle cls_name = Dart_NewString("_LocalInstanceMirrorImpl"); | 693 Dart_Handle cls_name = Dart_NewString("_LocalInstanceMirrorImpl"); |
| 642 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 694 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); |
| 643 if (Dart_IsError(cls)) { | 695 if (Dart_IsError(cls)) { |
| 644 return cls; | 696 return cls; |
| 645 } | 697 } |
| 646 Dart_Handle instance_cls = Dart_InstanceGetClass(instance); | 698 Dart_Handle instance_cls = Dart_InstanceGetClass(instance); |
| 647 if (Dart_IsError(instance_cls)) { | 699 if (Dart_IsError(instance_cls)) { |
| 648 return instance_cls; | 700 return instance_cls; |
| 649 } | 701 } |
| 650 | 702 |
| 651 bool is_simple = IsSimpleValue(instance); | |
| 652 Dart_Handle args[] = { | 703 Dart_Handle args[] = { |
| 653 CreateVMReference(instance), | 704 CreateVMReference(instance), |
| 654 CreateLazyMirror(instance_cls), | 705 CreateLazyMirror(instance_cls), |
| 655 Dart_NewBoolean(is_simple), | |
| 656 instance | 706 instance |
| 657 }; | 707 }; |
| 658 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 708 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); |
| 659 return mirror; | 709 return mirror; |
| 660 } | 710 } |
| 661 | 711 |
| 662 | 712 |
| 663 static Dart_Handle CreateMirroredError(Dart_Handle error) { | 713 static Dart_Handle CreateMirroredError(Dart_Handle error) { |
| 664 ASSERT(Dart_IsError(error)); | 714 ASSERT(Dart_IsError(error)); |
| 665 if (Dart_IsUnhandledExceptionError(error)) { | 715 if (Dart_IsUnhandledExceptionError(error)) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 Dart_SetReturnValue(args, wrapped_result); | 801 Dart_SetReturnValue(args, wrapped_result); |
| 752 } | 802 } |
| 753 | 803 |
| 754 void HandleMirrorsMessage(Isolate* isolate, | 804 void HandleMirrorsMessage(Isolate* isolate, |
| 755 Dart_Port reply_port, | 805 Dart_Port reply_port, |
| 756 const Instance& message) { | 806 const Instance& message) { |
| 757 UNIMPLEMENTED(); | 807 UNIMPLEMENTED(); |
| 758 } | 808 } |
| 759 | 809 |
| 760 } // namespace dart | 810 } // namespace dart |
| OLD | NEW |