Merge pull request #99 from PhasicFlow/develop

modifications to typeInfo.hpp and type system
This commit is contained in:
PhasicFlow 2024-04-12 00:23:19 +03:30 committed by GitHub
commit 70c1afceec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 13 deletions

View File

@ -58,7 +58,8 @@ struct checkStatic
}; };
template <typename T> template <typename T>
inline word basicTypeName() inline
word basicTypeName()
{ {
int status; int status;
auto &ti = typeid(T); auto &ti = typeid(T);
@ -117,7 +118,8 @@ inline word basicTypeName<real>()
} }
template <typename T> template <typename T>
word constexpr getTypeName() inline
word getTypeName()
{ {
if constexpr (checkStatic<T>::hasMember()) if constexpr (checkStatic<T>::hasMember())
{ {
@ -130,7 +132,8 @@ word constexpr getTypeName()
} }
template <typename T> template <typename T>
word constexpr getTypeName(const T &) inline
word getTypeName(const T &)
{ {
if constexpr (checkStatic<T>::hasMember()) if constexpr (checkStatic<T>::hasMember())
{ {
@ -157,6 +160,32 @@ bool checkType(Type2 &object)
} }
} // namespace pFlow } // namespace pFlow
#define QuadrupleTypeInfoNV(T) \
inline static word TYPENAME() \
{ \
return getTypeName<T>()+"x4"; \
} \
word typeName() const \
{ \
return TYPENAME(); \
}
#define TripleTypeInfoNV(T) \
inline static word TYPENAME() \
{ \
return getTypeName<T>()+"x3"; \
} \
word typeName() const \
{ \
return TYPENAME(); \
}
#define ClassInfo(tName) \
inline static word TYPENAME() \
{ \
return tName; \
}
#define TypeInfo(tName) \ #define TypeInfo(tName) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \

View File

@ -22,7 +22,7 @@ Licence:
#include "builtinTypes.hpp" #include "builtinTypes.hpp"
#include "bTypesFunctions.hpp" #include "bTypesFunctions.hpp"
#include "typeInfo.hpp"
namespace pFlow namespace pFlow
@ -62,7 +62,15 @@ private:
public: public:
/// Type info /// Type info
TypeInfoNV("Logical"); inline static word TYPENAME()
{
return "Logical";
}
inline word typeName()const
{
return TYPENAME();
}
//// Constructors //// Constructors

View File

@ -22,6 +22,7 @@ Licence:
#define __quadruple_hpp__ #define __quadruple_hpp__
#include "error.hpp" #include "error.hpp"
#include "typeInfo.hpp"
#include "iIstream.hpp" #include "iIstream.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
#include "token.hpp" #include "token.hpp"
@ -40,14 +41,13 @@ class iIstream;
// you can see it as a sequence of four elements (w,x,y,z) or an (scalar and // you can see it as a sequence of four elements (w,x,y,z) or an (scalar and
// vector) // vector)
template<typename T> template<typename T>
class quadruple struct quadruple
{ {
public:
T s_; T s_;
triple<T> v_; triple<T> v_;
public:
QuadrupleTypeInfoNV(T);
//// constructors //// constructors
INLINE_FUNCTION_HD INLINE_FUNCTION_HD

View File

@ -22,6 +22,7 @@ Licence:
#include "pFlowMacros.hpp" #include "pFlowMacros.hpp"
#include "numericConstants.hpp" #include "numericConstants.hpp"
#include "typeInfo.hpp"
#include "uniquePtr.hpp" #include "uniquePtr.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
#include "iIstream.hpp" #include "iIstream.hpp"
@ -49,6 +50,7 @@ struct triple
T y_; T y_;
T z_; T z_;
TripleTypeInfoNV(T);
//// Constructors //// Constructors
/// Initilize to zero /// Initilize to zero

View File

@ -50,16 +50,16 @@ using realx4 = quadruple<real>;
using realx4x3 = quadruple<realx3>; using realx4x3 = quadruple<realx3>;
template<> /*template<>
inline word inline word
basicTypeName<int8x3>() triple<int8>::TYPENAME()
{ {
return "int8x3"; return "int8x3";
} }
template<> template<>
inline word inline word
basicTypeName<int32x3>() triple<int32>::TYPENAME()
{ {
return "int32x3"; return "int32x3";
} }
@ -132,7 +132,7 @@ inline word
basicTypeName<realx4x3>() basicTypeName<realx4x3>()
{ {
return "realx4x3"; return "realx4x3";
} }*/
extern const realx3 zero3; extern const realx3 zero3;
extern const realx3 one3; extern const realx3 one3;