2010-06-28 14:07:55 +02:00
|
|
|
#ifndef INTERPRETER_TYPES_H_INCLUDED
|
|
|
|
#define INTERPRETER_TYPES_H_INCLUDED
|
|
|
|
|
2010-07-14 15:28:55 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2010-06-28 14:07:55 +02:00
|
|
|
namespace Interpreter
|
|
|
|
{
|
2023-01-12 22:51:54 +01:00
|
|
|
typedef std::uint32_t Type_Code;
|
2010-06-28 14:07:55 +02:00
|
|
|
|
2023-01-12 22:51:54 +01:00
|
|
|
typedef std::int16_t Type_Short;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2023-01-12 22:51:54 +01:00
|
|
|
typedef std::int32_t Type_Integer;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2023-01-12 22:51:54 +01:00
|
|
|
typedef float Type_Float;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-07-14 15:28:55 +02:00
|
|
|
union Data
|
|
|
|
{
|
|
|
|
Type_Integer mInteger;
|
|
|
|
Type_Float mFloat;
|
|
|
|
};
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-07-14 15:28:55 +02:00
|
|
|
template <typename T>
|
|
|
|
T& getData(Data& data)
|
|
|
|
{
|
|
|
|
throw std::runtime_error("unsupported data type");
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-07-14 15:28:55 +02:00
|
|
|
template <>
|
|
|
|
inline Type_Integer& getData(Data& data)
|
|
|
|
{
|
|
|
|
return data.mInteger;
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-07-14 15:28:55 +02:00
|
|
|
template <>
|
|
|
|
inline Type_Float& getData(Data& data)
|
|
|
|
{
|
|
|
|
return data.mFloat;
|
|
|
|
}
|
2010-06-28 14:07:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|