mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Try fixing mingw build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127153 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c9320426e
commit
a36be82664
@ -19,29 +19,6 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// \brief Statically get an integer for a type. For:
|
|
||||||
/// @code
|
|
||||||
/// PointerUnionTypeNum<PT1, PT2>::template NumFor<T>::Result
|
|
||||||
/// @endcode
|
|
||||||
/// Result will be 0 if T is PT1, 1 if it is PT2, and -1 otherwise.
|
|
||||||
template <typename PT1, typename PT2>
|
|
||||||
struct PointerUnionTypeNum {
|
|
||||||
private:
|
|
||||||
struct IsNeither { char x; };
|
|
||||||
struct IsPT1 { char x[2]; };
|
|
||||||
struct IsPT2 { char x[3]; };
|
|
||||||
|
|
||||||
static IsPT1 determine(PT1 *P);
|
|
||||||
static IsPT2 determine(PT2 *P);
|
|
||||||
static IsNeither determine(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
template <typename T>
|
|
||||||
struct NumFor {
|
|
||||||
static const int Result = (int)sizeof(determine((T*)0)) - 2;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct PointerUnionTypeSelectorReturn {
|
struct PointerUnionTypeSelectorReturn {
|
||||||
typedef T Return;
|
typedef T Return;
|
||||||
@ -105,6 +82,16 @@ namespace llvm {
|
|||||||
PointerUnionUIntTraits<PT1,PT2> > ValTy;
|
PointerUnionUIntTraits<PT1,PT2> > ValTy;
|
||||||
private:
|
private:
|
||||||
ValTy Val;
|
ValTy Val;
|
||||||
|
|
||||||
|
struct IsPT1 {
|
||||||
|
static const int Num = 0;
|
||||||
|
};
|
||||||
|
struct IsPT2 {
|
||||||
|
static const int Num = 1;
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
struct UNION_DOESNT_CONTAIN_TYPE { };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PointerUnion() {}
|
PointerUnion() {}
|
||||||
|
|
||||||
@ -127,10 +114,11 @@ namespace llvm {
|
|||||||
/// is<T>() return true if the Union currently holds the type matching T.
|
/// is<T>() return true if the Union currently holds the type matching T.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int is() const {
|
int is() const {
|
||||||
static const int TyNo =
|
typedef typename
|
||||||
::llvm::PointerUnionTypeNum<PT1, PT2>::template NumFor<T>::Result;
|
::llvm::PointerUnionTypeSelector<PT1, T, IsPT1,
|
||||||
char TYPE_IS_NOT_IN_UNION[TyNo*2+1]; // statically check the type.
|
::llvm::PointerUnionTypeSelector<PT2, T, IsPT2,
|
||||||
(void)TYPE_IS_NOT_IN_UNION;
|
UNION_DOESNT_CONTAIN_TYPE<T> > >::Return Ty;
|
||||||
|
int TyNo = Ty::Num;
|
||||||
return static_cast<int>(Val.getInt()) == TyNo;
|
return static_cast<int>(Val.getInt()) == TyNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user