| Index: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
|
| diff --git a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
|
| index 719b3464011e4c4afa886e37edc269fc1b4b797d..8682d351d131b39628b3b02079cbcc49e6697177 100644
|
| --- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
|
| +++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
|
| @@ -4,9 +4,10 @@
|
|
|
| import 'package:kernel/ast.dart' as ir;
|
|
|
| +import '../common.dart';
|
| import '../compiler.dart';
|
| import '../constants/values.dart';
|
| -import '../diagnostics/invariant.dart';
|
| +import '../dart_types.dart';
|
| import '../elements/elements.dart';
|
| import '../js_backend/js_backend.dart';
|
| import '../resolution/tree_elements.dart';
|
| @@ -26,6 +27,7 @@ class KernelAstAdapter {
|
| final ResolvedAst _resolvedAst;
|
| final Map<ir.Node, ast.Node> _nodeToAst;
|
| final Map<ir.Node, Element> _nodeToElement;
|
| + DartTypeConverter _typeConverter;
|
|
|
| KernelAstAdapter(
|
| this._backend,
|
| @@ -33,13 +35,18 @@ class KernelAstAdapter {
|
| this._nodeToAst,
|
| this._nodeToElement,
|
| Map<FunctionElement, ir.Member> functions,
|
| + Map<ClassElement, ir.Class> classes,
|
| Map<LibraryElement, ir.Library> libraries) {
|
| for (FunctionElement functionElement in functions.keys) {
|
| _nodeToElement[functions[functionElement]] = functionElement;
|
| }
|
| + for (ClassElement classElement in classes.keys) {
|
| + _nodeToElement[classes[classElement]] = classElement;
|
| + }
|
| for (LibraryElement libraryElement in libraries.keys) {
|
| _nodeToElement[libraries[libraryElement]] = libraryElement;
|
| }
|
| + _typeConverter = new DartTypeConverter(this);
|
| }
|
|
|
| Compiler get _compiler => _backend.compiler;
|
| @@ -80,6 +87,12 @@ class KernelAstAdapter {
|
| return _compiler.world.getSideEffectsOfElement(getElement(node));
|
| }
|
|
|
| + CallStructure getCallStructure(ir.Arguments arguments) {
|
| + int argumentCount = arguments.positional.length + arguments.named.length;
|
| + List<String> namedArguments = arguments.named.map((e) => e.name).toList();
|
| + return new CallStructure(argumentCount, namedArguments);
|
| + }
|
| +
|
| // TODO(het): Create the selector directly from the invocation
|
| Selector getSelector(ir.MethodInvocation invocation) {
|
| SelectorKind kind = Elements.isOperatorName(invocation.name.name)
|
| @@ -89,13 +102,7 @@ class KernelAstAdapter {
|
| ir.Name irName = invocation.name;
|
| Name name = new Name(
|
| irName.name, irName.isPrivate ? getElement(irName.library) : null);
|
| -
|
| - int argumentCount = invocation.arguments.positional.length +
|
| - invocation.arguments.named.length;
|
| - List<String> namedArguments =
|
| - invocation.arguments.named.map((e) => e.name).toList();
|
| - CallStructure callStructure =
|
| - new CallStructure(argumentCount, namedArguments);
|
| + CallStructure callStructure = getCallStructure(invocation.arguments);
|
|
|
| return new Selector(kind, name, callStructure);
|
| }
|
| @@ -113,4 +120,50 @@ class KernelAstAdapter {
|
| bool isIntercepted(ir.MethodInvocation invocation) {
|
| return _backend.isInterceptedSelector(getSelector(invocation));
|
| }
|
| +
|
| + DartType getDartType(ir.DartType type) {
|
| + return type.accept(_typeConverter);
|
| + }
|
| +}
|
| +
|
| +class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
|
| + final KernelAstAdapter astAdapter;
|
| +
|
| + DartTypeConverter(this.astAdapter);
|
| +
|
| + List<DartType> visitTypes(List<ir.DartType> types) {
|
| + return new List.generate(
|
| + types.length, (int index) => types[index].accept(this));
|
| + }
|
| +
|
| + @override
|
| + DartType visitTypeParameterType(ir.TypeParameterType node) {
|
| + return new TypeVariableType(astAdapter.getElement(node.parameter));
|
| + }
|
| +
|
| + @override
|
| + DartType visitFunctionType(ir.FunctionType node) {
|
| + throw new UnimplementedError("Function types not currently supported");
|
| + }
|
| +
|
| + @override
|
| + DartType visitInterfaceType(ir.InterfaceType node) {
|
| + ClassElement cls = astAdapter.getElement(node.classNode);
|
| + return new InterfaceType(cls, visitTypes(node.typeArguments));
|
| + }
|
| +
|
| + @override
|
| + DartType visitVoidType(ir.VoidType node) {
|
| + return const VoidType();
|
| + }
|
| +
|
| + @override
|
| + DartType visitDynamicType(ir.DynamicType node) {
|
| + return const DynamicType();
|
| + }
|
| +
|
| + @override
|
| + DartType visitInvalidType(ir.InvalidType node) {
|
| + throw new UnimplementedError("Invalid types not currently supported");
|
| + }
|
| }
|
|
|