diff --git a/src/SysYIRGenerator.cpp b/src/SysYIRGenerator.cpp index fd689ca..7ddee8e 100644 --- a/src/SysYIRGenerator.cpp +++ b/src/SysYIRGenerator.cpp @@ -623,7 +623,7 @@ std::any SysYIRGenerator::visitMulExp(SysYParser::MulExpContext *ctx) { cout << "unaryExp().size() > 1\n"; for(size_t i = 1; i < ctx->unaryExp().size(); i++){ Value* rhs = any_cast(ctx->unaryExp(i)->accept(this)); - auto opNode = dynamic_cast(ctx->children[2 * i + 1]); + auto opNode = dynamic_cast(ctx->children[2 * i - 1]); if(opNode->getText() == "*"){ res = builder.createMulInst(lhs, rhs, lhs->getName() + "*" + rhs->getName());