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 'dart_printer.dart'; | 7 import 'dart_printer.dart'; |
8 import '../tree/tree.dart' as tree; | 8 import '../tree/tree.dart' as tree; |
9 import '../scanner/scannerlib.dart'; | 9 import '../scanner/scannerlib.dart'; |
10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 319 } |
320 result = new tree.Send( | 320 result = new tree.Send( |
321 receiver, | 321 receiver, |
322 selector, | 322 selector, |
323 argList(exp.arguments.map(makeArgument))); | 323 argList(exp.arguments.map(makeArgument))); |
324 if (callee is Identifier) { | 324 if (callee is Identifier) { |
325 setElement(result, element, exp); | 325 setElement(result, element, exp); |
326 } | 326 } |
327 } else if (exp is CallMethod) { | 327 } else if (exp is CallMethod) { |
328 precedence = CALLEE; | 328 precedence = CALLEE; |
| 329 tree.Node receiver = exp.object is This |
| 330 ? null |
| 331 : makeExp(exp.object, PRIMARY, beginStmt: beginStmt); |
329 result = new tree.Send( | 332 result = new tree.Send( |
330 makeExp(exp.object, PRIMARY, beginStmt: beginStmt), | 333 receiver, |
331 makeIdentifier(exp.methodName), | 334 makeIdentifier(exp.methodName), |
332 argList(exp.arguments.map(makeArgument))); | 335 argList(exp.arguments.map(makeArgument))); |
333 } else if (exp is CallNew) { | 336 } else if (exp is CallNew) { |
334 precedence = CALLEE; | 337 precedence = CALLEE; |
335 tree.Node selector = makeName(exp.type.name); | 338 tree.Node selector = makeName(exp.type.name); |
336 if (exp.type.typeArguments.length > 0) { | 339 if (exp.type.typeArguments.length > 0) { |
337 selector = new tree.TypeAnnotation( | 340 selector = new tree.TypeAnnotation( |
338 selector, | 341 selector, |
339 typeArgList(exp.type.typeArguments.map(makeType))); | 342 typeArgList(exp.type.typeArguments.map(makeType))); |
340 setType(selector, exp.dartType, exp); | 343 setType(selector, exp.dartType, exp); |
(...skipping 22 matching lines...) Expand all Loading... |
363 } else if (exp is Conditional) { | 366 } else if (exp is Conditional) { |
364 precedence = CONDITIONAL; | 367 precedence = CONDITIONAL; |
365 result = new tree.Conditional( | 368 result = new tree.Conditional( |
366 makeExp(exp.condition, LOGICAL_OR, beginStmt: beginStmt), | 369 makeExp(exp.condition, LOGICAL_OR, beginStmt: beginStmt), |
367 makeExp(exp.thenExpression, EXPRESSION), | 370 makeExp(exp.thenExpression, EXPRESSION), |
368 makeExp(exp.elseExpression, EXPRESSION), | 371 makeExp(exp.elseExpression, EXPRESSION), |
369 question, | 372 question, |
370 colon); | 373 colon); |
371 } else if (exp is FieldExpression) { | 374 } else if (exp is FieldExpression) { |
372 precedence = PRIMARY; | 375 precedence = PRIMARY; |
373 result = new tree.Send( | 376 tree.Node receiver = exp.object is This |
374 makeExp(exp.object, PRIMARY, beginStmt: beginStmt), | 377 ? null |
375 makeIdentifier(exp.fieldName)); | 378 : makeExp(exp.object, PRIMARY, beginStmt: beginStmt); |
| 379 result = new tree.Send(receiver, makeIdentifier(exp.fieldName)); |
376 } else if (exp is FunctionExpression) { | 380 } else if (exp is FunctionExpression) { |
377 precedence = PRIMARY; | 381 precedence = PRIMARY; |
378 if (beginStmt && exp.name != null) { | 382 if (beginStmt && exp.name != null) { |
379 needParen = true; // Do not mistake for function declaration. | 383 needParen = true; // Do not mistake for function declaration. |
380 } | 384 } |
381 // exp.element can only be null in tests. | 385 // exp.element can only be null in tests. |
382 tree.Node body = exp.element != null && | 386 tree.Node body = exp.element != null && |
383 exp.element.node.body is tree.EmptyStatement | 387 exp.element.node.body is tree.EmptyStatement |
384 ? exp.element.node.body | 388 ? exp.element.node.body |
385 : makeFunctionBody(exp.body); | 389 : makeFunctionBody(exp.body); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 printStringChunk(chunk.previous), | 1012 printStringChunk(chunk.previous), |
1009 node); | 1013 node); |
1010 } else { | 1014 } else { |
1011 return node; | 1015 return node; |
1012 } | 1016 } |
1013 } | 1017 } |
1014 return printStringChunk(output.chunk); | 1018 return printStringChunk(output.chunk); |
1015 } | 1019 } |
1016 | 1020 |
1017 } | 1021 } |
OLD | NEW |