the swift.Slice type got removed a long time ago, being replaced with

what is now Swift.Array.  Update various internal stuff to refer to
Array instead of Slice.  NFC.


Swift SVN r14567
This commit is contained in:
Chris Lattner
2014-03-02 06:21:37 +00:00
parent aa337d4899
commit 11bedff2f3
14 changed files with 37 additions and 37 deletions

View File

@@ -343,8 +343,8 @@ public:
/// Retrieve the declaration of Swift.false. /// Retrieve the declaration of Swift.false.
ValueDecl *getFalseDecl() const; ValueDecl *getFalseDecl() const;
/// Retrieve the declaration of Swift.Slice<T>. /// Retrieve the declaration of Swift.Array<T>.
NominalTypeDecl *getSliceDecl() const; NominalTypeDecl *getArrayDecl() const;
/// Retrieve the declaration of Swift.Optional<T>. /// Retrieve the declaration of Swift.Optional<T>.
EnumDecl *getOptionalDecl() const; EnumDecl *getOptionalDecl() const;

View File

@@ -2308,7 +2308,7 @@ END_CAN_TYPE_WRAPPER(ArrayType, Type)
/// A type with a special syntax that is always sugar for a library type. /// A type with a special syntax that is always sugar for a library type.
/// ///
/// The prime examples are slices (T[] -> Slice<T>) and /// The prime examples are arrays (T[] -> Array<T>) and
/// optionals (T? -> Optional<T>). /// optionals (T? -> Optional<T>).
class SyntaxSugarType : public TypeBase { class SyntaxSugarType : public TypeBase {
Type Base; Type Base;
@@ -3198,7 +3198,7 @@ inline Type TupleTypeElt::getVarargBaseTy() const {
TypeBase *T = getType().getPointer(); TypeBase *T = getType().getPointer();
if (ArraySliceType *AT = dyn_cast<ArraySliceType>(T)) if (ArraySliceType *AT = dyn_cast<ArraySliceType>(T))
return AT->getBaseType(); return AT->getBaseType();
// It's the stdlib Slice<T>. // It's the stdlib Array<T>.
return cast<BoundGenericType>(T)->getGenericArgs()[0]; return cast<BoundGenericType>(T)->getGenericArgs()[0];
} }

View File

@@ -60,8 +60,8 @@ struct ASTContext::Implementation {
llvm::StringMap<char, llvm::BumpPtrAllocator&> IdentifierTable; llvm::StringMap<char, llvm::BumpPtrAllocator&> IdentifierTable;
/// The declaration of Swift.Slice<T>. /// The declaration of Swift.Array<T>.
NominalTypeDecl *SliceDecl = nullptr; NominalTypeDecl *ArrayDecl = nullptr;
/// The declaration of Swift.Optional<T>. /// The declaration of Swift.Optional<T>.
EnumDecl *OptionalDecl = nullptr; EnumDecl *OptionalDecl = nullptr;
@@ -406,11 +406,11 @@ static NominalTypeDecl *findSyntaxSugarImpl(const ASTContext &ctx,
return nullptr; return nullptr;
} }
NominalTypeDecl *ASTContext::getSliceDecl() const { NominalTypeDecl *ASTContext::getArrayDecl() const {
if (!Impl.SliceDecl) if (!Impl.ArrayDecl)
Impl.SliceDecl = findSyntaxSugarImpl(*this, "Array"); Impl.ArrayDecl = findSyntaxSugarImpl(*this, "Array");
return Impl.SliceDecl; return Impl.ArrayDecl;
} }
EnumDecl *ASTContext::getOptionalDecl() const { EnumDecl *ASTContext::getOptionalDecl() const {
@@ -766,8 +766,8 @@ ASTContext::getSubstitutions(BoundGenericType* bound) const {
if (known != boundGenericSubstitutions.end()) if (known != boundGenericSubstitutions.end())
return known->second; return known->second;
// We can trivially create substitutions for Slice and Optional. // We can trivially create substitutions for Array and Optional.
if (bound->getDecl() == getSliceDecl() || if (bound->getDecl() == getArrayDecl() ||
bound->getDecl() == getOptionalDecl()) bound->getDecl() == getOptionalDecl())
return createTrivialSubstitutions(bound); return createTrivialSubstitutions(bound);

View File

@@ -1407,7 +1407,7 @@ public:
if (Options.SynthesizeSugarOnTypes) { if (Options.SynthesizeSugarOnTypes) {
auto *NT = T->getDecl(); auto *NT = T->getDecl();
auto &Ctx = T->getASTContext(); auto &Ctx = T->getASTContext();
if (NT == Ctx.getSliceDecl()) { if (NT == Ctx.getArrayDecl()) {
printWithParensIfNotSimple(T->getGenericArgs()[0]); printWithParensIfNotSimple(T->getGenericArgs()[0]);
Printer << "[]"; Printer << "[]";
return; return;

View File

@@ -912,8 +912,8 @@ Type SyntaxSugarType::getImplementationType() {
NominalTypeDecl *implDecl; NominalTypeDecl *implDecl;
if (isa<ArraySliceType>(this)) { if (isa<ArraySliceType>(this)) {
implDecl = ctx.getSliceDecl(); implDecl = ctx.getArrayDecl();
assert(implDecl && "Slice type has not been set yet"); assert(implDecl && "Array type has not been set yet");
} else if (isa<OptionalType>(this)) { } else if (isa<OptionalType>(this)) {
implDecl = ctx.getOptionalDecl(); implDecl = ctx.getOptionalDecl();
assert(implDecl && "Optional type has not been set yet"); assert(implDecl && "Optional type has not been set yet");

View File

@@ -1560,7 +1560,7 @@ struct ASTNodeBase {};
auto *LastPattern = TP->getFields().back().getPattern(); auto *LastPattern = TP->getFields().back().getPattern();
Type T = cast<TypedPattern>(LastPattern)->getType()->getCanonicalType(); Type T = cast<TypedPattern>(LastPattern)->getType()->getCanonicalType();
if (auto *BGT = T->getAs<BoundGenericType>()) { if (auto *BGT = T->getAs<BoundGenericType>()) {
if (BGT->getDecl() == Ctx.getSliceDecl()) if (BGT->getDecl() == Ctx.getArrayDecl())
return; return;
} }
Out << "a vararg subpattern of a TuplePattern has wrong type"; Out << "a vararg subpattern of a TuplePattern has wrong type";

View File

@@ -1841,7 +1841,7 @@ private:
enum class SugarType { enum class SugarType {
None, None,
Optional, Optional,
Slice Array
}; };
SugarType findSugar(NodePointer pointer) { SugarType findSugar(NodePointer pointer) {
@@ -1871,7 +1871,7 @@ private:
if (isIdentifier(unboundType->getChild(1), "Array") && if (isIdentifier(unboundType->getChild(1), "Array") &&
typeArgs->getNumChildren() == 1 && typeArgs->getNumChildren() == 1 &&
isSwiftModule(unboundType->getChild(0))) { isSwiftModule(unboundType->getChild(0))) {
return SugarType::Slice; return SugarType::Array;
} }
} }
@@ -1914,7 +1914,7 @@ private:
Printer << "?"; Printer << "?";
} }
break; break;
case SugarType::Slice: { case SugarType::Array: {
Node *type = pointer->getChild(1)->getChild(0); Node *type = pointer->getChild(1)->getChild(0);
bool needs_parens = false; bool needs_parens = false;
if (findSugar(type) != SugarType::None) if (findSugar(type) != SugarType::None)

View File

@@ -1489,7 +1489,7 @@ RValue RValueEmitter::visitTupleShuffleExpr(TupleShuffleExpr *E,
assert(field.isVararg() && "Cannot initialize nonvariadic element"); assert(field.isVararg() && "Cannot initialize nonvariadic element");
// Okay, we have a varargs tuple element. All the remaining elements feed // Okay, we have a varargs tuple element. All the remaining elements feed
// into the varargs portion of this, which is then constructed into a Slice // into the varargs portion of this, which is then constructed into an Array
// through an informal protocol captured by the InjectionFn in the // through an informal protocol captured by the InjectionFn in the
// TupleShuffleExpr. // TupleShuffleExpr.
assert(E->getVarargsInjectionFunction() && assert(E->getVarargsInjectionFunction() &&
@@ -1670,7 +1670,7 @@ RValue RValueEmitter::visitNewArrayExpr(NewArrayExpr *E, SGFContext C) {
// FIXME: We need to initialize the elements of the array that are now // FIXME: We need to initialize the elements of the array that are now
// allocated. // allocated.
// Finally, build and return a Slice instance using the object // Finally, build and return an Array instance using the object
// header/base/count. // header/base/count.
return RValue(SGF, E, return RValue(SGF, E,
SGF.emitArrayInjectionCall(ObjectPtr, BasePtr, NumElements, SGF.emitArrayInjectionCall(ObjectPtr, BasePtr, NumElements,

View File

@@ -1885,7 +1885,7 @@ namespace {
expr->setElementType(elementType); expr->setElementType(elementType);
// Make sure that the result type is a slice type, even if // Make sure that the result type is a slice type, even if
// canonicalization mapped it down to Slice<T>. // canonicalization mapped it down to Array<T>.
auto sliceType = dyn_cast<ArraySliceType>(resultType.getPointer()); auto sliceType = dyn_cast<ArraySliceType>(resultType.getPointer());
if (!sliceType) { if (!sliceType) {
resultType = tc.getArraySliceType(expr->getLoc(), elementType); resultType = tc.getArraySliceType(expr->getLoc(), elementType);

View File

@@ -104,7 +104,7 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
if (literalProtocol) { if (literalProtocol) {
if (auto defaultType = TC.getDefaultType(literalProtocol, DC)) { if (auto defaultType = TC.getDefaultType(literalProtocol, DC)) {
// Check whether the nominal types match. This makes sure that we // Check whether the nominal types match. This makes sure that we
// properly handle Slice vs. Slice<T>. // properly handle Array vs. Array<T>.
if (defaultType->getAnyNominal() != type->getAnyNominal()) if (defaultType->getAnyNominal() != type->getAnyNominal())
increaseScore(SK_NonDefaultLiteral); increaseScore(SK_NonDefaultLiteral);
} }
@@ -587,7 +587,7 @@ Type ConstraintSystem::openType(
Type ConstraintSystem::openBindingType(Type type, DeclContext *dc) { Type ConstraintSystem::openBindingType(Type type, DeclContext *dc) {
Type result = openType(type, dc); Type result = openType(type, dc);
// FIXME: Better way to identify Slice<T>. // FIXME: Better way to identify Array<T>.
if (auto boundStruct if (auto boundStruct
= dyn_cast<BoundGenericStructType>(result.getPointer())) { = dyn_cast<BoundGenericStructType>(result.getPointer())) {
if (!boundStruct->getParent() && if (!boundStruct->getParent() &&

View File

@@ -94,15 +94,15 @@ Expr *TypeChecker::substituteInputSugarTypeForResult(ApplyExpr *E) {
Expr *TypeChecker::buildArrayInjectionFnRef(DeclContext *dc, Expr *TypeChecker::buildArrayInjectionFnRef(DeclContext *dc,
ArraySliceType *sliceType, ArraySliceType *sliceType,
Type lenTy, SourceLoc Loc) { Type lenTy, SourceLoc Loc) {
// Build the expression "Slice<T>". // Build the expression "Array<T>".
Expr *sliceTypeRef = Expr *sliceTypeRef =
new (Context) MetatypeExpr(nullptr, Loc, new (Context) MetatypeExpr(nullptr, Loc,
MetatypeType::get(sliceType, Context)); MetatypeType::get(sliceType, Context));
// Build the expression "Slice<T>.convertFromHeapArray". // Build the expression "Array<T>.convertFromHeapArray".
Expr *injectionFn = new (Context) UnresolvedDotExpr( Expr *injectionFn = new (Context) UnresolvedDotExpr(
sliceTypeRef, Loc, sliceTypeRef, Loc,
Context.getIdentifier("convertFromHeapArray"), Context.getIdentifier("convertFromHeapArray"),
Loc, /*Implicit=*/true); Loc, /*Implicit=*/true);
if (typeCheckExpressionShallow(injectionFn, dc)) if (typeCheckExpressionShallow(injectionFn, dc))
return nullptr; return nullptr;
@@ -530,7 +530,7 @@ Type TypeChecker::getDefaultType(ProtocolDecl *protocol, DeclContext *dc) {
type = &FloatLiteralType; type = &FloatLiteralType;
name = "FloatLiteralType"; name = "FloatLiteralType";
} }
// ArrayLiteralConvertible -> Slice // ArrayLiteralConvertible -> Array
else if (protocol == getProtocol(SourceLoc(), else if (protocol == getProtocol(SourceLoc(),
KnownProtocolKind::ArrayLiteralConvertible)){ KnownProtocolKind::ArrayLiteralConvertible)){
type = &ArrayLiteralType; type = &ArrayLiteralType;

View File

@@ -413,7 +413,7 @@ void StmtBuilder::printReplExpr(VarDecl *Arg, Type SugarT, CanType T,
} }
if (BoundGenericStructType *BGST = dyn_cast<BoundGenericStructType>(T)) { if (BoundGenericStructType *BGST = dyn_cast<BoundGenericStructType>(T)) {
// FIXME: We have to hack Slice into here, because replPrint on Slice isn't // FIXME: We have to hack Array into here, because replPrint on Array isn't
// implementable yet. We don't want the T argument of the slice to be // implementable yet. We don't want the T argument of the slice to be
// constrained to being replPrintable. We need replPrint to be more // constrained to being replPrintable. We need replPrint to be more
// dynamically reflective in its implementation. // dynamically reflective in its implementation.
@@ -433,10 +433,10 @@ void StmtBuilder::printReplExpr(VarDecl *Arg, Type SugarT, CanType T,
} }
if (BoundGenericClassType *BGCT = dyn_cast<BoundGenericClassType>(T)) { if (BoundGenericClassType *BGCT = dyn_cast<BoundGenericClassType>(T)) {
// FIXME: We have to hack Slice into here, because replPrint on Dictionary // FIXME: We have to hack Dictionary into here, because replPrint on
// isn't implementable yet. We don't want the T argument of the dictionary // Dictionary isn't implementable yet. We don't want the T argument of the
// to be constrained to being replPrintable. We need replPrint to be more // dictionary to be constrained to being replPrintable. We need replPrint
// dynamically reflective in its implementation. // to be more dynamically reflective in its implementation.
if (!BGCT->getParent() && BGCT->getDecl()->getName().str() == "Dictionary"){ if (!BGCT->getParent() && BGCT->getDecl()->getName().str() == "Dictionary"){
printCollection(Arg, BGCT->getGenericArgs()[0], printCollection(Arg, BGCT->getGenericArgs()[0],
BGCT->getGenericArgs()[1], Loc, EndLoc, BGCT->getGenericArgs()[1], Loc, EndLoc,

View File

@@ -33,7 +33,7 @@ using namespace swift;
GenericTypeResolver::~GenericTypeResolver() { } GenericTypeResolver::~GenericTypeResolver() { }
Type TypeChecker::getArraySliceType(SourceLoc loc, Type elementType) { Type TypeChecker::getArraySliceType(SourceLoc loc, Type elementType) {
if (!Context.getSliceDecl()) { if (!Context.getArrayDecl()) {
diagnose(loc, diag::sugar_type_not_found, 0); diagnose(loc, diag::sugar_type_not_found, 0);
return Type(); return Type();
} }

View File

@@ -340,9 +340,9 @@ public:
/// ///
/// \returns The substituted type, or null if the substitution failed. /// \returns The substituted type, or null if the substitution failed.
/// ///
/// FIXME: We probably want to have both silent and loud failure modes. However, /// FIXME: We probably want to have both silent and loud failure modes.
/// the only possible failure now is from array slice types, which occur /// However, the only possible failure now is from array slice types, which
/// simply because we don't have Slice<T> yet. /// occur simply because we don't have Array<T> yet.
Type substType(Module *module, Type T, TypeSubstitutionMap &Substitutions, Type substType(Module *module, Type T, TypeSubstitutionMap &Substitutions,
bool IgnoreMissing = false); bool IgnoreMissing = false);