66 lines
1.2 KiB
C
66 lines
1.2 KiB
C
#pragma once
|
|
#include "../std.h"
|
|
#include "../string/str.h"
|
|
#include "../instructions/instructions.h"
|
|
#include "../instructions/registers.h"
|
|
#include "../collections/List.h"
|
|
|
|
typedef enum ArgumentType {
|
|
ArgumentType_Unset,
|
|
ArgumentType_Register,
|
|
ArgumentType_ConstValue,
|
|
ArgumentType_VarDataName,
|
|
ArgumentType_ConstDataPointer,
|
|
ArgumentType_ConstDataSize,
|
|
} ArgumentType;
|
|
|
|
str ArgumentType_toString(ArgumentType t);
|
|
|
|
typedef struct Argument {
|
|
ArgumentType type;
|
|
union {
|
|
i64 i;
|
|
f64 f;
|
|
str data_name;
|
|
RegisterCode register_code;
|
|
} value;
|
|
} Argument;
|
|
|
|
List_declare(Argument);
|
|
|
|
|
|
typedef struct Operation {
|
|
List_Argument args;
|
|
Opcode opcode;
|
|
} Operation;
|
|
|
|
List_declare(Operation);
|
|
|
|
|
|
typedef struct DataDefinition {
|
|
str name;
|
|
List_u8 data;
|
|
u32 element_size;
|
|
} DataDefinition;
|
|
|
|
List_declare(DataDefinition);
|
|
|
|
|
|
typedef struct Section {
|
|
str name;
|
|
List_DataDefinition data;
|
|
List_Operation code;
|
|
} Section;
|
|
|
|
List_declare(Section);
|
|
|
|
void Section_init(Section* Section, str name);
|
|
void Section_free(Section* Section);
|
|
|
|
typedef struct AST {
|
|
List_Section sections;
|
|
} AST;
|
|
|
|
void AST_init(AST* ast);
|
|
void AST_free(AST* ast);
|