llvmir some opt
This commit is contained in:
27
error/Error.java
Normal file
27
error/Error.java
Normal 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
17
error/ErrorType.java
Normal 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
43
error/Errors.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user