From 544affe1dd056605ae3598f31e0afd14697b4845 Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Sun, 26 May 2024 13:08:34 +0200 Subject: [PATCH 1/3] FunctionCall - Set the weighting to `2` such that when this is used as a standalone statement-level call that is stays in its proper place, and doesn't (for example) jump prior to variable declarations --- source/tlang/compiler/symbols/data.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/tlang/compiler/symbols/data.d b/source/tlang/compiler/symbols/data.d index 7388fba0..57938dd7 100644 --- a/source/tlang/compiler/symbols/data.d +++ b/source/tlang/compiler/symbols/data.d @@ -1035,6 +1035,9 @@ public final class FunctionCall : Call, MStatementSearchable, MStatementReplacea { super(functionName); this.arguments = arguments; + + /* Weighted as 2 */ + weight = 2; } public override string toString() From 33fb23f71ad2548cffb80576fb99795d387c0f4f Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Sun, 26 May 2024 13:09:27 +0200 Subject: [PATCH 2/3] Compiler (unittests) - Added test for `simple_func_statement.t` Test cases - Added `simple_func_statement.t` --- source/tlang/compiler/core.d | 2 ++ source/tlang/testing/simple_func_statement.t | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 source/tlang/testing/simple_func_statement.t diff --git a/source/tlang/compiler/core.d b/source/tlang/compiler/core.d index eba1109b..7319112c 100644 --- a/source/tlang/compiler/core.d +++ b/source/tlang/compiler/core.d @@ -418,6 +418,8 @@ unittest "source/tlang/testing/simple_pointer_array_syntax.t", + + "source/tlang/testing/simple_func_statement.t" ]; foreach(string testFile; testFiles) { diff --git a/source/tlang/testing/simple_func_statement.t b/source/tlang/testing/simple_func_statement.t new file mode 100644 index 00000000..a91e449d --- /dev/null +++ b/source/tlang/testing/simple_func_statement.t @@ -0,0 +1,14 @@ +module simple_func_statement; + +void k(int* p) +{ + +} + +int main() +{ + int* arr; + k(arr); + + return 0; +} From e058313a3527b601892f809a869f018e8f677a6b Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Sun, 26 May 2024 13:10:43 +0200 Subject: [PATCH 3/3] Pipelines - Added test case for `simple_func_statement.t` --- .github/workflows/d.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index f5597b1e..48f87755 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -419,8 +419,10 @@ jobs: run: | ./tlang compile source/tlang/testing/simple_function_recursion_factorial.t ./tlang.out - - + - name: Simple function (statement-level) + run: | + ./tlang compile source/tlang/testing/simple_func_statement.t + ./tlang.out # TODO: Re-enable when we support the `discard` keyword again #- name: Simple variables