| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
| 9 import '../dart_types.dart' as types; | 9 import '../dart_types.dart' as types; |
| 10 import '../elements/elements.dart' as elements; | 10 import '../elements/elements.dart' as elements; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 tree.NodeList parameters = makeParameters(exp.parameters); | 488 tree.NodeList parameters = makeParameters(exp.parameters); |
| 489 tree.NodeList initializers = | 489 tree.NodeList initializers = |
| 490 exp.initializers == null || exp.initializers.isEmpty | 490 exp.initializers == null || exp.initializers.isEmpty |
| 491 ? null | 491 ? null |
| 492 : makeList(",", exp.initializers.map(makeExpression).toList()); | 492 : makeList(",", exp.initializers.map(makeExpression).toList()); |
| 493 tree.Node body = exp.isConst || exp.body == null | 493 tree.Node body = exp.isConst || exp.body == null |
| 494 ? new tree.EmptyStatement(semicolon) | 494 ? new tree.EmptyStatement(semicolon) |
| 495 : makeFunctionBody(exp.body); | 495 : makeFunctionBody(exp.body); |
| 496 result = new tree.FunctionExpression( | 496 result = new tree.FunctionExpression( |
| 497 constructorName(exp), | 497 constructorName(exp), |
| 498 // TODO(eernst): retrieve and pass the actual type variables. | |
| 499 null, // typeVariables | |
| 500 parameters, | 498 parameters, |
| 501 body, | 499 body, |
| 502 null, // return type | 500 null, // return type |
| 503 makeFunctionModifiers(exp), | 501 makeFunctionModifiers(exp), |
| 504 initializers, | 502 initializers, |
| 505 null, // get/set | 503 null, // get/set |
| 506 null); // async modifier | 504 null); // async modifier |
| 507 setElement(result, exp.element, exp); | 505 setElement(result, exp.element, exp); |
| 508 } else if (exp is FunctionExpression) { | 506 } else if (exp is FunctionExpression) { |
| 509 precedence = PRIMARY; | 507 precedence = PRIMARY; |
| 510 if (beginStmt && exp.name != null) { | 508 if (beginStmt && exp.name != null) { |
| 511 needParen = true; // Do not mistake for function declaration. | 509 needParen = true; // Do not mistake for function declaration. |
| 512 } | 510 } |
| 513 Token getOrSet = exp.isGetter ? getToken : exp.isSetter ? setToken : null; | 511 Token getOrSet = exp.isGetter ? getToken : exp.isSetter ? setToken : null; |
| 514 tree.NodeList parameters = | 512 tree.NodeList parameters = |
| 515 exp.isGetter ? makeList("", []) : makeParameters(exp.parameters); | 513 exp.isGetter ? makeList("", []) : makeParameters(exp.parameters); |
| 516 tree.Node body = makeFunctionBody(exp.body); | 514 tree.Node body = makeFunctionBody(exp.body); |
| 517 result = new tree.FunctionExpression( | 515 result = new tree.FunctionExpression( |
| 518 functionName(exp), | 516 functionName(exp), |
| 519 // TODO(eernst): retrieve and pass the actual type variables. | |
| 520 null, // typeVariables | |
| 521 parameters, | 517 parameters, |
| 522 body, | 518 body, |
| 523 exp.returnType == null || exp.element.isConstructor | 519 exp.returnType == null || exp.element.isConstructor |
| 524 ? null | 520 ? null |
| 525 : makeType(exp.returnType), | 521 : makeType(exp.returnType), |
| 526 makeFunctionModifiers(exp), | 522 makeFunctionModifiers(exp), |
| 527 null, // initializers | 523 null, // initializers |
| 528 getOrSet, // get/set | 524 getOrSet, // get/set |
| 529 null); // async modifier | 525 null); // async modifier |
| 530 elements.Element element = exp.element; | 526 elements.Element element = exp.element; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 if (stmt.leftHandValue is Identifier) { | 791 if (stmt.leftHandValue is Identifier) { |
| 796 left = makeExpression(stmt.leftHandValue); | 792 left = makeExpression(stmt.leftHandValue); |
| 797 } else { | 793 } else { |
| 798 left = makeVariableDeclarations(stmt.leftHandValue); | 794 left = makeVariableDeclarations(stmt.leftHandValue); |
| 799 } | 795 } |
| 800 return new tree.SyncForIn(left, makeExpression(stmt.expression), | 796 return new tree.SyncForIn(left, makeExpression(stmt.expression), |
| 801 makeStatement(stmt.body, shortIf: shortIf), forToken, inToken); | 797 makeStatement(stmt.body, shortIf: shortIf), forToken, inToken); |
| 802 } else if (stmt is FunctionDeclaration) { | 798 } else if (stmt is FunctionDeclaration) { |
| 803 tree.FunctionExpression function = new tree.FunctionExpression( | 799 tree.FunctionExpression function = new tree.FunctionExpression( |
| 804 stmt.name != null ? makeIdentifier(stmt.name) : null, | 800 stmt.name != null ? makeIdentifier(stmt.name) : null, |
| 805 // TODO(eernst): retrieve and pass the actual type variables. | |
| 806 null, // typeVariables | |
| 807 makeParameters(stmt.parameters), | 801 makeParameters(stmt.parameters), |
| 808 makeFunctionBody(stmt.body), | 802 makeFunctionBody(stmt.body), |
| 809 stmt.returnType != null ? makeType(stmt.returnType) : null, | 803 stmt.returnType != null ? makeType(stmt.returnType) : null, |
| 810 makeEmptyModifiers(), | 804 makeEmptyModifiers(), |
| 811 null, // initializers | 805 null, // initializers |
| 812 null, // get/set | 806 null, // get/set |
| 813 null); // async modifier | 807 null); // async modifier |
| 814 setElement(function, stmt.function.element, stmt); | 808 setElement(function, stmt.function.element, stmt); |
| 815 return new tree.FunctionDeclaration(function); | 809 return new tree.FunctionDeclaration(function); |
| 816 } else if (stmt is If) { | 810 } else if (stmt is If) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 nodes.add(new tree.NodeList(open, makeLink(opt), close, ',')); | 958 nodes.add(new tree.NodeList(open, makeLink(opt), close, ',')); |
| 965 } | 959 } |
| 966 return argList(nodes); | 960 return argList(nodes); |
| 967 } | 961 } |
| 968 | 962 |
| 969 /// [assignOperator] is used for writing the default value. | 963 /// [assignOperator] is used for writing the default value. |
| 970 tree.Node makeParameter(Parameter param, [Token assignOperator]) { | 964 tree.Node makeParameter(Parameter param, [Token assignOperator]) { |
| 971 if (param.isFunction) { | 965 if (param.isFunction) { |
| 972 tree.Node definition = new tree.FunctionExpression( | 966 tree.Node definition = new tree.FunctionExpression( |
| 973 makeIdentifier(param.name), | 967 makeIdentifier(param.name), |
| 974 // TODO(eernst): retrieve and pass the actual type variables. | |
| 975 null, // typeVariables | |
| 976 makeParameters(param.parameters), | 968 makeParameters(param.parameters), |
| 977 null, // body | 969 null, // body |
| 978 param.type == null ? null : makeType(param.type), | 970 param.type == null ? null : makeType(param.type), |
| 979 makeEmptyModifiers(), // TODO: Function parameter modifiers? | 971 makeEmptyModifiers(), // TODO: Function parameter modifiers? |
| 980 null, // initializers | 972 null, // initializers |
| 981 null, // get/set | 973 null, // get/set |
| 982 null); // async modifier | 974 null); // async modifier |
| 983 if (param.element != null) { | 975 if (param.element != null) { |
| 984 setElement(definition, param.element, param); | 976 setElement(definition, param.element, param); |
| 985 } | 977 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 if (chunk.previous != null) { | 1332 if (chunk.previous != null) { |
| 1341 return new tree.StringJuxtaposition( | 1333 return new tree.StringJuxtaposition( |
| 1342 printStringChunk(chunk.previous), node); | 1334 printStringChunk(chunk.previous), node); |
| 1343 } else { | 1335 } else { |
| 1344 return node; | 1336 return node; |
| 1345 } | 1337 } |
| 1346 } | 1338 } |
| 1347 return printStringChunk(output.chunk); | 1339 return printStringChunk(output.chunk); |
| 1348 } | 1340 } |
| 1349 } | 1341 } |
| OLD | NEW |