Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: runtime/lib/mirrors.cc

Issue 1868803002: Use symbols when looking up fields in a class (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // a special null instance. This is different from a field being null. Callers 710 // a special null instance. This is different from a field being null. Callers
711 // make sure that this null does not leak into Dartland. 711 // make sure that this null does not leak into Dartland.
712 return Object::sentinel().raw(); 712 return Object::sentinel().raw();
713 } 713 }
714 714
715 715
716 static RawInstance* InvokeClassGetter(const Class& klass, 716 static RawInstance* InvokeClassGetter(const Class& klass,
717 const String& getter_name, 717 const String& getter_name,
718 const bool throw_nsm_if_absent) { 718 const bool throw_nsm_if_absent) {
719 // Note static fields do not have implicit getters. 719 // Note static fields do not have implicit getters.
720 const Field& field = Field::Handle(klass.LookupStaticField(getter_name)); 720 const Field& field =
721 Field::Handle(klass.LookupStaticFieldAllowPrivate(getter_name));
721 if (field.IsNull() || field.IsUninitialized()) { 722 if (field.IsNull() || field.IsUninitialized()) {
722 const String& internal_getter_name = String::Handle( 723 const String& internal_getter_name = String::Handle(
723 Field::GetterName(getter_name)); 724 Field::GetterName(getter_name));
724 Function& getter = Function::Handle( 725 Function& getter = Function::Handle(
725 klass.LookupStaticFunction(internal_getter_name)); 726 klass.LookupStaticFunction(internal_getter_name));
726 727
727 if (getter.IsNull() || !getter.is_reflectable()) { 728 if (getter.IsNull() || !getter.is_reflectable()) {
728 if (getter.IsNull()) { 729 if (getter.IsNull()) {
729 getter = klass.LookupStaticFunction(getter_name); 730 getter = klass.LookupStaticFunction(getter_name);
730 if (!getter.IsNull()) { 731 if (!getter.IsNull()) {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 GET_NON_NULL_NATIVE_ARGUMENT(String, setter_name, arguments->NativeArgAt(2)); 1563 GET_NON_NULL_NATIVE_ARGUMENT(String, setter_name, arguments->NativeArgAt(2));
1563 GET_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(3)); 1564 GET_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(3));
1564 1565
1565 const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread)); 1566 const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread));
1566 if (!error.IsNull()) { 1567 if (!error.IsNull()) {
1567 Exceptions::PropagateError(error); 1568 Exceptions::PropagateError(error);
1568 UNREACHABLE(); 1569 UNREACHABLE();
1569 } 1570 }
1570 1571
1571 // Check for real fields and user-defined setters. 1572 // Check for real fields and user-defined setters.
1572 const Field& field = Field::Handle(klass.LookupStaticField(setter_name)); 1573 const Field& field =
1574 Field::Handle(klass.LookupStaticFieldAllowPrivate(setter_name));
1573 Function& setter = Function::Handle(); 1575 Function& setter = Function::Handle();
1574 const String& internal_setter_name = String::Handle( 1576 const String& internal_setter_name = String::Handle(
1575 Field::SetterName(setter_name)); 1577 Field::SetterName(setter_name));
1576 1578
1577 if (field.IsNull()) { 1579 if (field.IsNull()) {
1578 setter = klass.LookupStaticFunction(internal_setter_name); 1580 setter = klass.LookupStaticFunction(internal_setter_name);
1579 1581
1580 const int kNumArgs = 1; 1582 const int kNumArgs = 1;
1581 const Array& args = Array::Handle(Array::New(kNumArgs)); 1583 const Array& args = Array::Handle(Array::New(kNumArgs));
1582 args.SetAt(0, value); 1584 args.SetAt(0, value);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 2106
2105 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2107 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2106 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2108 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2107 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2109 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2108 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); 2110 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw();
2109 } 2111 }
2110 2112
2111 #endif // !PRODUCT 2113 #endif // !PRODUCT
2112 2114
2113 } // namespace dart 2115 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/math.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698