| 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 library dart2js.constants.constructors; | 5 library dart2js.constants.constructors; |
| 6 | 6 |
| 7 import '../dart2jslib.dart'; | 7 import '../dart2jslib.dart'; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 argumentNames.add(name); | 115 argumentNames.add(name); |
| 116 arguments.add(new NamedArgumentReference(name)); | 116 arguments.add(new NamedArgumentReference(name)); |
| 117 } else { | 117 } else { |
| 118 arguments.add(new PositionalArgumentReference(index)); | 118 arguments.add(new PositionalArgumentReference(index)); |
| 119 } | 119 } |
| 120 index++; | 120 index++; |
| 121 } | 121 } |
| 122 CallStructure callStructure = new CallStructure(index, argumentNames); | 122 CallStructure callStructure = new CallStructure(index, argumentNames); |
| 123 | 123 |
| 124 return new RedirectingFactoryConstantConstructor( | 124 return new RedirectingFactoryConstantConstructor( |
| 125 new ConstructedConstantExpression(null, | 125 new ConstructedConstantExpression( |
| 126 redirectionType, | 126 redirectionType, |
| 127 redirectionTarget, | 127 redirectionTarget, |
| 128 callStructure, | 128 callStructure, |
| 129 arguments)); | 129 arguments)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 @override | 132 @override |
| 133 visitFactoryConstructorDeclaration( | 133 visitFactoryConstructorDeclaration( |
| 134 FunctionExpression node, | 134 FunctionExpression node, |
| 135 ConstructorElement constructor, | 135 ConstructorElement constructor, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 ConstructedConstantExpression visitSuperConstructorInvoke( | 246 ConstructedConstantExpression visitSuperConstructorInvoke( |
| 247 Send node, | 247 Send node, |
| 248 ConstructorElement superConstructor, | 248 ConstructorElement superConstructor, |
| 249 InterfaceType type, | 249 InterfaceType type, |
| 250 NodeList arguments, | 250 NodeList arguments, |
| 251 CallStructure callStructure, | 251 CallStructure callStructure, |
| 252 _) { | 252 _) { |
| 253 List<ConstantExpression> argumentExpression = | 253 List<ConstantExpression> argumentExpression = |
| 254 arguments.nodes.map((a) => apply(a)).toList(); | 254 arguments.nodes.map((a) => apply(a)).toList(); |
| 255 return new ConstructedConstantExpression(null, | 255 return new ConstructedConstantExpression( |
| 256 type, | 256 type, |
| 257 superConstructor, | 257 superConstructor, |
| 258 callStructure, | 258 callStructure, |
| 259 argumentExpression); | 259 argumentExpression); |
| 260 } | 260 } |
| 261 | 261 |
| 262 ConstructedConstantExpression visitImplicitSuperConstructorInvoke( | 262 ConstructedConstantExpression visitImplicitSuperConstructorInvoke( |
| 263 FunctionExpression node, | 263 FunctionExpression node, |
| 264 ConstructorElement superConstructor, | 264 ConstructorElement superConstructor, |
| 265 InterfaceType type, | 265 InterfaceType type, |
| 266 _) { | 266 _) { |
| 267 return new ConstructedConstantExpression(null, | 267 return new ConstructedConstantExpression( |
| 268 type, | 268 type, |
| 269 superConstructor, | 269 superConstructor, |
| 270 CallStructure.NO_ARGS, | 270 CallStructure.NO_ARGS, |
| 271 const <ConstantExpression>[]); | 271 const <ConstantExpression>[]); |
| 272 } | 272 } |
| 273 | 273 |
| 274 ConstructedConstantExpression visitThisConstructorInvoke( | 274 ConstructedConstantExpression visitThisConstructorInvoke( |
| 275 Send node, | 275 Send node, |
| 276 ConstructorElement thisConstructor, | 276 ConstructorElement thisConstructor, |
| 277 NodeList arguments, | 277 NodeList arguments, |
| 278 CallStructure callStructure, | 278 CallStructure callStructure, |
| 279 _) { | 279 _) { |
| 280 List<ConstantExpression> argumentExpression = | 280 List<ConstantExpression> argumentExpression = |
| 281 arguments.nodes.map((a) => apply(a)).toList(); | 281 arguments.nodes.map((a) => apply(a)).toList(); |
| 282 return new ConstructedConstantExpression(null, | 282 return new ConstructedConstantExpression( |
| 283 currentClass.thisType, | 283 currentClass.thisType, |
| 284 thisConstructor, | 284 thisConstructor, |
| 285 callStructure, | 285 callStructure, |
| 286 argumentExpression); | 286 argumentExpression); |
| 287 } | 287 } |
| 288 | 288 |
| 289 @override | 289 @override |
| 290 ConstantExpression visitBinary( | 290 ConstantExpression visitBinary( |
| 291 Send node, | 291 Send node, |
| 292 Node left, | 292 Node left, |
| 293 BinaryOperator operator, | 293 BinaryOperator operator, |
| 294 Node right, | 294 Node right, |
| 295 _) { | 295 _) { |
| 296 return new BinaryConstantExpression(null, | 296 return new BinaryConstantExpression( |
| 297 apply(left), operator, apply(right)); | 297 apply(left), operator, apply(right)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 | 300 |
| 301 @override | 301 @override |
| 302 ConstantExpression visitUnary( | 302 ConstantExpression visitUnary( |
| 303 Send node, | 303 Send node, |
| 304 UnaryOperator operator, | 304 UnaryOperator operator, |
| 305 Node expression, | 305 Node expression, |
| 306 _) { | 306 _) { |
| 307 return new UnaryConstantExpression(null, | 307 return new UnaryConstantExpression( |
| 308 operator, apply(expression)); | 308 operator, apply(expression)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 @override | 311 @override |
| 312 ConstantExpression visitStaticFieldGet( | 312 ConstantExpression visitStaticFieldGet( |
| 313 Send node, | 313 Send node, |
| 314 FieldElement field, | 314 FieldElement field, |
| 315 _) { | 315 _) { |
| 316 return new VariableConstantExpression(null, field); | 316 return new VariableConstantExpression(field); |
| 317 } | 317 } |
| 318 | 318 |
| 319 @override | 319 @override |
| 320 ConstantExpression visitTopLevelFieldGet( | 320 ConstantExpression visitTopLevelFieldGet( |
| 321 Send node, | 321 Send node, |
| 322 FieldElement field, | 322 FieldElement field, |
| 323 _) { | 323 _) { |
| 324 return new VariableConstantExpression(null, field); | 324 return new VariableConstantExpression(field); |
| 325 } | 325 } |
| 326 | 326 |
| 327 @override | 327 @override |
| 328 ConstantExpression visitLiteralInt(LiteralInt node) { | 328 ConstantExpression visitLiteralInt(LiteralInt node) { |
| 329 return new IntConstantExpression( | 329 return new IntConstantExpression(node.value); |
| 330 node.value, new IntConstantValue(node.value)); | |
| 331 } | 330 } |
| 332 | 331 |
| 333 @override | 332 @override |
| 334 ConstantExpression visitLiteralBool(LiteralBool node) { | 333 ConstantExpression visitLiteralBool(LiteralBool node) { |
| 335 return new BoolConstantExpression(node.value, null); | 334 return new BoolConstantExpression(node.value); |
| 336 } | 335 } |
| 337 | 336 |
| 338 @override | 337 @override |
| 339 ConstantExpression visitLiteralNull(LiteralNull node) { | 338 ConstantExpression visitLiteralNull(LiteralNull node) { |
| 340 return new NullConstantExpression(new NullConstantValue()); | 339 return new NullConstantExpression(); |
| 341 } | 340 } |
| 342 | 341 |
| 343 @override | 342 @override |
| 344 ConstantExpression visitLiteralString(LiteralString node) { | 343 ConstantExpression visitLiteralString(LiteralString node) { |
| 345 return new StringConstantExpression(node.dartString.slowToString(), null); | 344 return new StringConstantExpression(node.dartString.slowToString()); |
| 346 } | 345 } |
| 347 | 346 |
| 348 @override | 347 @override |
| 349 ConstantExpression visitConditional(Conditional node) { | 348 ConstantExpression visitConditional(Conditional node) { |
| 350 return new ConditionalConstantExpression(null, | 349 return new ConditionalConstantExpression( |
| 351 apply(node.condition), | 350 apply(node.condition), |
| 352 apply(node.thenExpression), | 351 apply(node.thenExpression), |
| 353 apply(node.elseExpression)); | 352 apply(node.elseExpression)); |
| 354 } | 353 } |
| 355 | 354 |
| 356 @override | 355 @override |
| 357 ConstantExpression visitParenthesizedExpression(ParenthesizedExpression node)
{ | 356 ConstantExpression visitParenthesizedExpression(ParenthesizedExpression node)
{ |
| 358 return apply(node.expression); | 357 return apply(node.expression); |
| 359 } | 358 } |
| 360 | 359 |
| 361 @override | 360 @override |
| 362 ConstantExpression visitTopLevelFunctionInvoke( | 361 ConstantExpression visitTopLevelFunctionInvoke( |
| 363 Send node, | 362 Send node, |
| 364 MethodElement function, | 363 MethodElement function, |
| 365 NodeList arguments, | 364 NodeList arguments, |
| 366 CallStructure callStructure, | 365 CallStructure callStructure, |
| 367 _) { | 366 _) { |
| 368 if (function.name != 'identical' || !function.library.isDartCore) { | 367 if (function.name != 'identical' || !function.library.isDartCore) { |
| 369 throw new UnsupportedError("Unexpected function call: $function"); | 368 throw new UnsupportedError("Unexpected function call: $function"); |
| 370 } | 369 } |
| 371 return new IdenticalConstantExpression( | 370 return new IdenticalConstantExpression( |
| 372 null, apply(arguments.nodes.head), apply(arguments.nodes.tail.head)); | 371 apply(arguments.nodes.head), apply(arguments.nodes.tail.head)); |
| 373 } | 372 } |
| 374 | 373 |
| 375 @override | 374 @override |
| 376 ConstantExpression visitNamedArgument(NamedArgument node) { | 375 ConstantExpression visitNamedArgument(NamedArgument node) { |
| 377 return apply(node.expression); | 376 return apply(node.expression); |
| 378 } | 377 } |
| 379 } | 378 } |
| OLD | NEW |