Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index d47ed574a05e8638a17e13a4dfe1560f1f5959e4..2476e5ccaa1b547e318203a97010f22014317923 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -7380,6 +7380,39 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
} |
+RawInstance* Field::GetterClosure() const { |
+ ASSERT(is_static()); |
+ const Class& field_owner = Class::Handle(owner()); |
+ const char* field_name = String::Handle(name()).ToCString(); |
+ String& expr_src = String::Handle( |
+ String::NewFormatted("() { return %s; }", field_name)); |
+ Object& result = |
+ Object::Handle(field_owner.Evaluate(expr_src, |
Florian Schneider
2015/07/17 09:42:02
With precompilation we can't invoke the compiler a
hausner
2015/07/17 17:53:51
Yes. This evaluation happens at (pre-)compile time
|
+ Object::empty_array(), |
+ Object::empty_array())); |
+ ASSERT(result.IsInstance()); |
+ result = Object::Clone(result, Heap::kOld); |
Ivan Posva
2015/07/17 08:35:42
Why is this necessary?
hausner
2015/07/17 17:53:51
Because the result will be stuck into a LiteralNod
|
+ return Instance::RawCast(result.raw()); |
+} |
+ |
+ |
+RawInstance* Field::SetterClosure() const { |
+ ASSERT(is_static()); |
+ const Class& field_owner = Class::Handle(owner()); |
+ const char* field_name = String::Handle(name()).ToCString(); |
+ // TODO(hausner): Ensure that parameter name does not hide field name. |
+ String& expr_src = String::Handle( |
+ String::NewFormatted("(xxx) { return %s = xxx; }", field_name)); |
+ Object& result = |
+ Object::Handle(field_owner.Evaluate(expr_src, |
Florian Schneider
2015/07/17 09:42:02
Same issue here with precompiled code.
|
+ Object::empty_array(), |
+ Object::empty_array())); |
+ ASSERT(result.IsInstance()); |
+ result = Object::Clone(result, Heap::kOld); |
+ return Instance::RawCast(result.raw()); |
+} |
+ |
+ |
RawArray* Field::dependent_code() const { |
return raw_ptr()->dependent_code_; |
} |