OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4255 } else if (obj.IsType()) { | 4255 } else if (obj.IsType()) { |
4256 if (!Type::Cast(obj).IsFinalized()) { | 4256 if (!Type::Cast(obj).IsFinalized()) { |
4257 return Api::NewError( | 4257 return Api::NewError( |
4258 "%s expects argument 'container' to be a fully resolved type.", | 4258 "%s expects argument 'container' to be a fully resolved type.", |
4259 CURRENT_FUNC); | 4259 CURRENT_FUNC); |
4260 } | 4260 } |
4261 // To access a static field we may need to use the Field or the | 4261 // To access a static field we may need to use the Field or the |
4262 // getter Function. | 4262 // getter Function. |
4263 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); | 4263 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); |
4264 | 4264 |
4265 field = cls.LookupStaticField(field_name); | 4265 field = cls.LookupStaticFieldAllowPrivate(field_name); |
4266 if (field.IsNull() || field.IsUninitialized()) { | 4266 if (field.IsNull() || field.IsUninitialized()) { |
4267 const String& getter_name = | 4267 const String& getter_name = |
4268 String::Handle(Z, Field::GetterName(field_name)); | 4268 String::Handle(Z, Field::GetterName(field_name)); |
4269 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 4269 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
4270 } | 4270 } |
4271 | 4271 |
4272 if (!getter.IsNull()) { | 4272 if (!getter.IsNull()) { |
4273 // Invoke the getter and return the result. | 4273 // Invoke the getter and return the result. |
4274 return Api::NewHandle( | 4274 return Api::NewHandle( |
4275 T, DartEntry::InvokeFunction(getter, Object::empty_array())); | 4275 T, DartEntry::InvokeFunction(getter, Object::empty_array())); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4385 if (!Type::Cast(obj).IsFinalized()) { | 4385 if (!Type::Cast(obj).IsFinalized()) { |
4386 return Api::NewError( | 4386 return Api::NewError( |
4387 "%s expects argument 'container' to be a fully resolved type.", | 4387 "%s expects argument 'container' to be a fully resolved type.", |
4388 CURRENT_FUNC); | 4388 CURRENT_FUNC); |
4389 } | 4389 } |
4390 | 4390 |
4391 // To access a static field we may need to use the Field or the | 4391 // To access a static field we may need to use the Field or the |
4392 // setter Function. | 4392 // setter Function. |
4393 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); | 4393 Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); |
4394 | 4394 |
4395 field = cls.LookupStaticField(field_name); | 4395 field = cls.LookupStaticFieldAllowPrivate(field_name); |
4396 if (field.IsNull()) { | 4396 if (field.IsNull()) { |
4397 String& setter_name = String::Handle(Z, Field::SetterName(field_name)); | 4397 String& setter_name = String::Handle(Z, Field::SetterName(field_name)); |
4398 setter = cls.LookupStaticFunctionAllowPrivate(setter_name); | 4398 setter = cls.LookupStaticFunctionAllowPrivate(setter_name); |
4399 } | 4399 } |
4400 | 4400 |
4401 if (!setter.IsNull()) { | 4401 if (!setter.IsNull()) { |
4402 // Invoke the setter and return the result. | 4402 // Invoke the setter and return the result. |
4403 const int kNumArgs = 1; | 4403 const int kNumArgs = 1; |
4404 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); | 4404 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); |
4405 args.SetAt(0, value_instance); | 4405 args.SetAt(0, value_instance); |
(...skipping 18 matching lines...) Expand all Loading... |
4424 } | 4424 } |
4425 | 4425 |
4426 } else if (obj.IsInstance()) { | 4426 } else if (obj.IsInstance()) { |
4427 // Every instance field has a setter Function. Try to find the | 4427 // Every instance field has a setter Function. Try to find the |
4428 // setter in any superclass and use that function to access the | 4428 // setter in any superclass and use that function to access the |
4429 // field. | 4429 // field. |
4430 const Instance& instance = Instance::Cast(obj); | 4430 const Instance& instance = Instance::Cast(obj); |
4431 Class& cls = Class::Handle(Z, instance.clazz()); | 4431 Class& cls = Class::Handle(Z, instance.clazz()); |
4432 String& setter_name = String::Handle(Z, Field::SetterName(field_name)); | 4432 String& setter_name = String::Handle(Z, Field::SetterName(field_name)); |
4433 while (!cls.IsNull()) { | 4433 while (!cls.IsNull()) { |
4434 field = cls.LookupInstanceField(field_name); | 4434 field = cls.LookupInstanceFieldAllowPrivate(field_name); |
4435 if (!field.IsNull() && field.is_final()) { | 4435 if (!field.IsNull() && field.is_final()) { |
4436 return Api::NewError("%s: cannot set final field '%s'.", | 4436 return Api::NewError("%s: cannot set final field '%s'.", |
4437 CURRENT_FUNC, field_name.ToCString()); | 4437 CURRENT_FUNC, field_name.ToCString()); |
4438 } | 4438 } |
4439 setter = cls.LookupDynamicFunctionAllowPrivate(setter_name); | 4439 setter = cls.LookupDynamicFunctionAllowPrivate(setter_name); |
4440 if (!setter.IsNull()) { | 4440 if (!setter.IsNull()) { |
4441 break; | 4441 break; |
4442 } | 4442 } |
4443 cls = cls.SuperClass(); | 4443 cls = cls.SuperClass(); |
4444 } | 4444 } |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6113 return Api::Success(); | 6113 return Api::Success(); |
6114 } | 6114 } |
6115 #endif // DART_PRECOMPILER | 6115 #endif // DART_PRECOMPILER |
6116 | 6116 |
6117 | 6117 |
6118 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6118 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
6119 return Dart::IsRunningPrecompiledCode(); | 6119 return Dart::IsRunningPrecompiledCode(); |
6120 } | 6120 } |
6121 | 6121 |
6122 } // namespace dart | 6122 } // namespace dart |
OLD | NEW |