From 7f29d50e4558a700b7611dc72e87e7922ac6a345 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 25 Aug 2025 00:31:25 +0900 Subject: feat: support static function --- src/parse.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index 882d769..7750f40 100644 --- a/src/parse.c +++ b/src/parse.c @@ -519,8 +519,16 @@ BOOL is_type_token(Parser* p, Token* token) { Type* parse_type(Parser* p) { Token* t = next_token(p); - if (t->kind == TokenKind_keyword_const || t->kind == TokenKind_keyword_static) { - t = next_token(p); + BOOL has_static = FALSE; + while (1) { + if (t->kind == TokenKind_keyword_const) { + t = next_token(p); + } else if (t->kind == TokenKind_keyword_static) { + t = next_token(p); + has_static = TRUE; + } else { + break; + } } if (!is_type_token(p, t)) { fatal_error("%s:%d: parse_type: expected type, but got '%s'", t->loc.filename, t->loc.line, token_stringify(t)); @@ -578,6 +586,7 @@ Type* parse_type(Parser* p) { } ty = type_new_ptr(ty); } + ty->is_static = has_static; return ty; } @@ -1254,6 +1263,7 @@ AstNode* parse_func_decl_or_def(Parser* p) { func->node_stack_size = p->lvars.data[p->lvars.len - 1].stack_offset + type_sizeof(p->lvars.data[p->lvars.len - 1].ty); } + func->node_function_is_static = ty->is_static; return func; } -- cgit v1.2.3-70-g09d2