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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/container_builder.dart

Issue 891473002: Move reflection support out of model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// This class should morph into something that makes it easy to build 7 /// This class should morph into something that makes it easy to build
8 /// JavaScript representations of libraries, class-sides, and instance-sides. 8 /// JavaScript representations of libraries, class-sides, and instance-sides.
9 /// Initially, it is just a placeholder for code that is moved from 9 /// Initially, it is just a placeholder for code that is moved from
10 /// [CodeEmitterTask]. 10 /// [CodeEmitterTask].
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 selector.argumentCount, selector.namedArguments); 227 selector.argumentCount, selector.namedArguments);
228 if (!selector.appliesUnnamed(member, compiler.world)) continue; 228 if (!selector.appliesUnnamed(member, compiler.world)) continue;
229 if (untypedSelectors.add(selector)) { 229 if (untypedSelectors.add(selector)) {
230 addParameterStub(member, selector, defineStub); 230 addParameterStub(member, selector, defineStub);
231 } 231 }
232 } 232 }
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 String _tearOffNameForMember(FunctionElement member) {
238 if (member.isInstanceMember) {
239 return namer.getterName(member);
240 } else {
241 return namer.getStaticClosureName(member);
242 }
243 }
244
237 void addMemberMethod(DartMethod method, ClassBuilder builder) { 245 void addMemberMethod(DartMethod method, ClassBuilder builder) {
238 final FunctionElement member = method.element; 246 final FunctionElement member = method.element;
239 String name = method.name; 247 String name = method.name;
240 final FunctionSignature parameters = member.functionSignature; 248 final FunctionSignature parameters = member.functionSignature;
241 jsAst.Expression code = method.code; 249 jsAst.Expression code = method.code;
242 final bool needsStubs = method.needsStubs; 250 final bool needsStubs = method.needsStubs;
243 final bool canTearOff = method.needsTearOff;
244 final String tearOffName = method.tearOffName;
245 final bool canBeReflected = method.canBeReflected;
246 final bool canBeApplied = method.canBeApplied; 251 final bool canBeApplied = method.canBeApplied;
252 bool canTearOff = method.needsTearOff;
253 String tearOffName = method.tearOffName;
247 final bool isClosure = method is InstanceMethod && method.isClosure; 254 final bool isClosure = method is InstanceMethod && method.isClosure;
248 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias; 255 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias;
249 256
257 final bool canBeReflected = backend.isAccessibleByReflection(member) ||
floitsch 2015/01/29 15:01:22 I prefer if the comment is not on a sub-expression
herhut 2015/01/29 15:04:21 Done.
258 // During incremental compilation, we have to assume that reflection
259 // *might* get enabled.
260 compiler.hasIncrementalSupport;
261
262 if (canBeReflected) {
263 // Patch the effects of reflection into the received information.
264 bool isNotApplyTarget = member.isConstructor ||
265 member.isAccessor ||
266 member.isOperator ||
267 isClosure;
268 canTearOff = canTearOff || (canBeReflected && !isNotApplyTarget);
269 tearOffName = tearOffName != null ? tearOffName
270 : _tearOffNameForMember(member);
271 }
272
250 final bool needStructuredInfo = 273 final bool needStructuredInfo =
251 canTearOff || canBeReflected || canBeApplied || hasSuperAlias; 274 canTearOff || canBeReflected || canBeApplied || hasSuperAlias;
252 275
253 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); 276 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name);
254 277
255 if (!needStructuredInfo) { 278 if (!needStructuredInfo) {
256 compiler.dumpInfoTask.registerElementAst(member, 279 compiler.dumpInfoTask.registerElementAst(member,
257 builder.addProperty(name, code)); 280 builder.addProperty(name, code));
258 if (needsStubs) { 281 if (needsStubs) {
259 addParameterStubs( 282 addParameterStubs(
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 jsAst.ArrayInitializer arrayInit = 452 jsAst.ArrayInitializer arrayInit =
430 new jsAst.ArrayInitializer(expressions.toList()); 453 new jsAst.ArrayInitializer(expressions.toList());
431 compiler.dumpInfoTask.registerElementAst(member, 454 compiler.dumpInfoTask.registerElementAst(member,
432 builder.addProperty(name, arrayInit)); 455 builder.addProperty(name, arrayInit));
433 } 456 }
434 457
435 void addMemberField(Field field, ClassBuilder builder) { 458 void addMemberField(Field field, ClassBuilder builder) {
436 // For now, do nothing. 459 // For now, do nothing.
437 } 460 }
438 } 461 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698