Add basic parsing, sema and mangling support for throwing function types. Next up, metadata and serialization support, as well as more tests.

Swift SVN r26767
This commit is contained in:
Joe Pamer
2015-03-31 18:55:19 +00:00
parent 0b12af7225
commit eee40fc53f
33 changed files with 283 additions and 45 deletions

View File

@@ -1589,6 +1589,11 @@ private:
}
NodePointer demangleFunctionType(Node::Kind kind) {
bool throws = false;
if (Mangled &&
Mangled.nextIf('z')) {
throws = true;
}
NodePointer in_args = demangleType();
if (!in_args)
return nullptr;
@@ -1596,6 +1601,11 @@ private:
if (!out_args)
return nullptr;
NodePointer block = NodeFactory::create(kind);
if (throws) {
block->addChild(NodeFactory::create(Node::Kind::ThrowsAnnotation));
}
NodePointer in_node = NodeFactory::create(Node::Kind::ArgumentTuple);
block->addChild(in_node);
in_node->addChild(in_args);
@@ -2312,6 +2322,7 @@ private:
case Node::Kind::Weak:
case Node::Kind::WillSet:
case Node::Kind::WitnessTableOffset:
case Node::Kind::ThrowsAnnotation:
return false;
}
unreachable("bad node kind");
@@ -3277,6 +3288,10 @@ void NodePrinter::print(NodePointer pointer, bool asContext, bool suppressType)
Printer << '.' << pointer->getText();
return;
}
case Node::Kind::ThrowsAnnotation: {
Printer<< " throws ";
return;
}
}
unreachable("bad node kind!");
}