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

Side by Side Diff: runtime/vm/object.cc

Issue 1234883005: Implement tear-off closure operator # (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 years, 5 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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 7369 matching lines...) Expand 10 before | Expand all | Expand 10 after
7380 jsobj.AddProperty("_guardLength", guarded_list_length()); 7380 jsobj.AddProperty("_guardLength", guarded_list_length());
7381 } 7381 }
7382 const Class& origin_cls = Class::Handle(origin()); 7382 const Class& origin_cls = Class::Handle(origin());
7383 const Script& script = Script::Handle(origin_cls.script()); 7383 const Script& script = Script::Handle(origin_cls.script());
7384 if (!script.IsNull()) { 7384 if (!script.IsNull()) {
7385 jsobj.AddLocation(script, token_pos()); 7385 jsobj.AddLocation(script, token_pos());
7386 } 7386 }
7387 } 7387 }
7388 7388
7389 7389
7390 RawInstance* Field::GetterClosure() const {
7391 ASSERT(is_static());
7392 const Class& field_owner = Class::Handle(owner());
7393 const char* field_name = String::Handle(name()).ToCString();
7394 String& expr_src = String::Handle(
7395 String::NewFormatted("() { return %s; }", field_name));
7396 Object& result =
7397 Object::Handle(field_owner.Evaluate(expr_src,
7398 Object::empty_array(),
7399 Object::empty_array()));
7400 ASSERT(result.IsInstance());
7401 result = Object::Clone(result, Heap::kOld);
7402 return Instance::RawCast(result.raw());
7403 }
7404
7405
7406 RawInstance* Field::SetterClosure() const {
7407 ASSERT(is_static());
7408 const Class& field_owner = Class::Handle(owner());
7409 const char* field_name = String::Handle(name()).ToCString();
7410 // TODO(hausner): Ensure that parameter name does not hide field name.
7411 String& expr_src = String::Handle(
7412 String::NewFormatted("(xxx) { return %s = xxx; }", field_name));
Florian Schneider 2015/07/20 07:00:16 s/xxx/value/ to have a name that is already in ou
hausner 2015/07/21 17:18:36 Done.
7413 Object& result =
7414 Object::Handle(field_owner.Evaluate(expr_src,
7415 Object::empty_array(),
7416 Object::empty_array()));
7417 ASSERT(result.IsInstance());
7418 result = Object::Clone(result, Heap::kOld);
7419 return Instance::RawCast(result.raw());
7420 }
7421
7422
7390 RawArray* Field::dependent_code() const { 7423 RawArray* Field::dependent_code() const {
7391 return raw_ptr()->dependent_code_; 7424 return raw_ptr()->dependent_code_;
7392 } 7425 }
7393 7426
7394 7427
7395 void Field::set_dependent_code(const Array& array) const { 7428 void Field::set_dependent_code(const Array& array) const {
7396 StorePointer(&raw_ptr()->dependent_code_, array.raw()); 7429 StorePointer(&raw_ptr()->dependent_code_, array.raw());
7397 } 7430 }
7398 7431
7399 7432
(...skipping 13810 matching lines...) Expand 10 before | Expand all | Expand 10 after
21210 return tag_label.ToCString(); 21243 return tag_label.ToCString();
21211 } 21244 }
21212 21245
21213 21246
21214 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21247 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21215 Instance::PrintJSONImpl(stream, ref); 21248 Instance::PrintJSONImpl(stream, ref);
21216 } 21249 }
21217 21250
21218 21251
21219 } // namespace dart 21252 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698