123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #ifndef DATATYPE_H
- #define DATATYPE_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdbool.h>
- #include "Check.h"
- #include "Types.h"
- typedef enum {
- VT_INVALID = 0,
- VT_NOT_SET,
- VT_INT,
- VT_FLOAT,
- VT_POINTER,
- VT_ARRAY,
- VT_LAST
- } ValueType;
- typedef struct {
- uint32 typeAndOffset;
- union {
- int32 intValue;
- float32 floatValue;
- } data;
- } Value;
- #define DT_INT 0
- #define DT_FLOAT 1
- #define DT_VOID 2
- #define DT_STRUCT 3
- typedef struct {
- uint8 type : 7;
- uint8 pointer : 1;
- uint8 array;
- uint16 structId;
- } DataType;
- typedef struct {
- const char* name;
- DataType type;
- char padding[sizeof(const char*) - sizeof(DataType)];
- } StructVariable;
- typedef struct {
- const char* name;
- uint16 id;
- char padding[2];
- int amount;
- StructVariable* vars;
- } Struct;
- typedef struct {
- int capacity;
- int entries;
- Struct* data;
- } Structs;
- const char* vtGetName(ValueType vt);
- ValueType vGetType(Value v);
- check_return bool vSetType(Value* v, ValueType vt);
- uint32 vGetOffset(Value v);
- check_return bool vSetOffset(Value* v, uint32 offset);
- int dtGetSize(DataType dt, const Structs* sts);
- DataType dtInt(void);
- DataType dtFloat(void);
- DataType dtVoid(void);
- DataType dtStruct(const Struct* st);
- DataType dtText(void);
- DataType dtToArray(DataType dt);
- DataType dtRemoveArray(DataType dt);
- Struct* dtGetStruct(const Structs* sts, DataType dt);
- DataType dtToPointer(DataType dt);
- bool dtRemovePointer(DataType* dt);
- bool dtCompare(DataType a, DataType b);
- bool dtIsInt(DataType dt);
- bool dtIsFloat(DataType dt);
- bool dtIsVoid(DataType dt);
- bool dtIsArray(DataType dt);
- const char* dtGetName(const Structs* sts, DataType dt);
- void stAddVariable(Struct* st, const char* name, DataType type);
- void stsInit(Structs* sts);
- void stsDelete(Structs* sts);
- Struct* stsSearch(Structs* sts, const char* name);
- Struct* stsAdd(Structs* sts, const char* name);
- void gstsInit(void);
- void gstsDelete(void);
- Structs* gstsGet(void);
- Struct* gstsAdd(const char* name);
- #ifdef __cplusplus
- }
- #endif
- #endif
|