From aa5e82fe09ce9852144061c1d575cc70b27ecce9 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 15 Feb 2022 15:04:16 +0200 Subject: [PATCH] Added stub funccallinstr add to sotp segmentation fault on funciton calls being processed --- source/tlang/commandline/commands.d | 1 - source/tlang/compiler/codegen/instruction.d | 15 +++++++ source/tlang/compiler/typecheck/core.d | 18 ++++++++ source/tlang/testing/typecheck/simple_1.t | 12 +++++ test.d | 49 ++++----------------- 5 files changed, 53 insertions(+), 42 deletions(-) create mode 100644 source/tlang/testing/typecheck/simple_1.t diff --git a/source/tlang/commandline/commands.d b/source/tlang/commandline/commands.d index e6c58a0..099b8ee 100644 --- a/source/tlang/commandline/commands.d +++ b/source/tlang/commandline/commands.d @@ -47,7 +47,6 @@ struct compileCommand } } - /** * Only perform tokenization of the given source files */ diff --git a/source/tlang/compiler/codegen/instruction.d b/source/tlang/compiler/codegen/instruction.d index a293653..62ff137 100644 --- a/source/tlang/compiler/codegen/instruction.d +++ b/source/tlang/compiler/codegen/instruction.d @@ -128,4 +128,19 @@ public class BinOpInstr : Instruction addInfo = "BinOpType: "~to!(string)(operator)~", LhsValInstr: "~lhs.toString()~", RhsValInstr: "~rhs.toString(); } +} + +/** +* 2022 New things +* +*/ + +public class CallInstr : Instruction +{ + +} + +public class FuncCallInstr : CallInstr +{ + } \ No newline at end of file diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index 24ae0ae..492b217 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -260,6 +260,23 @@ public final class TypeChecker BinOpInstr addInst = new BinOpInstr(vLhsInstr, vRhsInstr, binOperator); addInstr(addInst); } + /* Function calls */ + else if(cast(FunctionCall)statement) + { + /* TODO: Implement me */ + gprintln("FuncCall hehe (REMOVE AFTER DONE)"); + + /** + * TODO: + * + * 1. Create FUncCallInstr + * 2. Evaluate args and process them?! wait done elsewhere yeah + * 3. Pop arts into here + * 4. AddInstr(combining those args) + * 5. DOne + */ + addInstr(new FuncCallInstr()); + } } /* VariableAssigbmentDNode */ else if(cast(compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode) @@ -279,6 +296,7 @@ public final class TypeChecker * 3. Generate VarAssignInstruction with Value-instruction */ Instruction valueInstr = popInstr(); + gprintln(valueInstr is null);/*TODO: FUnc calls not implemented? Then is null for simple_1.t */ VariableAssignmentInstr varAssInstr = new VariableAssignmentInstr(variableName, valueInstr); addInstr(varAssInstr); } diff --git a/source/tlang/testing/typecheck/simple_1.t b/source/tlang/testing/typecheck/simple_1.t new file mode 100644 index 0000000..6077290 --- /dev/null +++ b/source/tlang/testing/typecheck/simple_1.t @@ -0,0 +1,12 @@ +module simple; + +discard "return 1;"; + + + +int j = func(); + +int func() +{ + +} \ No newline at end of file diff --git a/test.d b/test.d index 7594747..3375cda 100644 --- a/test.d +++ b/test.d @@ -1,4 +1,4 @@ -module typeChecking3; +module simple; void main() { @@ -15,52 +15,19 @@ asm asm { - mov R14D, 21; + mov R14B, 65; } asm { - mov R13B, 65; - } - -asm - { - sub RSP, 4; - } - - - asm - { - mov R12D, 2; - } - -asm - { - sub RSP, 4; - } - - - asm - { - mov R11B, 65; + mov RSP, R15; } - asm - { - mov R10D, 4; - } - - - asm - { - mov R9D, 4; - } - - - asm - { - mov R8D, 4; - } + int h = -1; + h = *((&h)-4); + import std.stdio; + writeln(h); +}