From 99d57398863ab1734a9f81c2d336f82dab556383 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 24 May 2026 18:39:19 +0200 Subject: Emit c-header pragmas as includes Signed-off-by: Mel --- boot/lower.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/boot/lower.c b/boot/lower.c index 65eb18c..c72ad97 100644 --- a/boot/lower.c +++ b/boot/lower.c @@ -783,13 +783,25 @@ lower_pass_1_fill_bodies(struct Lower_Context* ctx, struct Tree* tree) } if (stmt->kind == TREE_STATEMENT_PRAGMA) { - lower_push_error( - ctx->unit, - (struct Lower_Error){ - .kind = LOWER_ERROR_UNIMPLEMENTED, - .span = stmt->span, - .detail = string_from_static_c_string("top-level pragmas"), - }); + for (struct Tree_Pragma* pragma = stmt->value.pragma.inner; pragma; + pragma = pragma->next) { + if (pragma->type == TREE_PRAGMA_C_HEADER && pragma->argument_count >= 1 + && pragma->arguments[0].type == TREE_PRAGMA_ARGUMENT_NAME_OR_STRING) { + struct Import import = { + .path = pragma->arguments[0].value.name_or_string, + .span = pragma->span, + }; + array_push(&ctx->unit->imports, &import); + } else { + lower_push_error( + ctx->unit, + (struct Lower_Error){ + .kind = LOWER_ERROR_UNIMPLEMENTED, + .span = pragma->span, + .detail = string_from_static_c_string("this pragma kind"), + }); + } + } continue; } -- cgit 1.4.1