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 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2714 Script::Handle(patch.script()), | 2714 Script::Handle(patch.script()), |
2715 func.token_pos(), | 2715 func.token_pos(), |
2716 Report::kError, | 2716 Report::kError, |
2717 Heap::kNew, | 2717 Heap::kNew, |
2718 "signature mismatch: '%s'", member_name.ToCString()); | 2718 "signature mismatch: '%s'", member_name.ToCString()); |
2719 return false; | 2719 return false; |
2720 } | 2720 } |
2721 } | 2721 } |
2722 for (intptr_t i = 0; i < patch_len; i++) { | 2722 for (intptr_t i = 0; i < patch_len; i++) { |
2723 func ^= patch_list.At(i); | 2723 func ^= patch_list.At(i); |
2724 if (func.IsConstructor() || func.IsFactory()) { | 2724 if (func.IsGenerativeConstructor() || func.IsFactory()) { |
2725 // Do not preserve the original implicit constructor, if any. | 2725 // Do not preserve the original implicit constructor, if any. |
2726 orig_implicit_ctor = Function::null(); | 2726 orig_implicit_ctor = Function::null(); |
2727 } | 2727 } |
2728 func.set_owner(patch_class); | 2728 func.set_owner(patch_class); |
2729 new_functions.Add(func); | 2729 new_functions.Add(func); |
2730 } | 2730 } |
2731 if (!orig_implicit_ctor.IsNull()) { | 2731 if (!orig_implicit_ctor.IsNull()) { |
2732 // Preserve the original implicit constructor. | 2732 // Preserve the original implicit constructor. |
2733 new_functions.Add(orig_implicit_ctor); | 2733 new_functions.Add(orig_implicit_ctor); |
2734 } | 2734 } |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3833 RawFunction* Class::CheckFunctionType(const Function& func, MemberKind kind) { | 3833 RawFunction* Class::CheckFunctionType(const Function& func, MemberKind kind) { |
3834 if (kind == kInstance) { | 3834 if (kind == kInstance) { |
3835 if (func.IsDynamicFunction()) { | 3835 if (func.IsDynamicFunction()) { |
3836 return func.raw(); | 3836 return func.raw(); |
3837 } | 3837 } |
3838 } else if (kind == kStatic) { | 3838 } else if (kind == kStatic) { |
3839 if (func.IsStaticFunction()) { | 3839 if (func.IsStaticFunction()) { |
3840 return func.raw(); | 3840 return func.raw(); |
3841 } | 3841 } |
3842 } else if (kind == kConstructor) { | 3842 } else if (kind == kConstructor) { |
3843 if (func.IsConstructor()) { | 3843 if (func.IsGenerativeConstructor()) { |
3844 ASSERT(!func.is_static()); | 3844 ASSERT(!func.is_static()); |
3845 return func.raw(); | 3845 return func.raw(); |
3846 } | 3846 } |
3847 } else if (kind == kFactory) { | 3847 } else if (kind == kFactory) { |
3848 if (func.IsFactory()) { | 3848 if (func.IsFactory()) { |
3849 ASSERT(func.is_static()); | 3849 ASSERT(func.is_static()); |
3850 return func.raw(); | 3850 return func.raw(); |
3851 } | 3851 } |
3852 } else if (kind == kAny) { | 3852 } else if (kind == kAny) { |
3853 return func.raw(); | 3853 return func.raw(); |
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5594 return num_fixed_parameters() + NumOptionalParameters(); | 5594 return num_fixed_parameters() + NumOptionalParameters(); |
5595 } | 5595 } |
5596 | 5596 |
5597 | 5597 |
5598 intptr_t Function::NumImplicitParameters() const { | 5598 intptr_t Function::NumImplicitParameters() const { |
5599 if (kind() == RawFunction::kConstructor) { | 5599 if (kind() == RawFunction::kConstructor) { |
5600 if (is_static()) { | 5600 if (is_static()) { |
5601 ASSERT(IsFactory()); | 5601 ASSERT(IsFactory()); |
5602 return 1; // Type arguments. | 5602 return 1; // Type arguments. |
5603 } else { | 5603 } else { |
5604 ASSERT(IsConstructor()); | 5604 ASSERT(IsGenerativeConstructor()); |
5605 return 2; // Instance, phase. | 5605 return 2; // Instance, phase. |
5606 } | 5606 } |
5607 } | 5607 } |
5608 if ((kind() == RawFunction::kClosureFunction) || | 5608 if ((kind() == RawFunction::kClosureFunction) || |
5609 (kind() == RawFunction::kSignatureFunction)) { | 5609 (kind() == RawFunction::kSignatureFunction)) { |
5610 return 1; // Closure object. | 5610 return 1; // Closure object. |
5611 } | 5611 } |
5612 if (!is_static()) { | 5612 if (!is_static()) { |
5613 // Closure functions defined inside instance (i.e. non-static) functions are | 5613 // Closure functions defined inside instance (i.e. non-static) functions are |
5614 // marked as non-static, but they do not have a receiver. | 5614 // marked as non-static, but they do not have a receiver. |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6056 } | 6056 } |
6057 } | 6057 } |
6058 return true; | 6058 return true; |
6059 } | 6059 } |
6060 | 6060 |
6061 | 6061 |
6062 // The compiler generates an implicit constructor if a class definition | 6062 // The compiler generates an implicit constructor if a class definition |
6063 // does not contain an explicit constructor or factory. The implicit | 6063 // does not contain an explicit constructor or factory. The implicit |
6064 // constructor has the same token position as the owner class. | 6064 // constructor has the same token position as the owner class. |
6065 bool Function::IsImplicitConstructor() const { | 6065 bool Function::IsImplicitConstructor() const { |
6066 return IsConstructor() && (token_pos() == end_token_pos()); | 6066 return IsGenerativeConstructor() && (token_pos() == end_token_pos()); |
6067 } | 6067 } |
6068 | 6068 |
6069 | 6069 |
6070 bool Function::IsImplicitClosureFunction() const { | 6070 bool Function::IsImplicitClosureFunction() const { |
6071 if (!IsClosureFunction()) { | 6071 if (!IsClosureFunction()) { |
6072 return false; | 6072 return false; |
6073 } | 6073 } |
6074 const Function& parent = Function::Handle(parent_function()); | 6074 const Function& parent = Function::Handle(parent_function()); |
6075 return (parent.implicit_closure_function() == raw()); | 6075 return (parent.implicit_closure_function() == raw()); |
6076 } | 6076 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6132 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); | 6132 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); |
6133 if (kind == RawFunction::kClosureFunction) { | 6133 if (kind == RawFunction::kClosureFunction) { |
6134 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6134 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
6135 result.set_data(data); | 6135 result.set_data(data); |
6136 } | 6136 } |
6137 return result.raw(); | 6137 return result.raw(); |
6138 } | 6138 } |
6139 | 6139 |
6140 | 6140 |
6141 RawFunction* Function::Clone(const Class& new_owner) const { | 6141 RawFunction* Function::Clone(const Class& new_owner) const { |
6142 ASSERT(!IsConstructor()); | 6142 ASSERT(!IsGenerativeConstructor()); |
6143 Function& clone = Function::Handle(); | 6143 Function& clone = Function::Handle(); |
6144 clone ^= Object::Clone(*this, Heap::kOld); | 6144 clone ^= Object::Clone(*this, Heap::kOld); |
6145 const Class& origin = Class::Handle(this->origin()); | 6145 const Class& origin = Class::Handle(this->origin()); |
6146 const PatchClass& clone_owner = | 6146 const PatchClass& clone_owner = |
6147 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 6147 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
6148 clone.set_owner(clone_owner); | 6148 clone.set_owner(clone_owner); |
6149 clone.ClearCode(); | 6149 clone.ClearCode(); |
6150 clone.set_usage_counter(0); | 6150 clone.set_usage_counter(0); |
6151 clone.set_deoptimization_counter(0); | 6151 clone.set_deoptimization_counter(0); |
6152 clone.set_regexp_cid(kIllegalCid); | 6152 clone.set_regexp_cid(kIllegalCid); |
(...skipping 14463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20616 return tag_label.ToCString(); | 20616 return tag_label.ToCString(); |
20617 } | 20617 } |
20618 | 20618 |
20619 | 20619 |
20620 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20620 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20621 Instance::PrintJSONImpl(stream, ref); | 20621 Instance::PrintJSONImpl(stream, ref); |
20622 } | 20622 } |
20623 | 20623 |
20624 | 20624 |
20625 } // namespace dart | 20625 } // namespace dart |
OLD | NEW |