parser+backend: Add support for public symbols
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
@@ -18,7 +18,7 @@ resolve_func(struct rifle_state *state, struct ast_node *root)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return mu_gen_label(state, symbol->name);
|
||||
return mu_gen_label(state, symbol->name, symbol->pub);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "rifle/parser.h"
|
||||
#include "rifle/token.h"
|
||||
#include "rifle/trace.h"
|
||||
@@ -402,8 +403,10 @@ parse_lbrace(struct rifle_state *state, tt_t scope, struct token *tok)
|
||||
static int
|
||||
parse_func(struct rifle_state *state, struct token *tok, struct ast_node **res)
|
||||
{
|
||||
struct token *prevtok;
|
||||
struct ast_node *root;
|
||||
struct symbol *symbol;
|
||||
bool is_pub = false;
|
||||
int error;
|
||||
|
||||
if (state == NULL || tok == NULL) {
|
||||
@@ -418,6 +421,12 @@ parse_func(struct rifle_state *state, struct token *tok, struct ast_node **res)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Is this marked as public? */
|
||||
if ((prevtok = tokbuf_lookbehind(&state->tokbuf, 1)) != NULL) {
|
||||
if (prevtok->type == TT_PUB)
|
||||
is_pub = true;
|
||||
}
|
||||
|
||||
/* EXPECT <IDENT> */
|
||||
if (parse_expect(state, TT_IDENT, tok) < 0) {
|
||||
return -1;
|
||||
@@ -440,6 +449,7 @@ parse_func(struct rifle_state *state, struct token *tok, struct ast_node **res)
|
||||
return -1;
|
||||
}
|
||||
|
||||
symbol->pub = is_pub;
|
||||
root->symbol = symbol;
|
||||
|
||||
/* EXPECT '(' */
|
||||
|
||||
Reference in New Issue
Block a user