mirror of
https://github.com/RoBaertschi/tt.git
synced 2025-04-19 23:33:30 +00:00
Compare commits
2 Commits
8137b45788
...
403f02a140
Author | SHA1 | Date | |
---|---|---|---|
403f02a140 | |||
fa9777c2a8 |
@ -9,10 +9,10 @@ _start:
|
|||||||
main:
|
main:
|
||||||
push rbp
|
push rbp
|
||||||
mov rbp, rsp
|
mov rbp, rsp
|
||||||
add rsp, -4
|
add rsp, -8
|
||||||
mov qword [rsp -4], 3
|
mov qword [rsp -8], 3
|
||||||
add qword [rsp -4], 3
|
add qword [rsp -8], 3
|
||||||
mov rax, qword [rsp -4]
|
mov rax, qword [rsp -8]
|
||||||
mov rsp, rbp
|
mov rsp, rbp
|
||||||
pop rbp
|
pop rbp
|
||||||
ret
|
ret
|
||||||
|
@ -313,7 +313,7 @@ func pseudoToStack(op Operand, r *replacePseudoPass) Operand {
|
|||||||
if offset, ok := r.identToOffset[string(pseudo)]; ok {
|
if offset, ok := r.identToOffset[string(pseudo)]; ok {
|
||||||
return Stack(offset)
|
return Stack(offset)
|
||||||
} else {
|
} else {
|
||||||
r.currentOffset -= 4
|
r.currentOffset -= 8
|
||||||
r.identToOffset[string(pseudo)] = r.currentOffset
|
r.identToOffset[string(pseudo)] = r.currentOffset
|
||||||
return Stack(r.currentOffset)
|
return Stack(r.currentOffset)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ func expectExpression(t *testing.T, expected ast.Expression, actual ast.Expressi
|
|||||||
|
|
||||||
func TestFunctionDeclaration(t *testing.T) {
|
func TestFunctionDeclaration(t *testing.T) {
|
||||||
test := parserTest{
|
test := parserTest{
|
||||||
input: "fn main() = 0;",
|
input: "fn main(): i64 = 0;",
|
||||||
expectedProgram: ast.Program{
|
expectedProgram: ast.Program{
|
||||||
Declarations: []ast.Declaration{
|
Declarations: []ast.Declaration{
|
||||||
&ast.FunctionDeclaration{
|
&ast.FunctionDeclaration{
|
||||||
@ -180,7 +180,7 @@ func TestFunctionDeclaration(t *testing.T) {
|
|||||||
|
|
||||||
func TestBinaryExpressions(t *testing.T) {
|
func TestBinaryExpressions(t *testing.T) {
|
||||||
test := parserTest{
|
test := parserTest{
|
||||||
input: "fn main() = true == true == true;",
|
input: "fn main(): i64 = true == true == true;",
|
||||||
expectedProgram: ast.Program{
|
expectedProgram: ast.Program{
|
||||||
Declarations: []ast.Declaration{
|
Declarations: []ast.Declaration{
|
||||||
&ast.FunctionDeclaration{
|
&ast.FunctionDeclaration{
|
||||||
@ -204,7 +204,7 @@ func TestBinaryExpressions(t *testing.T) {
|
|||||||
|
|
||||||
func TestBlockExpression(t *testing.T) {
|
func TestBlockExpression(t *testing.T) {
|
||||||
test := parserTest{
|
test := parserTest{
|
||||||
input: "fn main() = {\n3;\n{ 3+2 }\n}\n;",
|
input: "fn main(): i64 = {\n3;\n{ 3+2 }\n}\n;",
|
||||||
expectedProgram: ast.Program{
|
expectedProgram: ast.Program{
|
||||||
Declarations: []ast.Declaration{
|
Declarations: []ast.Declaration{
|
||||||
&ast.FunctionDeclaration{
|
&ast.FunctionDeclaration{
|
||||||
@ -231,7 +231,7 @@ func TestBlockExpression(t *testing.T) {
|
|||||||
|
|
||||||
func TestGroupedExpression(t *testing.T) {
|
func TestGroupedExpression(t *testing.T) {
|
||||||
test := parserTest{
|
test := parserTest{
|
||||||
input: "fn main() = (3);",
|
input: "fn main(): i64 = (3);",
|
||||||
expectedProgram: ast.Program{
|
expectedProgram: ast.Program{
|
||||||
Declarations: []ast.Declaration{
|
Declarations: []ast.Declaration{
|
||||||
&ast.FunctionDeclaration{
|
&ast.FunctionDeclaration{
|
||||||
@ -246,7 +246,7 @@ func TestGroupedExpression(t *testing.T) {
|
|||||||
|
|
||||||
func TestVariableExpression(t *testing.T) {
|
func TestVariableExpression(t *testing.T) {
|
||||||
test := parserTest{
|
test := parserTest{
|
||||||
input: "fn main() = { x : u32 = 3; x };",
|
input: "fn main(): i64 = { x : i64 = 3; x };",
|
||||||
expectedProgram: ast.Program{
|
expectedProgram: ast.Program{
|
||||||
Declarations: []ast.Declaration{
|
Declarations: []ast.Declaration{
|
||||||
&ast.FunctionDeclaration{
|
&ast.FunctionDeclaration{
|
||||||
@ -256,7 +256,7 @@ func TestVariableExpression(t *testing.T) {
|
|||||||
&ast.VariableDeclaration{
|
&ast.VariableDeclaration{
|
||||||
InitializingExpression: &ast.IntegerExpression{Value: 3},
|
InitializingExpression: &ast.IntegerExpression{Value: 3},
|
||||||
Identifier: "x",
|
Identifier: "x",
|
||||||
Type: "u32",
|
Type: "i64",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ReturnExpression: &ast.VariableReference{Identifier: "x"},
|
ReturnExpression: &ast.VariableReference{Identifier: "x"},
|
||||||
|
@ -131,7 +131,7 @@ func expectOperand(t *testing.T, expected Operand, actual Operand) {
|
|||||||
|
|
||||||
func TestBasicFunction(t *testing.T) {
|
func TestBasicFunction(t *testing.T) {
|
||||||
runTTIREmitterTest(t, ttirEmitterTest{
|
runTTIREmitterTest(t, ttirEmitterTest{
|
||||||
input: "fn main() = 0;",
|
input: "fn main(): i64 = 0;",
|
||||||
expected: Program{
|
expected: Program{
|
||||||
Functions: []*Function{
|
Functions: []*Function{
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ func TestBasicFunction(t *testing.T) {
|
|||||||
|
|
||||||
func TestBinaryExpression(t *testing.T) {
|
func TestBinaryExpression(t *testing.T) {
|
||||||
runTTIREmitterTest(t, ttirEmitterTest{
|
runTTIREmitterTest(t, ttirEmitterTest{
|
||||||
input: "fn main() = 3 + 3 + 3;",
|
input: "fn main(): i64 = 3 + 3 + 3;",
|
||||||
expected: Program{
|
expected: Program{
|
||||||
Functions: []*Function{
|
Functions: []*Function{
|
||||||
{Name: "main", Instructions: []Instruction{
|
{Name: "main", Instructions: []Instruction{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user