| Index: pkg/compiler/lib/src/constants/constant_constructors.dart
|
| diff --git a/pkg/compiler/lib/src/constants/constant_constructors.dart b/pkg/compiler/lib/src/constants/constant_constructors.dart
|
| index 4cc77b3c1c40f00c1e4a04ec97d9908447fc043b..c389eefef3426ac639fc17bf2590b34ffdc32db9 100644
|
| --- a/pkg/compiler/lib/src/constants/constant_constructors.dart
|
| +++ b/pkg/compiler/lib/src/constants/constant_constructors.dart
|
| @@ -11,14 +11,11 @@ import '../dart_types.dart';
|
| import '../elements/elements.dart';
|
| import '../resolution/operators.dart';
|
| import '../resolution/semantic_visitor.dart';
|
| -import '../resolution/send_resolver.dart' show
|
| - DeclarationResolverMixin;
|
| +import '../resolution/send_resolver.dart' show DeclarationResolverMixin;
|
| import '../resolution/send_structure.dart';
|
| -import '../resolution/tree_elements.dart' show
|
| - TreeElements;
|
| +import '../resolution/tree_elements.dart' show TreeElements;
|
| import '../tree/tree.dart';
|
| -import '../universe/call_structure.dart' show
|
| - CallStructure;
|
| +import '../universe/call_structure.dart' show CallStructure;
|
|
|
| import 'constructors.dart';
|
| import 'expressions.dart';
|
| @@ -30,32 +27,32 @@ ConstantConstructor computeConstantConstructor(ResolvedAst resolvedAst) {
|
| }
|
|
|
| class ConstantConstructorComputer extends SemanticVisitor
|
| - with SemanticDeclarationResolvedMixin,
|
| - DeclarationResolverMixin,
|
| - GetBulkMixin,
|
| - SetBulkMixin,
|
| - ErrorBulkMixin,
|
| - InvokeBulkMixin,
|
| - IndexSetBulkMixin,
|
| - CompoundBulkMixin,
|
| - SetIfNullBulkMixin,
|
| - UnaryBulkMixin,
|
| - BaseBulkMixin,
|
| - BinaryBulkMixin,
|
| - PrefixBulkMixin,
|
| - PostfixBulkMixin,
|
| - NewBulkMixin,
|
| - InitializerBulkMixin,
|
| - FunctionBulkMixin,
|
| - VariableBulkMixin
|
| + with
|
| + SemanticDeclarationResolvedMixin,
|
| + DeclarationResolverMixin,
|
| + GetBulkMixin,
|
| + SetBulkMixin,
|
| + ErrorBulkMixin,
|
| + InvokeBulkMixin,
|
| + IndexSetBulkMixin,
|
| + CompoundBulkMixin,
|
| + SetIfNullBulkMixin,
|
| + UnaryBulkMixin,
|
| + BaseBulkMixin,
|
| + BinaryBulkMixin,
|
| + PrefixBulkMixin,
|
| + PostfixBulkMixin,
|
| + NewBulkMixin,
|
| + InitializerBulkMixin,
|
| + FunctionBulkMixin,
|
| + VariableBulkMixin
|
| implements SemanticDeclarationVisitor, SemanticSendVisitor {
|
| final Map<FieldElement, ConstantExpression> fieldMap =
|
| <FieldElement, ConstantExpression>{};
|
| - final Map<dynamic/*int|String*/, ConstantExpression> defaultValues =
|
| - <dynamic/*int|String*/, ConstantExpression>{};
|
| + final Map<dynamic /*int|String*/, ConstantExpression> defaultValues =
|
| + <dynamic /*int|String*/, ConstantExpression>{};
|
|
|
| - ConstantConstructorComputer(TreeElements elements)
|
| - : super(elements);
|
| + ConstantConstructorComputer(TreeElements elements) : super(elements);
|
|
|
| SemanticDeclarationVisitor get declVisitor => this;
|
|
|
| @@ -73,7 +70,7 @@ class ConstantConstructorComputer extends SemanticVisitor
|
|
|
| @override
|
| bulkHandleNode(Node node, String template, _) {
|
| - internalError(node, template.replaceFirst('#' , '$node'));
|
| + internalError(node, template.replaceFirst('#', '$node'));
|
| }
|
|
|
| internalError(Node node, String message) {
|
| @@ -81,12 +78,12 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| }
|
|
|
| ConstantConstructor visitGenerativeConstructorDeclaration(
|
| - FunctionExpression node,
|
| - ConstructorElement constructor,
|
| - NodeList parameters,
|
| - NodeList initializers,
|
| - Node body,
|
| - _) {
|
| + FunctionExpression node,
|
| + ConstructorElement constructor,
|
| + NodeList parameters,
|
| + NodeList initializers,
|
| + Node body,
|
| + _) {
|
| applyParameters(parameters, _);
|
| ConstructedConstantExpression constructorInvocation =
|
| applyInitializers(node, _);
|
| @@ -131,18 +128,12 @@ class ConstantConstructorComputer extends SemanticVisitor
|
|
|
| return new RedirectingFactoryConstantConstructor(
|
| new ConstructedConstantExpression(
|
| - redirectionType,
|
| - redirectionTarget,
|
| - callStructure,
|
| - arguments));
|
| + redirectionType, redirectionTarget, callStructure, arguments));
|
| }
|
|
|
| @override
|
| - visitFactoryConstructorDeclaration(
|
| - FunctionExpression node,
|
| - ConstructorElement constructor,
|
| - NodeList parameters,
|
| - Node body, _) {
|
| + visitFactoryConstructorDeclaration(FunctionExpression node,
|
| + ConstructorElement constructor, NodeList parameters, Node body, _) {
|
| // TODO(johnniwinther): Handle constant constructors with errors.
|
| internalError(node, "Factory constructor cannot be constant: $node.");
|
| }
|
| @@ -151,12 +142,8 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| computeParameterStructures(parameters).forEach((s) => s.dispatch(this, _));
|
| }
|
|
|
| - visitParameterDeclaration(
|
| - VariableDefinitions node,
|
| - Node definition,
|
| - ParameterElement parameter,
|
| - int index,
|
| - _) {
|
| + visitParameterDeclaration(VariableDefinitions node, Node definition,
|
| + ParameterElement parameter, int index, _) {
|
| // Do nothing.
|
| }
|
|
|
| @@ -171,23 +158,15 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| defaultValues[index] = defaultValue;
|
| }
|
|
|
| - visitNamedParameterDeclaration(
|
| - VariableDefinitions node,
|
| - Node definition,
|
| - ParameterElement parameter,
|
| - ConstantExpression defaultValue,
|
| - _) {
|
| + visitNamedParameterDeclaration(VariableDefinitions node, Node definition,
|
| + ParameterElement parameter, ConstantExpression defaultValue, _) {
|
| assert(invariant(node, defaultValue != null));
|
| String name = parameter.name;
|
| defaultValues[name] = defaultValue;
|
| }
|
|
|
| - visitInitializingFormalDeclaration(
|
| - VariableDefinitions node,
|
| - Node definition,
|
| - InitializingFormalElement parameter,
|
| - int index,
|
| - _) {
|
| + visitInitializingFormalDeclaration(VariableDefinitions node, Node definition,
|
| + InitializingFormalElement parameter, int index, _) {
|
| fieldMap[parameter.fieldElement] = new PositionalArgumentReference(index);
|
| }
|
|
|
| @@ -231,18 +210,11 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| return constructorInvocation;
|
| }
|
|
|
| - visitFieldInitializer(
|
| - SendSet node,
|
| - FieldElement field,
|
| - Node initializer,
|
| - _) {
|
| + visitFieldInitializer(SendSet node, FieldElement field, Node initializer, _) {
|
| fieldMap[field] = apply(initializer);
|
| }
|
|
|
| - visitParameterGet(
|
| - Send node,
|
| - ParameterElement parameter,
|
| - _) {
|
| + visitParameterGet(Send node, ParameterElement parameter, _) {
|
| if (parameter.isNamed) {
|
| return new NamedArgumentReference(parameter.name);
|
| } else {
|
| @@ -261,10 +233,7 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| List<ConstantExpression> argumentExpression =
|
| arguments.nodes.map((a) => apply(a)).toList();
|
| return new ConstructedConstantExpression(
|
| - type,
|
| - superConstructor,
|
| - callStructure,
|
| - argumentExpression);
|
| + type, superConstructor, callStructure, argumentExpression);
|
| }
|
|
|
| ConstructedConstantExpression visitImplicitSuperConstructorInvoke(
|
| @@ -272,11 +241,8 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| ConstructorElement superConstructor,
|
| InterfaceType type,
|
| _) {
|
| - return new ConstructedConstantExpression(
|
| - type,
|
| - superConstructor,
|
| - CallStructure.NO_ARGS,
|
| - const <ConstantExpression>[]);
|
| + return new ConstructedConstantExpression(type, superConstructor,
|
| + CallStructure.NO_ARGS, const <ConstantExpression>[]);
|
| }
|
|
|
| ConstructedConstantExpression visitThisConstructorInvoke(
|
| @@ -287,48 +253,29 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| _) {
|
| List<ConstantExpression> argumentExpression =
|
| arguments.nodes.map((a) => apply(a)).toList();
|
| - return new ConstructedConstantExpression(
|
| - currentClass.thisType,
|
| - thisConstructor,
|
| - callStructure,
|
| - argumentExpression);
|
| + return new ConstructedConstantExpression(currentClass.thisType,
|
| + thisConstructor, callStructure, argumentExpression);
|
| }
|
|
|
| @override
|
| ConstantExpression visitBinary(
|
| - Send node,
|
| - Node left,
|
| - BinaryOperator operator,
|
| - Node right,
|
| - _) {
|
| - return new BinaryConstantExpression(
|
| - apply(left), operator, apply(right));
|
| + Send node, Node left, BinaryOperator operator, Node right, _) {
|
| + return new BinaryConstantExpression(apply(left), operator, apply(right));
|
| }
|
|
|
| -
|
| @override
|
| ConstantExpression visitUnary(
|
| - Send node,
|
| - UnaryOperator operator,
|
| - Node expression,
|
| - _) {
|
| - return new UnaryConstantExpression(
|
| - operator, apply(expression));
|
| + Send node, UnaryOperator operator, Node expression, _) {
|
| + return new UnaryConstantExpression(operator, apply(expression));
|
| }
|
|
|
| @override
|
| - ConstantExpression visitStaticFieldGet(
|
| - Send node,
|
| - FieldElement field,
|
| - _) {
|
| + ConstantExpression visitStaticFieldGet(Send node, FieldElement field, _) {
|
| return new VariableConstantExpression(field);
|
| }
|
|
|
| @override
|
| - ConstantExpression visitTopLevelFieldGet(
|
| - Send node,
|
| - FieldElement field,
|
| - _) {
|
| + ConstantExpression visitTopLevelFieldGet(Send node, FieldElement field, _) {
|
| return new VariableConstantExpression(field);
|
| }
|
|
|
| @@ -354,14 +301,13 @@ class ConstantConstructorComputer extends SemanticVisitor
|
|
|
| @override
|
| ConstantExpression visitConditional(Conditional node) {
|
| - return new ConditionalConstantExpression(
|
| - apply(node.condition),
|
| - apply(node.thenExpression),
|
| - apply(node.elseExpression));
|
| + return new ConditionalConstantExpression(apply(node.condition),
|
| + apply(node.thenExpression), apply(node.elseExpression));
|
| }
|
|
|
| @override
|
| - ConstantExpression visitParenthesizedExpression(ParenthesizedExpression node) {
|
| + ConstantExpression visitParenthesizedExpression(
|
| + ParenthesizedExpression node) {
|
| return apply(node.expression);
|
| }
|
|
|
| @@ -383,4 +329,4 @@ class ConstantConstructorComputer extends SemanticVisitor
|
| ConstantExpression visitNamedArgument(NamedArgument node) {
|
| return apply(node.expression);
|
| }
|
| -}
|
| +}
|
|
|