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

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

Issue 2359543003: Make sure unresolved function type parameter bounds do not end up in snapshot. (Closed)
Patch Set: address Siva/s comments Created 4 years, 3 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 set_num_own_type_arguments(num_type_params - num_overlapping_type_args); 2417 set_num_own_type_arguments(num_type_params - num_overlapping_type_args);
2418 return num_type_params - num_overlapping_type_args; 2418 return num_type_params - num_overlapping_type_args;
2419 } 2419 }
2420 } 2420 }
2421 // No overlap found. 2421 // No overlap found.
2422 set_num_own_type_arguments(num_type_params); 2422 set_num_own_type_arguments(num_type_params);
2423 return num_type_params; 2423 return num_type_params;
2424 } 2424 }
2425 2425
2426 2426
2427 bool Class::IsGeneric() const {
2428 return NumTypeParameters() != 0;
2429 }
2430
2431
2432 intptr_t Class::NumTypeArguments() const { 2427 intptr_t Class::NumTypeArguments() const {
2433 // Return cached value if already calculated. 2428 // Return cached value if already calculated.
2434 if (num_type_arguments() != kUnknownNumTypeArguments) { 2429 if (num_type_arguments() != kUnknownNumTypeArguments) {
2435 return num_type_arguments(); 2430 return num_type_arguments();
2436 } 2431 }
2437 // To work properly, this call requires the super class of this class to be 2432 // To work properly, this call requires the super class of this class to be
2438 // resolved, which is checked by the type_class() call on the super type. 2433 // resolved, which is checked by the type_class() call on the super type.
2439 // Note that calling type_class() on a MixinAppType fails. 2434 // Note that calling type_class() on a MixinAppType fails.
2440 Thread* thread = Thread::Current(); 2435 Thread* thread = Thread::Current();
2441 Zone* zone = thread->zone(); 2436 Zone* zone = thread->zone();
(...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after
5884 } 5879 }
5885 5880
5886 5881
5887 RawTypeParameter* Function::LookupTypeParameter( 5882 RawTypeParameter* Function::LookupTypeParameter(
5888 const String& type_name, intptr_t* function_level) const { 5883 const String& type_name, intptr_t* function_level) const {
5889 ASSERT(!type_name.IsNull()); 5884 ASSERT(!type_name.IsNull());
5890 Thread* thread = Thread::Current(); 5885 Thread* thread = Thread::Current();
5891 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); 5886 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
5892 REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread); 5887 REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread);
5893 REUSABLE_STRING_HANDLESCOPE(thread); 5888 REUSABLE_STRING_HANDLESCOPE(thread);
5889 REUSABLE_FUNCTION_HANDLESCOPE(thread);
5894 TypeArguments& type_params = thread->TypeArgumentsHandle(); 5890 TypeArguments& type_params = thread->TypeArgumentsHandle();
5895 TypeParameter& type_param = thread->TypeParameterHandle(); 5891 TypeParameter& type_param = thread->TypeParameterHandle();
5896 String& type_param_name = thread->StringHandle(); 5892 String& type_param_name = thread->StringHandle();
5897 Function& function = thread->FunctionHandle(); 5893 Function& function = thread->FunctionHandle();
5898 5894
5899 function ^= this->raw(); 5895 function ^= this->raw();
5900 intptr_t parent_level = -1; 5896 intptr_t parent_level = -1;
5901 while (!function.IsNull()) { 5897 while (!function.IsNull()) {
5902 type_params ^= function.type_parameters(); 5898 type_params ^= function.type_parameters();
5903 if (!type_params.IsNull()) { 5899 if (!type_params.IsNull()) {
(...skipping 12067 matching lines...) Expand 10 before | Expand all | Expand 10 after
17971 return result.raw(); 17967 return result.raw();
17972 } 17968 }
17973 17969
17974 17970
17975 void TypeParameter::set_token_pos(TokenPosition token_pos) const { 17971 void TypeParameter::set_token_pos(TokenPosition token_pos) const {
17976 ASSERT(!token_pos.IsClassifying()); 17972 ASSERT(!token_pos.IsClassifying());
17977 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 17973 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
17978 } 17974 }
17979 17975
17980 17976
17977 void TypeParameter::set_parent_level(uint8_t value) const {
17978 StoreNonPointer(&raw_ptr()->parent_level_, value);
17979 }
17980
17981
17981 void TypeParameter::set_type_state(int8_t state) const { 17982 void TypeParameter::set_type_state(int8_t state) const {
17982 ASSERT((state == RawTypeParameter::kAllocated) || 17983 ASSERT((state == RawTypeParameter::kAllocated) ||
17983 (state == RawTypeParameter::kBeingFinalized) || 17984 (state == RawTypeParameter::kBeingFinalized) ||
17984 (state == RawTypeParameter::kFinalizedUninstantiated)); 17985 (state == RawTypeParameter::kFinalizedUninstantiated));
17985 StoreNonPointer(&raw_ptr()->type_state_, state); 17986 StoreNonPointer(&raw_ptr()->type_state_, state);
17986 } 17987 }
17987 17988
17988 17989
17989 const char* TypeParameter::ToCString() const { 17990 const char* TypeParameter::ToCString() const {
17990 const char* format =
17991 "TypeParameter: name %s; index: %d; class: %s; bound: %s";
17992 const char* name_cstr = String::Handle(Name()).ToCString(); 17991 const char* name_cstr = String::Handle(Name()).ToCString();
17993 const Class& cls = Class::Handle(parameterized_class());
17994 const char* cls_cstr =
17995 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString();
17996 const AbstractType& upper_bound = AbstractType::Handle(bound()); 17992 const AbstractType& upper_bound = AbstractType::Handle(bound());
17997 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString(); 17993 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString();
17998 intptr_t len = OS::SNPrint( 17994 if (IsFunctionTypeParameter()) {
17999 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; 17995 const char* format = "TypeParameter: name %s; index: %d; parent_level: %d, "
18000 char* chars = Thread::Current()->zone()->Alloc<char>(len); 17996 "function: %s; bound: %s";
18001 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); 17997 const Function& function = Function::Handle(parameterized_function());
18002 return chars; 17998 const char* fun_cstr = String::Handle(function.name()).ToCString();
17999 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index(),
18000 parent_level(), fun_cstr, bound_cstr) + 1;
18001 char* chars = Thread::Current()->zone()->Alloc<char>(len);
18002 OS::SNPrint(chars, len, format, name_cstr, index(), parent_level(),
18003 fun_cstr, bound_cstr);
18004 return chars;
18005 } else {
18006 const char* format =
18007 "TypeParameter: name %s; index: %d; class: %s; bound: %s";
18008 const Class& cls = Class::Handle(parameterized_class());
18009 const char* cls_cstr =
18010 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString();
18011 intptr_t len = OS::SNPrint(
18012 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1;
18013 char* chars = Thread::Current()->zone()->Alloc<char>(len);
18014 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr);
18015 return chars;
18016 }
18003 } 18017 }
18004 18018
18005 18019
18006 bool BoundedType::IsMalformed() const { 18020 bool BoundedType::IsMalformed() const {
18007 return AbstractType::Handle(type()).IsMalformed(); 18021 return AbstractType::Handle(type()).IsMalformed();
18008 } 18022 }
18009 18023
18010 18024
18011 bool BoundedType::IsMalbounded() const { 18025 bool BoundedType::IsMalbounded() const {
18012 return AbstractType::Handle(type()).IsMalbounded(); 18026 return AbstractType::Handle(type()).IsMalbounded();
(...skipping 4934 matching lines...) Expand 10 before | Expand all | Expand 10 after
22947 return UserTag::null(); 22961 return UserTag::null();
22948 } 22962 }
22949 22963
22950 22964
22951 const char* UserTag::ToCString() const { 22965 const char* UserTag::ToCString() const {
22952 const String& tag_label = String::Handle(label()); 22966 const String& tag_label = String::Handle(label());
22953 return tag_label.ToCString(); 22967 return tag_label.ToCString();
22954 } 22968 }
22955 22969
22956 } // namespace dart 22970 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698