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

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

Issue 1311613005: Add ParameterMirror.isInitializingFormal to dart:mirrors Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.full_emitter; 5 part of dart2js.js_emitter.full_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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // ... 60 // ...
61 // N. Getter name for tearOff. 61 // N. Getter name for tearOff.
62 // N+1. (Required parameter count << 1) + (member.isAccessor ? 1 : 0). 62 // N+1. (Required parameter count << 1) + (member.isAccessor ? 1 : 0).
63 // N+2. (Optional parameter count << 1) + 63 // N+2. (Optional parameter count << 1) +
64 // (parameters.optionalParametersAreNamed ? 1 : 0). 64 // (parameters.optionalParametersAreNamed ? 1 : 0).
65 // N+3. Index to function type in constant pool. 65 // N+3. Index to function type in constant pool.
66 // N+4. First default argument. 66 // N+4. First default argument.
67 // ... 67 // ...
68 // O. First parameter name (if needed for reflection or Function.apply). 68 // O. First parameter name (if needed for reflection or Function.apply).
69 // ... 69 // ...
70 // P. Unmangled name (if reflectable). 70 // P. Whether the first argument is field initialization parameter
71 // P+1. First metadata (if reflectable). 71 // (if reflectable and a constructor)
72 // ...
73 // Q. Unmangled name (if reflectable).
74 // Q+1. First metadata (if reflectable).
72 // ... 75 // ...
73 // TODO(ahe): Consider one of the parameter counts can be replaced by the 76 // TODO(ahe): Consider one of the parameter counts can be replaced by the
74 // length property of the JavaScript function object. 77 // length property of the JavaScript function object.
75 78
76 List<jsAst.Expression> expressions = <jsAst.Expression>[]; 79 List<jsAst.Expression> expressions = <jsAst.Expression>[];
77 80
78 // Create the optional aliasing entry if this method is called via super. 81 // Create the optional aliasing entry if this method is called via super.
79 if (hasSuperAlias) { 82 if (hasSuperAlias) {
80 expressions.add(js.quoteName(superAlias)); 83 expressions.add(js.quoteName(superAlias));
81 } 84 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 backend.constants.getConstantValueForMetadata(annotation); 147 backend.constants.getConstantValueForMetadata(annotation);
145 backend.constants.addCompileTimeConstantForEmission(constant); 148 backend.constants.addCompileTimeConstantForEmission(constant);
146 return task.metadataCollector.reifyMetadata(annotation); 149 return task.metadataCollector.reifyMetadata(annotation);
147 }); 150 });
148 expressions.add(new jsAst.ArrayInitializer(metadataIndices.toList())); 151 expressions.add(new jsAst.ArrayInitializer(metadataIndices.toList()));
149 } 152 }
150 }); 153 });
151 } 154 }
152 if (canBeReflected) { 155 if (canBeReflected) {
153 jsAst.LiteralString reflectionName; 156 jsAst.LiteralString reflectionName;
157 List<jsAst.LiteralBool> argumentsInstantiatingFields = new List();
154 if (member.isConstructor) { 158 if (member.isConstructor) {
159 member.functionSignature.forEachParameter((element) =>
160 argumentsInstantiatingFields.add(js.boolean(element is InitializingFor malElement)));
155 // TODO(herhut): This registers name as a mangled name. Do we need this 161 // TODO(herhut): This registers name as a mangled name. Do we need this
156 // given that we use a different name below? 162 // given that we use a different name below?
157 emitter.getReflectionName(member, name); 163 emitter.getReflectionName(member, name);
158 reflectionName = 164 reflectionName =
159 new jsAst.LiteralString( 165 new jsAst.LiteralString(
160 '"new ${Elements.reconstructConstructorName(member)}"'); 166 '"new ${Elements.reconstructConstructorName(member)}"');
161 } else { 167 } else {
162 reflectionName = 168 reflectionName =
163 js.string(namer.privateName(member.memberName)); 169 js.string(namer.privateName(member.memberName));
170 member.functionSignature.forEachParameter((element) =>
171 argumentsInstantiatingFields.add(js.boolean(false)));
164 } 172 }
165 expressions 173 expressions
174 ..addAll(argumentsInstantiatingFields)
166 ..add(reflectionName) 175 ..add(reflectionName)
167 ..addAll(task.metadataCollector.computeMetadata(member)); 176 ..addAll(task.metadataCollector.computeMetadata(member));
168 } else if (isClosure && canBeApplied) { 177 } else if (isClosure && canBeApplied) {
169 expressions.add(js.string(namer.privateName(member.memberName))); 178 expressions.add(js.string(namer.privateName(member.memberName)));
170 } 179 }
171 180
172 jsAst.ArrayInitializer arrayInit = 181 jsAst.ArrayInitializer arrayInit =
173 new jsAst.ArrayInitializer(expressions.toList()); 182 new jsAst.ArrayInitializer(expressions.toList());
174 compiler.dumpInfoTask.registerElementAst(member, 183 compiler.dumpInfoTask.registerElementAst(member,
175 builder.addProperty(name, arrayInit)); 184 builder.addProperty(name, arrayInit));
176 } 185 }
177 186
178 void addMemberField(Field field, ClassBuilder builder) { 187 void addMemberField(Field field, ClassBuilder builder) {
179 // For now, do nothing. 188 // For now, do nothing.
180 } 189 }
181 } 190 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698