[lab2]checkopint with "while, continue, break" not implemented
This commit is contained in:
@@ -264,7 +264,7 @@ std::any SysYIRGenerator::visitUnaryExp(SysYParser::UnaryExpContext* ctx) {
|
||||
std::string argList = "";
|
||||
for (size_t i = 0; i < args.size(); ++i) {
|
||||
if (i > 0) argList += ", ";
|
||||
argList += args[i];
|
||||
argList +=tmpTable[args[i]] + " noundef " + args[i];
|
||||
}
|
||||
irStream << " " << temp << " = call " << currentReturnType << " @" << funcName << "(" << argList << ")\n";
|
||||
tmpTable[temp] = currentReturnType;
|
||||
|
||||
@@ -23,9 +23,11 @@ private:
|
||||
std::vector<std::string> breakStack;
|
||||
std::vector<std::string> continueStack;
|
||||
bool hasReturn = false;
|
||||
std::stack<std::string> loopEndStack;
|
||||
std::stack<std::string> loopCondStack;
|
||||
|
||||
struct LoopLabels {
|
||||
std::string breakLabel;
|
||||
std::string continueLabel;
|
||||
};
|
||||
std::stack<LoopLabels> loopStack; // 用于管理循环的break和continue标签
|
||||
std::string getNextTemp();
|
||||
std::string getLLVMType(const std::string& type);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//test file for backend lab
|
||||
|
||||
int main() {
|
||||
int a;
|
||||
int a = 1;
|
||||
const int b = 2;
|
||||
int c;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ int mul(int x, int y) {
|
||||
int main(){
|
||||
int a, b;
|
||||
a = 10;
|
||||
b = 0;
|
||||
b = 3;
|
||||
a = mul(a, b);
|
||||
return a + b;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user