Add register and number values to AST nodes

This commit is contained in:
omicron 2025-04-14 23:55:09 +02:00
parent 2cf69f5e18
commit dcf90b72e0

View File

@ -1,6 +1,7 @@
#ifndef INCLUDE_SRC_AST_H_ #ifndef INCLUDE_SRC_AST_H_
#define INCLUDE_SRC_AST_H_ #define INCLUDE_SRC_AST_H_
#include "data/registers.h"
#include "error.h" #include "error.h"
#include "lexer.h" #include "lexer.h"
#include "tokenlist.h" #include "tokenlist.h"
@ -63,6 +64,16 @@ constexpr size_t node_default_children_cap = 8;
/* 65K ought to be enough for anybody */ /* 65K ought to be enough for anybody */
constexpr size_t node_max_children_cap = 1 << 16; constexpr size_t node_max_children_cap = 1 << 16;
typedef struct number {
uint64_t value;
operand_size_t size;
} number_t;
typedef struct register_ {
register_id_t id;
operand_size_t size;
} register_t;
struct ast_node { struct ast_node {
node_id_t id; node_id_t id;
tokenlist_entry_t *token_entry; tokenlist_entry_t *token_entry;
@ -71,11 +82,8 @@ struct ast_node {
ast_node_t **children; ast_node_t **children;
union { union {
struct { register_t reg;
uint64_t value; number_t number;
int size;
} integer;
char *name;
} value; } value;
}; };