Compare commits

...

2 Commits

Author SHA1 Message Date
403f02a140 fixed tests 2025-03-13 10:55:54 +01:00
fa9777c2a8 there has never been a stupider person then me
we use 64 bit integers, but only reserve 4 bytes for them, well, that is
in fact not enough. They were overwriting each other, which caused some
problems ;-)
2025-03-13 10:52:34 +01:00
4 changed files with 13 additions and 13 deletions

View File

@ -9,10 +9,10 @@ _start:
main:
push rbp
mov rbp, rsp
add rsp, -4
mov qword [rsp -4], 3
add qword [rsp -4], 3
mov rax, qword [rsp -4]
add rsp, -8
mov qword [rsp -8], 3
add qword [rsp -8], 3
mov rax, qword [rsp -8]
mov rsp, rbp
pop rbp
ret

View File

@ -313,7 +313,7 @@ func pseudoToStack(op Operand, r *replacePseudoPass) Operand {
if offset, ok := r.identToOffset[string(pseudo)]; ok {
return Stack(offset)
} else {
r.currentOffset -= 4
r.currentOffset -= 8
r.identToOffset[string(pseudo)] = r.currentOffset
return Stack(r.currentOffset)
}

View File

@ -165,7 +165,7 @@ func expectExpression(t *testing.T, expected ast.Expression, actual ast.Expressi
func TestFunctionDeclaration(t *testing.T) {
test := parserTest{
input: "fn main() = 0;",
input: "fn main(): i64 = 0;",
expectedProgram: ast.Program{
Declarations: []ast.Declaration{
&ast.FunctionDeclaration{
@ -180,7 +180,7 @@ func TestFunctionDeclaration(t *testing.T) {
func TestBinaryExpressions(t *testing.T) {
test := parserTest{
input: "fn main() = true == true == true;",
input: "fn main(): i64 = true == true == true;",
expectedProgram: ast.Program{
Declarations: []ast.Declaration{
&ast.FunctionDeclaration{
@ -204,7 +204,7 @@ func TestBinaryExpressions(t *testing.T) {
func TestBlockExpression(t *testing.T) {
test := parserTest{
input: "fn main() = {\n3;\n{ 3+2 }\n}\n;",
input: "fn main(): i64 = {\n3;\n{ 3+2 }\n}\n;",
expectedProgram: ast.Program{
Declarations: []ast.Declaration{
&ast.FunctionDeclaration{
@ -231,7 +231,7 @@ func TestBlockExpression(t *testing.T) {
func TestGroupedExpression(t *testing.T) {
test := parserTest{
input: "fn main() = (3);",
input: "fn main(): i64 = (3);",
expectedProgram: ast.Program{
Declarations: []ast.Declaration{
&ast.FunctionDeclaration{
@ -246,7 +246,7 @@ func TestGroupedExpression(t *testing.T) {
func TestVariableExpression(t *testing.T) {
test := parserTest{
input: "fn main() = { x : u32 = 3; x };",
input: "fn main(): i64 = { x : i64 = 3; x };",
expectedProgram: ast.Program{
Declarations: []ast.Declaration{
&ast.FunctionDeclaration{
@ -256,7 +256,7 @@ func TestVariableExpression(t *testing.T) {
&ast.VariableDeclaration{
InitializingExpression: &ast.IntegerExpression{Value: 3},
Identifier: "x",
Type: "u32",
Type: "i64",
},
},
ReturnExpression: &ast.VariableReference{Identifier: "x"},

View File

@ -131,7 +131,7 @@ func expectOperand(t *testing.T, expected Operand, actual Operand) {
func TestBasicFunction(t *testing.T) {
runTTIREmitterTest(t, ttirEmitterTest{
input: "fn main() = 0;",
input: "fn main(): i64 = 0;",
expected: Program{
Functions: []*Function{
{
@ -149,7 +149,7 @@ func TestBasicFunction(t *testing.T) {
func TestBinaryExpression(t *testing.T) {
runTTIREmitterTest(t, ttirEmitterTest{
input: "fn main() = 3 + 3 + 3;",
input: "fn main(): i64 = 3 + 3 + 3;",
expected: Program{
Functions: []*Function{
{Name: "main", Instructions: []Instruction{