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

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

Issue 881363006: Store the aliasName of a method in the model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: REBASE 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].
11 class ContainerBuilder extends CodeEmitterHelper { 11 class ContainerBuilder extends CodeEmitterHelper {
12 12
13 void addMemberMethod(DartMethod method, ClassBuilder builder) { 13 void addMemberMethod(DartMethod method, ClassBuilder builder) {
14 final FunctionElement member = method.element; 14 FunctionElement member = method.element;
15 String name = method.name; 15 String name = method.name;
16 final FunctionSignature parameters = member.functionSignature; 16 FunctionSignature parameters = member.functionSignature;
17 jsAst.Expression code = method.code; 17 jsAst.Expression code = method.code;
18 final bool needsStubs = method.parameterStubs.isNotEmpty; 18 bool needsStubs = method.parameterStubs.isNotEmpty;
19 final bool canTearOff = method.needsTearOff; 19 bool canBeApplied = method.canBeApplied;
20 final String tearOffName = method.tearOffName; 20 bool canBeReflected = method.canBeReflected;
21 final bool canBeReflected = method.canBeReflected; 21 bool canTearOff = method.needsTearOff;
22 final bool canBeApplied = method.canBeApplied; 22 String tearOffName = method.tearOffName;
23 final bool isClosure = method is InstanceMethod && method.isClosure; 23 bool isClosure = method is InstanceMethod && method.isClosure;
24 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias; 24 String superAlias = method is InstanceMethod ? method.aliasName : null;
25 bool hasSuperAlias = superAlias != null;
25 26
26 final bool needStructuredInfo = 27 bool needStructuredInfo =
27 canTearOff || canBeReflected || canBeApplied || hasSuperAlias; 28 canTearOff || canBeReflected || canBeApplied || hasSuperAlias;
28 29
29 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); 30 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name);
30 31
31 if (!needStructuredInfo) { 32 if (!needStructuredInfo) {
32 compiler.dumpInfoTask.registerElementAst(member, 33 compiler.dumpInfoTask.registerElementAst(member,
33 builder.addProperty(name, code)); 34 builder.addProperty(name, code));
34 35
35 for (ParameterStubMethod stub in method.parameterStubs) { 36 for (ParameterStubMethod stub in method.parameterStubs) {
36 assert(stub.callName == null); 37 assert(stub.callName == null);
(...skipping 30 matching lines...) Expand all
67 // ... 68 // ...
68 // P. Unmangled name (if reflectable). 69 // P. Unmangled name (if reflectable).
69 // P+1. First metadata (if reflectable). 70 // P+1. First metadata (if reflectable).
70 // ... 71 // ...
71 // TODO(ahe): Consider one of the parameter counts can be replaced by the 72 // TODO(ahe): Consider one of the parameter counts can be replaced by the
72 // length property of the JavaScript function object. 73 // length property of the JavaScript function object.
73 74
74 List<jsAst.Expression> expressions = <jsAst.Expression>[]; 75 List<jsAst.Expression> expressions = <jsAst.Expression>[];
75 76
76 // Create the optional aliasing entry if this method is called via super. 77 // Create the optional aliasing entry if this method is called via super.
77 if (backend.isAliasedSuperMember(member)) { 78 if (hasSuperAlias) {
78 expressions.add(new jsAst.LiteralString( 79 expressions.add(new jsAst.LiteralString('"${superAlias}"'));
79 '"${namer.getNameOfAliasedSuperMember(member)}"'));
80 } 80 }
81 81
82 expressions.add(code); 82 expressions.add(code);
83 83
84 final bool onlyNeedsSuperAlias = 84 bool onlyNeedsSuperAlias =
85 !(canTearOff || canBeReflected || canBeApplied || needsStubs); 85 !(canTearOff || canBeReflected || canBeApplied || needsStubs);
86 86
87 if (onlyNeedsSuperAlias) { 87 if (onlyNeedsSuperAlias) {
88 jsAst.ArrayInitializer arrayInit = 88 jsAst.ArrayInitializer arrayInit =
89 new jsAst.ArrayInitializer(expressions); 89 new jsAst.ArrayInitializer(expressions);
90 compiler.dumpInfoTask.registerElementAst(member, 90 compiler.dumpInfoTask.registerElementAst(member,
91 builder.addProperty(name, arrayInit)); 91 builder.addProperty(name, arrayInit));
92 return; 92 return;
93 } 93 }
94 94
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 jsAst.ArrayInitializer arrayInit = 197 jsAst.ArrayInitializer arrayInit =
198 new jsAst.ArrayInitializer(expressions.toList()); 198 new jsAst.ArrayInitializer(expressions.toList());
199 compiler.dumpInfoTask.registerElementAst(member, 199 compiler.dumpInfoTask.registerElementAst(member,
200 builder.addProperty(name, arrayInit)); 200 builder.addProperty(name, arrayInit));
201 } 201 }
202 202
203 void addMemberField(Field field, ClassBuilder builder) { 203 void addMemberField(Field field, ClassBuilder builder) {
204 // For now, do nothing. 204 // For now, do nothing.
205 } 205 }
206 } 206 }
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