diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 17:34:34 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 17:34:34 -0400 |
| commit | 8ee23054bf771e56802ce21d70229b7f8f2e9654 (patch) | |
| tree | 58b7ac43f523ed1de1e8b5f49b6465d376c88843 /compile.c | |
| parent | 3cbc62ee43737e3afae0dd2e6597ff703689634e (diff) | |
Update Inline C syntax and documentation/tests
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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!"); |
