MalachScript/src/CoreData/PrimitiveTypes.hpp

77 lines
4.7 KiB
C++

#ifndef MALACHSCRIPT_PRIMITIVETYPES_HPP
#define MALACHSCRIPT_PRIMITIVETYPES_HPP
#include <string>
#include "../Binder/BoundType.hpp"
#include "Identifier.hpp"
#if !__cpp_constinit
#define constinit constexpr
#endif
namespace MalachScript {
static constinit Identifier _voidName = "void";
static constinit Identifier _intName = "int";
static constinit Identifier _int8Name = "int8";
static constinit Identifier _int16Name = "int16";
static constinit Identifier _int32Name = "int32";
static constinit Identifier _int64Name = "int64";
static constinit Identifier _uintName = "uint";
static constinit Identifier _uint8Name = "uint8";
static constinit Identifier _uint16Name = "uint16";
static constinit Identifier _uint32Name = "uint32";
static constinit Identifier _uint64Name = "uint64";
static constinit Identifier _floatName = "float";
static constinit Identifier _doubleName = "double";
static constinit Identifier _boolName = "bool";
static constinit Identifier _autoName = "auto";
static Binder::BoundType _int8Type = Binder::BoundType(_int8Name, ClassAttr::None, sizeof(int8_t));
static Binder::BoundType _int16Type = Binder::BoundType(_int16Name, ClassAttr::None, sizeof(int16_t));
static Binder::BoundType _int32Type = Binder::BoundType(_int32Name, ClassAttr::None, sizeof(int32_t));
static Binder::BoundType _int64Type = Binder::BoundType(_int64Name, ClassAttr::None, sizeof(int64_t));
static Binder::BoundType _uint8Type = Binder::BoundType(_uint8Name, ClassAttr::None, sizeof(uint8_t));
static Binder::BoundType _uint16Type = Binder::BoundType(_uint16Name, ClassAttr::None, sizeof(uint16_t));
static Binder::BoundType _uint32Type = Binder::BoundType(_uint32Name, ClassAttr::None, sizeof(uint32_t));
static Binder::BoundType _uint64Type = Binder::BoundType(_uint64Name, ClassAttr::None, sizeof(uint64_t));
static Binder::BoundType _floatType = Binder::BoundType(_floatName, ClassAttr::None, sizeof(float));
static Binder::BoundType _doubleType = Binder::BoundType(_doubleName, ClassAttr::None, sizeof(double));
static Binder::BoundType _boolType = Binder::BoundType(_boolName, ClassAttr::None, sizeof(uint8_t));
class PrimitiveTypes {
public:
constexpr static const Identifier& VoidName() noexcept { return _voidName; }
constexpr static const Identifier& IntName() noexcept { return _intName; }
constexpr static const Identifier& Int8Name() noexcept { return _int8Name; }
constexpr static const Identifier& Int16Name() noexcept { return _int16Name; }
constexpr static const Identifier& Int32Name() noexcept { return _int32Name; }
constexpr static const Identifier& Int64Name() noexcept { return _int64Name; }
constexpr static const Identifier& UintName() noexcept { return _uintName; }
constexpr static const Identifier& Uint8Name() noexcept { return _uint8Name; }
constexpr static const Identifier& Uint16Name() noexcept { return _uint16Name; }
constexpr static const Identifier& Uint32Name() noexcept { return _uint32Name; }
constexpr static const Identifier& Uint64Name() noexcept { return _uint64Name; }
constexpr static const Identifier& FloatName() noexcept { return _floatName; }
constexpr static const Identifier& DoubleName() noexcept { return _doubleName; }
constexpr static const Identifier& BoolName() noexcept { return _boolName; }
constexpr static const Identifier& AutoName() noexcept { return _autoName; }
constexpr static const Binder::BoundType* IntType() noexcept { return &_int32Type; }
constexpr static const Binder::BoundType* Int8Type() noexcept { return &_int8Type; }
constexpr static const Binder::BoundType* Int16Type() noexcept { return &_int16Type; }
constexpr static const Binder::BoundType* Int32Type() noexcept { return &_int32Type; }
constexpr static const Binder::BoundType* Int64Type() noexcept { return &_int64Type; }
constexpr static const Binder::BoundType* UintType() noexcept { return &_uint32Type; }
constexpr static const Binder::BoundType* Uint8Type() noexcept { return &_uint8Type; }
constexpr static const Binder::BoundType* Uint16Type() noexcept { return &_uint16Type; }
constexpr static const Binder::BoundType* Uint32Type() noexcept { return &_uint32Type; }
constexpr static const Binder::BoundType* Uint64Type() noexcept { return &_uint64Type; }
constexpr static const Binder::BoundType* FloatType() noexcept { return &_floatType; }
constexpr static const Binder::BoundType* DoubleType() noexcept { return &_doubleType; }
constexpr static const Binder::BoundType* BoolType() noexcept { return &_boolType; }
};
}
#endif // MALACHSCRIPT_PRIMITIVETYPES_HPP