OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.new_js_emitter.emitter; | 5 library dart2js.new_js_emitter.emitter; |
6 | 6 |
7 import 'package:_internal/compiler/js_lib/shared/embedded_names.dart' show | 7 import 'package:_internal/compiler/js_lib/shared/embedded_names.dart' show |
8 JsBuiltin, | 8 JsBuiltin, |
9 METADATA, | 9 METADATA, |
10 TYPES; | 10 TYPES; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return js.js.expressionTemplateYielding( | 140 return js.js.expressionTemplateYielding( |
141 typeAccess(_compiler.objectClass)); | 141 typeAccess(_compiler.objectClass)); |
142 | 142 |
143 case JsBuiltin.classNameFromIsCheckProperty: | 143 case JsBuiltin.classNameFromIsCheckProperty: |
144 int isPrefixLength = namer.operatorIsPrefix.length; | 144 int isPrefixLength = namer.operatorIsPrefix.length; |
145 return js.js.expressionTemplateFor('#.substring($isPrefixLength)'); | 145 return js.js.expressionTemplateFor('#.substring($isPrefixLength)'); |
146 | 146 |
147 case JsBuiltin.isFunctionType: | 147 case JsBuiltin.isFunctionType: |
148 return _backend.rti.representationGenerator.templateForIsFunctionType; | 148 return _backend.rti.representationGenerator.templateForIsFunctionType; |
149 | 149 |
150 case JsBuiltin.isFunctionTypeLiteral: | |
151 String functionClassName = | |
152 _backend.namer.runtimeTypeName(_compiler.functionClass); | |
153 | |
154 return js.js.expressionTemplateFor( | |
155 '#.$typeNameProperty === "$functionClassName"'); | |
156 | |
157 case JsBuiltin.typeName: | 150 case JsBuiltin.typeName: |
158 return js.js.expressionTemplateFor("#.$typeNameProperty"); | 151 return js.js.expressionTemplateFor("#.$typeNameProperty"); |
159 | 152 |
160 case JsBuiltin.rawRuntimeType: | 153 case JsBuiltin.rawRuntimeType: |
161 return js.js.expressionTemplateFor("#.constructor"); | 154 return js.js.expressionTemplateFor("#.constructor"); |
162 | 155 |
163 case JsBuiltin.createFunctionType: | 156 case JsBuiltin.createFunctionType: |
164 return _backend.rti.representationGenerator | 157 return _backend.rti.representationGenerator |
165 .templateForCreateFunctionType; | 158 .templateForCreateFunctionType; |
166 | 159 |
167 case JsBuiltin.isSubtype: | 160 case JsBuiltin.isSubtype: |
168 // TODO(floitsch): move this closer to where is-check properties are | 161 // TODO(floitsch): move this closer to where is-check properties are |
169 // built. | 162 // built. |
170 String isPrefix = namer.operatorIsPrefix; | 163 String isPrefix = namer.operatorIsPrefix; |
171 return js.js.expressionTemplateFor("('$isPrefix' + #) in #.prototype"); | 164 return js.js.expressionTemplateFor("('$isPrefix' + #) in #.prototype"); |
172 | 165 |
| 166 case JsBuiltin.isFunctionTypeRti: |
| 167 String functionClassName = |
| 168 _backend.namer.runtimeTypeName(_compiler.functionClass); |
| 169 return js.js.expressionTemplateFor( |
| 170 '#.$typeNameProperty === "$functionClassName"'); |
| 171 |
| 172 case JsBuiltin.isNullTypeRti: |
| 173 String nullClassName = |
| 174 _backend.namer.runtimeTypeName(_compiler.nullClass); |
| 175 return js.js.expressionTemplateFor( |
| 176 '#.$typeNameProperty === "$nullClassName"'); |
| 177 |
| 178 case JsBuiltin.isDartObjectTypeRti: |
| 179 String dartObjectClassName = |
| 180 _backend.namer.runtimeTypeName(_compiler.objectClass); |
| 181 return js.js.expressionTemplateFor( |
| 182 '#.$typeNameProperty === "$dartObjectClassName"'); |
| 183 |
173 case JsBuiltin.getMetadata: | 184 case JsBuiltin.getMetadata: |
174 return _emitter.templateForReadMetadata; | 185 return _emitter.templateForReadMetadata; |
175 | 186 |
176 case JsBuiltin.getType: | 187 case JsBuiltin.getType: |
177 return _emitter.templateForReadType; | 188 return _emitter.templateForReadType; |
178 | 189 |
179 default: | 190 default: |
180 _compiler.internalError(NO_LOCATION_SPANNABLE, | 191 _compiler.internalError(NO_LOCATION_SPANNABLE, |
181 "Unhandled Builtin: $builtin"); | 192 "Unhandled Builtin: $builtin"); |
182 return null; | 193 return null; |
183 } | 194 } |
184 } | 195 } |
185 | 196 |
186 @override | 197 @override |
187 void invalidateCaches() { | 198 void invalidateCaches() { |
188 } | 199 } |
189 } | 200 } |
OLD | NEW |