Skip to content

Commit f7924c8

Browse files
authored
Merge branch 'main' into mu/unbalancedFloats
2 parents 5fcf646 + 50a6034 commit f7924c8

43 files changed

Lines changed: 2112 additions & 507 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# commit with automatic reformatting for Java files
2-
d1be82c163b48fcc87991afc33f50c1380bf4949
2+
92ef20754111bce673603debf9934ae98816a70f
33
# commit with automatic reformatting for .key files
4-
f8441bba87de6fdc63ea3078a9fa0c79139b8b0a
4+
b1ed8d6bc836ea40f357a839707d41fbb04ed6e2
55
# commit with manual formatting corrections
6-
e405e67cb69ac9621efaa6098e87d03fb39a3efa
6+
a9fcedc6c8d96f2480549254a307b3fbe31f04bd

.github/workflows/tests.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ jobs:
4343
if: success() || failure()
4444
with:
4545
name: test-results
46-
path: "**/build/test-results/*/*.xml"
46+
path: |
47+
**/build/test-results/*/*.xml
48+
**/build/reports/
4749
4850
integration-tests:
4951
env:
@@ -84,8 +86,10 @@ jobs:
8486
if: success() || failure() # run this step even if previous step failed
8587
with:
8688
name: test-results
87-
path: "**/build/test-results/*/*.xml"
88-
89+
path: |
90+
**/build/test-results/*/*.xml
91+
**/build/reports/
92+
8993
optional-tests:
9094
runs-on: ubuntu-latest
9195
continue-on-error: true
@@ -107,23 +111,24 @@ jobs:
107111
# if: success() || failure() # run this step even if previous step failed
108112
with:
109113
name: test-results
110-
path: "**/build/test-results/*/*.xml"
111-
112-
113-
report:
114-
runs-on: ubuntu-latest
115-
needs: [optional-tests, unit-tests, integration-tests]
116-
steps:
117-
- uses: actions/checkout@v3
118-
- name: Download a Test Reports (JUnit XML)
119-
uses: actions/download-artifact@v3.0.2
120-
with:
121-
name: test-results
122-
123-
- name: Test reporting
124-
uses: dorny/test-reporter@v1
125-
if: success() || failure()
126-
with:
127-
name: Test Report
128-
path: "**/build/test-results/*/*.xml"
129-
reporter: java-junit
114+
path: |
115+
**/build/test-results/*/*.xml
116+
**/build/reports/
117+
118+
# report:
119+
# runs-on: ubuntu-latest
120+
# needs: [optional-tests, unit-tests, integration-tests]
121+
# steps:
122+
# - uses: actions/checkout@v3
123+
# - name: Download a Test Reports (JUnit XML)
124+
# uses: actions/download-artifact@v3.0.2
125+
# with:
126+
# name: test-results
127+
#
128+
# - name: Test reporting
129+
# uses: dorny/test-reporter@v1
130+
# if: success() || failure()
131+
# with:
132+
# name: Test Report
133+
# path: "**/build/test-results/*/*.xml"
134+
# reporter: java-junit

key.core/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ compileJavacc {
5555
from("src/main/javacc/de/uka/ilkd/key/parser/proofjava/Token.java")
5656
into "$javaCCOutputDirMain/de/uka/ilkd/key/parser/proofjava/"
5757
}
58+
copy {
59+
from("src/main/javacc/de/uka/ilkd/key/parser/schemajava/JavaCharStream.java")
60+
into "$javaCCOutputDirMain/de/uka/ilkd/key/parser/schemajava/"
61+
}
62+
copy {
63+
from("src/main/javacc/de/uka/ilkd/key/parser/proofjava/JavaCharStream.java")
64+
into "$javaCCOutputDirMain/de/uka/ilkd/key/parser/proofjava/"
65+
}
5866
}
5967
}
6068

key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public class PosConvertException extends ConvertException implements HasLocation
1919

2020
private static final long serialVersionUID = 758453353495075586L;
2121

