Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: runtime/lib/mirrors.cc

Issue 10778005: Add a limited version of ParameterMirrors that can only tell whether they are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
332 int64_t opt_param_count;
333 result = Dart_FunctionParameterCounts(func,
334 &fixed_param_count,
335 &opt_param_count);
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 the parameter mirrors with more than whether they are
353 // are optional.
354 for (int i = 0; i < fixed_param_count; i++) {
355 Dart_Handle args[] = { Dart_False() };
356 Dart_Handle fixed_param =
357 Dart_New(param_cls, Dart_Null(), ARRAY_SIZE(args), args);
358 if (Dart_IsError(fixed_param)) {
359 return fixed_param;
360 }
361 result = Dart_ListSetAt(parameter_mirrors, i, fixed_param);
362 if (Dart_IsError(result)) {
363 return result;
364 }
365 }
366
367 for (int i = 0; i < opt_param_count; i++) {
368 Dart_Handle args[] = { Dart_True() };
369 Dart_Handle opt_param =
370 Dart_New(param_cls, Dart_Null(), ARRAY_SIZE(args), args);
371 if (Dart_IsError(opt_param)) {
372 return opt_param;
373 }
374 result = Dart_ListSetAt(parameter_mirrors, i+fixed_param_count, opt_param);
375 if (Dart_IsError(result)) {
376 return result;
377 }
378 }
379
331 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). 380 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10).
332 Dart_Handle args[] = { 381 Dart_Handle args[] = {
333 func_name, 382 func_name,
334 lib_mirror, 383 lib_mirror,
384 parameter_mirrors,
335 Dart_NewBoolean(is_static), 385 Dart_NewBoolean(is_static),
336 Dart_NewBoolean(is_abstract), 386 Dart_NewBoolean(is_abstract),
337 Dart_NewBoolean(is_getter), 387 Dart_NewBoolean(is_getter),
338 Dart_NewBoolean(is_setter), 388 Dart_NewBoolean(is_setter),
339 Dart_NewBoolean(is_constructor), 389 Dart_NewBoolean(is_constructor),
340 Dart_False(), 390 Dart_False(),
341 Dart_False(), 391 Dart_False(),
342 Dart_False(), 392 Dart_False(),
343 Dart_False(), 393 Dart_False(),
344 }; 394 };
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 if (Dart_IsError(cls)) { 668 if (Dart_IsError(cls)) {
619 return cls; 669 return cls;
620 } 670 }
621 671
622 // TODO(turnidge): This is wrong. The Null class is distinct from object. 672 // TODO(turnidge): This is wrong. The Null class is distinct from object.
623 Dart_Handle object_class = Dart_GetClass(CoreLib(), Dart_NewString("Object")); 673 Dart_Handle object_class = Dart_GetClass(CoreLib(), Dart_NewString("Object"));
624 674
625 Dart_Handle args[] = { 675 Dart_Handle args[] = {
626 CreateVMReference(Dart_Null()), 676 CreateVMReference(Dart_Null()),
627 CreateLazyMirror(object_class), 677 CreateLazyMirror(object_class),
628 Dart_True(),
629 Dart_Null(), 678 Dart_Null(),
630 }; 679 };
631 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); 680 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args);
632 return mirror; 681 return mirror;
633 } 682 }
634 683
635 684
636 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) { 685 static Dart_Handle CreateInstanceMirror(Dart_Handle instance) {
637 if (Dart_IsNull(instance)) { 686 if (Dart_IsNull(instance)) {
638 return CreateNullMirror(); 687 return CreateNullMirror();
639 } 688 }
640 ASSERT(Dart_IsInstance(instance)); 689 ASSERT(Dart_IsInstance(instance));
641 Dart_Handle cls_name = Dart_NewString("_LocalInstanceMirrorImpl"); 690 Dart_Handle cls_name = Dart_NewString("_LocalInstanceMirrorImpl");
642 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); 691 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name);
643 if (Dart_IsError(cls)) { 692 if (Dart_IsError(cls)) {
644 return cls; 693 return cls;
645 } 694 }
646 Dart_Handle instance_cls = Dart_InstanceGetClass(instance); 695 Dart_Handle instance_cls = Dart_InstanceGetClass(instance);
647 if (Dart_IsError(instance_cls)) { 696 if (Dart_IsError(instance_cls)) {
648 return instance_cls; 697 return instance_cls;
649 } 698 }
650 699
651 bool is_simple = IsSimpleValue(instance);
652 Dart_Handle args[] = { 700 Dart_Handle args[] = {
653 CreateVMReference(instance), 701 CreateVMReference(instance),
654 CreateLazyMirror(instance_cls), 702 CreateLazyMirror(instance_cls),
655 Dart_NewBoolean(is_simple),
656 instance 703 instance
657 }; 704 };
658 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); 705 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args);
659 return mirror; 706 return mirror;
660 } 707 }
661 708
662 709
663 static Dart_Handle CreateMirroredError(Dart_Handle error) { 710 static Dart_Handle CreateMirroredError(Dart_Handle error) {
664 ASSERT(Dart_IsError(error)); 711 ASSERT(Dart_IsError(error));
665 if (Dart_IsUnhandledExceptionError(error)) { 712 if (Dart_IsUnhandledExceptionError(error)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 Dart_SetReturnValue(args, wrapped_result); 798 Dart_SetReturnValue(args, wrapped_result);
752 } 799 }
753 800
754 void HandleMirrorsMessage(Isolate* isolate, 801 void HandleMirrorsMessage(Isolate* isolate,
755 Dart_Port reply_port, 802 Dart_Port reply_port,
756 const Instance& message) { 803 const Instance& message) {
757 UNIMPLEMENTED(); 804 UNIMPLEMENTED();
758 } 805 }
759 806
760 } // namespace dart 807 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698