core: Associate data type with symbol, not ast node

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-02-16 03:39:07 -05:00
parent 995f40aa85
commit 1c2eed0a0d
3 changed files with 4 additions and 3 deletions

View File

@@ -472,7 +472,7 @@ parse_func(struct rifle_state *state, struct token *tok, struct ast_node **res)
}
/* Parse the return type */
if (parse_type(state, tok, &root->dtype) < 0) {
if (parse_type(state, tok, &symbol->dtype) < 0) {
return -1;
}

View File

@@ -21,7 +21,6 @@ typedef enum {
* Represents an abstract syntax tree node
*
* @type: Node type
* @dtype: Data type
* @left: Left leaf
* @right: Right leaf
* @symbol: Symbol associated with node
@@ -29,7 +28,6 @@ typedef enum {
*/
struct ast_node {
ast_type_t type;
struct data_type dtype;
struct ast_node *left;
struct ast_node *right;
struct symbol *symbol;

View File

@@ -3,6 +3,7 @@
#include <sys/queue.h>
#include <stdint.h>
#include "rifle/types.h"
/*
* Represents valid program symbol types
@@ -23,12 +24,14 @@ typedef enum {
* @name: Name of symbol
* @type: Type associated with symbol
* @pub: If set, symbol is public
* @dtype: Data type associated with symbol
* @link: Queue link
*/
struct symbol {
char *name;
symtype_t type;
uint8_t pub : 1;
struct data_type dtype;
TAILQ_ENTRY(symbol) link;
};