#ifndef DATATYPE_H
#define DATATYPE_H

#include <stdbool.h>

#define DT_INT 0
#define DT_FLOAT 1
#define DT_BOOL 2
#define DT_VOID 3
#define DT_STRUCT 4

typedef struct {
    unsigned int type : 4;
    unsigned int pointers : 4;
    unsigned int structId : 24;
} DataType;

typedef struct {
    const char* name;
    DataType type;
} StructVariable;

typedef struct {
    const char* name;
    int id;
    int amount;
    StructVariable* vars;
} Struct;

typedef struct {
    int capacity;
    int entries;
    Struct* data;
} Structs;

typedef struct {
    int array;
    int offset;
} Pointer;

int dtGetSize(DataType dt, Structs* sts);

DataType dtInt();
DataType dtFloat();
DataType dtBool();
DataType dtVoid();
DataType dtStruct(Struct* st);

DataType dtReference(DataType dt);
DataType dtDereference(DataType dt);
bool dtIsPointer(DataType dt);
Struct* dtGetStruct(Structs* sts, DataType dt);
DataType dtToVariable(DataType dt);
bool dtRemoveVariable(DataType* dt);

bool dtCompare(DataType a, DataType b);
int dtMaxDimensions();
const char* dtGetName(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);

#endif