Added stub funccallinstr add to sotp segmentation fault on funciton calls being processed

This commit is contained in:
Tristan B. Velloza Kildaire 2022-02-15 15:04:16 +02:00
parent 5641c7f164
commit aa5e82fe09
5 changed files with 53 additions and 42 deletions

View File

@ -47,7 +47,6 @@ struct compileCommand
} }
} }
/** /**
* Only perform tokenization of the given source files * Only perform tokenization of the given source files
*/ */

View File

@ -128,4 +128,19 @@ public class BinOpInstr : Instruction
addInfo = "BinOpType: "~to!(string)(operator)~", LhsValInstr: "~lhs.toString()~", RhsValInstr: "~rhs.toString(); addInfo = "BinOpType: "~to!(string)(operator)~", LhsValInstr: "~lhs.toString()~", RhsValInstr: "~rhs.toString();
} }
}
/**
* 2022 New things
*
*/
public class CallInstr : Instruction
{
}
public class FuncCallInstr : CallInstr
{
} }

View File

@ -260,6 +260,23 @@ public final class TypeChecker
BinOpInstr addInst = new BinOpInstr(vLhsInstr, vRhsInstr, binOperator); BinOpInstr addInst = new BinOpInstr(vLhsInstr, vRhsInstr, binOperator);
addInstr(addInst); 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 */ /* VariableAssigbmentDNode */
else if(cast(compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode) else if(cast(compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode)
@ -279,6 +296,7 @@ public final class TypeChecker
* 3. Generate VarAssignInstruction with Value-instruction * 3. Generate VarAssignInstruction with Value-instruction
*/ */
Instruction valueInstr = popInstr(); 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); VariableAssignmentInstr varAssInstr = new VariableAssignmentInstr(variableName, valueInstr);
addInstr(varAssInstr); addInstr(varAssInstr);
} }

View File

@ -0,0 +1,12 @@
module simple;
discard "return 1;";
int j = func();
int func()
{
}

49
test.d
View File

@ -1,4 +1,4 @@
module typeChecking3; module simple;
void main() void main()
{ {
@ -15,52 +15,19 @@ asm
asm asm
{ {
mov R14D, 21; mov R14B, 65;
} }
asm asm
{ {
mov R13B, 65; mov RSP, R15;
}
asm
{
sub RSP, 4;
}
asm
{
mov R12D, 2;
}
asm
{
sub RSP, 4;
}
asm
{
mov R11B, 65;
} }
asm int h = -1;
{ h = *((&h)-4);
mov R10D, 4; import std.stdio;
} writeln(h);
asm
{
mov R9D, 4;
}
asm
{
mov R8D, 4;
}
}