| 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 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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1085     params.forEachParameter((Element element) { | 1085     params.forEachParameter((Element element) { | 
| 1086       HInstruction newParameter = potentiallyCheckType( | 1086       HInstruction newParameter = potentiallyCheckType( | 
| 1087           localsHandler.directLocals[element], element); | 1087           localsHandler.directLocals[element], element); | 
| 1088       localsHandler.directLocals[element] = newParameter; | 1088       localsHandler.directLocals[element] = newParameter; | 
| 1089     }); | 1089     }); | 
| 1090   } | 1090   } | 
| 1091 | 1091 | 
| 1092   HInstruction potentiallyCheckType(HInstruction original, | 1092   HInstruction potentiallyCheckType(HInstruction original, | 
| 1093                                     Element sourceElement) { | 1093                                     Element sourceElement) { | 
| 1094     if (!compiler.enableTypeAssertions) return original; | 1094     if (!compiler.enableTypeAssertions) return original; | 
|  | 1095     return convertType(original, sourceElement, | 
|  | 1096                        HTypeConversion.CHECKED_MODE_CHECK); | 
|  | 1097   } | 
| 1095 | 1098 | 
|  | 1099   HInstruction convertType(HInstruction original, | 
|  | 1100                            Element sourceElement, | 
|  | 1101                            int kind) { | 
| 1096     Type type = sourceElement.computeType(compiler); | 1102     Type type = sourceElement.computeType(compiler); | 
| 1097     if (type === null) return original; | 1103     if (type === null) return original; | 
| 1098     if (type.element === compiler.dynamicClass) return original; | 1104     // Casts affect static type warnings. They can't be omitted yet. | 
| 1099     if (type.element === compiler.objectClass) return original; | 1105     if (kind != HTypeConversion.CAST_TYPE_CHECK) { | 
|  | 1106       if (type.element === compiler.dynamicClass) return original; | 
|  | 1107       if (type.element === compiler.objectClass) return original; | 
|  | 1108     } | 
| 1100 | 1109 | 
| 1101     HType convertedType = new HType.fromBoundedType(type, compiler, true); | 1110     // If the original can't be null, type conversion also can't produce null. | 
|  | 1111     bool canBeNull = original.guaranteedType.canBeNull(); | 
|  | 1112     HType convertedType = | 
|  | 1113         new HType.fromBoundedType(type, compiler, canBeNull); | 
| 1102 | 1114 | 
| 1103     // No need to convert if we know the instruction has | 1115     // No need to convert if we know the instruction has | 
| 1104     // [convertedType] as a bound. | 1116     // [convertedType] as a bound. | 
| 1105     if (original.guaranteedType == convertedType) { | 1117     if (original.guaranteedType == convertedType) { | 
| 1106       return original; | 1118       return original; | 
| 1107     } | 1119     } | 
| 1108 | 1120 | 
| 1109     HInstruction instruction = | 1121     HInstruction instruction = | 
| 1110         new HTypeConversion.checkedModeCheck(convertedType, original); | 1122         new HTypeConversion(convertedType, original, kind); | 
| 1111     add(instruction); | 1123     add(instruction); | 
| 1112     return instruction; | 1124     return instruction; | 
| 1113   } | 1125   } | 
| 1114 | 1126 | 
| 1115   HGraph closeFunction() { | 1127   HGraph closeFunction() { | 
| 1116     // TODO(kasperl): Make this goto an implicit return. | 1128     // TODO(kasperl): Make this goto an implicit return. | 
| 1117     if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); | 1129     if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); | 
| 1118     graph.finalize(); | 1130     graph.finalize(); | 
| 1119     return graph; | 1131     return graph; | 
| 1120   } | 1132   } | 
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1971           instruction = new HIs.withTypeInfoCall(type, expression, typeInfo); | 1983           instruction = new HIs.withTypeInfoCall(type, expression, typeInfo); | 
| 1972         } else { | 1984         } else { | 
| 1973           instruction = new HIs(type, expression); | 1985           instruction = new HIs(type, expression); | 
| 1974         } | 1986         } | 
| 1975         if (isNot) { | 1987         if (isNot) { | 
| 1976           add(instruction); | 1988           add(instruction); | 
| 1977           instruction = new HNot(instruction); | 1989           instruction = new HNot(instruction); | 
| 1978         } | 1990         } | 
| 1979         push(instruction); | 1991         push(instruction); | 
| 1980       } | 1992       } | 
|  | 1993     } else if (const SourceString("as") == op.source) { | 
|  | 1994       visit(node.receiver); | 
|  | 1995       HInstruction expression = pop(); | 
|  | 1996       Node argument = node.arguments.head; | 
|  | 1997       TypeAnnotation typeAnnotation = argument.asTypeAnnotation(); | 
|  | 1998       Type type = elements.getType(typeAnnotation); | 
|  | 1999       HInstruction converted = convertType(expression, type.element, | 
|  | 2000                                            HTypeConversion.CAST_TYPE_CHECK); | 
|  | 2001       stack.add(converted); | 
| 1981     } else { | 2002     } else { | 
| 1982       visit(node.receiver); | 2003       visit(node.receiver); | 
| 1983       visit(node.argumentsNode); | 2004       visit(node.argumentsNode); | 
| 1984       var right = pop(); | 2005       var right = pop(); | 
| 1985       var left = pop(); | 2006       var left = pop(); | 
| 1986       visitBinary(left, op, right); | 2007       visitBinary(left, op, right); | 
| 1987     } | 2008     } | 
| 1988   } | 2009   } | 
| 1989 | 2010 | 
| 1990   void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { | 2011   void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { | 
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3464   void visitNodeList(NodeList node) { | 3485   void visitNodeList(NodeList node) { | 
| 3465      node.visitChildren(this); | 3486      node.visitChildren(this); | 
| 3466   } | 3487   } | 
| 3467 | 3488 | 
| 3468   HInstruction concat(HInstruction left, HInstruction right) { | 3489   HInstruction concat(HInstruction left, HInstruction right) { | 
| 3469     HInstruction instruction = new HStringConcat(left, right, diagnosticNode); | 3490     HInstruction instruction = new HStringConcat(left, right, diagnosticNode); | 
| 3470     builder.add(instruction); | 3491     builder.add(instruction); | 
| 3471     return instruction; | 3492     return instruction; | 
| 3472   } | 3493   } | 
| 3473 } | 3494 } | 
| OLD | NEW | 
|---|