From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang v1] codegen: allow function call at the block level
Date: Thu, 17 Oct 2024 00:46:27 +0000 (UTC) [thread overview]
Message-ID: <20241017004619.294274-1-carlos@maniero.me> (raw)
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
next reply other threads:[~2024-10-17 0:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 0:46 Carlos Maniero [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241017004619.294274-1-carlos@maniero.me \
--to=carlos@maniero.me \
--cc=~johnnyrichard/olang-devel@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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