Remove VarargBaseType from TuplePatternElt and introduce a bit in TuplePattern to indicate if there is a vararg.

The semantics of varargs (only for the last element) make it more appropriate as a property of the TuplePattern.
Also free the Parser from needing to construct synthetic types (ArraySlice for type of vararg element) to
accommodate the TypeChecker and move the logic to the TypeChecker. This will be more beneficial when the parser stops
creating types in general.

Swift SVN r6271
This commit is contained in:
Argyrios Kyrtzidis
2013-07-15 20:21:30 +00:00
parent 189ffc49a5
commit 37dc84e13c
12 changed files with 129 additions and 131 deletions

View File

@@ -110,8 +110,9 @@ Pattern *ModuleFile::maybeReadPattern() {
case decls_block::TUPLE_PATTERN: {
TypeID tupleTypeID;
unsigned count;
bool hasVararg;
TuplePatternLayout::readRecord(scratch, tupleTypeID, count);
TuplePatternLayout::readRecord(scratch, tupleTypeID, count, hasVararg);
SmallVector<TuplePatternElt, 8> elements;
for ( ; count > 0; --count) {
@@ -122,21 +123,18 @@ Pattern *ModuleFile::maybeReadPattern() {
kind = DeclTypeCursor.readRecord(next.ID, scratch);
assert(kind == decls_block::TUPLE_PATTERN_ELT);
TypeID varargsTypeID;
TuplePatternEltLayout::readRecord(scratch, varargsTypeID);
// FIXME: Add something for this record or remove it.
// TuplePatternEltLayout::readRecord(scratch);
Pattern *subPattern = maybeReadPattern();
assert(subPattern);
elements.push_back(TuplePatternElt(subPattern));
if (varargsTypeID) {
BCOffsetRAII restoreOffset(DeclTypeCursor);
elements.back().setVarargBaseType(getType(varargsTypeID));
}
elements.push_back(TuplePatternElt(subPattern, nullptr));
}
auto result = TuplePattern::create(ModuleContext->Ctx, SourceLoc(),
elements, SourceLoc());
elements, SourceLoc(), hasVararg,
SourceLoc());
{
BCOffsetRAII restoreOffset(DeclTypeCursor);
result->setType(getType(tupleTypeID));