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