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

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

Issue 19030004: Stop resolving classes prematurely in the vm (issue 11023). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/object.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_mirrors_api.h" 5 #include "include/dart_mirrors_api.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 177
178 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle object) { 178 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle object) {
179 Isolate* isolate = Isolate::Current(); 179 Isolate* isolate = Isolate::Current();
180 DARTSCOPE(isolate); 180 DARTSCOPE(isolate);
181 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 181 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
182 if (!obj.IsType() && !obj.IsClass()) { 182 if (!obj.IsType() && !obj.IsClass()) {
183 RETURN_TYPE_ERROR(isolate, object, Class/Type); 183 RETURN_TYPE_ERROR(isolate, object, Class/Type);
184 } 184 }
185 // Ensure all classes are finalized.
186 Dart_Handle state = Api::CheckIsolateState(isolate);
187 if (::Dart_IsError(state)) {
188 return state;
189 }
185 const Class& cls = (obj.IsType()) ? 190 const Class& cls = (obj.IsType()) ?
186 Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj); 191 Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj);
187 // A class represents a function type when it is a canonical 192 // A class represents a function type when it is a canonical
188 // signature class. 193 // signature class.
189 return cls.IsCanonicalSignatureClass(); 194 return cls.IsCanonicalSignatureClass();
190 } 195 }
191 196
192 197
193 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle object) { 198 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle object) {
194 Isolate* isolate = Isolate::Current(); 199 Isolate* isolate = Isolate::Current();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 498 }
494 499
495 500
496 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function) { 501 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function) {
497 Isolate* isolate = Isolate::Current(); 502 Isolate* isolate = Isolate::Current();
498 DARTSCOPE(isolate); 503 DARTSCOPE(isolate);
499 const Function& func = Api::UnwrapFunctionHandle(isolate, function); 504 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
500 if (func.IsNull()) { 505 if (func.IsNull()) {
501 RETURN_TYPE_ERROR(isolate, function, Function); 506 RETURN_TYPE_ERROR(isolate, function, Function);
502 } 507 }
503 508 // Ensure all classes are finalized.
509 Dart_Handle state = Api::CheckIsolateState(isolate);
510 if (::Dart_IsError(state)) {
511 return state;
512 }
504 if (func.kind() == RawFunction::kConstructor) { 513 if (func.kind() == RawFunction::kConstructor) {
505 // Special case the return type for constructors. Inside the vm 514 // Special case the return type for constructors. Inside the vm
506 // we mark them as returning dynamic, but for the purposes of 515 // we mark them as returning dynamic, but for the purposes of
507 // reflection, they return the type of the class being 516 // reflection, they return the type of the class being
508 // constructed. 517 // constructed.
509 return Api::NewHandle(isolate, func.Owner()); 518 return Api::NewHandle(isolate, func.Owner());
510 } else { 519 } else {
511 const AbstractType& return_type = 520 const AbstractType& return_type =
512 AbstractType::Handle(isolate, func.result_type()); 521 AbstractType::Handle(isolate, func.result_type());
513 return TypeToHandle(isolate, "Dart_FunctionReturnType", return_type); 522 return TypeToHandle(isolate, "Dart_FunctionReturnType", return_type);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 557
549 558
550 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function, 559 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function,
551 int parameter_index) { 560 int parameter_index) {
552 Isolate* isolate = Isolate::Current(); 561 Isolate* isolate = Isolate::Current();
553 DARTSCOPE(isolate); 562 DARTSCOPE(isolate);
554 const Function& func = Api::UnwrapFunctionHandle(isolate, function); 563 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
555 if (func.IsNull()) { 564 if (func.IsNull()) {
556 RETURN_TYPE_ERROR(isolate, function, Function); 565 RETURN_TYPE_ERROR(isolate, function, Function);
557 } 566 }
558 567 // Ensure all classes are finalized.
568 Dart_Handle state = Api::CheckIsolateState(isolate);
569 if (::Dart_IsError(state)) {
570 return state;
571 }
559 const intptr_t num_implicit_params = func.NumImplicitParameters(); 572 const intptr_t num_implicit_params = func.NumImplicitParameters();
560 const intptr_t num_params = func.NumParameters() - num_implicit_params; 573 const intptr_t num_params = func.NumParameters() - num_implicit_params;
561 if (parameter_index < 0 || parameter_index >= num_params) { 574 if (parameter_index < 0 || parameter_index >= num_params) {
562 return Api::NewError( 575 return Api::NewError(
563 "%s: argument 'parameter_index' out of range. " 576 "%s: argument 'parameter_index' out of range. "
564 "Expected 0..%"Pd" but saw %d.", 577 "Expected 0..%"Pd" but saw %d.",
565 CURRENT_FUNC, num_params, parameter_index); 578 CURRENT_FUNC, num_params, parameter_index);
566 } 579 }
567 const AbstractType& param_type = 580 const AbstractType& param_type =
568 AbstractType::Handle(isolate, func.ParameterTypeAt( 581 AbstractType::Handle(isolate, func.ParameterTypeAt(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 715 }
703 716
704 717
705 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle variable) { 718 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle variable) {
706 Isolate* isolate = Isolate::Current(); 719 Isolate* isolate = Isolate::Current();
707 DARTSCOPE(isolate); 720 DARTSCOPE(isolate);
708 const Field& var = Api::UnwrapFieldHandle(isolate, variable); 721 const Field& var = Api::UnwrapFieldHandle(isolate, variable);
709 if (var.IsNull()) { 722 if (var.IsNull()) {
710 RETURN_TYPE_ERROR(isolate, variable, Field); 723 RETURN_TYPE_ERROR(isolate, variable, Field);
711 } 724 }
712 725 // Ensure all classes are finalized.
726 Dart_Handle state = Api::CheckIsolateState(isolate);
727 if (::Dart_IsError(state)) {
728 return state;
729 }
713 const AbstractType& type = AbstractType::Handle(isolate, var.type()); 730 const AbstractType& type = AbstractType::Handle(isolate, var.type());
714 return TypeToHandle(isolate, "Dart_VariableType", type); 731 return TypeToHandle(isolate, "Dart_VariableType", type);
715 } 732 }
716 733
717 734
718 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle object) { 735 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle object) {
719 Isolate* isolate = Isolate::Current(); 736 Isolate* isolate = Isolate::Current();
720 DARTSCOPE(isolate); 737 DARTSCOPE(isolate);
721 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 738 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
722 if (!obj.IsType() && !obj.IsClass()) { 739 if (!obj.IsType() && !obj.IsClass()) {
723 RETURN_TYPE_ERROR(isolate, object, Class/Type); 740 RETURN_TYPE_ERROR(isolate, object, Class/Type);
724 } 741 }
742 // Ensure all classes are finalized.
743 Dart_Handle state = Api::CheckIsolateState(isolate);
744 if (::Dart_IsError(state)) {
745 return state;
746 }
725 const Class& cls = (obj.IsType()) ? 747 const Class& cls = (obj.IsType()) ?
726 Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj); 748 Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj);
727 const intptr_t num_type_params = cls.NumTypeParameters(); 749 const intptr_t num_type_params = cls.NumTypeParameters();
728 const TypeArguments& type_params = 750 const TypeArguments& type_params =
729 TypeArguments::Handle(cls.type_parameters()); 751 TypeArguments::Handle(cls.type_parameters());
730 752
731 const GrowableObjectArray& names = 753 const GrowableObjectArray& names =
732 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); 754 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New());
733 TypeParameter& type_param = TypeParameter::Handle(isolate); 755 TypeParameter& type_param = TypeParameter::Handle(isolate);
734 String& name = String::Handle(isolate); 756 String& name = String::Handle(isolate);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } else if (obj.IsField()) { 917 } else if (obj.IsField()) {
896 cls = Field::Cast(obj).origin(); 918 cls = Field::Cast(obj).origin();
897 } else { 919 } else {
898 return Api::NewHandle(isolate, Object::empty_array().raw()); 920 return Api::NewHandle(isolate, Object::empty_array().raw());
899 } 921 }
900 const Library& lib = Library::Handle(cls.library()); 922 const Library& lib = Library::Handle(cls.library());
901 return Api::NewHandle(isolate, lib.GetMetadata(obj)); 923 return Api::NewHandle(isolate, lib.GetMetadata(obj));
902 } 924 }
903 925
904 } // namespace dart 926 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698