llvmir some opt

This commit is contained in:
邓智航
2025-12-10 17:58:17 +08:00
commit 84827838e2
103 changed files with 5838 additions and 0 deletions

27
error/Error.java Normal file
View File

@@ -0,0 +1,27 @@
package error;
public class Error {
private int line;
private ErrorType type;
public Error(int line, ErrorType type) {
this.line = line;
this.type = type;
}
public void printError() {
System.out.println(this.line + " " + this.type);
}
public int getLine() {
return this.line;
}
public ErrorType getType() {
return this.type;
}
public String toString() {
return this.line + " " + this.type + "\n";
}
}

17
error/ErrorType.java Normal file
View File

@@ -0,0 +1,17 @@
package error;
public enum ErrorType {
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m
}

43
error/Errors.java Normal file
View File

@@ -0,0 +1,43 @@
package error;
import java.util.ArrayList;
public class Errors {
private ArrayList<Error> errors;
public Errors() {
this.errors = new ArrayList<Error>();
}
public void addError(Error error) {
int index = 0;
if (this.errors.size() == 0 ||
this.errors.get(this.errors.size() - 1).getLine() <= error.getLine()) {
this.errors.add(error);
return;
}
if (this.errors.get(0).getLine() > error.getLine()) {
this.errors.add(index, error);
return;
}
for (int i = this.errors.size() - 1; i >= 0; i--) {
if (this.errors.get(i).getLine() <= error.getLine()) {
index = i + 1;
break;
}
}
this.errors.add(index, error);
}
public int size() {
return this.errors.size();
}
public StringBuilder toStringBuilder() {
StringBuilder sb = new StringBuilder();
for (Error error : this.errors) {
sb.append(error.toString());
}
return sb;
}
}