Skip to content

SE-0139: Bridge all standard number types to NSNumber. #4933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 5 additions & 64 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,48 +363,14 @@ class ASTContext {
ProtocolDecl *getErrorDecl() const;
CanType getExceptionType() const;

/// Retrieve the declaration of Swift.Bool.
NominalTypeDecl *getBoolDecl() const;

/// Retrieve the declaration of Swift.Int.
NominalTypeDecl *getIntDecl() const;

/// Retrieve the declaration of Swift.UInt.
NominalTypeDecl *getUIntDecl() const;

/// Retrieve the declaration of Swift.Float.
NominalTypeDecl *getFloatDecl() const;

/// Retrieve the declaration of Swift.Double.
NominalTypeDecl *getDoubleDecl() const;

/// Retrieve the declaration of Swift.String.
NominalTypeDecl *getStringDecl() const;

/// Retrieve the declaration of Swift.Array<T>.
NominalTypeDecl *getArrayDecl() const;

/// Retrieve the declaration of Swift.Set<T>.
NominalTypeDecl *getSetDecl() const;

/// Retrieve the declaration of Swift.Sequence<T>.
NominalTypeDecl *getSequenceDecl() const;

/// Retrieve the declaration of Swift.Dictionary<K, V>.
NominalTypeDecl *getDictionaryDecl() const;

/// Retrieve the declaration of Swift.AnyHashable.
NominalTypeDecl *getAnyHashableDecl() const;
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
/** Retrieve the declaration of Swift.NAME. */ \
DECL_CLASS *get##NAME##Decl() const;
#include "swift/AST/KnownStdlibTypes.def"

/// Retrieve the declaration of Swift.Optional or ImplicitlyUnwrappedOptional.
EnumDecl *getOptionalDecl(OptionalTypeKind kind) const;

/// Retrieve the declaration of Swift.Optional<T>.
EnumDecl *getOptionalDecl() const;

/// Retrieve the declaration of Swift.ImplicitlyUnwrappedOptional<T>.
EnumDecl *getImplicitlyUnwrappedOptionalDecl() const;

/// Retrieve the declaration of Swift.Optional<T>.Some.
EnumElementDecl *getOptionalSomeDecl() const;

Expand All @@ -420,35 +386,10 @@ class ASTContext {
EnumElementDecl *getOptionalSomeDecl(OptionalTypeKind kind) const;
EnumElementDecl *getOptionalNoneDecl(OptionalTypeKind kind) const;

/// Retrieve the declaration of Swift.OptionSet.
NominalTypeDecl *getOptionSetDecl() const;

/// Retrieve the declaration of Swift.COpaquePointer.
NominalTypeDecl *getOpaquePointerDecl() const;

/// Retrieve the declaration of Swift.UnsafeMutableRawPointer.
NominalTypeDecl *getUnsafeMutableRawPointerDecl() const;

/// Retrieve the declaration of Swift.UnsafeRawPointer.
NominalTypeDecl *getUnsafeRawPointerDecl() const;

/// Retrieve the declaration of Swift.UnsafeMutablePointer<T>.
NominalTypeDecl *getUnsafeMutablePointerDecl() const;

/// Retrieve the declaration of Swift.UnsafePointer<T>.
NominalTypeDecl *getUnsafePointerDecl() const;

/// Retrieve the declaration of Swift.AutoreleasingUnsafeMutablePointer<T>.
NominalTypeDecl *getAutoreleasingUnsafeMutablePointerDecl() const;

/// Retrieve the declaration of Swift.Unmanaged<T>.
NominalTypeDecl *getUnmanagedDecl() const;

/// Retrieve the declaration of the "pointee" property of a pointer type.
VarDecl *getPointerPointeePropertyDecl(PointerTypeKind ptrKind) const;

/// Retrieve the declaration of Swift.Never.
NominalTypeDecl *getNeverDecl() const;
/// Retrieve the type Swift.Never.
CanType getNeverType() const;

/// Retrieve the declaration of Swift.Void.
Expand Down
68 changes: 68 additions & 0 deletions include/swift/AST/KnownStdlibTypes.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//===--- KnownStdlibTypes.cpp - Common standard library types -------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This xmacro generates code for common standard library types the compiler
// has special knowledge of.
//
//===----------------------------------------------------------------------===//

#ifndef KNOWN_STDLIB_TYPE_DECL
/// KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS)
///
/// The macro is expanded for each known standard library type. NAME is
/// bound to the unqualified name of the type. DECL_CLASS is bound to the
/// Decl subclass it is expected to be an instance of. NUM_GENERIC_PARAMS is
/// bound to the number of generic parameters the type is expected to have.
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS)
#endif

KNOWN_STDLIB_TYPE_DECL(Bool, NominalTypeDecl, 0)

KNOWN_STDLIB_TYPE_DECL(Int, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Int64, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Int32, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Int16, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Int8, NominalTypeDecl, 0)

KNOWN_STDLIB_TYPE_DECL(UInt, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UInt64, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UInt32, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UInt16, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UInt8, NominalTypeDecl, 0)

KNOWN_STDLIB_TYPE_DECL(Float, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Double, NominalTypeDecl, 0)

KNOWN_STDLIB_TYPE_DECL(String, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(Array, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(Set, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(Sequence, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(Dictionary, NominalTypeDecl, 2)
KNOWN_STDLIB_TYPE_DECL(AnyHashable, NominalTypeDecl, 0)

KNOWN_STDLIB_TYPE_DECL(Optional, EnumDecl, 1)
KNOWN_STDLIB_TYPE_DECL(ImplicitlyUnwrappedOptional, EnumDecl, 1)

KNOWN_STDLIB_TYPE_DECL(OptionSet, NominalTypeDecl, 1)

KNOWN_STDLIB_TYPE_DECL(UnsafeMutableRawPointer, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UnsafeRawPointer, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(UnsafeMutablePointer, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(UnsafePointer, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(OpaquePointer, NominalTypeDecl, 0)
KNOWN_STDLIB_TYPE_DECL(AutoreleasingUnsafeMutablePointer, NominalTypeDecl, 1)

KNOWN_STDLIB_TYPE_DECL(Unmanaged, NominalTypeDecl, 1)

KNOWN_STDLIB_TYPE_DECL(Never, NominalTypeDecl, 0)

#undef KNOWN_STDLIB_TYPE_DECL
Loading