OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import '../common/codegen.dart' show CodegenRegistry; | 5 import '../common/codegen.dart' show CodegenRegistry; |
6 import '../compiler.dart'; | 6 import '../compiler.dart'; |
7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
8 import '../elements/entities.dart' show Entity, Local; | 8 import '../elements/entities.dart' show Entity, Local; |
9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
10 import '../js_backend/js_backend.dart'; | 10 import '../js_backend/js_backend.dart'; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 void visitVoidType(ResolutionVoidType type, GraphBuilder builder) { | 255 void visitVoidType(ResolutionVoidType type, GraphBuilder builder) { |
256 ClassElement cls = builder.backend.helpers.VoidRuntimeType; | 256 ClassElement cls = builder.backend.helpers.VoidRuntimeType; |
257 builder.push(new HVoidType(type, new TypeMask.exact(cls, closedWorld))); | 257 builder.push(new HVoidType(type, new TypeMask.exact(cls, closedWorld))); |
258 } | 258 } |
259 | 259 |
260 void visitTypeVariableType( | 260 void visitTypeVariableType( |
261 ResolutionTypeVariableType type, GraphBuilder builder) { | 261 ResolutionTypeVariableType type, GraphBuilder builder) { |
262 ClassElement cls = builder.backend.helpers.RuntimeType; | 262 ClassElement cls = builder.backend.helpers.RuntimeType; |
263 TypeMask instructionType = new TypeMask.subclass(cls, closedWorld); | 263 TypeMask instructionType = new TypeMask.subclass(cls, closedWorld); |
264 | |
265 // TODO(floitsch): this hack maps type variables of generic function | |
266 // typedefs to dynamic. For example: `typedef F = Function<T>(T)`. | |
267 if (type is MethodTypeVariableType) { | |
268 visitDynamicType(const ResolutionDynamicType(), builder); | |
269 return; | |
270 } | |
271 | |
272 if (!builder.sourceElement.enclosingElement.isClosure && | 264 if (!builder.sourceElement.enclosingElement.isClosure && |
273 builder.sourceElement.isInstanceMember) { | 265 builder.sourceElement.isInstanceMember) { |
274 HInstruction receiver = builder.localsHandler.readThis(); | 266 HInstruction receiver = builder.localsHandler.readThis(); |
275 builder.push(new HReadTypeVariable(type, receiver, instructionType)); | 267 builder.push(new HReadTypeVariable(type, receiver, instructionType)); |
276 } else { | 268 } else { |
277 builder.push(new HReadTypeVariable.noReceiver( | 269 builder.push(new HReadTypeVariable.noReceiver( |
278 type, | 270 type, |
279 builder.typeBuilder | 271 builder.typeBuilder |
280 .addTypeVariableReference(type, builder.sourceElement), | 272 .addTypeVariableReference(type, builder.sourceElement), |
281 instructionType)); | 273 instructionType)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type'; | 329 if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type'; |
338 unaliased.accept(this, builder); | 330 unaliased.accept(this, builder); |
339 } | 331 } |
340 | 332 |
341 void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) { | 333 void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) { |
342 JavaScriptBackend backend = builder.compiler.backend; | 334 JavaScriptBackend backend = builder.compiler.backend; |
343 ClassElement cls = backend.helpers.DynamicRuntimeType; | 335 ClassElement cls = backend.helpers.DynamicRuntimeType; |
344 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); | 336 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); |
345 } | 337 } |
346 } | 338 } |
OLD | NEW |