| 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 "lib/mirrors.h" | 5 #include "lib/mirrors.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bootstrap_natives.h" | 8 #include "vm/bootstrap_natives.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 const Array& functions = Array::Handle(klass.functions()); | 1070 const Array& functions = Array::Handle(klass.functions()); |
| 1071 const intptr_t num_functions = functions.Length(); | 1071 const intptr_t num_functions = functions.Length(); |
| 1072 | 1072 |
| 1073 Instance& member_mirror = Instance::Handle(); | 1073 Instance& member_mirror = Instance::Handle(); |
| 1074 const GrowableObjectArray& member_mirrors = GrowableObjectArray::Handle( | 1074 const GrowableObjectArray& member_mirrors = GrowableObjectArray::Handle( |
| 1075 GrowableObjectArray::New(num_fields + num_functions)); | 1075 GrowableObjectArray::New(num_fields + num_functions)); |
| 1076 | 1076 |
| 1077 Field& field = Field::Handle(); | 1077 Field& field = Field::Handle(); |
| 1078 for (intptr_t i = 0; i < num_fields; i++) { | 1078 for (intptr_t i = 0; i < num_fields; i++) { |
| 1079 field ^= fields.At(i); | 1079 field ^= fields.At(i); |
| 1080 if (!field.is_synthetic()) { | 1080 if (field.is_reflectable()) { |
| 1081 member_mirror = CreateVariableMirror(field, owner_mirror); | 1081 member_mirror = CreateVariableMirror(field, owner_mirror); |
| 1082 member_mirrors.Add(member_mirror); | 1082 member_mirrors.Add(member_mirror); |
| 1083 } | 1083 } |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 Function& func = Function::Handle(); | 1086 Function& func = Function::Handle(); |
| 1087 for (intptr_t i = 0; i < num_functions; i++) { | 1087 for (intptr_t i = 0; i < num_functions; i++) { |
| 1088 func ^= functions.At(i); | 1088 func ^= functions.At(i); |
| 1089 if (func.is_reflectable() && | 1089 if (func.is_reflectable() && |
| 1090 (func.kind() == RawFunction::kRegularFunction || | 1090 (func.kind() == RawFunction::kRegularFunction || |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 !klass.IsMixinApplication()) { | 1165 !klass.IsMixinApplication()) { |
| 1166 type = klass.DeclarationType(); | 1166 type = klass.DeclarationType(); |
| 1167 member_mirror = CreateClassMirror(klass, | 1167 member_mirror = CreateClassMirror(klass, |
| 1168 type, | 1168 type, |
| 1169 Bool::True(), // is_declaration | 1169 Bool::True(), // is_declaration |
| 1170 owner_mirror); | 1170 owner_mirror); |
| 1171 member_mirrors.Add(member_mirror); | 1171 member_mirrors.Add(member_mirror); |
| 1172 } | 1172 } |
| 1173 } else if (entry.IsField()) { | 1173 } else if (entry.IsField()) { |
| 1174 const Field& field = Field::Cast(entry); | 1174 const Field& field = Field::Cast(entry); |
| 1175 if (!field.is_synthetic()) { | 1175 if (field.is_reflectable()) { |
| 1176 member_mirror = CreateVariableMirror(field, owner_mirror); | 1176 member_mirror = CreateVariableMirror(field, owner_mirror); |
| 1177 member_mirrors.Add(member_mirror); | 1177 member_mirrors.Add(member_mirror); |
| 1178 } | 1178 } |
| 1179 } else if (entry.IsFunction()) { | 1179 } else if (entry.IsFunction()) { |
| 1180 const Function& func = Function::Cast(entry); | 1180 const Function& func = Function::Cast(entry); |
| 1181 if (func.is_reflectable() && | 1181 if (func.is_reflectable() && |
| 1182 (func.kind() == RawFunction::kRegularFunction || | 1182 (func.kind() == RawFunction::kRegularFunction || |
| 1183 func.kind() == RawFunction::kGetterFunction || | 1183 func.kind() == RawFunction::kGetterFunction || |
| 1184 func.kind() == RawFunction::kSetterFunction)) { | 1184 func.kind() == RawFunction::kSetterFunction)) { |
| 1185 member_mirror = CreateMethodMirror(func, owner_mirror, | 1185 member_mirror = CreateMethodMirror(func, owner_mirror, |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 // Invoke the setter and return the result. | 1602 // Invoke the setter and return the result. |
| 1603 Object& result = Object::Handle( | 1603 Object& result = Object::Handle( |
| 1604 DartEntry::InvokeFunction(setter, args)); | 1604 DartEntry::InvokeFunction(setter, args)); |
| 1605 if (result.IsError()) { | 1605 if (result.IsError()) { |
| 1606 Exceptions::PropagateError(Error::Cast(result)); | 1606 Exceptions::PropagateError(Error::Cast(result)); |
| 1607 UNREACHABLE(); | 1607 UNREACHABLE(); |
| 1608 } | 1608 } |
| 1609 return result.raw(); | 1609 return result.raw(); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 if (field.is_final()) { | 1612 if (field.is_final() || !field.is_reflectable()) { |
| 1613 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), | 1613 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), |
| 1614 internal_setter_name, | 1614 internal_setter_name, |
| 1615 setter, | 1615 setter, |
| 1616 Object::null_array(), | 1616 Object::null_array(), |
| 1617 Object::null_array(), | 1617 Object::null_array(), |
| 1618 InvocationMirror::kStatic, | 1618 InvocationMirror::kStatic, |
| 1619 InvocationMirror::kSetter); | 1619 InvocationMirror::kSetter); |
| 1620 UNREACHABLE(); | 1620 UNREACHABLE(); |
| 1621 } | 1621 } |
| 1622 | 1622 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 // Invoke the setter and return the result. | 1899 // Invoke the setter and return the result. |
| 1900 const Object& result = Object::Handle( | 1900 const Object& result = Object::Handle( |
| 1901 DartEntry::InvokeFunction(setter, args)); | 1901 DartEntry::InvokeFunction(setter, args)); |
| 1902 if (result.IsError()) { | 1902 if (result.IsError()) { |
| 1903 Exceptions::PropagateError(Error::Cast(result)); | 1903 Exceptions::PropagateError(Error::Cast(result)); |
| 1904 UNREACHABLE(); | 1904 UNREACHABLE(); |
| 1905 } | 1905 } |
| 1906 return result.raw(); | 1906 return result.raw(); |
| 1907 } | 1907 } |
| 1908 | 1908 |
| 1909 if (field.is_final()) { | 1909 if (field.is_final() || !field.is_reflectable()) { |
| 1910 ThrowNoSuchMethod(Instance::null_instance(), | 1910 ThrowNoSuchMethod(Instance::null_instance(), |
| 1911 internal_setter_name, | 1911 internal_setter_name, |
| 1912 setter, | 1912 setter, |
| 1913 Object::null_array(), | 1913 Object::null_array(), |
| 1914 Object::null_array(), | 1914 Object::null_array(), |
| 1915 InvocationMirror::kTopLevel, | 1915 InvocationMirror::kTopLevel, |
| 1916 InvocationMirror::kSetter); | 1916 InvocationMirror::kSetter); |
| 1917 UNREACHABLE(); | 1917 UNREACHABLE(); |
| 1918 } | 1918 } |
| 1919 | 1919 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 } | 2097 } |
| 2098 | 2098 |
| 2099 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { | 2099 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { |
| 2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
| 2101 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2101 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
| 2102 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); | 2102 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); |
| 2103 } | 2103 } |
| 2104 | 2104 |
| 2105 | 2105 |
| 2106 } // namespace dart | 2106 } // namespace dart |
| OLD | NEW |