Skip to content

Commit

Permalink
bugfix and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rapiz1 committed Nov 3, 2021
1 parent 8a0a4c8 commit d38686b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,24 @@ void CodeGenExprVisitor::visit(Unary* expr) {
default:
break;
}
l.builder->CreateStore(addr, value);
l.builder->CreateStore(value, addr);
}
}

void CodeGenExprVisitor::visit(Postfix* expr) {
visit(expr->child);
auto val = getValue();
auto addr = getAddr();
if (!val->getType()->isIntegerTy())
if (!value->getType()->isIntegerTy())
abortMsg("cant apply " + expr->op.lexeme + "to non integer");
int width = val->getType()->getIntegerBitWidth();
auto con = llvm::Constant::getIntegerValue(val->getType(),
int width = value->getType()->getIntegerBitWidth();
auto con = llvm::Constant::getIntegerValue(value->getType(),
llvm::APInt(width, 1, true));
llvm::Value* ret = nullptr;
switch (expr->op.tokenType) {
case PLUSPLUS:
ret = l.builder->CreateAdd(val, con);
ret = l.builder->CreateAdd(value, con);
break;
case MINUSMINUS:
ret = l.builder->CreateSub(val, con);
ret = l.builder->CreateSub(value, con);
break;
default:
abortMsg("unimplemented postfix operator " + expr->op.lexeme);
Expand Down

0 comments on commit d38686b

Please sign in to comment.