| OLD | NEW |
| 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.ir_builder; | 5 part of dart2js.ir_builder; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This task iterates through all resolved elements and builds [ir.Node]s. The | 8 * This task iterates through all resolved elements and builds [ir.Node]s. The |
| 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and | 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and |
| 10 * [getIr]. | 10 * [getIr]. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 "Unexpected initializer type $initializer"); | 230 "Unexpected initializer type $initializer"); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } | 233 } |
| 234 if (!explicitSuperInitializer) { | 234 if (!explicitSuperInitializer) { |
| 235 // No super initializer found. Try to find the default constructor if | 235 // No super initializer found. Try to find the default constructor if |
| 236 // the class is not Object. | 236 // the class is not Object. |
| 237 ClassElement enclosingClass = element.enclosingClass; | 237 ClassElement enclosingClass = element.enclosingClass; |
| 238 if (!enclosingClass.isObject) { | 238 if (!enclosingClass.isObject) { |
| 239 ClassElement superClass = enclosingClass.superclass; | 239 ClassElement superClass = enclosingClass.superclass; |
| 240 Selector selector = | 240 FunctionElement target = superClass.lookupDefaultConstructor(); |
| 241 new Selector.callDefaultConstructor(enclosingClass.library); | |
| 242 FunctionElement target = superClass.lookupConstructor(selector); | |
| 243 if (target == null) { | 241 if (target == null) { |
| 244 compiler.internalError(superClass, | 242 compiler.internalError(superClass, |
| 245 "No default constructor available."); | 243 "No default constructor available."); |
| 246 } | 244 } |
| 245 Selector selector = new Selector.fromElement(target); |
| 247 result.add(irBuilder.makeSuperInitializer(target, | 246 result.add(irBuilder.makeSuperInitializer(target, |
| 248 <ir.RunnableBody>[], | 247 <ir.RunnableBody>[], |
| 249 selector)); | 248 selector)); |
| 250 } | 249 } |
| 251 } | 250 } |
| 252 return result; | 251 return result; |
| 253 } | 252 } |
| 254 | 253 |
| 255 ir.Primitive visit(ast.Node node) => node.accept(this); | 254 ir.Primitive visit(ast.Node node) => node.accept(this); |
| 256 | 255 |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 hasConstructorCall = true; | 1364 hasConstructorCall = true; |
| 1366 } else { | 1365 } else { |
| 1367 compiler.internalError(initializer, | 1366 compiler.internalError(initializer, |
| 1368 "Unexpected initializer type $initializer"); | 1367 "Unexpected initializer type $initializer"); |
| 1369 } | 1368 } |
| 1370 } | 1369 } |
| 1371 } | 1370 } |
| 1372 // If no super() or this() was found, also call default superconstructor. | 1371 // If no super() or this() was found, also call default superconstructor. |
| 1373 if (!hasConstructorCall && !enclosingClass.isObject) { | 1372 if (!hasConstructorCall && !enclosingClass.isObject) { |
| 1374 ClassElement superClass = enclosingClass.superclass; | 1373 ClassElement superClass = enclosingClass.superclass; |
| 1375 Selector selector = | 1374 FunctionElement target = superClass.lookupDefaultConstructor(); |
| 1376 new Selector.callDefaultConstructor(enclosingClass.library); | |
| 1377 FunctionElement target = superClass.lookupConstructor(selector); | |
| 1378 if (target == null) { | 1375 if (target == null) { |
| 1379 compiler.internalError(superClass, "No default constructor available."); | 1376 compiler.internalError(superClass, "No default constructor available."); |
| 1380 } | 1377 } |
| 1381 evaluateConstructorFieldInitializers(target, supers); | 1378 evaluateConstructorFieldInitializers(target, supers); |
| 1382 } | 1379 } |
| 1383 // Add this constructor after the superconstructors. | 1380 // Add this constructor after the superconstructors. |
| 1384 supers.add(constructor); | 1381 supers.add(constructor); |
| 1385 } | 1382 } |
| 1386 | 1383 |
| 1387 /// In preparation of inlining (part of) [target], the [arguments] are moved | 1384 /// In preparation of inlining (part of) [target], the [arguments] are moved |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 element, | 1540 element, |
| 1544 node, | 1541 node, |
| 1545 elements); | 1542 elements); |
| 1546 IrBuilder builder = | 1543 IrBuilder builder = |
| 1547 new JsIrBuilder(compiler.backend.constantSystem, element); | 1544 new JsIrBuilder(compiler.backend.constantSystem, element); |
| 1548 return withBuilder(builder, () => _makeFunctionBody(element, node)); | 1545 return withBuilder(builder, () => _makeFunctionBody(element, node)); |
| 1549 } | 1546 } |
| 1550 | 1547 |
| 1551 } | 1548 } |
| 1552 | 1549 |
| OLD | NEW |