1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef DATATYPE_H
- #define DATATYPE_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdbool.h>
- #include "Types.h"
- #define VT_NOT_SET 0
- #define VT_INT 1
- #define VT_FLOAT 2
- #define VT_POINTER 3
- #define VT_ARRAY 4
- typedef struct {
- unsigned int type : 4;
- unsigned int offset : 28;
- union {
- int intValue;
- float 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;
- 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
|