Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2015 StorePointer(&raw_ptr()->library_, value.raw()); | 2015 StorePointer(&raw_ptr()->library_, value.raw()); |
| 2016 } | 2016 } |
| 2017 | 2017 |
| 2018 | 2018 |
| 2019 void Class::set_type_parameters(const TypeArguments& value) const { | 2019 void Class::set_type_parameters(const TypeArguments& value) const { |
| 2020 StorePointer(&raw_ptr()->type_parameters_, value.raw()); | 2020 StorePointer(&raw_ptr()->type_parameters_, value.raw()); |
| 2021 } | 2021 } |
| 2022 | 2022 |
| 2023 | 2023 |
| 2024 intptr_t Class::NumTypeParameters(Isolate* isolate) const { | 2024 intptr_t Class::NumTypeParameters(Isolate* isolate) const { |
| 2025 if (IsMixinApplication() && !is_mixin_type_applied()) { | 2025 if (IsAnonymousMixinApplication() && !is_mixin_type_applied()) { |
| 2026 ClassFinalizer::ApplyMixinType(*this); | 2026 ClassFinalizer::ApplyMixinType(*this); |
| 2027 } | 2027 } |
| 2028 if (type_parameters() == TypeArguments::null()) { | 2028 if (type_parameters() == TypeArguments::null()) { |
| 2029 return 0; | 2029 return 0; |
| 2030 } | 2030 } |
| 2031 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate); | 2031 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate); |
| 2032 TypeArguments& type_params = isolate->TypeArgumentsHandle(); | 2032 TypeArguments& type_params = isolate->TypeArgumentsHandle(); |
| 2033 type_params = type_parameters(); | 2033 type_params = type_parameters(); |
| 2034 return type_params.Length(); | 2034 return type_params.Length(); |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 | 2037 |
| 2038 intptr_t Class::NumOwnTypeArguments() const { | 2038 intptr_t Class::NumOwnTypeArguments() const { |
| 2039 // Return cached value if already calculated. | 2039 // Return cached value if already calculated. |
| 2040 if (num_own_type_arguments() != kUnknownNumTypeArguments) { | 2040 if (num_own_type_arguments() != kUnknownNumTypeArguments) { |
| 2041 return num_own_type_arguments(); | 2041 return num_own_type_arguments(); |
| 2042 } | 2042 } |
| 2043 Isolate* isolate = Isolate::Current(); | 2043 Isolate* isolate = Isolate::Current(); |
| 2044 const intptr_t num_type_params = NumTypeParameters(); | 2044 const intptr_t num_type_params = NumTypeParameters(); |
| 2045 if (!FLAG_overlap_type_arguments || | 2045 if (!FLAG_overlap_type_arguments || |
| 2046 (num_type_params == 0) || | 2046 (num_type_params == 0) || |
| 2047 (super_type() == AbstractType::null()) || | 2047 (super_type() == AbstractType::null()) || |
| 2048 (super_type() == isolate->object_store()->object_type())) { | 2048 (super_type() == isolate->object_store()->object_type())) { |
| 2049 set_num_own_type_arguments(num_type_params); | 2049 set_num_own_type_arguments(num_type_params); |
| 2050 return num_type_params; | 2050 return num_type_params; |
| 2051 } | 2051 } |
| 2052 ASSERT(!IsMixinApplication() || is_mixin_type_applied()); | 2052 ASSERT(!IsAnonymousMixinApplication() || is_mixin_type_applied()); |
| 2053 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type()); | 2053 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type()); |
| 2054 const TypeArguments& sup_type_args = | 2054 const TypeArguments& sup_type_args = |
| 2055 TypeArguments::Handle(isolate, sup_type.arguments()); | 2055 TypeArguments::Handle(isolate, sup_type.arguments()); |
| 2056 if (sup_type_args.IsNull()) { | 2056 if (sup_type_args.IsNull()) { |
| 2057 // The super type is raw or the super class is non generic. | 2057 // The super type is raw or the super class is non generic. |
| 2058 // In either case, overlapping is not possible. | 2058 // In either case, overlapping is not possible. |
| 2059 set_num_own_type_arguments(num_type_params); | 2059 set_num_own_type_arguments(num_type_params); |
| 2060 return num_type_params; | 2060 return num_type_params; |
| 2061 } | 2061 } |
| 2062 const intptr_t num_sup_type_args = sup_type_args.Length(); | 2062 const intptr_t num_sup_type_args = sup_type_args.Length(); |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 | 3181 |
| 3182 void Class::set_mixin(const Type& value) const { | 3182 void Class::set_mixin(const Type& value) const { |
| 3183 ASSERT(!value.IsNull()); | 3183 ASSERT(!value.IsNull()); |
| 3184 StorePointer(&raw_ptr()->mixin_, value.raw()); | 3184 StorePointer(&raw_ptr()->mixin_, value.raw()); |
| 3185 } | 3185 } |
| 3186 | 3186 |
| 3187 | 3187 |
| 3188 bool Class::IsMixinApplication() const { | 3188 bool Class::IsMixinApplication() const { |
| 3189 return mixin() != Type::null(); | 3189 return mixin() != Type::null() || is_mixin_app_alias(); |
|
regis
2014/03/27 18:23:58
See my comment in parser.cc first.
I would not ma
| |
| 3190 } | 3190 } |
| 3191 | 3191 |
| 3192 | |
| 3192 bool Class::IsAnonymousMixinApplication() const { | 3193 bool Class::IsAnonymousMixinApplication() const { |
| 3193 return IsMixinApplication() && !is_mixin_app_alias(); | 3194 return IsMixinApplication() && !is_mixin_app_alias(); |
|
regis
2014/03/27 18:23:58
This is what you need to fix. IsAnonymousMixinAppl
| |
| 3194 } | 3195 } |
| 3195 | 3196 |
| 3197 | |
| 3196 void Class::set_patch_class(const Class& cls) const { | 3198 void Class::set_patch_class(const Class& cls) const { |
| 3197 ASSERT(patch_class() == Class::null()); | 3199 ASSERT(patch_class() == Class::null()); |
| 3198 StorePointer(&raw_ptr()->patch_class_, cls.raw()); | 3200 StorePointer(&raw_ptr()->patch_class_, cls.raw()); |
| 3199 } | 3201 } |
| 3200 | 3202 |
| 3201 | 3203 |
| 3202 void Class::AddDirectSubclass(const Class& subclass) const { | 3204 void Class::AddDirectSubclass(const Class& subclass) const { |
| 3203 ASSERT(!subclass.IsNull()); | 3205 ASSERT(!subclass.IsNull()); |
| 3204 ASSERT(subclass.SuperClass() == raw()); | 3206 ASSERT(subclass.SuperClass() == raw()); |
| 3205 // Do not keep track of the direct subclasses of class Object. | 3207 // Do not keep track of the direct subclasses of class Object. |
| (...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5074 ASSERT(IsFactory()); | 5076 ASSERT(IsFactory()); |
| 5075 Object& obj = Object::Handle(raw_ptr()->data_); | 5077 Object& obj = Object::Handle(raw_ptr()->data_); |
| 5076 if (obj.IsNull()) { | 5078 if (obj.IsNull()) { |
| 5077 obj = RedirectionData::New(); | 5079 obj = RedirectionData::New(); |
| 5078 set_data(obj); | 5080 set_data(obj); |
| 5079 } | 5081 } |
| 5080 RedirectionData::Cast(obj).set_target(target); | 5082 RedirectionData::Cast(obj).set_target(target); |
| 5081 } | 5083 } |
| 5082 | 5084 |
| 5083 | 5085 |
| 5086 bool Function::IsForwardingConstructor() const { | |
| 5087 if (!IsImplicitConstructor()) return false; | |
| 5088 const Class& owner = Class::Handle(Owner()); | |
| 5089 return owner.IsMixinApplication(); | |
| 5090 } | |
| 5091 | |
| 5092 | |
| 5093 RawFunction* Function::ForwardingTarget() const { | |
| 5094 ASSERT(IsForwardingConstructor()); | |
| 5095 Object& obj = Object::Handle(raw_ptr()->data_); | |
| 5096 ASSERT(!obj.IsNull()); | |
| 5097 return Function::Cast(obj).raw(); | |
|
hausner
2014/03/27 17:10:27
Asserting that obj is indeed a function?
regis
2014/03/27 18:23:58
I am pretty sure that the Cast checks the actual t
| |
| 5098 } | |
| 5099 | |
| 5100 | |
| 5101 void Function::SetForwardingTarget(const Function& target) const { | |
| 5102 ASSERT(IsForwardingConstructor()); | |
| 5103 ASSERT(Object::Handle(raw_ptr()->data_).IsNull()); | |
| 5104 set_data(target); | |
| 5105 } | |
| 5106 | |
| 5107 | |
| 5084 void Function::set_data(const Object& value) const { | 5108 void Function::set_data(const Object& value) const { |
| 5085 StorePointer(&raw_ptr()->data_, value.raw()); | 5109 StorePointer(&raw_ptr()->data_, value.raw()); |
| 5086 } | 5110 } |
| 5087 | 5111 |
| 5088 | 5112 |
| 5089 bool Function::IsInFactoryScope() const { | 5113 bool Function::IsInFactoryScope() const { |
| 5090 if (!IsLocalFunction()) { | 5114 if (!IsLocalFunction()) { |
| 5091 return IsFactory(); | 5115 return IsFactory(); |
| 5092 } | 5116 } |
| 5093 Function& outer_function = Function::Handle(parent_function()); | 5117 Function& outer_function = Function::Handle(parent_function()); |
| (...skipping 12909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18003 return "_MirrorReference"; | 18027 return "_MirrorReference"; |
| 18004 } | 18028 } |
| 18005 | 18029 |
| 18006 | 18030 |
| 18007 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18031 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 18008 Instance::PrintToJSONStream(stream, ref); | 18032 Instance::PrintToJSONStream(stream, ref); |
| 18009 } | 18033 } |
| 18010 | 18034 |
| 18011 | 18035 |
| 18012 } // namespace dart | 18036 } // namespace dart |
| OLD | NEW |