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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1227873004: dart2js cps: Implement compilation of redirecting factory constructors for reflection. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comment. 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
« no previous file with comments | « no previous file | pkg/pkg.status » ('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 library dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 return null; 246 return null;
247 } 247 }
248 248
249 ir.Primitive visitRethrow(ast.Rethrow node) { 249 ir.Primitive visitRethrow(ast.Rethrow node) {
250 assert(irBuilder.isOpen); 250 assert(irBuilder.isOpen);
251 irBuilder.buildRethrow(); 251 irBuilder.buildRethrow();
252 return null; 252 return null;
253 } 253 }
254 254
255 /// Construct a method that executes the forwarding call to the target
256 /// constructor. This is only required, if the forwarding factory
257 /// constructor can potentially be the target of a reflective call, because
258 /// the builder shortcuts calls to redirecting factories at the call site
259 /// (see [JsIrBuilderVisitor.handleConstructorInvoke]).
260 visitRedirectingFactoryBody(ast.RedirectingFactoryBody node) {
261 ConstructorElement targetConstructor =
262 elements.getRedirectingTargetConstructor(node).implementation;
263 ConstructorElement redirectingConstructor =
264 irBuilder.state.currentElement.implementation;
265 List<ir.Primitive> arguments = <ir.Primitive>[];
266 FunctionSignature redirectingSignature =
267 redirectingConstructor.functionSignature;
268 List<String> namedParameters = <String>[];
269 redirectingSignature.forEachParameter((ParameterElement parameter) {
270 arguments.add(irBuilder.environment.lookup(parameter));
271 if (parameter.isNamed) {
272 namedParameters.add(parameter.name);
273 }
274 });
275 ClassElement cls = redirectingConstructor.enclosingClass;
276 InterfaceType targetType =
277 redirectingConstructor.computeEffectiveTargetType(cls.thisType);
278 CallStructure callStructure = new CallStructure(
279 redirectingSignature.parameterCount,
280 namedParameters);
281 arguments = normalizeStaticArguments(callStructure, targetConstructor,
282 arguments);
283 ir.Primitive instance = irBuilder.buildConstructorInvocation(
284 targetConstructor,
285 callStructure,
286 targetType,
287 arguments);
288 irBuilder.buildReturn(instance);
289 }
290
255 visitFor(ast.For node) { 291 visitFor(ast.For node) {
256 List<LocalElement> loopVariables = <LocalElement>[]; 292 List<LocalElement> loopVariables = <LocalElement>[];
257 if (node.initializer is ast.VariableDefinitions) { 293 if (node.initializer is ast.VariableDefinitions) {
258 ast.VariableDefinitions definitions = node.initializer; 294 ast.VariableDefinitions definitions = node.initializer;
259 for (ast.Node node in definitions.definitions.nodes) { 295 for (ast.Node node in definitions.definitions.nodes) {
260 LocalElement loopVariable = elements[node]; 296 LocalElement loopVariable = elements[node];
261 loopVariables.add(loopVariable); 297 loopVariables.add(loopVariable);
262 } 298 }
263 } 299 }
264 300
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3283 } 3319 }
3284 3320
3285 processSetStatic(ir.SetStatic node) { 3321 processSetStatic(ir.SetStatic node) {
3286 node.body = replacementFor(node.body); 3322 node.body = replacementFor(node.body);
3287 } 3323 }
3288 3324
3289 processContinuation(ir.Continuation node) { 3325 processContinuation(ir.Continuation node) {
3290 node.body = replacementFor(node.body); 3326 node.body = replacementFor(node.body);
3291 } 3327 }
3292 } 3328 }
OLDNEW
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698