Skip to content

Commit

Permalink
Fixed binary negation
Browse files Browse the repository at this point in the history
  • Loading branch information
QFSW committed Mar 26, 2019
1 parent 37b0888 commit b0be958
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ast/operators/unaryOperators/unaryMinus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void UnaryMinus::generatePython(std::ostream &os, PythonContext &context, int sc
void UnaryMinus::generateIL(std::vector<Instr> &instrs, ILContext &context, std::string destReg) const
{
getOperand()->generateIL(instrs, context, "$t0");
instrs.push_back(Instr("subi", destReg, "$0", "$t0"));
instrs.push_back(Instr("sub", destReg, "$0", "$t0"));
}

int UnaryMinus::evalConst() const
Expand Down
19 changes: 11 additions & 8 deletions test/parser/testProgram.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
int main()
int not(int arg)
{
int x, y, z;
while (x > 0)
{
break;
return 10;
}
return !arg;
}

return 1;
int neg(int arg)
{
return -arg;
}

int inv(int arg)
{
return ~arg;
}

0 comments on commit b0be958

Please sign in to comment.