From 002a7df5091db3c04190e6ece2707a300deaf260 Mon Sep 17 00:00:00 2001 From: mlokr Date: Sat, 15 Jun 2024 09:37:19 +0200 Subject: [PATCH] adding more elaborate directive example --- hblang/examples/directives.hb | 10 +++++++++- hblang/tests/codegen_tests_different_types.txt | 2 +- hblang/tests/codegen_tests_directives.txt | 2 +- hblang/tests/codegen_tests_example.txt | 2 +- hblang/tests/codegen_tests_fb_driver.txt | 2 +- hblang/tests/codegen_tests_if_statements.txt | 2 +- hblang/tests/codegen_tests_structs.txt | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hblang/examples/directives.hb b/hblang/examples/directives.hb index b371db42..c4caf9cd 100644 --- a/hblang/examples/directives.hb +++ b/hblang/examples/directives.hb @@ -4,5 +4,13 @@ Type := struct { } main := fn(): int { - return @eca(int, 1, Type.(10, 20), @sizeof(Type), @alignof(Type), 5, 6); + byte := @as(u8, 10); + same_type_as_byte := @as(@TypeOf(byte), 30); + wide_uint := @as(u32, 40); + truncated_uint := @as(u8, @intcast(wide_uint)); + size_of_Type_in_bytes := @sizeof(Type); + align_of_Type_in_bytes := @alignof(Type); + hardcoded_pointer := @as(^u8, @bitcast(10)); + ecall_that_returns_int := @eca(int, 1, Type.(10, 20), 5, 6); + return 0; } diff --git a/hblang/tests/codegen_tests_different_types.txt b/hblang/tests/codegen_tests_different_types.txt index d6f5ec3d..13fe3f06 100644 --- a/hblang/tests/codegen_tests_different_types.txt +++ b/hblang/tests/codegen_tests_different_types.txt @@ -1,3 +1,3 @@ -code size: 477 +code size: 471 ret: 512 status: Ok(()) diff --git a/hblang/tests/codegen_tests_directives.txt b/hblang/tests/codegen_tests_directives.txt index 0c040308..831d0486 100644 --- a/hblang/tests/codegen_tests_directives.txt +++ b/hblang/tests/codegen_tests_directives.txt @@ -1,4 +1,4 @@ ev: Ecall -code size: 182 +code size: 235 ret: 0 status: Ok(()) diff --git a/hblang/tests/codegen_tests_example.txt b/hblang/tests/codegen_tests_example.txt index 93fa5415..b1b92cc2 100644 --- a/hblang/tests/codegen_tests_example.txt +++ b/hblang/tests/codegen_tests_example.txt @@ -1,3 +1,3 @@ -code size: 85 +code size: 82 ret: 1 status: Ok(()) diff --git a/hblang/tests/codegen_tests_fb_driver.txt b/hblang/tests/codegen_tests_fb_driver.txt index 07dad9fa..32750759 100644 --- a/hblang/tests/codegen_tests_fb_driver.txt +++ b/hblang/tests/codegen_tests_fb_driver.txt @@ -1,3 +1,3 @@ -code size: 525 +code size: 513 ret: 0 status: Ok(()) diff --git a/hblang/tests/codegen_tests_if_statements.txt b/hblang/tests/codegen_tests_if_statements.txt index f95d4bda..2ae138d5 100644 --- a/hblang/tests/codegen_tests_if_statements.txt +++ b/hblang/tests/codegen_tests_if_statements.txt @@ -1,3 +1,3 @@ -code size: 265 +code size: 262 ret: 55 status: Ok(()) diff --git a/hblang/tests/codegen_tests_structs.txt b/hblang/tests/codegen_tests_structs.txt index 5c3dce3f..473452e1 100644 --- a/hblang/tests/codegen_tests_structs.txt +++ b/hblang/tests/codegen_tests_structs.txt @@ -1,3 +1,3 @@ -code size: 420 +code size: 417 ret: 3 status: Ok(())