Big testing update
This commit is contained in:
@ -118,7 +118,7 @@ CGNode *findCG(TableNode *tn) {
|
|||||||
CGNode *addCG(TableNode *tn, int sp) {
|
CGNode *addCG(TableNode *tn, int sp) {
|
||||||
CGNode *cg = calloc(1, sizeof(CGNode));
|
CGNode *cg = calloc(1, sizeof(CGNode));
|
||||||
cg->tn = tn;
|
cg->tn = tn;
|
||||||
offset += getPrimSize(getTypeEntry(tn));
|
offset += 4; // <- quick fix getPrimSize(getTypeEntry(tn))
|
||||||
cg->address = offset;
|
cg->address = offset;
|
||||||
cg->next = cgList;
|
cg->next = cgList;
|
||||||
cgList = cg;
|
cgList = cg;
|
||||||
|
@ -1214,7 +1214,7 @@ void yyerror(const char *err) {
|
|||||||
insert_code_line(error_message, line);
|
insert_code_line(error_message, line);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, " LINE (%d:%d) ** SYNTAX ERROR: Incorrect syntax at token %s\n\n", line, column, yytext);
|
fprintf(stderr, " LINE (%d:%d) ** SYNTAX ERROR: Incorrect syntax at token %s\n", line, column, yytext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
test.sh
4
test.sh
@ -84,7 +84,7 @@ if [ $# -eq 0 ]; then
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||||
./alpha -st -debug "$file"
|
./alpha -cg "$file"
|
||||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n${WHITE}"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n${WHITE}"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -154,7 +154,7 @@ else
|
|||||||
if [[ "$file" == *"$1"* ]]; then
|
if [[ "$file" == *"$1"* ]]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||||
./alpha -st -debug "$file"
|
./alpha -cg -debug "$file"
|
||||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
|
@ -21,7 +21,7 @@ make_list (a) := {
|
|||||||
} else {
|
} else {
|
||||||
ret := reserve ret;
|
ret := reserve ret;
|
||||||
ret.prev := null;
|
ret.prev := null;
|
||||||
ret.next :s= null;g
|
ret.next := null;
|
||||||
ret.val := a;
|
ret.val := a;
|
||||||
while (0 < a) {
|
while (0 < a) {
|
||||||
temp := reserve temp;
|
temp := reserve temp;
|
||||||
|
@ -8,12 +8,12 @@ entry (arg) := {
|
|||||||
|
|
||||||
x := 3 + 2 * 8;
|
x := 3 + 2 * 8;
|
||||||
x := 3 - 2 / 8;
|
x := 3 - 2 / 8;
|
||||||
x := a * 2 % 8;s
|
x := a * 2 % 8;
|
||||||
b2 := 3 * 2 % 8;
|
b2 := 3 * 2 % 8;
|
||||||
x := 3 % 2 * 8;
|
x := 3 % 2 * 8;
|
||||||
x := 3 + arr - 8;
|
x := 3 + arr - 8;
|
||||||
x := r.x;
|
x := r.x;
|
||||||
x := a.x;
|
x := a.x;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
12
tests/sprint4/expected/sp4_cg_add.expected
Normal file
12
tests/sprint4/expected/sp4_cg_add.expected
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $3, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -16(%rbp), %eax #addition start
|
||||||
|
movl -16(%rbp), %eax
|
||||||
|
addl %edx, %eax
|
||||||
|
movl %eax, -20(%rbp) #addition end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
20
tests/sprint4/expected/sp4_cg_and.expected
Normal file
20
tests/sprint4/expected/sp4_cg_and.expected
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
movl $-1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $-1, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
cmpl $0, -8(%rbp) #start and
|
||||||
|
je .L1or2
|
||||||
|
cmpl $0, -16(%rbp)
|
||||||
|
je .L1or2
|
||||||
|
movl $1, %eax
|
||||||
|
jmp .L1or3
|
||||||
|
.L1or2:
|
||||||
|
movl $0, %eax
|
||||||
|
.L1or3:
|
||||||
|
movb %al, -20(%rbp)
|
||||||
|
andb $1, -20(%rbp) #and end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl $1, -24(%rbp) #constant assign
|
12
tests/sprint4/expected/sp4_cg_div.expected
Normal file
12
tests/sprint4/expected/sp4_cg_div.expected
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $3, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -16(%rbp), %eax #division start
|
||||||
|
cltd
|
||||||
|
idivl -8(%rbp)
|
||||||
|
movl %eax, -20(%rbp) #division end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
13
tests/sprint4/expected/sp4_cg_equal_to.expected
Normal file
13
tests/sprint4/expected/sp4_cg_equal_to.expected
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $2, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -8(%rbp), %eax #equal to start
|
||||||
|
cmpl -16(%rbp), %eax
|
||||||
|
sete %al
|
||||||
|
movb %al, -20(%rbp) #equal to end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -24(%rbp) #assign end
|
||||||
|
movl $1, -28(%rbp) #constant assign
|
13
tests/sprint4/expected/sp4_cg_less_than.expected
Normal file
13
tests/sprint4/expected/sp4_cg_less_than.expected
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $2, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -8(%rbp), %eax #less than start
|
||||||
|
cmpl -16(%rbp), %eax
|
||||||
|
setl %al
|
||||||
|
movb %al, -20(%rbp) #less than end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -24(%rbp) #assign end
|
||||||
|
movl $1, -28(%rbp) #constant assign
|
12
tests/sprint4/expected/sp4_cg_mod.expected
Normal file
12
tests/sprint4/expected/sp4_cg_mod.expected
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $3, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -16(%rbp), %eax #mod start
|
||||||
|
cltd
|
||||||
|
idivl -8(%rbp)
|
||||||
|
movl %edx, -20(%rbp) #mod end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
11
tests/sprint4/expected/sp4_cg_mult.expected
Normal file
11
tests/sprint4/expected/sp4_cg_mult.expected
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $3, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -16(%rbp), %eax #multiplication start
|
||||||
|
imull -16(%rbp), %eax
|
||||||
|
movl %eax, -20(%rbp) #multiplication end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
8
tests/sprint4/expected/sp4_cg_neg.expected
Normal file
8
tests/sprint4/expected/sp4_cg_neg.expected
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
movl $3, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl -8(%rbp), %eax #negation start
|
||||||
|
negl %eax
|
||||||
|
movl %eax, -12(%rbp) #negation end
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
13
tests/sprint4/expected/sp4_cg_not.expected
Normal file
13
tests/sprint4/expected/sp4_cg_not.expected
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
movl $-1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movzbl -8(%rbp), %eax #not start
|
||||||
|
testl %eax, %eax
|
||||||
|
setne %al
|
||||||
|
xorl $1, %eax
|
||||||
|
movzbl %al, %eax
|
||||||
|
movb %al, -12(%rbp)
|
||||||
|
andb $1, -12(%rbp) #not end
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl $1, -20(%rbp) #constant assign
|
21
tests/sprint4/expected/sp4_cg_or.expected
Normal file
21
tests/sprint4/expected/sp4_cg_or.expected
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
movl $-1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $-1, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
cmpl $0, -8(%rbp) #start or
|
||||||
|
jne .L1or2
|
||||||
|
cmpl $0, -16(%rbp)
|
||||||
|
je .L1or3
|
||||||
|
.L1or2:
|
||||||
|
movl $1, %eax
|
||||||
|
jmp .L1or4
|
||||||
|
.L1or3:
|
||||||
|
movl $0, %eax
|
||||||
|
.L1or4:
|
||||||
|
movb %al, -20(%rbp)
|
||||||
|
andb $1, -20(%rbp) #or end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl $1, -24(%rbp) #constant assign
|
11
tests/sprint4/expected/sp4_cg_sub.expected
Normal file
11
tests/sprint4/expected/sp4_cg_sub.expected
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
movl $1, -4(%rbp) #constant assign
|
||||||
|
movl -4(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
||||||
|
movl $3, -12(%rbp) #constant assign
|
||||||
|
movl -12(%rbp), %eax #assign start
|
||||||
|
movl %eax, -16(%rbp) #assign end
|
||||||
|
movl -16(%rbp), %eax #subtraction start
|
||||||
|
subl -8(%rbp), %eax
|
||||||
|
movl %eax, -20(%rbp) #subtraction end
|
||||||
|
movl -20(%rbp), %eax #assign start
|
||||||
|
movl %eax, -8(%rbp) #assign end
|
10
tests/sprint4/test/sp4_cg_add.alpha
Normal file
10
tests/sprint4/test/sp4_cg_add.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
y := 1;
|
||||||
|
x := 3;
|
||||||
|
y := x + y;
|
||||||
|
return y;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_and.alpha
Normal file
10
tests/sprint4/test/sp4_cg_and.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[Boolean:b; Boolean: c; Boolean: d]
|
||||||
|
c := true;
|
||||||
|
d := false;
|
||||||
|
d := c & d;
|
||||||
|
return 1;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_div.alpha
Normal file
10
tests/sprint4/test/sp4_cg_div.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
y := 1;
|
||||||
|
x := 3;
|
||||||
|
y := x / y;
|
||||||
|
return y;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_equal_to.alpha
Normal file
10
tests/sprint4/test/sp4_cg_equal_to.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[Boolean: b; integer: x; integer: y]
|
||||||
|
x := 1;
|
||||||
|
y := 2;
|
||||||
|
b := x = y;
|
||||||
|
return 1;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_less_than.alpha
Normal file
10
tests/sprint4/test/sp4_cg_less_than.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[Boolean: b; integer: x; integer: y]
|
||||||
|
x := 1;
|
||||||
|
y := 2;
|
||||||
|
b := x < y;
|
||||||
|
return 1;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_mod.alpha
Normal file
10
tests/sprint4/test/sp4_cg_mod.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
y := 1;
|
||||||
|
x := 3;
|
||||||
|
y := x % y;
|
||||||
|
return y;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_mult.alpha
Normal file
10
tests/sprint4/test/sp4_cg_mult.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
y := 1;
|
||||||
|
x := 3;
|
||||||
|
y := x * x;
|
||||||
|
return y;
|
||||||
|
}
|
9
tests/sprint4/test/sp4_cg_neg.alpha
Normal file
9
tests/sprint4/test/sp4_cg_neg.alpha
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
x := 3;
|
||||||
|
y := -x;
|
||||||
|
return y;
|
||||||
|
}
|
9
tests/sprint4/test/sp4_cg_not.alpha
Normal file
9
tests/sprint4/test/sp4_cg_not.alpha
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[Boolean: c; Boolean: d]
|
||||||
|
c := true;
|
||||||
|
d := !c;
|
||||||
|
return 1;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_or.alpha
Normal file
10
tests/sprint4/test/sp4_cg_or.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[Boolean:b; Boolean: c; Boolean: d]
|
||||||
|
c := true;
|
||||||
|
d := false;
|
||||||
|
d := c | d;
|
||||||
|
return 1;
|
||||||
|
}
|
10
tests/sprint4/test/sp4_cg_sub.alpha
Normal file
10
tests/sprint4/test/sp4_cg_sub.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type main: integer -> integer
|
||||||
|
function test: main
|
||||||
|
|
||||||
|
test (a) := {
|
||||||
|
[integer:x; integer:y]
|
||||||
|
y := 1;
|
||||||
|
x := 3;
|
||||||
|
y := x - y;
|
||||||
|
return y;
|
||||||
|
}
|
Reference in New Issue
Block a user