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
|
|
|
|
{
|
|
|
|
typedef unsigned int Type_Code; // 32 bit
|
|
|
|
|
2010-06-28 16:48:19 +02:00
|
|
|
typedef unsigned int Type_Data; // 32 bit
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-06-28 20:07:17 +02:00
|
|
|
typedef short Type_Short; // 16 bit
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-06-28 18:27:45 +02:00
|
|
|
typedef int Type_Integer; // 32 bit
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2010-06-28 18:27:45 +02:00
|
|
|
typedef float Type_Float; // 32 bit
|
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
|