llvmir some opt
This commit is contained in:
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