aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-18 16:31:34 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-18 16:31:34 -0400
commit1df26851d73e50407a3b7c79bcdb5b0cc053fe67 (patch)
treec2e3c393b30ab34d782fd6839100c6854abd7e91 /compile.c
parente439fcd1e2090ff797b46c80c6264f08ea9e9cfb (diff)
Add syntax for "inline C(...)"
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 99e7d77b..0e73eaa1 100644
--- a/compile.c
+++ b/compile.c
@@ -1940,7 +1940,13 @@ CORD compile(env_t *env, ast_t *ast)
default: code_err(ast, "Indexing is not supported for type: %T", container_t);
}
}
- case InlineCCode: return Match(ast, InlineCCode)->code;
+ case InlineCCode: {
+ type_t *t = get_type(env, ast);
+ if (t->tag == VoidType)
+ return CORD_all("{\n", Match(ast, InlineCCode)->code, "\n}");
+ else
+ return Match(ast, InlineCCode)->code;
+ }
case Use: return CORD_EMPTY;
case LinkerDirective: code_err(ast, "Linker directives are not supported yet");
case Extern: code_err(ast, "Externs are not supported as expressions");