Commit 8e7a29bf authored by sarah.grebing's avatar sarah.grebing

Merge branch 'master' into 'gradle'

Recent changes into new build infrastructure

See merge request !10
parents 3d8b9312 c62ccd21
Pipeline #18552 failed with stages
in 0 seconds
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
# Execute this in this folder. # Execute this in this folder.
# Set to key/key/deployment/components/ # Set to key/key/deployment/components/
#COMPONENTS=${COMPONENTS:-/home/sarah/Documents/KIT_Mitarbeiter/KeYDevelopment/KeYGitDir/key/key/deployment/components/} COMPONENTS=${COMPONENTS:-/home/sarah/Documents/KIT_Mitarbeiter/KeYDevelopment/KeYGitDir/key/key/deployment/components/}
#COMPONENTS=$HOME/work/key/key/deployment/components/ #COMPONENTS=$HOME/work/key/key/deployment/components/
COMPONENTS=lib/components/ #COMPONENTS=lib/components/
......
...@@ -212,4 +212,4 @@ QUESTION_MARK: '?'; ...@@ -212,4 +212,4 @@ QUESTION_MARK: '?';
DIGITS : DIGIT+ ; DIGITS : DIGIT+ ;
fragment DIGIT : [0-9] ; fragment DIGIT : [0-9] ;
ID : ([a-zA-Z]|'#') ([_a-zA-Z0-9] | '.' | '\\'| '#')*; ID : ([a-zA-Z]|'#'|'_') ([_a-zA-Z0-9] | '.' | '\\'| '#')*;
\ No newline at end of file \ No newline at end of file
...@@ -197,7 +197,11 @@ public class PrettyPrinter extends DefaultASTVisitor<Void> { ...@@ -197,7 +197,11 @@ public class PrettyPrinter extends DefaultASTVisitor<Void> {
@Override @Override
public Void visit(TermLiteral termLiteral) { public Void visit(TermLiteral termLiteral) {
s.append(String.format("`%s`", termLiteral.getText())); String termLit = termLiteral.getText();
if (termLit.contains("\n")) {
termLit = termLit.trim();
}
s.append(String.format("`%s`", termLit));
return super.visit(termLiteral); return super.visit(termLiteral);
} }
......
...@@ -39,7 +39,7 @@ import lombok.Setter; ...@@ -39,7 +39,7 @@ import lombok.Setter;
@RequiredArgsConstructor @RequiredArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public abstract class CaseStatement extends Statement<ScriptLanguageParser.CasesListContext> { public abstract class CaseStatement extends Statement<ScriptLanguageParser.CasesListContext> {
protected Statements body; protected Statements body = new Statements();
/** /**
* {@inheritDoc} * {@inheritDoc}
......
...@@ -102,7 +102,7 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -102,7 +102,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
* Match the label of a goal node * Match the label of a goal node
* *
* @param currentState goal node as possible match cancidate * @param currentState goal node as possible match cancidate
* @param label String representation for regualr expression for label to match * @param label String representation for regular expression for label to match
* @return List of matches if match was sucessful, empty list otherwise * @return List of matches if match was sucessful, empty list otherwise
*/ */
@Override @Override
...@@ -111,10 +111,17 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -111,10 +111,17 @@ public class KeYMatcher implements MatcherApi<KeyData> {
List<VariableAssignment> assignments = new ArrayList<>(); List<VariableAssignment> assignments = new ArrayList<>();
resultsFromLabelMatch = new ArrayList<>(); resultsFromLabelMatch = new ArrayList<>();
//compile pattern //compile pattern
Pattern regexpForLabel = Pattern.compile(label); String cleanLabel = label.replaceAll(" ", "");
String cleanLabel2 = cleanLabel.replaceAll("\\(", "\\\\(");
cleanLabel = cleanLabel2.replaceAll("\\)", "\\\\)");
String branchLabel = currentState.getData().getBranchingLabel(); String branchLabel = currentState.getData().getBranchingLabel();
Matcher branchLabelMatcher = regexpForLabel.matcher(branchLabel); String cleanBranchLabel = branchLabel.replaceAll(" ", "");
Pattern regexpForLabel = Pattern.compile(cleanLabel);
Matcher branchLabelMatcher = regexpForLabel.matcher(cleanBranchLabel);
if (branchLabelMatcher.matches()) { if (branchLabelMatcher.matches()) {
...@@ -160,16 +167,6 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -160,16 +167,6 @@ public class KeYMatcher implements MatcherApi<KeyData> {
return assignments.isEmpty()? null: assignments; return assignments.isEmpty()? null: assignments;
} }
private Value<String> toValueTerm(KeyData currentState, Term matched) {
String reprTerm = LogicPrinter.quickPrintTerm(matched, currentState.getEnv().getServices());
//Hack: to avoid newlines
String reprTermReformatted = reprTerm.trim();
return new Value<>(
new TermType(new SortType(matched.sort())),
reprTermReformatted
);
}
@Override @Override
public List<VariableAssignment> matchSeq(GoalNode<KeyData> currentState, public List<VariableAssignment> matchSeq(GoalNode<KeyData> currentState,
String data, String data,
...@@ -178,7 +175,7 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -178,7 +175,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
//System.out.println("Signature " + sig.toString()); //System.out.println("Signature " + sig.toString());
Matchings m = MatcherFacade.matches(data, Matchings m = MatcherFacade.matches(data,
currentState.getData().getNode().sequent(), false, services); currentState.getData().getNode().sequent(), false, currentState.getData().getProof().getServices());
if (m.isEmpty()) { if (m.isEmpty()) {
LOGGER.debug("currentState has no match= " + currentState.getData().getNode().sequent()); LOGGER.debug("currentState has no match= " + currentState.getData().getNode().sequent());
...@@ -208,6 +205,17 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -208,6 +205,17 @@ public class KeYMatcher implements MatcherApi<KeyData> {
} }
} }
private Value<String> toValueTerm(KeyData currentState, Term matched) {
String reprTerm = LogicPrinter.quickPrintTerm(matched, currentState.getProof().getServices());
//Hack: to avoid newlines
String reprTermReformatted = reprTerm.trim();
return new Value<>(
new TermType(new SortType(matched.sort())),
reprTermReformatted
);
}
//private TermLiteral from(SequentFormula sf) { //private TermLiteral from(SequentFormula sf) {
// return new TermLiteral(sf.toString()); // return new TermLiteral(sf.toString());
......
...@@ -16,5 +16,6 @@ ...@@ -16,5 +16,6 @@
<li><code>occ</code> : <em>INT</em> occurence of the top-level formula</li> <li><code>occ</code> : <em>INT</em> occurence of the top-level formula</li>
<li><code>with</code> : <em>TERM</em> the term with which variables should be instantiated</li> <li><code>with</code> : <em>TERM</em> the term with which variables should be instantiated</li>
</ul> </ul>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -73,5 +73,13 @@ public class KeYInterpreterTest { ...@@ -73,5 +73,13 @@ public class KeYInterpreterTest {
} }
@Test
public void testHookAssignments() throws IOException, ProblemLoaderException {
facade.loadKeyFileSync(new File("src/test/resources/edu/kit/iti/formal/psdbg/interpreter/contraposition/contraposition.key"));
Interpreter<KeyData> i = execute(getClass().getResourceAsStream("contraposition/hookTestScript.kps"));
Assert.assertTrue(i.isStrictMode());
}
} }
script hookTest(){
__STRICT_MODE:= true;
impRight;
}
\ No newline at end of file
...@@ -140,6 +140,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -140,6 +140,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
if (fireVariableAssignmentHook(node, var.getIdentifier(), v)) { if (fireVariableAssignmentHook(node, var.getIdentifier(), v)) {
node.setVariableValue(var, v); node.setVariableValue(var, v);
} }
node.setVariableValue(var, v);
} }
} }
exitScope(assignmentStatement); exitScope(assignmentStatement);
...@@ -628,7 +629,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -628,7 +629,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
Set<GoalNode<T>> prevNodes = new HashSet<>(prev.getGoals()); Set<GoalNode<T>> prevNodes = new HashSet<>(prev.getGoals());
Set<GoalNode<T>> endNodes = new HashSet<>(end.getGoals()); Set<GoalNode<T>> endNodes = new HashSet<>(end.getGoals());
b = prevNodes.equals(endNodes); b = prevNodes.equals(endNodes);
b = b && counter <= maxIterationsRepeat; b = !b && counter <= maxIterationsRepeat;
} while (b); } while (b);
} catch (InterpreterRuntimeException e) { } catch (InterpreterRuntimeException e) {
logger.debug("Catched!", e); logger.debug("Catched!", e);
......
...@@ -39,7 +39,8 @@ public abstract class DefaultAssignmentHook<T> implements VariableAssignmentHook ...@@ -39,7 +39,8 @@ public abstract class DefaultAssignmentHook<T> implements VariableAssignmentHook
Variable<T, S> variable = (Variable<T, S>) variables.get(variableName); Variable<T, S> variable = (Variable<T, S>) variables.get(variableName);
return variable.setter.apply(data, value); return variable.setter.apply(data, value);
} }
return true; //@AW: TODO was true: Why?
return false;
} }
......
package edu.kit.iti.formal.psdbg.examples.lulu.bigIntProof; package edu.kit.iti.formal.psdbg.examples.lulu.bigIntProof;
import edu.kit.iti.formal.psdbg.examples.JavaExample; import edu.kit.iti.formal.psdbg.examples.Example;
public class BigIntExample extends JavaExample { public class BigIntExample extends Example {
public BigIntExample() { public BigIntExample() {
setName("BigInt");
defaultInit(getClass());
} }
} }
...@@ -136,7 +136,7 @@ public class DebuggerMain implements Initializable { ...@@ -136,7 +136,7 @@ public class DebuggerMain implements Initializable {
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
private ProofTree proofTree = new ProofTree(); private ProofTree proofTree = new ProofTree();
private DockNode proofTreeDock = new DockNode(proofTree, "Proof Tree"); private DockNode proofTreeDock = new DockNode(proofTree, "Proof Tree");
private WelcomePaneFMEdition welcomePane = new WelcomePaneFMEdition(this); private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT)); private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock; private DockNode activeInspectorDock;
private CommandHelp commandHelp = new CommandHelp(); private CommandHelp commandHelp = new CommandHelp();
...@@ -428,31 +428,51 @@ public class DebuggerMain implements Initializable { ...@@ -428,31 +428,51 @@ public class DebuggerMain implements Initializable {
executeScript(FACADE.buildInterpreter(), addInitBreakpoint); executeScript(FACADE.buildInterpreter(), addInitBreakpoint);
} }
/**
* Reload a problem from the beginning
*
* @param event
*/
@FXML @FXML
public void abortExecution() { public void reloadProblem(ActionEvent event) {
//abort current execution();
//save old information and refresh models
statusBar.publishMessage("Reloading...");
File lastLoaded;
if (model.getKeyFile() != null) {
lastLoaded = model.getKeyFile();
} else {
Contract chosen = model.getChosenContract();
lastLoaded = model.getJavaFile();
}
//model.reload();
abortExecution();
Platform.runLater(() -> model.setStatePointer(null));
handleStatePointerUI(null);
if (model.getDebuggerFramework() != null) { //reload getInspectionViewsController().getActiveInspectionViewTab().getModel()
try { InspectionModel iModel = getInspectionViewsController().getActiveInspectionViewTab().getModel();
// try to friendly //iModel.setHighlightedJavaLines(FXCollections.emptyObservableSet());
Future future = executorService.submit(() -> { iModel.clearHighlightLines();
model.getDebuggerFramework().stop(); iModel.getGoals().clear();
model.getDebuggerFramework().unregister(); iModel.setSelectedGoalNodeToShow(null);
model.getDebuggerFramework().release();
});
// wait a second! try {
future.get(1, TimeUnit.SECONDS); FACADE.reload(lastLoaded);
// urgently stop if (iModel.getGoals().size() > 0) {
model.getDebuggerFramework().hardStop(); iModel.setSelectedGoalNodeToShow(iModel.getGoals().get(0));
} catch (InterruptedException | ExecutionException | TimeoutException e) {
e.printStackTrace();
} finally {
model.setDebuggerFramework(null);
} }
} else { if (FACADE.getReadyToExecute()) {
LOGGER.info("no interpreter running"); LOGGER.info("Reloaded Successfully");
statusBar.publishMessage("Reloaded Sucessfully");
}
} catch (ProofInputException e) {
e.printStackTrace();
} catch (ProblemLoaderException e) {
e.printStackTrace();
} }
assert model.getDebuggerFramework() == null;
} }
@FXML @FXML
...@@ -768,44 +788,32 @@ public class DebuggerMain implements Initializable { ...@@ -768,44 +788,32 @@ public class DebuggerMain implements Initializable {
} }
} }
/**
* Reload a problem from the beginning
*
* @param event
*/
@FXML @FXML
public void reloadProblem(ActionEvent event) { public void abortExecution() {
//abort current execution(); statusBar.publishMessage("Aborting Execution...");
//save old information and refresh models if (model.getDebuggerFramework() != null) {
File lastLoaded; try {
if (model.getKeyFile() != null) { // try to friendly
lastLoaded = model.getKeyFile(); Future future = executorService.submit(() -> {
} else { model.getDebuggerFramework().stop();
Contract chosen = model.getChosenContract(); model.getDebuggerFramework().unregister();
lastLoaded = model.getJavaFile(); model.getDebuggerFramework().release();
} });
//model.reload();
abortExecution();
handleStatePointerUI(null);
model.setStatePointer(null);
//reload getInspectionViewsController().getActiveInspectionViewTab().getModel()
InspectionModel iModel = getInspectionViewsController().getActiveInspectionViewTab().getModel();
iModel.setHighlightedJavaLines(null);
iModel.getGoals().clear();
iModel.setSelectedGoalNodeToShow(null);
try { // wait a second!
FACADE.reload(lastLoaded); future.get(1, TimeUnit.SECONDS);
if (iModel.getGoals().size() > 0) { // urgently stop
iModel.setSelectedGoalNodeToShow(iModel.getGoals().get(0)); model.getDebuggerFramework().hardStop();
} catch (InterruptedException | ExecutionException | TimeoutException e) {
e.printStackTrace();
} finally {
model.setDebuggerFramework(null);
statusBar.publishMessage("Execution aborted.");
} }
} catch (ProofInputException e) { } else {
e.printStackTrace(); LOGGER.info("no interpreter running");
} catch (ProblemLoaderException e) {
e.printStackTrace();
} }
assert model.getDebuggerFramework() == null;
} }
@FXML @FXML
......
...@@ -9,6 +9,7 @@ import de.uka.ilkd.key.logic.SequentFormula; ...@@ -9,6 +9,7 @@ import de.uka.ilkd.key.logic.SequentFormula;
import de.uka.ilkd.key.macros.scripts.EngineState; import de.uka.ilkd.key.macros.scripts.EngineState;
import de.uka.ilkd.key.macros.scripts.RuleCommand; import de.uka.ilkd.key.macros.scripts.RuleCommand;
import de.uka.ilkd.key.macros.scripts.ScriptException; import de.uka.ilkd.key.macros.scripts.ScriptException;
import de.uka.ilkd.key.pp.LogicPrinter;
import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Goal;
import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.proof.Proof;
...@@ -54,6 +55,7 @@ public class InteractiveModeController { ...@@ -54,6 +55,7 @@ public class InteractiveModeController {
private static final Logger LOGGER = LogManager.getLogger(InteractiveModeController.class); private static final Logger LOGGER = LogManager.getLogger(InteractiveModeController.class);
private final Map<Node, Statements> cases = new HashMap<>(); private final Map<Node, Statements> cases = new HashMap<>();
private final ScriptController scriptController; private final ScriptController scriptController;
private BooleanProperty activated = new SimpleBooleanProperty(); private BooleanProperty activated = new SimpleBooleanProperty();
private ScriptArea scriptArea; private ScriptArea scriptArea;
...@@ -72,6 +74,8 @@ public class InteractiveModeController { ...@@ -72,6 +74,8 @@ public class InteractiveModeController {
private boolean moreThanOneMatch = false; private boolean moreThanOneMatch = false;
private CasesStatement casesStatement;
public void start(Proof currentProof, InspectionModel model) { public void start(Proof currentProof, InspectionModel model) {
Events.register(this); Events.register(this);
cases.clear(); cases.clear();
...@@ -81,7 +85,17 @@ public class InteractiveModeController { ...@@ -81,7 +85,17 @@ public class InteractiveModeController {
}); });
this.scriptArea = scriptController.newScript(); this.scriptArea = scriptController.newScript();
this.model = model; this.model = model;
casesStatement = new CasesStatement();
cases.forEach((k, v) -> {
val gcs = new GuardedCaseStatement();
val m = new MatchExpression();
m.setPattern(new StringLiteral(
format(LabelFactory.getBranchingLabel(k))
));
gcs.setGuard(m);
gcs.setBody(v);
casesStatement.getCases().add(gcs);
});
savepointslist = new ArrayList<>(); savepointslist = new ArrayList<>();
savepointsstatement = new ArrayList<>(); savepointsstatement = new ArrayList<>();
nodeAtInteractionStart = debuggerFramework.getStatePointer(); nodeAtInteractionStart = debuggerFramework.getStatePointer();
...@@ -147,19 +161,9 @@ public class InteractiveModeController { ...@@ -147,19 +161,9 @@ public class InteractiveModeController {
SequentFormula seqForm = tap.getPio().sequentFormula(); SequentFormula seqForm = tap.getPio().sequentFormula();
//transform term to parsable string representation //transform term to parsable string representation
Sequent seq = g.sequent(); Sequent seq = g.sequent();
String sfTerm = edu.kit.iti.formal.psdbg.termmatcher.Utils.toPrettyTerm(seqForm.formula()); String sfTerm = LogicPrinter.quickPrintTerm(seqForm.formula(), keYServices, false, false);
String onTerm = edu.kit.iti.formal.psdbg.termmatcher.Utils.toPrettyTerm(tap.getPio().subTerm()); String onTerm = LogicPrinter.quickPrintTerm(tap.getPio().subTerm(), keYServices, false, false);
//check whether more than one possibility for match
//Matchings matches = MatcherFacade.matches(term, seq, true, keYServices);
/*Parameters params = new Parameters();
params.put(new Variable("formula"), new TermLiteral(term));
if (matches.size() > 1) {
moreThanOneMatch = true;
params.put(new Variable("occ"), new StringLiteral("0"));
}*/
RuleCommand.Parameters params = new RuleCommand.Parameters(); RuleCommand.Parameters params = new RuleCommand.Parameters();
params.formula = seqForm.formula(); params.formula = seqForm.formula();
...@@ -170,7 +174,6 @@ public class InteractiveModeController { ...@@ -170,7 +174,6 @@ public class InteractiveModeController {
int occ = rch.getOccurence(tap.getApp()); int occ = rch.getOccurence(tap.getApp());
Parameters callp = new Parameters(); Parameters callp = new Parameters();
// callp.put(new Variable("formula"), new TermLiteral(sfTerm));
callp.put(new Variable("formula"), new TermLiteral(sfTerm)); callp.put(new Variable("formula"), new TermLiteral(sfTerm));
callp.put(new Variable("occ"), new IntegerLiteral(BigInteger.valueOf(occ))); callp.put(new Variable("occ"), new IntegerLiteral(BigInteger.valueOf(occ)));
callp.put(new Variable("on"), new TermLiteral(onTerm)); callp.put(new Variable("on"), new TermLiteral(onTerm));
...@@ -191,8 +194,8 @@ public class InteractiveModeController { ...@@ -191,8 +194,8 @@ public class InteractiveModeController {
applyRule(call, g); applyRule(call, g);
// Insert into the right cases // Insert into the right cases
Node currentNode = g.node(); // Node currentNode = g.node();
cases.get(findRoot(currentNode)).add(call); // cases.get(findRoot(currentNode)).add(call);
// How to Play this on the Proof? // How to Play this on the Proof?
// How to Build a new StatePointer? Is it still possible? // How to Build a new StatePointer? Is it still possible?
...@@ -228,35 +231,11 @@ public class InteractiveModeController { ...@@ -228,35 +231,11 @@ public class InteractiveModeController {
} }
public String getCasesAsString() { public String getCasesAsString() {
CasesStatement c = new CasesStatement();
cases.forEach((k, v) -> {
val gcs = new GuardedCaseStatement();
val m = new MatchExpression();
m.setPattern(new StringLiteral(
format(LabelFactory.getBranchingLabel(k))
));
gcs.setGuard(m);
gcs.setBody(v);
c.getCases().add(gcs);
});
PrettyPrinter pp = new PrettyPrinter(); PrettyPrinter pp = new PrettyPrinter();
c.accept(pp); casesStatement.accept(pp);
return pp.toString(); return pp.toString();
} }
private String format(String branchingLabel) {
System.out.println("branchingLabel = " + branchingLabel);
String newLabel = branchingLabel;
if (branchingLabel.endsWith("$$")) {
newLabel = branchingLabel.substring(0, branchingLabel.length() - 2);
newLabel += ".*";
System.out.println("newLabel = " + newLabel);
}
return newLabel;
}
private void applyRule(CallStatement call, Goal g) throws ScriptCommandNotApplicableException { private void applyRule(CallStatement call, Goal g) throws ScriptCommandNotApplicableException {
savepointslist.add(g.node()); savepointslist.add(g.node());
savepointsstatement.add(call); savepointsstatement.add(call);
...@@ -289,21 +268,46 @@ public class InteractiveModeController { ...@@ -289,21 +268,46 @@ public class InteractiveModeController {
map.put("#2", call.getCommand()); map.put("#2", call.getCommand());
EngineState estate = new EngineState(g.proof()); EngineState estate = new EngineState(g.proof());
estate.setGoal(g); estate.setGoal(g);
// System.out.println("on = " + map.get("on"));