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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 11125005: Support for type dynamic in VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 2654
2655 const GrowableObjectArray& names = 2655 const GrowableObjectArray& names =
2656 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); 2656 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New());
2657 Function& func = Function::Handle(); 2657 Function& func = Function::Handle();
2658 String& name = String::Handle(); 2658 String& name = String::Handle();
2659 2659
2660 if (obj.IsClass()) { 2660 if (obj.IsClass()) {
2661 const Class& cls = Class::Cast(obj); 2661 const Class& cls = Class::Cast(obj);
2662 const Array& func_array = Array::Handle(cls.functions()); 2662 const Array& func_array = Array::Handle(cls.functions());
2663 2663
2664 // Some special types like 'Dynamic' have a null functions list. 2664 // Some special types like 'dynamic' have a null functions list.
2665 if (!func_array.IsNull()) { 2665 if (!func_array.IsNull()) {
2666 for (intptr_t i = 0; i < func_array.Length(); ++i) { 2666 for (intptr_t i = 0; i < func_array.Length(); ++i) {
2667 func ^= func_array.At(i); 2667 func ^= func_array.At(i);
2668 2668
2669 // Skip implicit getters and setters. 2669 // Skip implicit getters and setters.
2670 if (func.kind() == RawFunction::kImplicitGetter || 2670 if (func.kind() == RawFunction::kImplicitGetter ||
2671 func.kind() == RawFunction::kImplicitSetter || 2671 func.kind() == RawFunction::kImplicitSetter ||
2672 func.kind() == RawFunction::kConstImplicitGetter) { 2672 func.kind() == RawFunction::kConstImplicitGetter) {
2673 continue; 2673 continue;
2674 } 2674 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function) { 2909 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function) {
2910 Isolate* isolate = Isolate::Current(); 2910 Isolate* isolate = Isolate::Current();
2911 DARTSCOPE(isolate); 2911 DARTSCOPE(isolate);
2912 const Function& func = Api::UnwrapFunctionHandle(isolate, function); 2912 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
2913 if (func.IsNull()) { 2913 if (func.IsNull()) {
2914 RETURN_TYPE_ERROR(isolate, function, Function); 2914 RETURN_TYPE_ERROR(isolate, function, Function);
2915 } 2915 }
2916 2916
2917 if (func.kind() == RawFunction::kConstructor) { 2917 if (func.kind() == RawFunction::kConstructor) {
2918 // Special case the return type for constructors. Inside the vm 2918 // Special case the return type for constructors. Inside the vm
2919 // we mark them as returning Dynamic, but for the purposes of 2919 // we mark them as returning dynamic, but for the purposes of
2920 // reflection, they return the type of the class being 2920 // reflection, they return the type of the class being
2921 // constructed. 2921 // constructed.
2922 return Api::NewHandle(isolate, func.Owner()); 2922 return Api::NewHandle(isolate, func.Owner());
2923 } else { 2923 } else {
2924 const AbstractType& return_type = 2924 const AbstractType& return_type =
2925 AbstractType::Handle(isolate, func.result_type()); 2925 AbstractType::Handle(isolate, func.result_type());
2926 return TypeToHandle(isolate, "Dart_FunctionReturnType", return_type); 2926 return TypeToHandle(isolate, "Dart_FunctionReturnType", return_type);
2927 } 2927 }
2928 } 2928 }
2929 2929
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 2994
2995 const GrowableObjectArray& names = 2995 const GrowableObjectArray& names =
2996 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); 2996 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New());
2997 Field& field = Field::Handle(isolate); 2997 Field& field = Field::Handle(isolate);
2998 String& name = String::Handle(isolate); 2998 String& name = String::Handle(isolate);
2999 2999
3000 if (obj.IsClass()) { 3000 if (obj.IsClass()) {
3001 const Class& cls = Class::Cast(obj); 3001 const Class& cls = Class::Cast(obj);
3002 const Array& field_array = Array::Handle(cls.fields()); 3002 const Array& field_array = Array::Handle(cls.fields());
3003 3003
3004 // Some special types like 'Dynamic' have a null fields list. 3004 // Some special types like 'dynamic' have a null fields list.
3005 // 3005 //
3006 // TODO(turnidge): Fix 'Dynamic' so that it does not have a null 3006 // TODO(turnidge): Fix 'dynamic' so that it does not have a null
3007 // fields list. This will have to wait until the empty array is 3007 // fields list. This will have to wait until the empty array is
3008 // allocated in the vm isolate. 3008 // allocated in the vm isolate.
3009 if (!field_array.IsNull()) { 3009 if (!field_array.IsNull()) {
3010 for (intptr_t i = 0; i < field_array.Length(); ++i) { 3010 for (intptr_t i = 0; i < field_array.Length(); ++i) {
3011 field ^= field_array.At(i); 3011 field ^= field_array.At(i);
3012 name = field.UserVisibleName(); 3012 name = field.UserVisibleName();
3013 names.Add(name); 3013 names.Add(name);
3014 } 3014 }
3015 } 3015 }
3016 } else if (obj.IsLibrary()) { 3016 } else if (obj.IsLibrary()) {
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
4477 } 4477 }
4478 { 4478 {
4479 NoGCScope no_gc; 4479 NoGCScope no_gc;
4480 RawObject* raw_obj = obj.raw(); 4480 RawObject* raw_obj = obj.raw();
4481 isolate->heap()->SetPeer(raw_obj, peer); 4481 isolate->heap()->SetPeer(raw_obj, peer);
4482 } 4482 }
4483 return Api::Success(isolate); 4483 return Api::Success(isolate);
4484 } 4484 }
4485 4485
4486 } // namespace dart 4486 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698