From 8ee23054bf771e56802ce21d70229b7f8f2e9654 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 15 Sep 2024 17:34:34 -0400 Subject: Update Inline C syntax and documentation/tests --- compile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 3aeebfd6..61947d51 100644 --- a/compile.c +++ b/compile.c @@ -1354,7 +1354,13 @@ CORD compile_statement(env_t *env, ast_t *ast) return compile_statement(env, loop); } case Extern: return CORD_EMPTY; - case InlineCCode: return Match(ast, InlineCCode)->code; + case InlineCCode: { + auto inline_code = Match(ast, InlineCCode); + if (inline_code->type) + return CORD_all("({ ", inline_code->code, "; })"); + else + return inline_code->code; + } case Use: { auto use = Match(ast, Use); if (use->what == USE_LOCAL) { @@ -3232,7 +3238,7 @@ CORD compile(env_t *env, ast_t *ast) if (t->tag == VoidType) return CORD_all("{\n", Match(ast, InlineCCode)->code, "\n}"); else - return Match(ast, InlineCCode)->code; + return CORD_all("({ ", Match(ast, InlineCCode)->code, "; })"); } case Use: code_err(ast, "Compiling 'use' as expression!"); case Defer: code_err(ast, "Compiling 'defer' as expression!"); -- cgit v1.2.3