Commit 4c49b115 authored by zygzagZ's avatar zygzagZ

Fix additional tests

parent 643396b9
...@@ -198,6 +198,8 @@ string Compiler::getRef(const VariablePtr &v) { ...@@ -198,6 +198,8 @@ string Compiler::getRef(const VariablePtr &v) {
temps.emplace(v); temps.emplace(v);
v->localOffset = 4 * (temps.size() + localInfos.size()); v->localOffset = 4 * (temps.size() + localInfos.size());
} }
if (v->localOffset > 0) v->name += "+";
v->name += to_string(v->localOffset);
} }
return to_string(-v->localOffset) + "(%ebp)"; return to_string(-v->localOffset) + "(%ebp)";
} else { } else {
...@@ -252,6 +254,7 @@ void Compiler::generateQParam(QParam &q) { ...@@ -252,6 +254,7 @@ void Compiler::generateQParam(QParam &q) {
auto offset = 4 * (q.num - Register::calleeSaved.size() - 1); // push regs + ebp auto offset = 4 * (q.num - Register::calleeSaved.size() - 1); // push regs + ebp
if (reg == 0) { if (reg == 0) {
q.param->localOffset = offset; q.param->localOffset = offset;
if (q.param->info) q.param->info->localOffset = offset;
} else { } else {
append("MOVL", to_string(-offset)+"(%ebp)", reg); append("MOVL", to_string(-offset)+"(%ebp)", reg);
} }
......
...@@ -499,7 +499,11 @@ void TypeCheck::visitListStmt(ListStmt *list_stmt) ...@@ -499,7 +499,11 @@ void TypeCheck::visitListStmt(ListStmt *list_stmt)
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i) for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{ {
(*i)->accept(this); (*i)->accept(this);
if (returnType) break; if (returnType) {
i++;
list_stmt->erase(i, list_stmt->end());
break;
}
} }
} }
......
...@@ -522,7 +522,7 @@ void QuadrupleGenerator::compileCond(Expr *expr_, Stmt *stmt_1, Stmt *stmt_2) { ...@@ -522,7 +522,7 @@ void QuadrupleGenerator::compileCond(Expr *expr_, Stmt *stmt_1, Stmt *stmt_2) {
assert(!dynamic_pointer_cast<QJump>(lastQuad)); assert(!dynamic_pointer_cast<QJump>(lastQuad));
if (condVar->val) { if (condVar->val) {
stmt_1->accept(this); stmt_1->accept(this);
} else { } else if (stmt_2) {
stmt_2->accept(this); stmt_2->accept(this);
} }
return; return;
......
...@@ -29,7 +29,29 @@ make -j8 && for i in lat/lattests/good/*.lat; do ...@@ -29,7 +29,29 @@ make -j8 && for i in lat/lattests/good/*.lat; do
red "ERROR $i" red "ERROR $i"
exit 1 exit 1
fi fi
done && green good OK && for i in lat/lattests/bad/*.lat; do done && green good OK && for ext in `ls tests/good/`; do
ok=1
for i in tests/good/$ext/*.lat; do
($BIN "$i" &>/dev/null);
if ! [ $? -eq 0 ]; then
red "$ext fails on $i";
$BIN "$i"
ok=0;
break;
fi
done
if [ $ok -eq 1 ]; then
green "OK: $ext passed!"
fi
done && for i in lat/lattests/bad/*.lat; do
t=$((t+1))
($BIN "$i" &>/dev/null);
if [ $? -eq 0 ]; then
red "FAIL $i";
$BIN "$i"
exit 1;
fi
done && green "OK: $t bad tests passed!" && for i in tests/bad/semantic/*.lat; do
t=$((t+1)) t=$((t+1))
($BIN "$i" &>/dev/null); ($BIN "$i" &>/dev/null);
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
...@@ -37,7 +59,21 @@ done && green good OK && for i in lat/lattests/bad/*.lat; do ...@@ -37,7 +59,21 @@ done && green good OK && for i in lat/lattests/bad/*.lat; do
$BIN "$i" $BIN "$i"
exit 1; exit 1;
fi fi
done && green "OK: $t tests passed!" && for ext in `ls lat/lattests/extensions`; do done && green "OK: $t bad+ tests passed!" && for ext in `ls lat/lattests/extensions`; do
ok=1
for i in lat/lattests/extensions/$ext/*.lat; do
($BIN "$i" &>/dev/null);
if ! [ $? -eq 0 ]; then
red "$ext fails on $i";
$BIN "$i"
ok=0;
break;
fi
done
if [ $ok -eq 1 ]; then
green "OK: $ext passed!"
fi
done && for ext in `ls tests/extensions`; do
ok=1 ok=1
for i in lat/lattests/extensions/$ext/*.lat; do for i in lat/lattests/extensions/$ext/*.lat; do
($BIN "$i" &>/dev/null); ($BIN "$i" &>/dev/null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment