From 9405c03e10584917ef5b61eede04f025f1a74523 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sat, 17 Dec 2022 14:31:03 +0200 Subject: [PATCH] DGen - Cleaned up emit() method - New test case hashes inserted for entryPoint test code Test cases - Updated `simple_function_decls.t` to be exactly that, ONLY declarations with basic bodies - Migrated advanced function usage testing code to a new unit test: `simple_functions.t` --- source/tlang/compiler/codegen/emit/dgen.d | 15 +++++--------- source/tlang/testing/simple_function_decls.t | 7 ------- source/tlang/testing/simple_functions.t | 21 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 source/tlang/testing/simple_functions.t diff --git a/source/tlang/compiler/codegen/emit/dgen.d b/source/tlang/compiler/codegen/emit/dgen.d index f5f303e0..2f5bfdb2 100644 --- a/source/tlang/compiler/codegen/emit/dgen.d +++ b/source/tlang/compiler/codegen/emit/dgen.d @@ -195,20 +195,15 @@ public final class DCodeEmitter : CodeEmitter // Emit header comment (NOTE: Change this to a useful piece of text) emitHeaderComment("Place any extra information by code generator here"); // NOTE: We can pass a string with extra information to it if we want to + // Emit static allocation code emitStaticAllocations(); + // Emit globals emitCodeQueue(); + // Emit function definitions emitFunctionDefinitions(); - gprintln("\n\n\n"); - - // emitCodeQueue(); - - gprintln("\n\n\n"); - - //TODO: Emit function definitions - //TODO: Emit main (entry point) emitEntryPoint(); } @@ -376,9 +371,9 @@ public final class DCodeEmitter : CodeEmitter #include int main() { - printf("k: %u\n", t_0c9714cea1ccdfdd0345347c86885620); + printf("k: %u\n", t_7b6d477c5859059f16bc9da72fc8cc3b); banana(1); - printf("k: %u\n", t_0c9714cea1ccdfdd0345347c86885620); + printf("k: %u\n", t_7b6d477c5859059f16bc9da72fc8cc3b); return 0; }`); } diff --git a/source/tlang/testing/simple_function_decls.t b/source/tlang/testing/simple_function_decls.t index 59d79d47..6d89bd1c 100644 --- a/source/tlang/testing/simple_function_decls.t +++ b/source/tlang/testing/simple_function_decls.t @@ -6,16 +6,9 @@ int k = 22; int apple(int arg1, int arg2) { int h = 69; - - arg1=1+arg1; - - k=arg1+arg2; } int banana(int arg1) { int h = 64; - - k=1+h+apple(1, apple(2, 3))+k; - } \ No newline at end of file diff --git a/source/tlang/testing/simple_functions.t b/source/tlang/testing/simple_functions.t new file mode 100644 index 00000000..61b3f997 --- /dev/null +++ b/source/tlang/testing/simple_functions.t @@ -0,0 +1,21 @@ +module simple_functions; + +int j = 21; +int k = 22; + +int apple(int arg1, int arg2) +{ + int h = 69; + + arg1=1+arg1; + + k=arg1+arg2; +} + +int banana(int arg1) +{ + int h = 64; + + k=1+h+apple(1, apple(2, 3))+k; + +} \ No newline at end of file