| 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 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
| 9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| 11 import '../dart_types.dart'; | 11 import '../dart_types.dart'; |
| 12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
| 13 import '../js_backend/js_backend.dart'; | 13 import '../js_backend/js_backend.dart'; |
| 14 import '../kernel/kernel.dart'; | 14 import '../kernel/kernel.dart'; |
| 15 import '../kernel/kernel_debug.dart'; |
| 15 import '../resolution/tree_elements.dart'; | 16 import '../resolution/tree_elements.dart'; |
| 16 import '../tree/tree.dart' as ast; | 17 import '../tree/tree.dart' as ast; |
| 17 import '../types/masks.dart'; | 18 import '../types/masks.dart'; |
| 18 import '../types/types.dart'; | 19 import '../types/types.dart'; |
| 19 import '../universe/call_structure.dart'; | 20 import '../universe/call_structure.dart'; |
| 20 import '../universe/selector.dart'; | 21 import '../universe/selector.dart'; |
| 21 import '../universe/side_effects.dart'; | 22 import '../universe/side_effects.dart'; |
| 22 import '../world.dart'; | 23 import '../world.dart'; |
| 23 import 'locals_handler.dart'; | 24 import 'locals_handler.dart'; |
| 24 import 'types.dart'; | 25 import 'types.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 54 for (LocalFunctionElement localFunction in kernel.localFunctions.keys) { | 55 for (LocalFunctionElement localFunction in kernel.localFunctions.keys) { |
| 55 _nodeToElement[kernel.localFunctions[localFunction]] = localFunction; | 56 _nodeToElement[kernel.localFunctions[localFunction]] = localFunction; |
| 56 } | 57 } |
| 57 _typeConverter = new DartTypeConverter(this); | 58 _typeConverter = new DartTypeConverter(this); |
| 58 } | 59 } |
| 59 | 60 |
| 60 Compiler get _compiler => _backend.compiler; | 61 Compiler get _compiler => _backend.compiler; |
| 61 TreeElements get elements => _resolvedAst.elements; | 62 TreeElements get elements => _resolvedAst.elements; |
| 62 GlobalTypeInferenceResults get _inferenceResults => | 63 GlobalTypeInferenceResults get _inferenceResults => |
| 63 _compiler.globalInference.results; | 64 _compiler.globalInference.results; |
| 65 DiagnosticReporter get reporter => _compiler.reporter; |
| 64 | 66 |
| 65 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) { | 67 ConstantValue getConstantForSymbol(ir.SymbolLiteral node) { |
| 66 ast.Node astNode = getNode(node); | 68 ast.Node astNode = getNode(node); |
| 67 ConstantValue constantValue = _backend.constants | 69 ConstantValue constantValue = _backend.constants |
| 68 .getConstantValueForNode(astNode, _resolvedAst.elements); | 70 .getConstantValueForNode(astNode, _resolvedAst.elements); |
| 69 assert(invariant(astNode, constantValue != null, | 71 assert(invariant(astNode, constantValue != null, |
| 70 message: 'No constant computed for $node')); | 72 message: 'No constant computed for $node')); |
| 71 return constantValue; | 73 return constantValue; |
| 72 } | 74 } |
| 73 | 75 |
| 74 Element getElement(ir.Node node) { | 76 Element getElement(ir.Node node) { |
| 75 Element result = _nodeToElement[node]; | 77 Element result = _nodeToElement[node]; |
| 76 assert(result != null); | 78 assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null, |
| 79 message: "No element found for $node.")); |
| 77 return result; | 80 return result; |
| 78 } | 81 } |
| 79 | 82 |
| 80 ast.Node getNode(ir.Node node) { | 83 ast.Node getNode(ir.Node node) { |
| 81 ast.Node result = _nodeToAst[node]; | 84 ast.Node result = _nodeToAst[node]; |
| 82 assert(result != null); | 85 assert(result != null); |
| 83 return result; | 86 return result; |
| 84 } | 87 } |
| 85 | 88 |
| 86 Local getLocal(ir.VariableDeclaration variable) { | 89 Local getLocal(ir.VariableDeclaration variable) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 291 |
| 289 DartType visitType(ir.DartType type) => type.accept(this); | 292 DartType visitType(ir.DartType type) => type.accept(this); |
| 290 | 293 |
| 291 List<DartType> visitTypes(List<ir.DartType> types) { | 294 List<DartType> visitTypes(List<ir.DartType> types) { |
| 292 return new List.generate( | 295 return new List.generate( |
| 293 types.length, (int index) => types[index].accept(this)); | 296 types.length, (int index) => types[index].accept(this)); |
| 294 } | 297 } |
| 295 | 298 |
| 296 @override | 299 @override |
| 297 DartType visitTypeParameterType(ir.TypeParameterType node) { | 300 DartType visitTypeParameterType(ir.TypeParameterType node) { |
| 298 return new TypeVariableType(astAdapter.getElement(node.parameter)); | 301 if (node.parameter.parent is ir.Class) { |
| 302 ir.Class cls = node.parameter.parent; |
| 303 int index = cls.typeParameters.indexOf(node.parameter); |
| 304 ClassElement classElement = astAdapter.getElement(cls); |
| 305 return classElement.typeVariables[index]; |
| 306 } else if (node.parameter.parent is ir.FunctionNode) { |
| 307 ir.FunctionNode func = node.parameter.parent; |
| 308 int index = func.typeParameters.indexOf(node.parameter); |
| 309 ConstructorElement constructorElement = astAdapter.getElement(func); |
| 310 ClassElement classElement = constructorElement.enclosingClass; |
| 311 return classElement.typeVariables[index]; |
| 312 } |
| 313 throw new UnsupportedError('Unsupported type parameter type node $node.'); |
| 299 } | 314 } |
| 300 | 315 |
| 301 @override | 316 @override |
| 302 DartType visitFunctionType(ir.FunctionType node) { | 317 DartType visitFunctionType(ir.FunctionType node) { |
| 303 return new FunctionType.synthesized( | 318 return new FunctionType.synthesized( |
| 304 visitType(node.returnType), | 319 visitType(node.returnType), |
| 305 visitTypes(node.positionalParameters | 320 visitTypes(node.positionalParameters |
| 306 .take(node.requiredParameterCount) | 321 .take(node.requiredParameterCount) |
| 307 .toList()), | 322 .toList()), |
| 308 visitTypes(node.positionalParameters | 323 visitTypes(node.positionalParameters |
| (...skipping 17 matching lines...) Expand all Loading... |
| 326 @override | 341 @override |
| 327 DartType visitDynamicType(ir.DynamicType node) { | 342 DartType visitDynamicType(ir.DynamicType node) { |
| 328 return const DynamicType(); | 343 return const DynamicType(); |
| 329 } | 344 } |
| 330 | 345 |
| 331 @override | 346 @override |
| 332 DartType visitInvalidType(ir.InvalidType node) { | 347 DartType visitInvalidType(ir.InvalidType node) { |
| 333 throw new UnimplementedError("Invalid types not currently supported"); | 348 throw new UnimplementedError("Invalid types not currently supported"); |
| 334 } | 349 } |
| 335 } | 350 } |
| OLD | NEW |