|
18 | 18 | #include "swift/Demangling/Demangle.h"
|
19 | 19 | #include "swift/AST/Ownership.h"
|
20 | 20 | #include "swift/Strings.h"
|
| 21 | +#include <cassert> |
21 | 22 | #include <cstdio>
|
22 | 23 | #include <cstdlib>
|
23 | 24 |
|
@@ -753,6 +754,35 @@ class NodePrinter {
|
753 | 754 | setInvalid();
|
754 | 755 | return;
|
755 | 756 | }
|
| 757 | + |
| 758 | + switch (node->getKind()) { |
| 759 | + case Node::Kind::FunctionType: |
| 760 | + case Node::Kind::UncurriedFunctionType: |
| 761 | + case Node::Kind::NoEscapeFunctionType: |
| 762 | + break; |
| 763 | + case Node::Kind::AutoClosureType: |
| 764 | + case Node::Kind::EscapingAutoClosureType: |
| 765 | + Printer << "@autoclosure "; break; |
| 766 | + case Node::Kind::ThinFunctionType: |
| 767 | + Printer << "@convention(thin) "; break; |
| 768 | + case Node::Kind::CFunctionPointer: |
| 769 | + Printer << "@convention(c) "; break; |
| 770 | + case Node::Kind::ObjCBlock: |
| 771 | + Printer << "@convention(block) "; break; |
| 772 | + case Node::Kind::EscapingObjCBlock: |
| 773 | + Printer << "@escaping @convention(block) "; break; |
| 774 | + case Node::Kind::DifferentiableFunctionType: |
| 775 | + Printer << "@differentiable "; break; |
| 776 | + case Node::Kind::EscapingDifferentiableFunctionType: |
| 777 | + Printer << "@escaping @differentiable "; break; |
| 778 | + case Node::Kind::LinearFunctionType: |
| 779 | + Printer << "@differentiable(linear) "; break; |
| 780 | + case Node::Kind::EscapingLinearFunctionType: |
| 781 | + Printer << "@escaping @differentiable(linear) "; break; |
| 782 | + default: |
| 783 | + assert(false && "Unhandled function type in printFunctionType!"); |
| 784 | + } |
| 785 | + |
756 | 786 | unsigned startIndex = 0;
|
757 | 787 | bool isAsync = false, isThrows = false;
|
758 | 788 | if (node->getChild(startIndex)->getKind() == Node::Kind::ThrowsAnnotation) {
|
@@ -1256,39 +1286,19 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
|
1256 | 1286 | case Node::Kind::UnknownIndex:
|
1257 | 1287 | Printer << "unknown index";
|
1258 | 1288 | return nullptr;
|
| 1289 | + case Node::Kind::FunctionType: |
| 1290 | + case Node::Kind::UncurriedFunctionType: |
1259 | 1291 | case Node::Kind::NoEscapeFunctionType:
|
1260 |
| - printFunctionType(nullptr, Node); |
1261 |
| - return nullptr; |
1262 |
| - case Node::Kind::EscapingAutoClosureType: |
1263 |
| - Printer << "@autoclosure "; |
1264 |
| - printFunctionType(nullptr, Node); |
1265 |
| - return nullptr; |
1266 | 1292 | case Node::Kind::AutoClosureType:
|
1267 |
| - Printer << "@autoclosure "; |
1268 |
| - printFunctionType(nullptr, Node); |
1269 |
| - return nullptr; |
| 1293 | + case Node::Kind::EscapingAutoClosureType: |
1270 | 1294 | case Node::Kind::ThinFunctionType:
|
1271 |
| - Printer << "@convention(thin) "; |
1272 |
| - printFunctionType(nullptr, Node); |
1273 |
| - return nullptr; |
| 1295 | + case Node::Kind::CFunctionPointer: |
| 1296 | + case Node::Kind::ObjCBlock: |
| 1297 | + case Node::Kind::EscapingObjCBlock: |
1274 | 1298 | case Node::Kind::DifferentiableFunctionType:
|
1275 |
| - Printer << "@differentiable "; |
1276 |
| - printFunctionType(nullptr, Node); |
1277 |
| - return nullptr; |
1278 | 1299 | case Node::Kind::EscapingDifferentiableFunctionType:
|
1279 |
| - Printer << "@escaping @differentiable "; |
1280 |
| - printFunctionType(nullptr, Node); |
1281 |
| - return nullptr; |
1282 | 1300 | case Node::Kind::LinearFunctionType:
|
1283 |
| - Printer << "@differentiable(linear) "; |
1284 |
| - printFunctionType(nullptr, Node); |
1285 |
| - return nullptr; |
1286 | 1301 | case Node::Kind::EscapingLinearFunctionType:
|
1287 |
| - Printer << "@escaping @differentiable(linear) "; |
1288 |
| - printFunctionType(nullptr, Node); |
1289 |
| - return nullptr; |
1290 |
| - case Node::Kind::FunctionType: |
1291 |
| - case Node::Kind::UncurriedFunctionType: |
1292 | 1302 | printFunctionType(nullptr, Node);
|
1293 | 1303 | return nullptr;
|
1294 | 1304 | case Node::Kind::ArgumentTuple:
|
@@ -1881,21 +1891,6 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
|
1881 | 1891 | case Node::Kind::DynamicSelf:
|
1882 | 1892 | Printer << "Self";
|
1883 | 1893 | return nullptr;
|
1884 |
| - case Node::Kind::CFunctionPointer: { |
1885 |
| - Printer << "@convention(c) "; |
1886 |
| - printFunctionType(nullptr, Node); |
1887 |
| - return nullptr; |
1888 |
| - } |
1889 |
| - case Node::Kind::ObjCBlock: { |
1890 |
| - Printer << "@convention(block) "; |
1891 |
| - printFunctionType(nullptr, Node); |
1892 |
| - return nullptr; |
1893 |
| - } |
1894 |
| - case Node::Kind::EscapingObjCBlock: { |
1895 |
| - Printer << "@escaping @convention(block) "; |
1896 |
| - printFunctionType(nullptr, Node); |
1897 |
| - return nullptr; |
1898 |
| - } |
1899 | 1894 | case Node::Kind::SILBoxType: {
|
1900 | 1895 | Printer << "@box ";
|
1901 | 1896 | NodePointer type = Node->getChild(0);
|
@@ -2648,14 +2643,6 @@ void NodePrinter::printEntityType(NodePointer Entity, NodePointer type,
|
2648 | 2643 | Printer << ' ';
|
2649 | 2644 | type = dependentType->getFirstChild();
|
2650 | 2645 | }
|
2651 |
| - if (type->getKind() == Node::Kind::DifferentiableFunctionType) |
2652 |
| - Printer << "@differentiable "; |
2653 |
| - else if (type->getKind() == Node::Kind::EscapingDifferentiableFunctionType) |
2654 |
| - Printer << "@escaping @differentiable "; |
2655 |
| - else if (type->getKind() == Node::Kind::LinearFunctionType) |
2656 |
| - Printer << "@differentiable(linear) "; |
2657 |
| - else if (type->getKind() == Node::Kind::EscapingLinearFunctionType) |
2658 |
| - Printer << "@escaping @differentiable(linear) "; |
2659 | 2646 | printFunctionType(labelList, type);
|
2660 | 2647 | } else {
|
2661 | 2648 | print(type);
|
|
0 commit comments