Big testing update

This commit is contained in:
Scarlett
2025-04-25 23:26:50 -04:00
parent 747a48b211
commit 6e4841f0c1
27 changed files with 262 additions and 8 deletions

View File

@ -118,7 +118,7 @@ CGNode *findCG(TableNode *tn) {
CGNode *addCG(TableNode *tn, int sp) {
CGNode *cg = calloc(1, sizeof(CGNode));
cg->tn = tn;
offset += getPrimSize(getTypeEntry(tn));
offset += 4; // <- quick fix getPrimSize(getTypeEntry(tn))
cg->address = offset;
cg->next = cgList;
cgList = cg;

View File

@ -1214,7 +1214,7 @@ void yyerror(const char *err) {
insert_code_line(error_message, line);
}
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);
}
}
}

View File

@ -84,7 +84,7 @@ if [ $# -eq 0 ]; then
if [ -f "$file" ]; then
filename=$(basename -- "$file")
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}"
switchfunc
fi
@ -154,7 +154,7 @@ else
if [[ "$file" == *"$1"* ]]; then
filename=$(basename -- "$file")
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"
switchfunc
fi

View File

@ -21,7 +21,7 @@ make_list (a) := {
} else {
ret := reserve ret;
ret.prev := null;
ret.next :s= null;g
ret.next := null;
ret.val := a;
while (0 < a) {
temp := reserve temp;

View File

@ -8,7 +8,7 @@ entry (arg) := {
x := 3 + 2 * 8;
x := 3 - 2 / 8;
x := a * 2 % 8;s
x := a * 2 % 8;
b2 := 3 * 2 % 8;
x := 3 % 2 * 8;
x := 3 + arr - 8;

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View File

@ -0,0 +1,9 @@
type main: integer -> integer
function test: main
test (a) := {
[integer:x; integer:y]
x := 3;
y := -x;
return y;
}

View File

@ -0,0 +1,9 @@
type main: integer -> integer
function test: main
test (a) := {
[Boolean: c; Boolean: d]
c := true;
d := !c;
return 1;
}

View 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;
}

View 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;
}