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

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

Issue 2736733005: Manage and capture class and function instantiators in the parser. (Closed)
Patch Set: work in progress Created 3 years, 9 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
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 5928 matching lines...) Expand 10 before | Expand all | Expand 10 after
5939 while (!function.IsNull()) { 5939 while (!function.IsNull()) {
5940 type_params ^= function.type_parameters(); 5940 type_params ^= function.type_parameters();
5941 if (!type_params.IsNull()) { 5941 if (!type_params.IsNull()) {
5942 const intptr_t num_type_params = type_params.Length(); 5942 const intptr_t num_type_params = type_params.Length();
5943 for (intptr_t i = 0; i < num_type_params; i++) { 5943 for (intptr_t i = 0; i < num_type_params; i++) {
5944 type_param ^= type_params.TypeAt(i); 5944 type_param ^= type_params.TypeAt(i);
5945 type_param_name = type_param.name(); 5945 type_param_name = type_param.name();
5946 if (type_param_name.Equals(type_name)) { 5946 if (type_param_name.Equals(type_name)) {
5947 if (parent_level > 0) { 5947 if (parent_level > 0) {
5948 // Clone type parameter and set parent_level. 5948 // Clone type parameter and set parent_level.
5949 return TypeParameter::New( 5949 type_param = TypeParameter::New(
5950 Class::Handle(), function, type_param.index(), parent_level, 5950 Class::Handle(), function, type_param.index(), parent_level,
5951 type_param_name, AbstractType::Handle(type_param.bound()), 5951 type_param_name, AbstractType::Handle(type_param.bound()),
5952 TokenPosition::kNoSource); 5952 TokenPosition::kNoSource);
5953 type_param.SetIsFinalized();
5953 } 5954 }
5954 return type_param.raw(); 5955 return type_param.raw();
5955 } 5956 }
5956 } 5957 }
5957 } 5958 }
5958 function ^= function.parent_function(); 5959 function ^= function.parent_function();
5959 parent_level++; 5960 parent_level++;
5960 if (function_level != NULL) { 5961 if (function_level != NULL) {
5961 (*function_level)--; 5962 (*function_level)--;
5962 } 5963 }
(...skipping 11761 matching lines...) Expand 10 before | Expand all | Expand 10 after
17724 // Unfold right hand type. Divergence is controlled by left hand type. 17725 // Unfold right hand type. Divergence is controlled by left hand type.
17725 const AbstractType& other_ref_type = 17726 const AbstractType& other_ref_type =
17726 AbstractType::Handle(TypeRef::Cast(other).type()); 17727 AbstractType::Handle(TypeRef::Cast(other).type());
17727 ASSERT(!other_ref_type.IsTypeRef()); 17728 ASSERT(!other_ref_type.IsTypeRef());
17728 return IsEquivalent(other_ref_type, trail); 17729 return IsEquivalent(other_ref_type, trail);
17729 } 17730 }
17730 if (!other.IsTypeParameter()) { 17731 if (!other.IsTypeParameter()) {
17731 return false; 17732 return false;
17732 } 17733 }
17733 const TypeParameter& other_type_param = TypeParameter::Cast(other); 17734 const TypeParameter& other_type_param = TypeParameter::Cast(other);
17734 if (parameterized_class() != other_type_param.parameterized_class()) { 17735 if (parameterized_class_id() != other_type_param.parameterized_class_id()) {
17736 return false;
17737 }
17738 if (parameterized_function() != other_type_param.parameterized_function()) {
17735 return false; 17739 return false;
17736 } 17740 }
17737 if (IsFinalized() == other_type_param.IsFinalized()) { 17741 if (IsFinalized() == other_type_param.IsFinalized()) {
17738 return index() == other_type_param.index(); 17742 return (index() == other_type_param.index()) &&
17743 (parent_level() == other_type_param.parent_level());
17739 } 17744 }
17740 return name() == other_type_param.name(); 17745 return name() == other_type_param.name();
17741 } 17746 }
17742 17747
17743 17748
17744 void TypeParameter::set_parameterized_class(const Class& value) const { 17749 void TypeParameter::set_parameterized_class(const Class& value) const {
17745 // Set value may be null. 17750 // Set value may be null.
17746 classid_t cid = kFunctionCid; // Denotes a function type parameter. 17751 classid_t cid = kFunctionCid; // Denotes a function type parameter.
17747 if (!value.IsNull()) { 17752 if (!value.IsNull()) {
17748 cid = value.id(); 17753 cid = value.id();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
17922 pieces.Add(Symbols::SpaceIsFromSpace()); 17927 pieces.Add(Symbols::SpaceIsFromSpace());
17923 const Library& library = Library::Handle(zone, cls.library()); 17928 const Library& library = Library::Handle(zone, cls.library());
17924 pieces.Add(String::Handle(zone, library.url())); 17929 pieces.Add(String::Handle(zone, library.url()));
17925 pieces.Add(Symbols::NewLine()); 17930 pieces.Add(Symbols::NewLine());
17926 return Symbols::FromConcatAll(thread, pieces); 17931 return Symbols::FromConcatAll(thread, pieces);
17927 } 17932 }
17928 17933
17929 17934
17930 intptr_t TypeParameter::ComputeHash() const { 17935 intptr_t TypeParameter::ComputeHash() const {
17931 ASSERT(IsFinalized()); 17936 ASSERT(IsFinalized());
17932 uint32_t result = Class::Handle(parameterized_class()).id(); 17937 uint32_t result;
17938 if (IsClassTypeParameter()) {
17939 result = parameterized_class_id();
17940 } else {
17941 result = Function::Handle(parameterized_function()).Hash();
17942 result = CombineHashes(result, parent_level());
17943 }
17933 // No need to include the hash of the bound, since the type parameter is fully 17944 // No need to include the hash of the bound, since the type parameter is fully
17934 // identified by its class and index. 17945 // identified by its class and index.
17935 result = CombineHashes(result, index()); 17946 result = CombineHashes(result, index());
17936 result = FinalizeHash(result, kHashBits); 17947 result = FinalizeHash(result, kHashBits);
17937 SetHash(result); 17948 SetHash(result);
17938 return result; 17949 return result;
17939 } 17950 }
17940 17951
17941 17952
17942 RawTypeParameter* TypeParameter::New() { 17953 RawTypeParameter* TypeParameter::New() {
(...skipping 4996 matching lines...) Expand 10 before | Expand all | Expand 10 after
22939 return UserTag::null(); 22950 return UserTag::null();
22940 } 22951 }
22941 22952
22942 22953
22943 const char* UserTag::ToCString() const { 22954 const char* UserTag::ToCString() const {
22944 const String& tag_label = String::Handle(label()); 22955 const String& tag_label = String::Handle(label());
22945 return tag_label.ToCString(); 22956 return tag_label.ToCString();
22946 } 22957 }
22947 22958
22948 } // namespace dart 22959 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698