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

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

Issue 10989017: Fix invalid locations problem for inline super constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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) 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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) { 1159 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) {
1160 assert(link.head is Send); 1160 assert(link.head is Send);
1161 if (link.head is !SendSet) { 1161 if (link.head is !SendSet) {
1162 // A super initializer or constructor redirection. 1162 // A super initializer or constructor redirection.
1163 Send call = link.head; 1163 Send call = link.head;
1164 assert(Initializers.isSuperConstructorCall(call) || 1164 assert(Initializers.isSuperConstructorCall(call) ||
1165 Initializers.isConstructorRedirect(call)); 1165 Initializers.isConstructorRedirect(call));
1166 FunctionElement target = elements[call]; 1166 FunctionElement target = elements[call];
1167 Selector selector = elements.getSelector(call); 1167 Selector selector = elements.getSelector(call);
1168 Link<Node> arguments = call.arguments; 1168 Link<Node> arguments = call.arguments;
1169 sourceElementStack.add(target);
1169 inlineSuperOrRedirect(target, selector, arguments, constructors, 1170 inlineSuperOrRedirect(target, selector, arguments, constructors,
1170 fieldValues); 1171 fieldValues);
1172 sourceElementStack.removeLast();
1171 foundSuperOrRedirect = true; 1173 foundSuperOrRedirect = true;
1172 } else { 1174 } else {
1173 // A field initializer. 1175 // A field initializer.
1174 SendSet init = link.head; 1176 SendSet init = link.head;
1175 Link<Node> arguments = init.arguments; 1177 Link<Node> arguments = init.arguments;
1176 assert(!arguments.isEmpty() && arguments.tail.isEmpty()); 1178 assert(!arguments.isEmpty() && arguments.tail.isEmpty());
1177 sourceElementStack.add(constructor); 1179 sourceElementStack.add(constructor);
1178 visit(arguments.head); 1180 visit(arguments.head);
1179 sourceElementStack.removeLast(); 1181 sourceElementStack.removeLast();
1180 fieldValues[elements[init]] = pop(); 1182 fieldValues[elements[init]] = pop();
1181 } 1183 }
1182 } 1184 }
1183 } 1185 }
1184 1186
1185 if (!foundSuperOrRedirect) { 1187 if (!foundSuperOrRedirect) {
1186 // No super initializer found. Try to find the default constructor if 1188 // No super initializer found. Try to find the default constructor if
1187 // the class is not Object. 1189 // the class is not Object.
1188 ClassElement enclosingClass = constructor.getEnclosingClass(); 1190 ClassElement enclosingClass = constructor.getEnclosingClass();
1189 ClassElement superClass = enclosingClass.superclass; 1191 ClassElement superClass = enclosingClass.superclass;
1190 if (!enclosingClass.isObject(compiler)) { 1192 if (!enclosingClass.isObject(compiler)) {
1191 assert(superClass !== null); 1193 assert(superClass !== null);
1192 assert(superClass.resolutionState == STATE_DONE); 1194 assert(superClass.resolutionState == STATE_DONE);
1193 Selector selector = 1195 Selector selector =
1194 new Selector.call(superClass.name, enclosingClass.getLibrary(), 0); 1196 new Selector.call(superClass.name, enclosingClass.getLibrary(), 0);
1195 FunctionElement target = superClass.lookupConstructor(superClass.name); 1197 FunctionElement target = superClass.lookupConstructor(superClass.name);
1196 if (target === null) { 1198 if (target === null) {
1197 compiler.internalError("no default constructor available"); 1199 compiler.internalError("no default constructor available");
1198 } 1200 }
1201 sourceElementStack.add(target.implementation);
1199 inlineSuperOrRedirect(target.implementation, 1202 inlineSuperOrRedirect(target.implementation,
1200 selector, 1203 selector,
1201 const EmptyLink<Node>(), 1204 const EmptyLink<Node>(),
1202 constructors, 1205 constructors,
1203 fieldValues); 1206 fieldValues);
1207 sourceElementStack.removeLast();
1204 } 1208 }
1205 } 1209 }
1206 } 1210 }
1207 1211
1208 /** 1212 /**
1209 * Run through the fields of [cls] and add their potential 1213 * Run through the fields of [cls] and add their potential
1210 * initializers. 1214 * initializers.
1211 * 1215 *
1212 * Invariant: [classElement] must be a declaration element. 1216 * Invariant: [classElement] must be a declaration element.
1213 */ 1217 */
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 isNot = true; 2294 isNot = true;
2291 } 2295 }
2292 2296
2293 DartType type = elements.getType(typeAnnotation); 2297 DartType type = elements.getType(typeAnnotation);
2294 HInstruction typeInfo = null; 2298 HInstruction typeInfo = null;
2295 if (compiler.codegenWorld.rti.hasTypeArguments(type)) { 2299 if (compiler.codegenWorld.rti.hasTypeArguments(type)) {
2296 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), expression); 2300 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), expression);
2297 typeInfo = pop(); 2301 typeInfo = pop();
2298 } 2302 }
2299 if (type.element.isTypeVariable()) { 2303 if (type.element.isTypeVariable()) {
2300 // TODO(karlklose): We currently answer true to any is check 2304 // TODO(karlklose): We currently answer true to any is check
2301 // involving a type variable -- both is T and is !T -- until 2305 // involving a type variable -- both is T and is !T -- until
2302 // we have a proper implementation of reified generics. 2306 // we have a proper implementation of reified generics.
2303 stack.add(graph.addConstantBool(true, constantSystem)); 2307 stack.add(graph.addConstantBool(true, constantSystem));
2304 } else { 2308 } else {
2305 HInstruction instruction; 2309 HInstruction instruction;
2306 if (typeInfo !== null) { 2310 if (typeInfo !== null) {
2307 instruction = new HIs.withTypeInfoCall(type, expression, typeInfo); 2311 instruction = new HIs.withTypeInfoCall(type, expression, typeInfo);
2308 } else { 2312 } else {
2309 instruction = new HIs(type, expression); 2313 instruction = new HIs(type, expression);
2310 } 2314 }
2311 if (isNot) { 2315 if (isNot) {
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 new HSubGraphBlockInformation(elseBranch.graph)); 4347 new HSubGraphBlockInformation(elseBranch.graph));
4344 4348
4345 HBasicBlock conditionStartBlock = conditionBranch.block; 4349 HBasicBlock conditionStartBlock = conditionBranch.block;
4346 conditionStartBlock.setBlockFlow(info, joinBlock); 4350 conditionStartBlock.setBlockFlow(info, joinBlock);
4347 SubGraph conditionGraph = conditionBranch.graph; 4351 SubGraph conditionGraph = conditionBranch.graph;
4348 HIf branch = conditionGraph.end.last; 4352 HIf branch = conditionGraph.end.last;
4349 assert(branch is HIf); 4353 assert(branch is HIf);
4350 branch.blockInformation = conditionStartBlock.blockFlow; 4354 branch.blockInformation = conditionStartBlock.blockFlow;
4351 } 4355 }
4352 } 4356 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698