Add the "verifyATN" deserialization option

This commit is contained in:
Sam Harwell 2013-11-20 08:17:43 -06:00
parent affbe51077
commit c4c2546fc9
2 changed files with 16 additions and 1 deletions

View File

@ -44,11 +44,14 @@ public class ATNDeserializationOptions {
}
private boolean readOnly;
private boolean verifyATN;
public ATNDeserializationOptions() {
this.verifyATN = true;
}
public ATNDeserializationOptions(ATNDeserializationOptions options) {
this.verifyATN = options.verifyATN;
}
@NotNull
@ -64,6 +67,15 @@ public class ATNDeserializationOptions {
readOnly = true;
}
public final boolean isVerifyATN() {
return verifyATN;
}
public final void setVerifyATN(boolean verifyATN) {
throwIfReadOnly();
this.verifyATN = verifyATN;
}
protected void throwIfReadOnly() {
if (isReadOnly()) {
throw new IllegalStateException("The object is read only.");

View File

@ -358,7 +358,10 @@ public class ATNDeserializer {
decState.decision = i-1;
}
verifyATN(atn);
if (deserializationOptions.isVerifyATN()) {
verifyATN(atn);
}
return atn;
}