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

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

Issue 1234883005: Implement tear-off closure operator # (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/resolver.h" 5 #include "vm/resolver.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (FLAG_trace_resolving) { 107 if (FLAG_trace_resolving) {
108 OS::Print("ResolveDynamic '%s' for class %s\n", 108 OS::Print("ResolveDynamic '%s' for class %s\n",
109 function_name.ToCString(), 109 function_name.ToCString(),
110 String::Handle(cls.Name()).ToCString()); 110 String::Handle(cls.Name()).ToCString());
111 } 111 }
112 112
113 const bool is_getter = Field::IsGetterName(function_name); 113 const bool is_getter = Field::IsGetterName(function_name);
114 String& field_name = String::Handle(); 114 String& field_name = String::Handle();
115 if (is_getter) { 115 if (is_getter) {
116 field_name ^= Field::NameFromGetter(function_name); 116 field_name ^= Field::NameFromGetter(function_name);
117
118 if (field_name.CharAt(0) == '#') {
Ivan Posva 2015/07/17 08:35:42 Please add explanation here how we generate the cl
hausner 2015/07/17 17:53:51 Correct. I will add a comment. The # in the getter
119 String& property_name = String::Handle(String::SubString(field_name, 1));
120
121 ASSERT(!Field::IsGetterName(property_name));
122 String& method_name = String::Handle();
123 if (!Field::IsSetterName(property_name)) {
Ivan Posva 2015/07/17 08:35:42 Please add comment why the property name needs to
hausner 2015/07/17 17:53:51 Will do.
124 method_name = Field::GetterName(property_name);
125 }
126
127 Function& function = Function::Handle();
128 while (!cls.IsNull()) {
129 function = cls.LookupDynamicFunction(property_name);
130 if (!function.IsNull()) {
131 return CreateMethodExtractor(function_name, function);
132 }
133 if (!method_name.IsNull()) {
134 function = cls.LookupDynamicFunction(method_name);
135 if (!function.IsNull()) {
136 return CreateMethodExtractor(function_name, function);
137 }
138 }
139 cls = cls.SuperClass();
140 }
141 return Function::null();
142 }
117 } 143 }
118 144
119 // Now look for an instance function whose name matches function_name 145 // Now look for an instance function whose name matches function_name
120 // in the class. 146 // in the class.
121 Function& function = Function::Handle(); 147 Function& function = Function::Handle();
122 while (!cls.IsNull()) { 148 while (!cls.IsNull()) {
123 function ^= cls.LookupDynamicFunction(function_name); 149 function ^= cls.LookupDynamicFunction(function_name);
124 if (!function.IsNull()) { 150 if (!function.IsNull()) {
125 return function.raw(); 151 return function.raw();
126 } 152 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 OS::Print("ResolveStaticAllowPrivate error '%s': %s.\n", 277 OS::Print("ResolveStaticAllowPrivate error '%s': %s.\n",
252 function_name.ToCString(), 278 function_name.ToCString(),
253 error_message.ToCString()); 279 error_message.ToCString());
254 } 280 }
255 return Function::null(); 281 return Function::null();
256 } 282 }
257 return function.raw(); 283 return function.raw();
258 } 284 }
259 285
260 } // namespace dart 286 } // namespace dart
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/parser.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698