| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_tree_printer; | 5 library dart_tree_printer; |
| 6 | 6 |
| 7 import '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
| 8 import '../dart_types.dart' as types; | 8 import '../dart_types.dart' as types; |
| 9 import '../dart2jslib.dart' as dart2js; | 9 import '../dart2jslib.dart' as dart2js; |
| 10 import '../elements/elements.dart' as elements; | 10 import '../elements/elements.dart' as elements; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 result = new tree.Send( | 392 result = new tree.Send( |
| 393 receiver, | 393 receiver, |
| 394 selector, | 394 selector, |
| 395 argList(exp.arguments.map(makeArgument))); | 395 argList(exp.arguments.map(makeArgument))); |
| 396 if (callee is Identifier) { | 396 if (callee is Identifier) { |
| 397 setElement(result, element, exp); | 397 setElement(result, element, exp); |
| 398 } | 398 } |
| 399 } else if (exp is CallMethod) { | 399 } else if (exp is CallMethod) { |
| 400 precedence = CALLEE; | 400 precedence = CALLEE; |
| 401 tree.Node receiver = exp.object is This | 401 // TODO(sra): Elide receiver when This, but only if not in a scope that |
| 402 ? null | 402 // shadows the method (e.g. constructor body). |
| 403 : makeExp(exp.object, PRIMARY, beginStmt: beginStmt); | 403 tree.Node receiver = makeExp(exp.object, PRIMARY, beginStmt: beginStmt); |
| 404 result = new tree.Send( | 404 result = new tree.Send( |
| 405 receiver, | 405 receiver, |
| 406 makeIdentifier(exp.methodName), | 406 makeIdentifier(exp.methodName), |
| 407 argList(exp.arguments.map(makeArgument))); | 407 argList(exp.arguments.map(makeArgument))); |
| 408 } else if (exp is CallNew) { | 408 } else if (exp is CallNew) { |
| 409 precedence = CALLEE; | 409 precedence = CALLEE; |
| 410 tree.Node selector = makeName(exp.type.name); | 410 tree.Node selector = makeName(exp.type.name); |
| 411 if (exp.type.typeArguments.length > 0) { | 411 if (exp.type.typeArguments.length > 0) { |
| 412 selector = new tree.TypeAnnotation( | 412 selector = new tree.TypeAnnotation( |
| 413 selector, | 413 selector, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 438 } else if (exp is Conditional) { | 438 } else if (exp is Conditional) { |
| 439 precedence = CONDITIONAL; | 439 precedence = CONDITIONAL; |
| 440 result = new tree.Conditional( | 440 result = new tree.Conditional( |
| 441 makeExp(exp.condition, LOGICAL_OR, beginStmt: beginStmt), | 441 makeExp(exp.condition, LOGICAL_OR, beginStmt: beginStmt), |
| 442 makeExp(exp.thenExpression, EXPRESSION), | 442 makeExp(exp.thenExpression, EXPRESSION), |
| 443 makeExp(exp.elseExpression, EXPRESSION), | 443 makeExp(exp.elseExpression, EXPRESSION), |
| 444 question, | 444 question, |
| 445 colon); | 445 colon); |
| 446 } else if (exp is FieldExpression) { | 446 } else if (exp is FieldExpression) { |
| 447 precedence = PRIMARY; | 447 precedence = PRIMARY; |
| 448 tree.Node receiver = exp.object is This | 448 // TODO(sra): Elide receiver when This, but only if not in a scope that |
| 449 ? null | 449 // shadows the method (e.g. constructor body). |
| 450 : makeExp(exp.object, PRIMARY, beginStmt: beginStmt); | 450 tree.Node receiver = makeExp(exp.object, PRIMARY, beginStmt: beginStmt); |
| 451 result = new tree.Send(receiver, makeIdentifier(exp.fieldName)); | 451 result = new tree.Send(receiver, makeIdentifier(exp.fieldName)); |
| 452 } else if (exp is ConstructorDefinition) { | 452 } else if (exp is ConstructorDefinition) { |
| 453 precedence = EXPRESSION; | 453 precedence = EXPRESSION; |
| 454 tree.NodeList parameters = makeParameters(exp.parameters); | 454 tree.NodeList parameters = makeParameters(exp.parameters); |
| 455 tree.NodeList initializers = | 455 tree.NodeList initializers = |
| 456 exp.initializers == null || exp.initializers.isEmpty | 456 exp.initializers == null || exp.initializers.isEmpty |
| 457 ? null | 457 ? null |
| 458 : makeList(",", exp.initializers.map(makeExpression).toList()); | 458 : makeList(",", exp.initializers.map(makeExpression).toList()); |
| 459 tree.Node body = exp.isConst || exp.body == null | 459 tree.Node body = exp.isConst || exp.body == null |
| 460 ? new tree.EmptyStatement(semicolon) | 460 ? new tree.EmptyStatement(semicolon) |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 printStringChunk(chunk.previous), | 1333 printStringChunk(chunk.previous), |
| 1334 node); | 1334 node); |
| 1335 } else { | 1335 } else { |
| 1336 return node; | 1336 return node; |
| 1337 } | 1337 } |
| 1338 } | 1338 } |
| 1339 return printStringChunk(output.chunk); | 1339 return printStringChunk(output.chunk); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 } | 1342 } |
| OLD | NEW |