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

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

Issue 10970070: Fix bad diagnostic positions when inlining super constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | 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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 * Documentation wanted -- johnniwinther 1089 * Documentation wanted -- johnniwinther
1090 * 1090 *
1091 * Invariant: [constructor] and [constructors] must all be implementation 1091 * Invariant: [constructor] and [constructors] must all be implementation
1092 * elements. 1092 * elements.
1093 */ 1093 */
1094 void inlineSuperOrRedirect(FunctionElement constructor, 1094 void inlineSuperOrRedirect(FunctionElement constructor,
1095 Selector selector, 1095 Selector selector,
1096 Link<Node> arguments, 1096 Link<Node> arguments,
1097 List<FunctionElement> constructors, 1097 List<FunctionElement> constructors,
1098 Map<Element, HInstruction> fieldValues) { 1098 Map<Element, HInstruction> fieldValues) {
1099 assert(invariant(constructor, constructor.isImplementation)); 1099 compiler.withCurrentElement(constructor, () {
1100 constructors.addLast(constructor); 1100 assert(invariant(constructor, constructor.isImplementation));
1101 constructors.addLast(constructor);
1101 1102
1102 List<HInstruction> compiledArguments = new List<HInstruction>(); 1103 List<HInstruction> compiledArguments = new List<HInstruction>();
1103 bool succeeded = addStaticSendArgumentsToList(selector, 1104 bool succeeded = addStaticSendArgumentsToList(selector,
1104 arguments, 1105 arguments,
1105 constructor, 1106 constructor,
1106 compiledArguments); 1107 compiledArguments);
1107 if (!succeeded) { 1108 if (!succeeded) {
1108 // Non-matching super and redirects are compile-time errors and thus 1109 // Non-matching super and redirects are compile-time errors and thus
1109 // checked by the resolver. 1110 // checked by the resolver.
1110 compiler.internalError( 1111 compiler.internalError(
1111 "Parameters and arguments didn't match for super/redirect call", 1112 "Parameters and arguments didn't match for super/redirect call",
1112 element: constructor); 1113 element: constructor);
1113 } 1114 }
1114 1115
1115 buildFieldInitializers(constructor.enclosingElement, fieldValues); 1116 buildFieldInitializers(constructor.enclosingElement, fieldValues);
1116 1117
1117 int index = 0; 1118 int index = 0;
1118 FunctionSignature params = constructor.computeSignature(compiler); 1119 FunctionSignature params = constructor.computeSignature(compiler);
1119 params.forEachParameter((Element parameter) { 1120 params.forEachParameter((Element parameter) {
1120 HInstruction argument = compiledArguments[index++]; 1121 HInstruction argument = compiledArguments[index++];
1121 localsHandler.updateLocal(parameter, argument); 1122 localsHandler.updateLocal(parameter, argument);
1122 // Don't forget to update the field, if the parameter is of the 1123 // Don't forget to update the field, if the parameter is of the
1123 // form [:this.x:]. 1124 // form [:this.x:].
1124 if (parameter.kind == ElementKind.FIELD_PARAMETER) { 1125 if (parameter.kind == ElementKind.FIELD_PARAMETER) {
1125 FieldParameterElement fieldParameterElement = parameter; 1126 FieldParameterElement fieldParameterElement = parameter;
1126 fieldValues[fieldParameterElement.fieldElement] = argument; 1127 fieldValues[fieldParameterElement.fieldElement] = argument;
1127 } 1128 }
1129 });
1130
1131 // Build the initializers in the context of the new constructor.
1132 TreeElements oldElements = elements;
1133 elements = compiler.resolver.resolveMethodElement(constructor);
1134 buildInitializers(constructor, constructors, fieldValues);
1135 elements = oldElements;
1128 }); 1136 });
1129
1130 // Build the initializers in the context of the new constructor.
1131 TreeElements oldElements = elements;
1132 elements = compiler.resolver.resolveMethodElement(constructor);
1133 buildInitializers(constructor, constructors, fieldValues);
1134 elements = oldElements;
1135 } 1137 }
1136 1138
1137 /** 1139 /**
1138 * Run through the initializers and inline all field initializers. Recursively 1140 * Run through the initializers and inline all field initializers. Recursively
1139 * inlines super initializers. 1141 * inlines super initializers.
1140 * 1142 *
1141 * The constructors of the inlined initializers is added to [constructors] 1143 * The constructors of the inlined initializers is added to [constructors]
1142 * with sub constructors having a lower index than super constructors. 1144 * with sub constructors having a lower index than super constructors.
1143 * 1145 *
1144 * Invariant: The [constructor] and elements in [constructors] must all be 1146 * Invariant: The [constructor] and elements in [constructors] must all be
(...skipping 3197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 new HSubGraphBlockInformation(elseBranch.graph)); 4344 new HSubGraphBlockInformation(elseBranch.graph));
4343 4345
4344 HBasicBlock conditionStartBlock = conditionBranch.block; 4346 HBasicBlock conditionStartBlock = conditionBranch.block;
4345 conditionStartBlock.setBlockFlow(info, joinBlock); 4347 conditionStartBlock.setBlockFlow(info, joinBlock);
4346 SubGraph conditionGraph = conditionBranch.graph; 4348 SubGraph conditionGraph = conditionBranch.graph;
4347 HIf branch = conditionGraph.end.last; 4349 HIf branch = conditionGraph.end.last;
4348 assert(branch is HIf); 4350 assert(branch is HIf);
4349 branch.blockInformation = conditionStartBlock.blockFlow; 4351 branch.blockInformation = conditionStartBlock.blockFlow;
4350 } 4352 }
4351 } 4353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698