| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 lib.LookupClassAllowPrivate(Symbols::_LocalMethodMirror())); | 595 lib.LookupClassAllowPrivate(Symbols::_LocalMethodMirror())); |
| 596 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); | 596 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); |
| 597 ASSERT(error.IsNull()); | 597 ASSERT(error.IsNull()); |
| 598 | 598 |
| 599 Field& field = Field::Handle(); | 599 Field& field = Field::Handle(); |
| 600 Smi& value = Smi::Handle(); | 600 Smi& value = Smi::Handle(); |
| 601 | 601 |
| 602 #define CHECK_KIND_SHIFT(name) \ | 602 #define CHECK_KIND_SHIFT(name) \ |
| 603 field = cls.LookupField(String::Handle(String::New(#name))); \ | 603 field = cls.LookupField(String::Handle(String::New(#name))); \ |
| 604 ASSERT(!field.IsNull()); \ | 604 ASSERT(!field.IsNull()); \ |
| 605 value ^= field.value(); \ | 605 value ^= field.StaticFieldValue(); \ |
| 606 ASSERT(value.Value() == Mirrors::name); | 606 ASSERT(value.Value() == Mirrors::name); |
| 607 MIRRORS_KIND_SHIFT_LIST(CHECK_KIND_SHIFT) | 607 MIRRORS_KIND_SHIFT_LIST(CHECK_KIND_SHIFT) |
| 608 #undef CHECK_KIND_SHIFT | 608 #undef CHECK_KIND_SHIFT |
| 609 #endif | 609 #endif |
| 610 } | 610 } |
| 611 | 611 |
| 612 | 612 |
| 613 static RawInstance* ReturnResult(const Object& result) { | 613 static RawInstance* ReturnResult(const Object& result) { |
| 614 if (result.IsError()) { | 614 if (result.IsError()) { |
| 615 Exceptions::PropagateError(Error::Cast(result)); | 615 Exceptions::PropagateError(Error::Cast(result)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 getter = library.LookupLocalFunction(getter_name); | 670 getter = library.LookupLocalFunction(getter_name); |
| 671 if (!getter.IsNull()) { | 671 if (!getter.IsNull()) { |
| 672 // Looking for a getter but found a regular method: closurize it. | 672 // Looking for a getter but found a regular method: closurize it. |
| 673 const Function& closure_function = | 673 const Function& closure_function = |
| 674 Function::Handle(getter.ImplicitClosureFunction()); | 674 Function::Handle(getter.ImplicitClosureFunction()); |
| 675 return closure_function.ImplicitStaticClosure(); | 675 return closure_function.ImplicitStaticClosure(); |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 } else { | 678 } else { |
| 679 if (!field.IsUninitialized()) { | 679 if (!field.IsUninitialized()) { |
| 680 return field.value(); | 680 return field.StaticFieldValue(); |
| 681 } | 681 } |
| 682 // An uninitialized field was found. Check for a getter in the field's | 682 // An uninitialized field was found. Check for a getter in the field's |
| 683 // owner classs. | 683 // owner classs. |
| 684 const Class& klass = Class::Handle(field.owner()); | 684 const Class& klass = Class::Handle(field.owner()); |
| 685 const String& internal_getter_name = | 685 const String& internal_getter_name = |
| 686 String::Handle(Field::GetterName(getter_name)); | 686 String::Handle(Field::GetterName(getter_name)); |
| 687 getter = klass.LookupStaticFunction(internal_getter_name); | 687 getter = klass.LookupStaticFunction(internal_getter_name); |
| 688 } | 688 } |
| 689 | 689 |
| 690 if (!getter.IsNull() && getter.is_reflectable()) { | 690 if (!getter.IsNull() && getter.is_reflectable()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 // using a special null instance. This is different from a field being | 747 // using a special null instance. This is different from a field being |
| 748 // null. Callers make sure that this null does not leak into Dartland. | 748 // null. Callers make sure that this null does not leak into Dartland. |
| 749 return Object::sentinel().raw(); | 749 return Object::sentinel().raw(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 // Invoke the getter and return the result. | 752 // Invoke the getter and return the result. |
| 753 const Object& result = Object::Handle( | 753 const Object& result = Object::Handle( |
| 754 DartEntry::InvokeFunction(getter, Object::empty_array())); | 754 DartEntry::InvokeFunction(getter, Object::empty_array())); |
| 755 return ReturnResult(result); | 755 return ReturnResult(result); |
| 756 } | 756 } |
| 757 return field.value(); | 757 return field.StaticFieldValue(); |
| 758 } | 758 } |
| 759 | 759 |
| 760 | 760 |
| 761 static RawAbstractType* InstantiateType(const AbstractType& type, | 761 static RawAbstractType* InstantiateType(const AbstractType& type, |
| 762 const AbstractType& instantiator) { | 762 const AbstractType& instantiator) { |
| 763 ASSERT(type.IsFinalized()); | 763 ASSERT(type.IsFinalized()); |
| 764 PROPAGATE_IF_MALFORMED(type); | 764 PROPAGATE_IF_MALFORMED(type); |
| 765 ASSERT(type.IsCanonical() || type.IsTypeParameter() || type.IsBoundedType()); | 765 ASSERT(type.IsCanonical() || type.IsTypeParameter() || type.IsBoundedType()); |
| 766 | 766 |
| 767 if (type.IsInstantiated() || instantiator.IsNull()) { | 767 if (type.IsInstantiated() || instantiator.IsNull()) { |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 1623 field.set_value(value); | 1623 field.SetStaticFieldValue(value); |
| 1624 return value.raw(); | 1624 return value.raw(); |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 | 1627 |
| 1628 DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) { | 1628 DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) { |
| 1629 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1629 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1630 const Class& klass = Class::Handle(ref.GetClassReferent()); | 1630 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 1631 GET_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(1)); | 1631 GET_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(1)); |
| 1632 GET_NON_NULL_NATIVE_ARGUMENT( | 1632 GET_NON_NULL_NATIVE_ARGUMENT( |
| 1633 String, constructor_name, arguments->NativeArgAt(2)); | 1633 String, constructor_name, arguments->NativeArgAt(2)); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 1920 field.set_value(value); | 1920 field.SetStaticFieldValue(value); |
| 1921 return value.raw(); | 1921 return value.raw(); |
| 1922 } | 1922 } |
| 1923 | 1923 |
| 1924 | 1924 |
| 1925 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 2) { | 1925 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 2) { |
| 1926 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1926 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1927 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); | 1927 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); |
| 1928 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 1928 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
| 1929 if (func.IsNonImplicitClosureFunction()) { | 1929 if (func.IsNonImplicitClosureFunction()) { |
| 1930 return CreateMethodMirror(Function::Handle( | 1930 return CreateMethodMirror(Function::Handle( |
| (...skipping 166 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 |