| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(johnniwinther): Remove this library when all constant constructors are | 5 // TODO(johnniwinther): Remove this library when all constant constructors are |
| 6 // computed during resolution. | 6 // computed during resolution. |
| 7 library dart2js.constants.constant_constructors; | 7 library dart2js.constants.constant_constructors; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../elements/resolution_types.dart'; | 10 import '../elements/resolution_types.dart'; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 ConstructedConstantExpression constructorInvocation = | 105 ConstructedConstantExpression constructorInvocation = |
| 106 applyInitializers(node, _); | 106 applyInitializers(node, _); |
| 107 return new RedirectingGenerativeConstantConstructor( | 107 return new RedirectingGenerativeConstantConstructor( |
| 108 defaultValues, constructorInvocation); | 108 defaultValues, constructorInvocation); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ConstantConstructor visitRedirectingFactoryConstructorDeclaration( | 111 ConstantConstructor visitRedirectingFactoryConstructorDeclaration( |
| 112 FunctionExpression node, | 112 FunctionExpression node, |
| 113 ConstructorElement constructor, | 113 ConstructorElement constructor, |
| 114 NodeList parameters, | 114 NodeList parameters, |
| 115 InterfaceType redirectionType, | 115 ResolutionInterfaceType redirectionType, |
| 116 ConstructorElement redirectionTarget, | 116 ConstructorElement redirectionTarget, |
| 117 _) { | 117 _) { |
| 118 List<String> argumentNames = []; | 118 List<String> argumentNames = []; |
| 119 List<ConstantExpression> arguments = []; | 119 List<ConstantExpression> arguments = []; |
| 120 int index = 0; | 120 int index = 0; |
| 121 for (ParameterElement parameter in constructor.parameters) { | 121 for (ParameterElement parameter in constructor.parameters) { |
| 122 if (parameter.isNamed) { | 122 if (parameter.isNamed) { |
| 123 String name = parameter.name; | 123 String name = parameter.name; |
| 124 argumentNames.add(name); | 124 argumentNames.add(name); |
| 125 arguments.add(new NamedArgumentReference(name)); | 125 arguments.add(new NamedArgumentReference(name)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return new NamedArgumentReference(parameter.name); | 223 return new NamedArgumentReference(parameter.name); |
| 224 } else { | 224 } else { |
| 225 return new PositionalArgumentReference( | 225 return new PositionalArgumentReference( |
| 226 parameter.functionDeclaration.parameters.indexOf(parameter)); | 226 parameter.functionDeclaration.parameters.indexOf(parameter)); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 ConstructedConstantExpression visitSuperConstructorInvoke( | 230 ConstructedConstantExpression visitSuperConstructorInvoke( |
| 231 Send node, | 231 Send node, |
| 232 ConstructorElement superConstructor, | 232 ConstructorElement superConstructor, |
| 233 InterfaceType type, | 233 ResolutionInterfaceType type, |
| 234 NodeList arguments, | 234 NodeList arguments, |
| 235 CallStructure callStructure, | 235 CallStructure callStructure, |
| 236 _) { | 236 _) { |
| 237 List<ConstantExpression> argumentExpression = | 237 List<ConstantExpression> argumentExpression = |
| 238 arguments.nodes.map((a) => apply(a)).toList(); | 238 arguments.nodes.map((a) => apply(a)).toList(); |
| 239 return new ConstructedConstantExpression( | 239 return new ConstructedConstantExpression( |
| 240 type, superConstructor, callStructure, argumentExpression); | 240 type, superConstructor, callStructure, argumentExpression); |
| 241 } | 241 } |
| 242 | 242 |
| 243 ConstructedConstantExpression visitImplicitSuperConstructorInvoke( | 243 ConstructedConstantExpression visitImplicitSuperConstructorInvoke( |
| 244 FunctionExpression node, | 244 FunctionExpression node, |
| 245 ConstructorElement superConstructor, | 245 ConstructorElement superConstructor, |
| 246 InterfaceType type, | 246 ResolutionInterfaceType type, |
| 247 _) { | 247 _) { |
| 248 return new ConstructedConstantExpression(type, superConstructor, | 248 return new ConstructedConstantExpression(type, superConstructor, |
| 249 CallStructure.NO_ARGS, const <ConstantExpression>[]); | 249 CallStructure.NO_ARGS, const <ConstantExpression>[]); |
| 250 } | 250 } |
| 251 | 251 |
| 252 ConstructedConstantExpression visitThisConstructorInvoke( | 252 ConstructedConstantExpression visitThisConstructorInvoke( |
| 253 Send node, | 253 Send node, |
| 254 ConstructorElement thisConstructor, | 254 ConstructorElement thisConstructor, |
| 255 NodeList arguments, | 255 NodeList arguments, |
| 256 CallStructure callStructure, | 256 CallStructure callStructure, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 ConstantExpression visitNamedArgument(NamedArgument node) { | 350 ConstantExpression visitNamedArgument(NamedArgument node) { |
| 351 return apply(node.expression); | 351 return apply(node.expression); |
| 352 } | 352 } |
| 353 | 353 |
| 354 @override | 354 @override |
| 355 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { | 355 ConstantExpression visitIfNull(Send node, Node left, Node right, _) { |
| 356 return new BinaryConstantExpression( | 356 return new BinaryConstantExpression( |
| 357 apply(left), BinaryOperator.IF_NULL, apply(right)); | 357 apply(left), BinaryOperator.IF_NULL, apply(right)); |
| 358 } | 358 } |
| 359 } | 359 } |
| OLD | NEW |