Compare commits

..

No commits in common. "403f02a140a875608a0f3f2353f05f41fbf535c6" and "8137b45788ed6272c44dbec29dffe55a62fbfe4b" have entirely different histories.

4 changed files with 13 additions and 13 deletions

View File

@ -9,10 +9,10 @@ _start:
main:
push rbp
mov rbp, rsp
add rsp, -8
mov qword [rsp -8], 3
add qword [rsp -8], 3
mov rax, qword [rsp -8]
add rsp, -4
mov qword [rsp -4], 3
add qword [rsp -4], 3
mov rax, qword [rsp -4]
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 -= 8
r.currentOffset -= 4
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(): i64 = 0;",
input: "fn main() = 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(): i64 = true == true == true;",
input: "fn main() = 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(): i64 = {\n3;\n{ 3+2 }\n}\n;",
input: "fn main() = {\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(): i64 = (3);",
input: "fn main() = (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(): i64 = { x : i64 = 3; x };",
input: "fn main() = { x : u32 = 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: "i64",
Type: "u32",
},
},
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(): i64 = 0;",
input: "fn main() = 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(): i64 = 3 + 3 + 3;",
input: "fn main() = 3 + 3 + 3;",
expected: Program{
Functions: []*Function{
{Name: "main", Instructions: []Instruction{