@@ -54,6 +54,7 @@ namespace swift {
54
54
class GenericParamList ;
55
55
class GenericSignature ;
56
56
class Identifier ;
57
+ class InOutType ;
57
58
enum class ReferenceCounting : uint8_t ;
58
59
enum class ResilienceExpansion : unsigned ;
59
60
class SILModule ;
@@ -2627,9 +2628,13 @@ class AnyFunctionType : public TypeBase {
2627
2628
2628
2629
class Param {
2629
2630
public:
2630
- explicit Param (const TupleTypeElt &tte);
2631
- explicit Param (Type t, Identifier l, ParameterTypeFlags f);
2632
-
2631
+ explicit Param (Type t,
2632
+ Identifier l = Identifier(),
2633
+ ParameterTypeFlags f = ParameterTypeFlags())
2634
+ : Ty(t), Label(l), Flags(f) {
2635
+ assert (!t || !t->is <InOutType>() && " set flags instead" );
2636
+ }
2637
+
2633
2638
private:
2634
2639
// / The type of the parameter. For a variadic parameter, this is the
2635
2640
// / element type.
@@ -2642,14 +2647,10 @@ class AnyFunctionType : public TypeBase {
2642
2647
ParameterTypeFlags Flags = {};
2643
2648
2644
2649
public:
2645
- Type getType () const ;
2646
- CanType getCanType () const {
2647
- assert (getType ()->isCanonical ());
2648
- return CanType (getType ());
2649
- }
2650
-
2651
2650
// / FIXME(Remove InOutType): This is mostly for copying between param
2652
2651
// / types and should go away.
2652
+ Type getType () const ;
2653
+
2653
2654
Type getPlainType () const { return Ty; }
2654
2655
2655
2656
bool hasLabel () const { return !Label.empty (); }
@@ -2694,6 +2695,7 @@ class AnyFunctionType : public TypeBase {
2694
2695
static CanParam getFromParam (const Param ¶m) { return CanParam (param); }
2695
2696
2696
2697
CanType getType () const { return CanType (Param::getType ()); }
2698
+ CanType getPlainType () const { return CanType (Param::getPlainType ()); }
2697
2699
};
2698
2700
2699
2701
using CanParamArrayRef =
@@ -2890,7 +2892,7 @@ class AnyFunctionType : public TypeBase {
2890
2892
protected:
2891
2893
AnyFunctionType (TypeKind Kind, const ASTContext *CanTypeContext,
2892
2894
Type Input, Type Output, RecursiveTypeProperties properties,
2893
- unsigned NumParams, const ExtInfo & Info)
2895
+ unsigned NumParams, ExtInfo Info)
2894
2896
: TypeBase(Kind, CanTypeContext, properties), Input(Input), Output(Output) {
2895
2897
Bits.AnyFunctionType .ExtInfo = Info.Bits ;
2896
2898
Bits.AnyFunctionType .NumParams = NumParams;
@@ -2904,7 +2906,7 @@ class AnyFunctionType : public TypeBase {
2904
2906
public:
2905
2907
// / \brief Break an input type into an array of \c AnyFunctionType::Params.
2906
2908
static void decomposeInput (Type type,
2907
- SmallVectorImpl<AnyFunctionType:: Param> &result);
2909
+ SmallVectorImpl<Param> &result);
2908
2910
2909
2911
// / \brief Take an array of parameters and turn it into an input type.
2910
2912
// /
@@ -2918,15 +2920,14 @@ class AnyFunctionType : public TypeBase {
2918
2920
}
2919
2921
2920
2922
// / \brief Given two arrays of parameters determine if they are equal.
2921
- static bool equalParams (ArrayRef<AnyFunctionType::Param> a,
2922
- ArrayRef<AnyFunctionType::Param> b);
2923
+ static bool equalParams (ArrayRef<Param> a, ArrayRef<Param> b);
2923
2924
2924
2925
// / \brief Given two arrays of parameters determine if they are equal.
2925
2926
static bool equalParams (CanParamArrayRef a, CanParamArrayRef b);
2926
2927
2927
2928
Type getInput () const { return Input; }
2928
2929
Type getResult () const { return Output; }
2929
- ArrayRef<AnyFunctionType:: Param> getParams () const ;
2930
+ ArrayRef<Param> getParams () const ;
2930
2931
unsigned getNumParams () const { return Bits.AnyFunctionType .NumParams ; }
2931
2932
2932
2933
GenericSignature *getOptGenericSignature () const ;
@@ -2978,14 +2979,13 @@ BEGIN_CAN_TYPE_WRAPPER(AnyFunctionType, Type)
2978
2979
using ExtInfo = AnyFunctionType::ExtInfo;
2979
2980
using CanParamArrayRef = AnyFunctionType::CanParamArrayRef;
2980
2981
2981
- static CanAnyFunctionType get (CanGenericSignature signature,
2982
- CanType input, CanType result);
2983
- static CanAnyFunctionType get (CanGenericSignature signature,
2984
- CanType input, CanType result,
2985
- const ExtInfo &extInfo);
2982
+ static CanAnyFunctionType getOld (CanGenericSignature signature,
2983
+ CanType input, CanType result,
2984
+ ExtInfo extInfo = ExtInfo());
2986
2985
static CanAnyFunctionType get (CanGenericSignature signature,
2987
2986
CanParamArrayRef params,
2988
- CanType result, const ExtInfo &info);
2987
+ CanType result,
2988
+ ExtInfo info = ExtInfo());
2989
2989
2990
2990
CanGenericSignature getOptGenericSignature () const ;
2991
2991
@@ -3018,19 +3018,17 @@ class FunctionType final : public AnyFunctionType,
3018
3018
3019
3019
public:
3020
3020
// / 'Constructor' Factory Function
3021
- static FunctionType *get (Type Input, Type Result) {
3022
- return get (Input, Result, ExtInfo ());
3023
- }
3024
-
3025
- static FunctionType *get (Type Input, Type Result, const ExtInfo &Info);
3021
+ static FunctionType *getOld (Type Input, Type Result,
3022
+ ExtInfo Info = ExtInfo());
3026
3023
3027
- static FunctionType *get (ArrayRef<AnyFunctionType::Param> params,
3028
- Type result, const ExtInfo &info,
3024
+ static FunctionType *get (ArrayRef<Param> params,
3025
+ Type result,
3026
+ ExtInfo info = ExtInfo(),
3029
3027
bool canonicalVararg = false);
3030
3028
3031
3029
// Retrieve the input parameters of this function type.
3032
- ArrayRef<AnyFunctionType:: Param> getParams () const {
3033
- return {getTrailingObjects<AnyFunctionType:: Param>(), getNumParams ()};
3030
+ ArrayRef<Param> getParams () const {
3031
+ return {getTrailingObjects<Param>(), getNumParams ()};
3034
3032
}
3035
3033
3036
3034
// Implement isa/cast/dyncast/etc.
@@ -3039,23 +3037,19 @@ class FunctionType final : public AnyFunctionType,
3039
3037
}
3040
3038
3041
3039
private:
3042
- FunctionType (ArrayRef<AnyFunctionType:: Param> params,
3040
+ FunctionType (ArrayRef<Param> params,
3043
3041
Type Input, Type Result,
3044
3042
RecursiveTypeProperties properties,
3045
- const ExtInfo & Info);
3043
+ ExtInfo Info);
3046
3044
};
3047
3045
BEGIN_CAN_TYPE_WRAPPER (FunctionType, AnyFunctionType)
3048
- static CanFunctionType get(CanType input, CanType result) {
3049
- auto fnType = FunctionType::get (input, result);
3050
- return cast<FunctionType>(fnType->getCanonicalType ());
3051
- }
3052
- static CanFunctionType get (CanType input, CanType result,
3053
- const ExtInfo &info) {
3054
- auto fnType = FunctionType::get (input, result, info);
3046
+ static CanFunctionType getOld(CanType input, CanType result,
3047
+ ExtInfo info = ExtInfo()) {
3048
+ auto fnType = FunctionType::getOld (input, result, info);
3055
3049
return cast<FunctionType>(fnType->getCanonicalType ());
3056
3050
}
3057
3051
static CanFunctionType get (CanParamArrayRef params, CanType result,
3058
- const ExtInfo & info) {
3052
+ ExtInfo info = ExtInfo() ) {
3059
3053
auto fnType = FunctionType::get (params.getOriginalArray (),
3060
3054
result, info, /* canonicalVararg=*/ true );
3061
3055
return cast<FunctionType>(fnType->getCanonicalType ());
@@ -3100,30 +3094,30 @@ class GenericFunctionType final : public AnyFunctionType,
3100
3094
3101
3095
// / Construct a new generic function type.
3102
3096
GenericFunctionType (GenericSignature *sig,
3103
- ArrayRef<AnyFunctionType:: Param> params,
3097
+ ArrayRef<Param> params,
3104
3098
Type input,
3105
3099
Type result,
3106
- const ExtInfo & info,
3100
+ ExtInfo info,
3107
3101
const ASTContext *ctx,
3108
3102
RecursiveTypeProperties properties);
3109
3103
3110
3104
public:
3111
3105
// / Create a new generic function type.
3112
- static GenericFunctionType *get (GenericSignature *sig,
3113
- Type input,
3114
- Type result,
3115
- const ExtInfo & info);
3106
+ static GenericFunctionType *getOld (GenericSignature *sig,
3107
+ Type input,
3108
+ Type result,
3109
+ ExtInfo info = ExtInfo() );
3116
3110
3117
3111
// / Create a new generic function type.
3118
3112
static GenericFunctionType *get (GenericSignature *sig,
3119
3113
ArrayRef<Param> params,
3120
3114
Type result,
3121
- const ExtInfo & info,
3115
+ ExtInfo info = ExtInfo() ,
3122
3116
bool canonicalVararg = false);
3123
3117
3124
3118
// Retrieve the input parameters of this function type.
3125
- ArrayRef<AnyFunctionType:: Param> getParams () const {
3126
- return {getTrailingObjects<AnyFunctionType:: Param>(), getNumParams ()};
3119
+ ArrayRef<Param> getParams () const {
3120
+ return {getTrailingObjects<Param>(), getNumParams ()};
3127
3121
}
3128
3122
3129
3123
// / Retrieve the generic signature of this function type.
@@ -3149,7 +3143,7 @@ class GenericFunctionType final : public AnyFunctionType,
3149
3143
GenericSignature *sig,
3150
3144
Type input,
3151
3145
Type result,
3152
- const ExtInfo & info);
3146
+ ExtInfo info);
3153
3147
3154
3148
// Implement isa/cast/dyncast/etc.
3155
3149
static bool classof (const TypeBase *T) {
@@ -3158,19 +3152,20 @@ class GenericFunctionType final : public AnyFunctionType,
3158
3152
};
3159
3153
3160
3154
BEGIN_CAN_TYPE_WRAPPER (GenericFunctionType, AnyFunctionType)
3161
- static CanGenericFunctionType get (CanGenericSignature sig,
3162
- CanType input, CanType result,
3163
- const ExtInfo & info) {
3155
+ static CanGenericFunctionType getOld (CanGenericSignature sig,
3156
+ CanType input, CanType result,
3157
+ ExtInfo info = ExtInfo() ) {
3164
3158
// Knowing that the argument types are independently canonical is
3165
3159
// not sufficient to guarantee that the function type will be canonical.
3166
- auto fnType = GenericFunctionType::get (sig, input, result, info);
3160
+ auto fnType = GenericFunctionType::getOld (sig, input, result, info);
3167
3161
return cast<GenericFunctionType>(fnType->getCanonicalType ());
3168
3162
}
3169
3163
3170
3164
// / Create a new generic function type.
3171
3165
static CanGenericFunctionType get (CanGenericSignature sig,
3172
- CanParamArrayRef params, CanType result,
3173
- const ExtInfo &info) {
3166
+ CanParamArrayRef params,
3167
+ CanType result,
3168
+ ExtInfo info = ExtInfo()) {
3174
3169
// Knowing that the argument types are independently canonical is
3175
3170
// not sufficient to guarantee that the function type will be canonical.
3176
3171
auto fnType = GenericFunctionType::get (sig, params.getOriginalArray (),
@@ -3194,24 +3189,18 @@ BEGIN_CAN_TYPE_WRAPPER(GenericFunctionType, AnyFunctionType)
3194
3189
END_CAN_TYPE_WRAPPER (GenericFunctionType, AnyFunctionType)
3195
3190
3196
3191
inline CanAnyFunctionType
3197
- CanAnyFunctionType::get(CanGenericSignature signature,
3198
- CanType input, CanType result) {
3199
- return get (signature, input, result, ExtInfo ());
3200
- }
3201
-
3202
- inline CanAnyFunctionType
3203
- CanAnyFunctionType::get (CanGenericSignature signature,
3204
- CanType input, CanType result, const ExtInfo &extInfo) {
3192
+ CanAnyFunctionType::getOld(CanGenericSignature signature,
3193
+ CanType input, CanType result, ExtInfo extInfo) {
3205
3194
if (signature) {
3206
- return CanGenericFunctionType::get (signature, input, result, extInfo);
3195
+ return CanGenericFunctionType::getOld (signature, input, result, extInfo);
3207
3196
} else {
3208
- return CanFunctionType::get (input, result, extInfo);
3197
+ return CanFunctionType::getOld (input, result, extInfo);
3209
3198
}
3210
3199
}
3211
3200
3212
3201
inline CanAnyFunctionType
3213
3202
CanAnyFunctionType::get (CanGenericSignature signature, CanParamArrayRef params,
3214
- CanType result, const ExtInfo & extInfo) {
3203
+ CanType result, ExtInfo extInfo) {
3215
3204
if (signature) {
3216
3205
return CanGenericFunctionType::get (signature, params, result, extInfo);
3217
3206
} else {
0 commit comments