22+
/**
23+
* The file this error references. May be null.
24+
*/
25+
private String file;
26+
2227
/**
2328
* The line
2429
*/
@@ -40,6 +45,22 @@ public PosConvertException(String message, int line, int column) {
4045
super(message);
4146
this.line = line;
4247
this.column = column;
48+
this.file = null;
49+
}
50+
51+
/**
52+
* Instantiates a new exception with position and file information.
53+
*
54+
* @param message the message, not null
55+
* @param line the line to point to
56+
* @param column the column to point to
57+
* @param file the file that contains the error
58+
*/
59+
public PosConvertException(String message, int line, int column, String file) {
60+
super(message);
61+
this.line = line;
62+
this.column = column;
63+
this.file = file;
4364
}
4465

4566
/**
@@ -53,6 +74,7 @@ public PosConvertException(Throwable cause, int line, int column) {
5374
super(cause);
5475
this.line = line;
5576
this.column = column;
77+
this.file = null;
5678
}
5779

5880

@@ -78,12 +100,15 @@ public int getColumn() {
78100
@Override
79101
public Location getLocation() throws MalformedURLException {
80102
Throwable cause = getCause();
81-
String file = "";
82-
if (cause instanceof UnresolvedReferenceException) {
83-
UnresolvedReferenceException ure = (UnresolvedReferenceException) cause;
84-
CompilationUnit cu = UnitKit.getCompilationUnit(ure.getUnresolvedReference());
85-
String dataloc = cu.getDataLocation().toString();
86-
file = dataloc.substring(dataloc.indexOf(':') + 1);
103+
if (this.file == null) {
104+
if (cause instanceof UnresolvedReferenceException) {
105+
UnresolvedReferenceException ure = (UnresolvedReferenceException) cause;
106+
CompilationUnit cu = UnitKit.getCompilationUnit(ure.getUnresolvedReference());
107+
String dataloc = cu.getDataLocation().toString();
108+
this.file = dataloc.substring(dataloc.indexOf(':') + 1);
109+
} else {
110+
this.file = "";
111+
}
87112
}
88113
return new Location(file, getLine(), getColumn());
89114
}

key.core/src/main/java/de/uka/ilkd/key/java/PrettyPrinter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,10 @@ public void printCase(Case x) throws java.io.IOException {
29142914

29152915
public void printCatch(Catch x) throws java.io.IOException {
29162916
printHeader(x);
2917+
boolean oldLineFeed = noLinefeed;
2918+
noLinefeed = true;
29172919
writeToken("catch", x);
2920+
noLinefeed = oldLineFeed;
29182921
write(" (");
29192922
if (x.getParameterDeclaration() != null) {
29202923
noLinefeed = true;

key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import java.io.*;
4242
import java.nio.charset.StandardCharsets;
4343
import java.nio.file.Paths;
44-
import java.text.MessageFormat;
4544
import java.util.*;
4645

4746
/**
@@ -1234,9 +1233,14 @@ public static void reportError(String message, Throwable t) {
12341233
}
12351234

12361235
int[] pos = extractPositionInfo(cause.toString());
1236+
reportErrorWithPositionInFile(message, cause, pos, null);
1237+
}
1238+
1239+
public static void reportErrorWithPositionInFile(String message, Throwable cause, int[] pos,
1240+
String file) {
12371241
final RuntimeException rte;
12381242
if (pos.length > 0) {
1239-
rte = new PosConvertException(message, pos[0], pos[1]);
1243+
rte = new PosConvertException(message, pos[0], pos[1], file);
12401244
rte.initCause(cause);
12411245
} else {
12421246
rte = new ConvertException(message, cause);

key.core/src/main/java/de/uka/ilkd/key/java/recoderext/ConstantStringExpressionEvaluator.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package de.uka.ilkd.key.java.recoderext;
22

3+
import de.uka.ilkd.key.java.Recoder2KeY;
34
import recoder.CrossReferenceServiceConfiguration;
45
import recoder.abstraction.Type;
56
import recoder.java.Expression;
67
import recoder.java.NonTerminalProgramElement;
78
import recoder.java.ProgramElement;
9+
import recoder.java.SourceElement;
810
import recoder.java.declaration.TypeDeclaration;
911
import recoder.java.expression.literal.NullLiteral;
1012
import recoder.java.expression.literal.StringLiteral;
@@ -26,7 +28,18 @@ private void evaluateConstantStringExpressions(NonTerminalProgramElement td) {
2628

2729
ConstantEvaluator.EvaluationResult res = new ConstantEvaluator.EvaluationResult();
2830

29-
Type expType = services.getSourceInfo().getType((Expression) pe);
31+
Type expType = null;
32+
try {
33+
expType = services.getSourceInfo().getType((Expression) pe);
34+
} catch (Exception e) {
35+
// on failure: report with position information
36+
SourceElement.Position pos = pe.getStartPosition();
37+
int[] posArr = new int[] { pos.getLine(), pos.getColumn() };
38+
String file = td.compilationUnit().getDataLocation().toString();
39+
Recoder2KeY.reportErrorWithPositionInFile(
40+
"failed to perform constant evaluation", e,
41+
posArr, file);
42+
}
3043

3144
if (!(pe instanceof NullLiteral) && expType != null
3245
&& expType.getFullName().equals("java.lang.String")) {

key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public TextualJMLAssertStatement.Kind getKind() {
9090
*/
9191
public String getConditionText() {
9292
if (cond != null) {
93-
return LogicPrinter.quickPrintTerm(cond, services);
93+
return LogicPrinter.quickPrintTerm(cond, services).trim();
9494
}
9595
// this will lose whitespace, so e.g. \forall will not be printed correctly
9696
// but normally the term form should get printed.

key.core/src/main/java/de/uka/ilkd/key/macros/scripts/EngineState.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import de.uka.ilkd.key.proof.Proof;
2323
import de.uka.ilkd.key.settings.ProofSettings;
2424

25+
import javax.annotation.Nonnull;
26+
2527
/**
2628
* @author Alexander Weigl
2729
* @version 1 (28.03.17)
@@ -87,7 +89,7 @@ public Proof getProof() {
8789
* @throws ScriptException If there is no such {@link Goal}, or something else goes wrong.
8890
*/
8991
@SuppressWarnings("unused")
90-
public Goal getFirstOpenGoal(boolean checkAutomatic) throws ScriptException {
92+
public @Nonnull Goal getFirstOpenGoal(boolean checkAutomatic) throws ScriptException {
9193
if (proof.closed()) {
9294
throw new ProofAlreadyClosedException("The proof is closed already");
9395
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package de.uka.ilkd.key.macros.scripts;
2+
3+
import de.uka.ilkd.key.logic.*;
4+
import de.uka.ilkd.key.logic.op.SchemaVariable;
5+
import de.uka.ilkd.key.macros.scripts.meta.Option;
6+
import de.uka.ilkd.key.proof.Goal;
7+
import de.uka.ilkd.key.rule.FindTaclet;
8+
import de.uka.ilkd.key.rule.PosTacletApp;
9+
import de.uka.ilkd.key.rule.Taclet;
10+
import de.uka.ilkd.key.rule.TacletApp;
11+
import de.uka.ilkd.key.rule.inst.SVInstantiations;
12+
import org.key_project.util.collection.ImmutableList;
13+
14+
import java.util.Iterator;
15+
import java.util.Set;
16+
17+
/**
18+
* The command "focus" allows you to select formulas from the current sequent
19+
* to focus verification on. This means that all other formulas are discarded
20+
* (i.e. hidden using hide_right, hide_left).
21+
*
22+
* Benefits are: The automation is guided into focussing on a relevant set of
23+
* formulas.
24+
*
25+
* The selected set of sequent formulas can be regarded as an equivalent to an
26+
* unsat core.
27+
*
28+
* @author Created by sarah on 1/12/17.
29+
* @author Mattias Ulbrich, 2023
30+
*/
31+
public class FocusCommand extends AbstractCommand<FocusCommand.Parameters> {
32+
33+
public FocusCommand() {
34+
super(Parameters.class);
35+
}
36+
37+
static class Parameters {
38+
@Option("#2")
39+
public Sequent toKeep;
40+
}
41+
42+
@Override
43+
public void execute(Parameters s) throws ScriptException, InterruptedException {
44+
if (s == null) {
45+
throw new ScriptException("Missing 'sequent' argument for focus");
46+
}
47+
48+
Sequent toKeep = s.toKeep;
49+
50+
hideAll(toKeep);
51+
}
52+
53+
@Override
54+
public String getName() {
55+
return "focus";
56+
}
57+
58+
/**
59+
* Hide all formulas of the sequent that are not on focus sequent
60+
*
61+
* @param toKeep sequent containing formulas to keep
62+
* @throws ScriptException if no goal is currently open
63+
*/
64+
private void hideAll(Sequent toKeep) throws ScriptException {
65+
Goal goal = state.getFirstOpenAutomaticGoal();
66+
assert goal != null : "not null by contract of the method";
67+
68+
// The formulas to keep in the antecedent
69+
ImmutableList<Term> keepAnte = toKeep.antecedent().asList().map(SequentFormula::formula);
70+
ImmutableList<SequentFormula> ante = goal.sequent().antecedent().asList();
71+
72+
for (SequentFormula seqFormula : ante) {
73+
// This means "!keepAnte.contains(seqFormula.formula)" but with equality mod renaming!
74+
if (!keepAnte.exists(it -> it.equalsModRenaming(seqFormula.formula()))) {
75+
Taclet tac = getHideTaclet("left");
76+
makeTacletApp(goal, seqFormula, tac, true);
77+
}
78+
}
79+
80+
ImmutableList<Term> keepSucc = toKeep.succedent().asList().map(SequentFormula::formula);
81+
ImmutableList<SequentFormula> succ = goal.sequent().succedent().asList();
82+
for (SequentFormula seqFormula : succ) {
83+
if (!keepSucc.exists(it -> it.equalsModRenaming(seqFormula.formula()))) {
84+
Taclet tac = getHideTaclet("right");
85+
makeTacletApp(goal, seqFormula, tac, false);
86+
}
87+
}
88+
}
89+
90+
// determine where formula in sequent and apply either hide_left or hide_right
91+
private Taclet getHideTaclet(String pos) {
92+
String ruleName = "hide_" + pos;
93+
return proof.getEnv().getInitConfigForEnvironment().lookupActiveTaclet(new Name(ruleName));
94+
}
95+
96+
/**
97+
* Make tacletApp for one sequent formula to hide on the sequent
98+
*
99+
* @param g the goal on which this hide rule should be applied to
100+
* @param toHide the sequent formula to hide
101+
* @param tac the taclet top apply (either hide_left or hide_right)
102+
* @param antec whether the formula is in the antecedent
103+
*/
104+
private void makeTacletApp(Goal g, SequentFormula toHide, Taclet tac, boolean antec) {
105+
106+
// hide rules only applicable to top-level terms/sequent formulas
107+
PosInTerm pit = PosInTerm.getTopLevel();
108+
109+
PosInOccurrence pio = new PosInOccurrence(toHide, pit, antec);
110+
111+
Set<SchemaVariable> svs = tac.collectSchemaVars();
112+
assert svs.size() == 1;
113+
Iterator<SchemaVariable> iter = svs.iterator();
114+
SchemaVariable sv = (SchemaVariable) iter.next();
115+
116+
SVInstantiations inst = SVInstantiations.EMPTY_SVINSTANTIATIONS;
117+
118+
TacletApp app =
119+
PosTacletApp.createPosTacletApp((FindTaclet) tac, inst, pio, proof.getServices());
120+
app = app.addCheckedInstantiation(sv, toHide.formula(), proof.getServices(), true);
121+
g.apply(app);
122+
123+
}
124+
125+
}
126+

0 commit comments

Comments
 (0)