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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 14168003: Implement implicit constructors in mixin applications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 // Don't forget to update the field, if the parameter is of the 1298 // Don't forget to update the field, if the parameter is of the
1299 // form [:this.x:]. 1299 // form [:this.x:].
1300 if (parameter.kind == ElementKind.FIELD_PARAMETER) { 1300 if (parameter.kind == ElementKind.FIELD_PARAMETER) {
1301 FieldParameterElement fieldParameterElement = parameter; 1301 FieldParameterElement fieldParameterElement = parameter;
1302 fieldValues[fieldParameterElement.fieldElement] = argument; 1302 fieldValues[fieldParameterElement.fieldElement] = argument;
1303 } 1303 }
1304 }); 1304 });
1305 1305
1306 // Build the initializers in the context of the new constructor. 1306 // Build the initializers in the context of the new constructor.
1307 TreeElements oldElements = elements; 1307 TreeElements oldElements = elements;
1308 if (constructor.isForwardingConstructor) {
kasperl 2013/04/25 12:13:12 How does this work if the target constructor is a
karlklose 2013/05/03 09:35:45 They are now short-circuited.
1309 constructor = constructor.targetConstructor;
1310 }
1308 elements = 1311 elements =
1309 compiler.enqueuer.resolution.getCachedElements(constructor); 1312 compiler.enqueuer.resolution.getCachedElements(constructor);
1310
1311 ClosureClassMap oldClosureData = localsHandler.closureData; 1313 ClosureClassMap oldClosureData = localsHandler.closureData;
1312 Node node = constructor.parseNode(compiler); 1314 Node node = constructor.parseNode(compiler);
1313 ClosureClassMap newClosureData = 1315 ClosureClassMap newClosureData =
1314 compiler.closureToClassMapper.computeClosureToClassMapping( 1316 compiler.closureToClassMapper.computeClosureToClassMapping(
1315 constructor, node, elements); 1317 constructor, node, elements);
1316 // The [:this:] element now refers to the one in the new closure 1318 // The [:this:] element now refers to the one in the new closure
1317 // data, that is the [:this:] of the super constructor. We 1319 // data, that is the [:this:] of the super constructor. We
1318 // update the element to refer to the current [:this:]. 1320 // update the element to refer to the current [:this:].
1319 localsHandler.updateLocal(newClosureData.thisElement, 1321 localsHandler.updateLocal(newClosureData.thisElement,
1320 localsHandler.readThis()); 1322 localsHandler.readThis());
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 Link<Node> arguments, 2878 Link<Node> arguments,
2877 FunctionElement element, 2879 FunctionElement element,
2878 List<HInstruction> list) { 2880 List<HInstruction> list) {
2879 assert(invariant(element, element.isImplementation)); 2881 assert(invariant(element, element.isImplementation));
2880 2882
2881 HInstruction compileArgument(Node argument) { 2883 HInstruction compileArgument(Node argument) {
2882 visit(argument); 2884 visit(argument);
2883 return pop(); 2885 return pop();
2884 } 2886 }
2885 2887
2888 if (element.isForwardingConstructor) {
kasperl 2013/04/25 12:13:12 Same comment as above.
karlklose 2013/05/03 09:35:45 Done.
karlklose 2013/05/03 09:35:45 I added an invariant when they are created.
2889 element = element.targetConstructor;
2890 }
2891
2886 return selector.addArgumentsToList(arguments, 2892 return selector.addArgumentsToList(arguments,
2887 list, 2893 list,
2888 element, 2894 element,
2889 compileArgument, 2895 compileArgument,
2890 handleConstantForOptionalParameter, 2896 handleConstantForOptionalParameter,
2891 compiler); 2897 compiler);
2892 } 2898 }
2893 2899
2894 void addGenericSendArgumentsToList(Link<Node> link, List<HInstruction> list) { 2900 void addGenericSendArgumentsToList(Link<Node> link, List<HInstruction> list) {
2895 for (; !link.isEmpty; link = link.tail) { 2901 for (; !link.isEmpty; link = link.tail) {
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 } else if (element.isGenerativeConstructor()) { 3377 } else if (element.isGenerativeConstructor()) {
3372 ClassElement cls = element.getEnclosingClass(); 3378 ClassElement cls = element.getEnclosingClass();
3373 return new HType.nonNullExact(cls.thisType, compiler); 3379 return new HType.nonNullExact(cls.thisType, compiler);
3374 } else { 3380 } else {
3375 return HType.UNKNOWN; 3381 return HType.UNKNOWN;
3376 } 3382 }
3377 } 3383 }
3378 3384
3379 Element constructor = elements[node]; 3385 Element constructor = elements[node];
3380 Selector selector = elements.getSelector(node); 3386 Selector selector = elements.getSelector(node);
3387 if (constructor.isForwardingConstructor) {
3388 compiler.unimplemented('forwarded constructor in named mixin application',
3389 element: constructor.getEnclosingClass());
3390 }
3381 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { 3391 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) {
3382 compiler.internalError("Unresolved element: $constructor", node: node); 3392 compiler.internalError("Unresolved element: $constructor", node: node);
3383 } 3393 }
3384 FunctionElement functionElement = constructor; 3394 FunctionElement functionElement = constructor;
3385 constructor = functionElement.redirectionTarget; 3395 constructor = functionElement.redirectionTarget;
3386 final bool isSymbolConstructor = 3396 final bool isSymbolConstructor =
3387 functionElement == compiler.symbolConstructor; 3397 functionElement == compiler.symbolConstructor;
3388 3398
3389 if (isSymbolConstructor) { 3399 if (isSymbolConstructor) {
3390 constructor = compiler.symbolValidatedConstructor; 3400 constructor = compiler.symbolValidatedConstructor;
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
5248 new HSubGraphBlockInformation(elseBranch.graph)); 5258 new HSubGraphBlockInformation(elseBranch.graph));
5249 5259
5250 HBasicBlock conditionStartBlock = conditionBranch.block; 5260 HBasicBlock conditionStartBlock = conditionBranch.block;
5251 conditionStartBlock.setBlockFlow(info, joinBlock); 5261 conditionStartBlock.setBlockFlow(info, joinBlock);
5252 SubGraph conditionGraph = conditionBranch.graph; 5262 SubGraph conditionGraph = conditionBranch.graph;
5253 HIf branch = conditionGraph.end.last; 5263 HIf branch = conditionGraph.end.last;
5254 assert(branch is HIf); 5264 assert(branch is HIf);
5255 branch.blockInformation = conditionStartBlock.blockFlow; 5265 branch.blockInformation = conditionStartBlock.blockFlow;
5256 } 5266 }
5257 } 5267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698