| OLD | NEW |
| 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 implement [TypedElement.type] because our | 9 * methods. We need to implement [TypedElement.type] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 * [visitForIn]. | 1608 * [visitForIn]. |
| 1609 */ | 1609 */ |
| 1610 return currentNode.asForIn() != null; | 1610 return currentNode.asForIn() != null; |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 /** | 1613 /** |
| 1614 * In checked mode, generate type tests for the parameters of the inlined | 1614 * In checked mode, generate type tests for the parameters of the inlined |
| 1615 * function. | 1615 * function. |
| 1616 */ | 1616 */ |
| 1617 void potentiallyCheckInlinedParameterTypes(FunctionElement function) { | 1617 void potentiallyCheckInlinedParameterTypes(FunctionElement function) { |
| 1618 if (!compiler.enableTypeAssertions) return; |
| 1619 |
| 1618 FunctionSignature signature = function.functionSignature; | 1620 FunctionSignature signature = function.functionSignature; |
| 1621 |
| 1622 InterfaceType contextType; |
| 1623 if (function.isSynthesized && function.isGenerativeConstructor()) { |
| 1624 // Synthesized constructors reuse the parameters from the |
| 1625 // [targetConstructor]. In face of generic types, the type variables |
| 1626 // occurring in the parameter types must be substituted by the type |
| 1627 // arguments of the enclosing class. |
| 1628 FunctionElement target = function; |
| 1629 while (target.targetConstructor != null) { |
| 1630 target = target.targetConstructor; |
| 1631 } |
| 1632 if (target != function) { |
| 1633 ClassElement functionClass = function.getEnclosingClass(); |
| 1634 ClassElement targetClass = target.getEnclosingClass(); |
| 1635 contextType = functionClass.thisType.asInstanceOf(targetClass); |
| 1636 } |
| 1637 } |
| 1638 |
| 1619 signature.orderedForEachParameter((ParameterElement parameter) { | 1639 signature.orderedForEachParameter((ParameterElement parameter) { |
| 1620 HInstruction argument = localsHandler.readLocal(parameter); | 1640 HInstruction argument = localsHandler.readLocal(parameter); |
| 1621 potentiallyCheckType(argument, parameter.type); | 1641 DartType parameterType = parameter.type; |
| 1642 if (contextType != null) { |
| 1643 parameterType = parameterType.substByContext(contextType); |
| 1644 } |
| 1645 potentiallyCheckType(argument, parameterType); |
| 1622 }); | 1646 }); |
| 1623 } | 1647 } |
| 1624 | 1648 |
| 1625 /** | 1649 /** |
| 1626 * Documentation wanted -- johnniwinther | 1650 * Documentation wanted -- johnniwinther |
| 1627 * | 1651 * |
| 1628 * Invariant: [constructors] must contain only implementation elements. | 1652 * Invariant: [constructors] must contain only implementation elements. |
| 1629 */ | 1653 */ |
| 1630 void inlineSuperOrRedirect(FunctionElement callee, | 1654 void inlineSuperOrRedirect(FunctionElement callee, |
| 1631 List<HInstruction> compiledArguments, | 1655 List<HInstruction> compiledArguments, |
| (...skipping 4660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6292 DartType unaliased = type.unalias(builder.compiler); | 6316 DartType unaliased = type.unalias(builder.compiler); |
| 6293 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6317 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 6294 unaliased.accept(this, builder); | 6318 unaliased.accept(this, builder); |
| 6295 } | 6319 } |
| 6296 | 6320 |
| 6297 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 6321 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 6298 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); | 6322 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); |
| 6299 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); | 6323 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); |
| 6300 } | 6324 } |
| 6301 } | 6325 } |
| OLD | NEW |