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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 | 140 |
141 // The following functions are marked as invisible, meaning they will be hidden | 141 // The following functions are marked as invisible, meaning they will be hidden |
142 // in the stack trace. | 142 // in the stack trace. |
143 // (Library, class name, method name) | 143 // (Library, class name, method name) |
144 #define INVISIBLE_LIST(V) \ | 144 #define INVISIBLE_LIST(V) \ |
145 V(CoreLibrary, Object, _noSuchMethod) \ | 145 V(CoreLibrary, Object, _noSuchMethod) \ |
146 V(CoreLibrary, Object, _as) \ | 146 V(CoreLibrary, Object, _as) \ |
147 V(CoreLibrary, Object, _instanceOf) \ | 147 V(CoreLibrary, Object, _instanceOf) \ |
148 V(CoreLibrary, _ObjectArray, _ObjectArray.) \ | 148 V(CoreLibrary, _ObjectArray, _ObjectArray.) \ |
149 V(CoreLibrary, _AssertionErrorImplementation, _throwNew) \ | 149 V(CoreLibrary, AssertionError, _throwNew) \ |
150 V(CoreLibrary, _TypeErrorImplementation, _throwNew) \ | 150 V(CoreLibrary, TypeError, _throwNew) \ |
151 V(CoreLibrary, _FallThroughErrorImplementation, _throwNew) \ | 151 V(CoreLibrary, FallThroughError, _throwNew) \ |
152 V(CoreLibrary, _AbstractClassInstantiationErrorImplementation, _throwNew) \ | 152 V(CoreLibrary, AbstractClassInstantiationError, _throwNew) \ |
153 V(CoreLibrary, NoSuchMethodError, _throwNew) \ | 153 V(CoreLibrary, NoSuchMethodError, _throwNew) \ |
154 V(CoreLibrary, int, _throwFormatException) \ | 154 V(CoreLibrary, int, _throwFormatException) \ |
155 V(CoreLibrary, int, _parse) \ | 155 V(CoreLibrary, int, _parse) \ |
156 V(CoreLibrary, StackTrace, _setupFullStackTrace) \ | 156 V(CoreLibrary, StackTrace, _setupFullStackTrace) \ |
157 | 157 |
158 | 158 |
159 static void MarkFunctionAsInvisible(const Library& lib, | 159 static void MarkFunctionAsInvisible(const Library& lib, |
160 const char* class_name, | 160 const char* class_name, |
161 const char* function_name) { | 161 const char* function_name) { |
162 ASSERT(!lib.IsNull()); | 162 ASSERT(!lib.IsNull()); |
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 | 1918 |
1919 Array& orig_list = Array::Handle(functions()); | 1919 Array& orig_list = Array::Handle(functions()); |
1920 intptr_t orig_len = orig_list.Length(); | 1920 intptr_t orig_len = orig_list.Length(); |
1921 Array& patch_list = Array::Handle(patch.functions()); | 1921 Array& patch_list = Array::Handle(patch.functions()); |
1922 intptr_t patch_len = patch_list.Length(); | 1922 intptr_t patch_len = patch_list.Length(); |
1923 | 1923 |
1924 // TODO(iposva): Verify that only patching existing methods and adding only | 1924 // TODO(iposva): Verify that only patching existing methods and adding only |
1925 // new private methods. | 1925 // new private methods. |
1926 Function& func = Function::Handle(); | 1926 Function& func = Function::Handle(); |
1927 Function& orig_func = Function::Handle(); | 1927 Function& orig_func = Function::Handle(); |
| 1928 // Lookup the original implicit constructor, if any. |
| 1929 member_name = Name(); |
| 1930 member_name = String::Concat(member_name, Symbols::Dot()); |
| 1931 Function& orig_implicit_ctor = Function::Handle(LookupFunction(member_name)); |
| 1932 if (!orig_implicit_ctor.IsNull() && |
| 1933 !orig_implicit_ctor.IsImplicitConstructor()) { |
| 1934 // Not an implicit constructor, but a user declared one. |
| 1935 orig_implicit_ctor = Function::null(); |
| 1936 } |
1928 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle( | 1937 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle( |
1929 GrowableObjectArray::New(orig_len)); | 1938 GrowableObjectArray::New(orig_len)); |
1930 for (intptr_t i = 0; i < orig_len; i++) { | 1939 for (intptr_t i = 0; i < orig_len; i++) { |
1931 orig_func ^= orig_list.At(i); | 1940 orig_func ^= orig_list.At(i); |
1932 member_name ^= orig_func.name(); | 1941 member_name ^= orig_func.name(); |
1933 func = patch.LookupFunction(member_name); | 1942 func = patch.LookupFunction(member_name); |
1934 if (func.IsNull()) { | 1943 if (func.IsNull()) { |
1935 // Non-patched function is preserved, all patched functions are added in | 1944 // Non-patched function is preserved, all patched functions are added in |
1936 // the loop below. | 1945 // the loop below. |
1937 new_functions.Add(orig_func); | 1946 // However, an implicitly created constructor should not be preserved if |
| 1947 // the patch provides a constructor or a factory. Wait for now. |
| 1948 if (orig_func.raw() != orig_implicit_ctor.raw()) { |
| 1949 new_functions.Add(orig_func); |
| 1950 } |
1938 } else if (!func.HasCompatibleParametersWith(orig_func) && | 1951 } else if (!func.HasCompatibleParametersWith(orig_func) && |
1939 !(func.IsFactory() && orig_func.IsConstructor() && | 1952 !(func.IsFactory() && orig_func.IsConstructor() && |
1940 (func.num_fixed_parameters() + 1 == | 1953 (func.num_fixed_parameters() + 1 == |
1941 orig_func.num_fixed_parameters()))) { | 1954 orig_func.num_fixed_parameters()))) { |
1942 return FormatPatchError("mismatched parameters: %s", member_name); | 1955 return FormatPatchError("mismatched parameters: %s", member_name); |
1943 } | 1956 } |
1944 } | 1957 } |
1945 for (intptr_t i = 0; i < patch_len; i++) { | 1958 for (intptr_t i = 0; i < patch_len; i++) { |
1946 func ^= patch_list.At(i); | 1959 func ^= patch_list.At(i); |
| 1960 if (func.IsConstructor() || func.IsFactory()) { |
| 1961 // Do not preserve the original implicit constructor, if any. |
| 1962 orig_implicit_ctor = Function::null(); |
| 1963 } |
1947 func.set_owner(patch_class); | 1964 func.set_owner(patch_class); |
1948 new_functions.Add(func); | 1965 new_functions.Add(func); |
1949 } | 1966 } |
| 1967 if (!orig_implicit_ctor.IsNull()) { |
| 1968 // Preserve the original implicit constructor. |
| 1969 new_functions.Add(orig_implicit_ctor); |
| 1970 } |
1950 Array& new_list = Array::Handle(Array::MakeArray(new_functions)); | 1971 Array& new_list = Array::Handle(Array::MakeArray(new_functions)); |
1951 SetFunctions(new_list); | 1972 SetFunctions(new_list); |
1952 | 1973 |
1953 // Merge the two list of fields. Raise an error when duplicates are found or | 1974 // Merge the two list of fields. Raise an error when duplicates are found or |
1954 // when a public field is being added. | 1975 // when a public field is being added. |
1955 orig_list = fields(); | 1976 orig_list = fields(); |
1956 orig_len = orig_list.Length(); | 1977 orig_len = orig_list.Length(); |
1957 patch_list = patch.fields(); | 1978 patch_list = patch.fields(); |
1958 patch_len = patch_list.Length(); | 1979 patch_len = patch_list.Length(); |
1959 | 1980 |
(...skipping 12583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14543 } | 14564 } |
14544 | 14565 |
14545 | 14566 |
14546 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14567 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14547 stream->OpenObject(); | 14568 stream->OpenObject(); |
14548 stream->CloseObject(); | 14569 stream->CloseObject(); |
14549 } | 14570 } |
14550 | 14571 |
14551 | 14572 |
14552 } // namespace dart | 14573 } // namespace dart |
OLD | NEW |