| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
| 8 | 8 |
| 9 class ReturnInfo { | 9 class ReturnInfo { |
| 10 HType returnType; | 10 HType returnType; |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 void addedDynamicSetter(Selector setter, HType type) { | 1106 void addedDynamicSetter(Selector setter, HType type) { |
| 1107 fieldTypes.addedDynamicSetter(setter, type); | 1107 fieldTypes.addedDynamicSetter(setter, type); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 HType optimisticFieldType(Element element) { | 1110 HType optimisticFieldType(Element element) { |
| 1111 return fieldTypes.optimisticFieldType(element); | 1111 return fieldTypes.optimisticFieldType(element); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 /** |
| 1115 * Return the checked mode helper name that will be needed to do a |
| 1116 * type check on [type] at runtime. Note that this method is being |
| 1117 * called both by the resolver with interface types (int, String, |
| 1118 * ...), and by the SSA backend with implementation types (JSInt, |
| 1119 * JSString, ...). |
| 1120 */ |
| 1114 SourceString getCheckedModeHelper(DartType type) { | 1121 SourceString getCheckedModeHelper(DartType type) { |
| 1115 Element element = type.element; | 1122 Element element = type.element; |
| 1116 bool nativeCheck = | 1123 bool nativeCheck = |
| 1117 emitter.nativeEmitter.requiresNativeIsCheck(element); | 1124 emitter.nativeEmitter.requiresNativeIsCheck(element); |
| 1118 if (type.isMalformed) { | 1125 if (type.isMalformed) { |
| 1119 // Check for malformed types first, because the type may be a list type | 1126 // Check for malformed types first, because the type may be a list type |
| 1120 // with a malformed argument type. | 1127 // with a malformed argument type. |
| 1121 return const SourceString('malformedTypeCheck'); | 1128 return const SourceString('malformedTypeCheck'); |
| 1122 } else if (type == compiler.types.voidType) { | 1129 } else if (type == compiler.types.voidType) { |
| 1123 return const SourceString('voidTypeCheck'); | 1130 return const SourceString('voidTypeCheck'); |
| 1124 } else if (element == compiler.stringClass) { | 1131 } else if (element == jsStringClass || element == compiler.stringClass) { |
| 1125 return const SourceString('stringTypeCheck'); | 1132 return const SourceString('stringTypeCheck'); |
| 1126 } else if (element == compiler.doubleClass) { | 1133 } else if (element == jsDoubleClass || element == compiler.doubleClass) { |
| 1127 return const SourceString('doubleTypeCheck'); | 1134 return const SourceString('doubleTypeCheck'); |
| 1128 } else if (element == compiler.numClass) { | 1135 } else if (element == jsNumberClass || element == compiler.numClass) { |
| 1129 return const SourceString('numTypeCheck'); | 1136 return const SourceString('numTypeCheck'); |
| 1130 } else if (element == compiler.boolClass) { | 1137 } else if (element == jsBoolClass || element == compiler.boolClass) { |
| 1131 return const SourceString('boolTypeCheck'); | 1138 return const SourceString('boolTypeCheck'); |
| 1132 } else if (element == compiler.functionClass) { | 1139 } else if (element == jsFunctionClass |
| 1140 || element == compiler.functionClass) { |
| 1133 return const SourceString('functionTypeCheck'); | 1141 return const SourceString('functionTypeCheck'); |
| 1134 } else if (element == compiler.intClass) { | 1142 } else if (element == jsIntClass || element == compiler.intClass) { |
| 1135 return const SourceString('intTypeCheck'); | 1143 return const SourceString('intTypeCheck'); |
| 1136 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { | 1144 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { |
| 1137 return nativeCheck | 1145 return nativeCheck |
| 1138 ? const SourceString('numberOrStringSuperNativeTypeCheck') | 1146 ? const SourceString('numberOrStringSuperNativeTypeCheck') |
| 1139 : const SourceString('numberOrStringSuperTypeCheck'); | 1147 : const SourceString('numberOrStringSuperTypeCheck'); |
| 1140 } else if (Elements.isStringOnlySupertype(element, compiler)) { | 1148 } else if (Elements.isStringOnlySupertype(element, compiler)) { |
| 1141 return nativeCheck | 1149 return nativeCheck |
| 1142 ? const SourceString('stringSuperNativeTypeCheck') | 1150 ? const SourceString('stringSuperNativeTypeCheck') |
| 1143 : const SourceString('stringSuperTypeCheck'); | 1151 : const SourceString('stringSuperTypeCheck'); |
| 1144 } else if (identical(element, compiler.listClass)) { | 1152 } else if (element == compiler.listClass || element == jsArrayClass) { |
| 1145 return const SourceString('listTypeCheck'); | 1153 return const SourceString('listTypeCheck'); |
| 1146 } else { | 1154 } else { |
| 1147 if (Elements.isListSupertype(element, compiler)) { | 1155 if (Elements.isListSupertype(element, compiler)) { |
| 1148 return nativeCheck | 1156 return nativeCheck |
| 1149 ? const SourceString('listSuperNativeTypeCheck') | 1157 ? const SourceString('listSuperNativeTypeCheck') |
| 1150 : const SourceString('listSuperTypeCheck'); | 1158 : const SourceString('listSuperTypeCheck'); |
| 1151 } else { | 1159 } else { |
| 1152 return nativeCheck | 1160 return nativeCheck |
| 1153 ? const SourceString('callTypeCheck') | 1161 ? const SourceString('callTypeCheck') |
| 1154 : const SourceString('propertyTypeCheck'); | 1162 : const SourceString('propertyTypeCheck'); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 } | 1210 } |
| 1203 | 1211 |
| 1204 Element getSetRuntimeTypeInfo() { | 1212 Element getSetRuntimeTypeInfo() { |
| 1205 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); | 1213 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); |
| 1206 } | 1214 } |
| 1207 | 1215 |
| 1208 Element getGetRuntimeTypeInfo() { | 1216 Element getGetRuntimeTypeInfo() { |
| 1209 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); | 1217 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); |
| 1210 } | 1218 } |
| 1211 } | 1219 } |
| OLD | NEW |