Chromium Code Reviews| Index: pkg/kernel/lib/transformations/mixin_full_resolution.dart |
| diff --git a/pkg/kernel/lib/transformations/mixin_full_resolution.dart b/pkg/kernel/lib/transformations/mixin_full_resolution.dart |
| index d4c03fc9c8b41343e63357f61e66e3de7bee012a..9117cd3cdc6014c96c9230bf9414317c8f072d5e 100644 |
| --- a/pkg/kernel/lib/transformations/mixin_full_resolution.dart |
| +++ b/pkg/kernel/lib/transformations/mixin_full_resolution.dart |
| @@ -7,10 +7,11 @@ import '../ast.dart'; |
| import '../class_hierarchy.dart'; |
| import '../clone.dart'; |
| import '../core_types.dart'; |
| +import '../target/targets.dart' show NoneTarget, Target; |
| import '../type_algebra.dart'; |
| Program transformProgram(Program program) { |
| - new MixinFullResolution().transform(program); |
| + new MixinFullResolution(new NoneTarget(null)).transform(program); |
| return program; |
| } |
| @@ -21,9 +22,13 @@ Program transformProgram(Program program) { |
| /// Super calls (as well as super initializer invocations) are also resolved |
| /// to their targets in this pass. |
| class MixinFullResolution { |
| + final Target vmTarget; |
|
Johnni Winther
2017/05/22 12:33:12
Rename [vmTarget] to [target]? (I assume MixinFull
ahe
2017/05/22 13:30:59
I've changed it to targetInfo. The word target is
|
| + |
| ClassHierarchy hierarchy; |
| CoreTypes coreTypes; |
| + MixinFullResolution(this.vmTarget); |
| + |
| void transform(Program program) { |
| var transformedClasses = new Set<Class>(); |
| @@ -52,14 +57,14 @@ class MixinFullResolution { |
| for (var procedure in class_.procedures) { |
| if (procedure.containsSuperCalls) { |
| new SuperCallResolutionTransformer( |
| - hierarchy, coreTypes, class_.superclass) |
| + hierarchy, coreTypes, class_.superclass, vmTarget) |
| .visit(procedure); |
| } |
| } |
| for (var constructor in class_.constructors) { |
| if (constructor.containsSuperCalls) { |
| new SuperCallResolutionTransformer( |
| - hierarchy, coreTypes, class_.superclass) |
| + hierarchy, coreTypes, class_.superclass, vmTarget) |
| .visit(constructor); |
| } |
| if (hasTransformedSuperclass && constructor.initializers.length > 0) { |
| @@ -176,11 +181,11 @@ class SuperCallResolutionTransformer extends Transformer { |
| final ClassHierarchy hierarchy; |
| final CoreTypes coreTypes; |
| final Class lookupClass; |
| + final Target vmTarget; |
| Constructor _invocationMirrorConstructor; // cached |
| - Procedure _listFrom; // cached |
| SuperCallResolutionTransformer( |
| - this.hierarchy, this.coreTypes, this.lookupClass); |
| + this.hierarchy, this.coreTypes, this.lookupClass, this.vmTarget); |
| TreeNode visit(TreeNode node) => node.accept(this); |
| @@ -278,55 +283,8 @@ class SuperCallResolutionTransformer extends Transformer { |
| _invocationMirrorConstructor = clazz.constructors[0]; |
| } |
| - // The _InvocationMirror constructor takes the following arguments: |
| - // * Method name (a string). |
| - // * An arguments descriptor - a list consisting of: |
| - // - length of passed type argument vector, 0 if none passed. |
| - // - number of arguments (including receiver). |
| - // - number of positional arguments (including receiver). |
| - // - pairs (2 entries in the list) of |
| - // * named arguments name. |
| - // * index of named argument in arguments list. |
| - // * A list of arguments, where the first ones are the positional arguments. |
| - // * Whether it's a super invocation or not. |
| - |
| - int typeArgsLen = 0; // TODO(regis): Type arguments of generic function. |
| - int numPositionalArguments = callArguments.positional.length + 1; |
| - int numArguments = numPositionalArguments + callArguments.named.length; |
| - List<Expression> argumentsDescriptor = [ |
| - new IntLiteral(typeArgsLen), |
| - new IntLiteral(numArguments), |
| - new IntLiteral(numPositionalArguments) |
| - ]; |
| - List<Expression> arguments = []; |
| - arguments.add(receiver); |
| - for (Expression pos in callArguments.positional) { |
| - arguments.add(pos); |
| - } |
| - for (NamedExpression named in callArguments.named) { |
| - argumentsDescriptor.add(new StringLiteral(named.name)); |
| - argumentsDescriptor.add(new IntLiteral(arguments.length)); |
| - arguments.add(named.value); |
| - } |
| - |
| - return new ConstructorInvocation( |
| - _invocationMirrorConstructor, |
| - new Arguments([ |
| - new StringLiteral(methodName), |
| - _fixedLengthList(argumentsDescriptor), |
| - _fixedLengthList(arguments), |
| - new BoolLiteral(isSuperInvocation) |
| - ])); |
| - } |
| - |
| - /// Create a fixed length list containing given expressions. |
| - Expression _fixedLengthList(List<Expression> list) { |
| - _listFrom ??= coreTypes.getMember('dart:core', 'List', 'from'); |
| - return new StaticInvocation( |
| - _listFrom, |
| - new Arguments([new ListLiteral(list)], |
| - named: [new NamedExpression("growable", new BoolLiteral(false))], |
| - types: [const DynamicType()])); |
| + return vmTarget.instantiateInvocation(_invocationMirrorConstructor, |
| + receiver, methodName, callArguments, -1, isSuperInvocation); |
| } |
| /// Check that a call to the targetFunction is legal given the arguments. |