use of com.dat3m.dartagnan.exception.MalformedProgramException in project Dat3M by hernanponcedeleon.
the class ProgramBuilder method validateLabels.
private void validateLabels(Thread thread) throws MalformedProgramException {
Map<String, Label> threadLabels = new HashMap<>();
Set<String> referencedLabels = new HashSet<>();
Event e = thread.getEntry();
while (e != null) {
if (e instanceof CondJump) {
referencedLabels.add(((CondJump) e).getLabel().getName());
} else if (e instanceof Label) {
Label label = labels.remove(((Label) e).getName());
if (label == null) {
throw new MalformedProgramException("Duplicated label " + ((Label) e).getName());
}
threadLabels.put(label.getName(), label);
}
e = e.getSuccessor();
}
for (String labelName : referencedLabels) {
if (!threadLabels.containsKey(labelName)) {
throw new MalformedProgramException("Illegal jump to label " + labelName);
}
}
}
Aggregations