* [PATCH olang v1] codegen: allow function call at the block level
@ 2024-10-17 0:46 Carlos Maniero
2024-10-17 0:47 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-17 18:54 ` [PATCH olang v1] codegen: allow function call at the block level Johnny Richard
0 siblings, 2 replies; 3+ messages in thread
From: Carlos Maniero @ 2024-10-17 0:46 UTC (permalink / raw)
To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero
The extern test was also renamed to match its intention.
Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
src/codegen_x86_64.c | 3 ++-
...037_variable_overflow.ol => 0037_extern_call.ol} | 13 ++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
rename tests/olc/{0037_variable_overflow.ol => 0037_extern_call.ol} (82%)
diff --git a/src/codegen_x86_64.c b/src/codegen_x86_64.c
index c4cef3c..deb7e24 100644
--- a/src/codegen_x86_64.c
+++ b/src/codegen_x86_64.c
@@ -745,7 +745,8 @@ codegen_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block)
break;
}
- case AST_NODE_BINARY_OP: {
+ case AST_NODE_BINARY_OP:
+ case AST_NODE_FN_CALL: {
codegen_x86_64_emit_expression(codegen, node);
break;
}
diff --git a/tests/olc/0037_variable_overflow.ol b/tests/olc/0037_extern_call.ol
similarity index 82%
rename from tests/olc/0037_variable_overflow.ol
rename to tests/olc/0037_extern_call.ol
index be36e77..68fe139 100644
--- a/tests/olc/0037_variable_overflow.ol
+++ b/tests/olc/0037_extern_call.ol
@@ -16,12 +16,14 @@
extern fn putchar(c: u32): u32
fn main(): u32 {
- return putchar(111)
+ putchar(111)
+
+ return 0
}
# TEST test_compile(exit_code=0)
#
-# TEST test_run_binary(exit_code=111)
+# TEST test_run_binary(exit_code=0)
#
# TEST test_ast WITH
# Translation_Unit
@@ -29,11 +31,12 @@ fn main(): u32 {
# | `-Param_Definition <name:c> <type:u32>
# `-Function_Definition <name:main> <return:u32>
# `-Block
+# |-Function_Call <name:putchar>
+# | `-Literal <kind:u32> <value:111>
# `-Return_Statement
-# `-Function_Call <name:putchar>
-# `-Literal <kind:u32> <value:111>
+# `-Literal <kind:u32> <value:0>
# END
#
# TEST test_contains_tokens WITH
-# ./0037_variable_overflow.ol:16:1: <extern>
+# ./0037_extern_call.ol:16:1: <extern>
# END
base-commit: 9c38120024f10cbfcedb8525ea7bd6c98d7f7b1e
--
2.46.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-17 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17 0:46 [PATCH olang v1] codegen: allow function call at the block level Carlos Maniero
2024-10-17 0:47 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-17 18:54 ` [PATCH olang v1] codegen: allow function call at the block level Johnny Richard
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox