Commit e0c77460 authored by Sarah Grebing's avatar Sarah Grebing

local converter for local namespaces

parent 9aba5490
Pipeline #18884 failed with stages
in 2 minutes and 12 seconds
...@@ -46,6 +46,7 @@ assignment ...@@ -46,6 +46,7 @@ assignment
| variable=ID (COLON type=ID)? ASSIGN expression SEMICOLON | variable=ID (COLON type=ID)? ASSIGN expression SEMICOLON
; ;
expression expression
: :
expression MUL expression #exprMultiplication expression MUL expression #exprMultiplication
...@@ -56,6 +57,7 @@ expression ...@@ -56,6 +57,7 @@ expression
| expression AND expression #exprAnd | expression AND expression #exprAnd
| expression OR expression #exprOr | expression OR expression #exprOr
| expression IMP expression #exprIMP | expression IMP expression #exprIMP
| expression USING LBRACKET argList RBRACKET #namespaceset
//| expression EQUIV expression already covered by EQ/NEQ //| expression EQUIV expression already covered by EQ/NEQ
| expression LBRACKET substExpressionList RBRACKET #exprSubst | expression LBRACKET substExpressionList RBRACKET #exprSubst
| ID LPAREN (expression (',' expression)*)? RPAREN #function | ID LPAREN (expression (',' expression)*)? RPAREN #function
......
...@@ -226,4 +226,11 @@ public interface ASTTraversal<T> extends Visitor<T> { ...@@ -226,4 +226,11 @@ public interface ASTTraversal<T> extends Visitor<T> {
relaxBlock.getBody().accept(this); relaxBlock.getBody().accept(this);
return null; return null;
} }
@Override
default T visit(NamespaceSetExpression nss) {
nss.getExpression().accept(this);
nss.getSignature().accept(this);
return null;
}
} }
...@@ -176,5 +176,10 @@ public class DefaultASTVisitor<T> implements Visitor<T> { ...@@ -176,5 +176,10 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
public T visit(RelaxBlock relaxBlock) { public T visit(RelaxBlock relaxBlock) {
return defaultVisit(relaxBlock); return defaultVisit(relaxBlock);
} }
@Override
public T visit(NamespaceSetExpression nss) {
return defaultVisit(nss);
}
} }
...@@ -244,6 +244,14 @@ public class TransformAst implements ScriptLanguageVisitor<Object> { ...@@ -244,6 +244,14 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return ctx.matchPattern().accept(this); return ctx.matchPattern().accept(this);
} }
@Override
public Object visitNamespaceset(ScriptLanguageParser.NamespacesetContext ctx) {
NamespaceSetExpression nse = new NamespaceSetExpression();
nse.setExpression((Expression) ctx.expression().accept(this));
nse.setSignature((Signature) ctx.argList().accept(this));
return nse;
}
@Override @Override
public Object visitExprIMP(ScriptLanguageParser.ExprIMPContext ctx) { public Object visitExprIMP(ScriptLanguageParser.ExprIMPContext ctx) {
return createBinaryExpression(ctx, ctx.expression(), Operator.IMPLICATION); return createBinaryExpression(ctx, ctx.expression(), Operator.IMPLICATION);
......
...@@ -90,4 +90,5 @@ public interface Visitor<T> { ...@@ -90,4 +90,5 @@ public interface Visitor<T> {
T visit(RelaxBlock relaxBlock); T visit(RelaxBlock relaxBlock);
T visit(NamespaceSetExpression nss);
} }
package edu.kit.iti.formal.psdbg.parser.ast;
import edu.kit.iti.formal.psdbg.parser.NotWelldefinedException;
import edu.kit.iti.formal.psdbg.parser.ScriptLanguageParser;
import edu.kit.iti.formal.psdbg.parser.Visitor;
import edu.kit.iti.formal.psdbg.parser.types.Type;
import lombok.Getter;
import lombok.Setter;
public class NamespaceSetExpression extends Expression<ScriptLanguageParser.NamespacesetContext>{
@Getter @Setter
private Expression expression;
@Getter @Setter
private Signature signature = new Signature();
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
@Override
public boolean hasMatchExpression() {
return expression.hasMatchExpression();
}
@Override
public int getPrecedence() {
return 5;
}
@Override
public NamespaceSetExpression copy() {
NamespaceSetExpression nse = new NamespaceSetExpression();
nse.expression = expression.copy();
nse.signature = signature.copy();
return nse;
}
@Override
public Type getType(Signature signature) throws NotWelldefinedException {
return expression.getType(signature);
}
}
...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.parser.data; ...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.parser.data;
import edu.kit.iti.formal.psdbg.parser.ast.*; import edu.kit.iti.formal.psdbg.parser.ast.*;
import edu.kit.iti.formal.psdbg.parser.types.SimpleType; import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.Type; import edu.kit.iti.formal.psdbg.parser.types.Type;
import edu.kit.iti.formal.psdbg.parser.types.TypeFacade; import edu.kit.iti.formal.psdbg.parser.types.TypeFacade;
import lombok.Getter; import lombok.Getter;
......
...@@ -23,27 +23,52 @@ package edu.kit.iti.formal.psdbg.parser.types; ...@@ -23,27 +23,52 @@ package edu.kit.iti.formal.psdbg.parser.types;
*/ */
import javax.annotation.Nullable;
/** /**
* Represents the possible types (including scriptVarTypes). * Represents the possible types (including scriptVarTypes).
* <p> * <p>
* Created at 30.04.2017 * Created at 30.04.2017
* * INT("\\term int"),
BOOL("\\term bool"),
ANY("\\term any"),
INT_ARRAY("\\term int[]"),
OBJECT("\\term Object"),
HEAP("\\term Heap"),
FIELD("\\term Field"),
LOCSET("\\term LocSet"),
FORMULA("\\formula"),
SEQ("\\term Seq");
* @author Sarah Grebing * @author Sarah Grebing
*/ */
public enum SimpleType implements Type { public enum SimpleType implements Type {
STRING("string"), ANY("any"), STRING("string", "string"),
PATTERN("pattern"), //ANY("any", "any"),
INT("int"), BOOL("bool"), INT_ARRAY("int[]"), OBJECT("object"), PATTERN("pattern", null),
HEAP("heap"), FIELD("field"), LOCSET("locset"), NULL("null"), FORMULA("formula"), SEQ("Seq"); INT("int", "int"),
BOOL("bool", "bool"),
/*NULL("null", interpreterSort),
FORMULA("formula", interpreterSort),
SEQ("Seq", interpreterSort)*/;
private final String symbol; private final String symbol;
private @Nullable final String interpreterSort;
SimpleType(String symbol) { SimpleType(String symbol, @Nullable String interpreterSort) {
this.symbol = symbol; this.symbol = symbol;
this.interpreterSort = interpreterSort;
} }
@Override @Override
public String symbol() { public String symbol() {
return symbol; return symbol;
} }
@Override
public String interpreterSort() {
return interpreterSort;
}
} }
...@@ -29,4 +29,8 @@ public class TermType implements Type { ...@@ -29,4 +29,8 @@ public class TermType implements Type {
+ ">"; + ">";
} }
@Override
public String interpreterSort() {
return argTypes.get(0).interpreterSort();
}
} }
...@@ -6,4 +6,5 @@ package edu.kit.iti.formal.psdbg.parser.types; ...@@ -6,4 +6,5 @@ package edu.kit.iti.formal.psdbg.parser.types;
*/ */
public interface Type { public interface Type {
String symbol(); String symbol();
String interpreterSort();
} }
package edu.kit.iti.formal.psdbg.interpreter;
import de.uka.ilkd.key.logic.Name;
import de.uka.ilkd.key.logic.NamespaceSet;
import de.uka.ilkd.key.logic.Term;
import de.uka.ilkd.key.logic.op.LogicVariable;
import de.uka.ilkd.key.logic.op.QuantifiableVariable;
import de.uka.ilkd.key.logic.sort.Sort;
import de.uka.ilkd.key.proof.Goal;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.TermValue;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.Expression;
import edu.kit.iti.formal.psdbg.parser.ast.NamespaceSetExpression;
import edu.kit.iti.formal.psdbg.parser.ast.SubstituteExpression;
import edu.kit.iti.formal.psdbg.parser.ast.Variable;
import edu.kit.iti.formal.psdbg.parser.data.Value;
import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.Type;
import edu.kit.iti.formal.psdbg.parser.types.TypeFacade;
import org.key_project.util.collection.ImmutableArray;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class KeyEvaluator extends Evaluator<KeyData> {
public KeyEvaluator(VariableAssignment assignments, GoalNode<KeyData> g) {
super(assignments, g);
}
@Override
public Value visit(NamespaceSetExpression nss) {
Value term = (Value) nss.getExpression().accept(this);
if (term.getType() instanceof TermType) {
TermValue data = ((TermValue) term.getData()).copy();
nss.getSignature().forEach((v,s) -> {
Sort sort = asKeySort(s, getGoal().getData().getGoal());
data.getNs().variables().add(new LogicVariable(new Name(v.getIdentifier()), sort));
});
return new Value(term.getType(), data);
}else {
throw new IllegalStateException("Try to apply substitute on a non-term value.");
}
}
private Sort asKeySort(Type symbol, Goal g) {
NamespaceSet global = g.proof().getServices().getNamespaces();
Sort s = global.sorts().lookup(symbol.interpreterSort());
if(s!=null)
return s;
return g.getLocalNamespaces().sorts().lookup(symbol.interpreterSort());
}
@Override
public Value visit(SubstituteExpression expr) {
Value term = (Value) expr.getSub().accept(this);
if (term.getType() instanceof TermType) {
TermType tt = (TermType) term.getData();
//TODO better and new
Pattern pattern = Pattern.compile("\\?[a-zA-Z_]+");
String termstr = term.getData().toString();
Matcher m = pattern.matcher(termstr);
StringBuffer newTerm = new StringBuffer();
while (m.find()) {
String name = m.group().substring(1); // remove trailing '?'
Expression t = expr.getSubstitution().get(m.group());
//either evalute the substitent or find ?X in the
String newVal = "";
if (t != null)
newVal = ((Value) t.accept(this)).getData().toString();
else
// newVal = state.getValue(new Variable(name)).getData().toString();
m.appendReplacement(newTerm, newVal);
}
m.appendTail(newTerm);
return new Value<>(TypeFacade.ANY_TERM, newTerm.toString());
} else {
throw new IllegalStateException("Try to apply substitute on a non-term value.");
}
}
}
package edu.kit.iti.formal.psdbg.interpreter; package edu.kit.iti.formal.psdbg.interpreter;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import de.uka.ilkd.key.api.VariableAssignments; import de.uka.ilkd.key.api.VariableAssignments;
import de.uka.ilkd.key.logic.sort.Sort;
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;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.*;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.interpreter.funchdl.CommandLookup; import edu.kit.iti.formal.psdbg.interpreter.funchdl.CommandLookup;
import edu.kit.iti.formal.psdbg.parser.Visitor; import edu.kit.iti.formal.psdbg.parser.Visitor;
import edu.kit.iti.formal.psdbg.parser.ast.ClosesCase; import edu.kit.iti.formal.psdbg.parser.ast.ClosesCase;
import edu.kit.iti.formal.psdbg.parser.ast.Statements; import edu.kit.iti.formal.psdbg.parser.ast.Statements;
import edu.kit.iti.formal.psdbg.parser.ast.TermLiteral;
import edu.kit.iti.formal.psdbg.parser.ast.TryCase; import edu.kit.iti.formal.psdbg.parser.ast.TryCase;
import edu.kit.iti.formal.psdbg.parser.data.Value;
import edu.kit.iti.formal.psdbg.parser.types.SimpleType; import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.Type;
import edu.kit.iti.formal.psdbg.parser.types.TypeFacade;
import lombok.Getter; import lombok.Getter;
import lombok.val;
import java.util.List; import java.util.List;
import java.util.function.Function;
/** /**
* @author Alexander Weigl * @author Alexander Weigl
...@@ -27,15 +33,17 @@ public class KeyInterpreter extends Interpreter<KeyData> { ...@@ -27,15 +33,17 @@ public class KeyInterpreter extends Interpreter<KeyData> {
@Getter @Getter
private static final BiMap<SimpleType, VariableAssignments.VarType> typeConversionBiMap = private static final BiMap<SimpleType, VariableAssignments.VarType> typeConversionBiMap =
new ImmutableBiMap.Builder<SimpleType, VariableAssignments.VarType>() new ImmutableBiMap.Builder<SimpleType, VariableAssignments.VarType>()
.put(SimpleType.ANY, VariableAssignments.VarType.ANY) // .put(SimpleType.ANY, VariableAssignments.VarType.ANY)
.put(SimpleType.BOOL, VariableAssignments.VarType.BOOL) .put(SimpleType.BOOL, VariableAssignments.VarType.BOOL)
//.put(SimpleType.TERM, VariableAssignments.VarType.FORMULA) //TODO: parametrisierte Terms //.put(SimpleType.TERM, VariableAssignments.VarType.FORMULA) //TODO: parametrisierte Terms
.put(SimpleType.INT, VariableAssignments.VarType.INT) .put(SimpleType.INT, VariableAssignments.VarType.INT)
.put(SimpleType.STRING, VariableAssignments.VarType.OBJECT) .put(SimpleType.STRING, VariableAssignments.VarType.OBJECT)
.put(SimpleType.INT_ARRAY, VariableAssignments.VarType.INT_ARRAY) // .put(SimpleType.INT_ARRAY, VariableAssignments.VarType.INT_ARRAY)
.put(SimpleType.SEQ, VariableAssignments.VarType.SEQ) // .put(SimpleType.SEQ, VariableAssignments.VarType.SEQ)
.build(); .build();
public KeyInterpreter(CommandLookup lookup) { public KeyInterpreter(CommandLookup lookup) {
super(lookup); super(lookup);
} }
...@@ -126,4 +134,17 @@ public class KeyInterpreter extends Interpreter<KeyData> { ...@@ -126,4 +134,17 @@ public class KeyInterpreter extends Interpreter<KeyData> {
entryListeners = backupEntryListener; entryListeners = backupEntryListener;
} }
} }
@Override
protected Evaluator<KeyData> createEvaluator(VariableAssignment assignments, GoalNode<KeyData> g) {
KeyEvaluator eval = new KeyEvaluator(assignments, g);
eval.setMatcher(getMatcherApi());
eval.setTermValueFactory(new Function<TermLiteral, Value>() {
@Override
public Value apply(TermLiteral termLiteral) {
return new Value(TypeFacade.ANY_TERM, new TermValue(termLiteral.getText()));
}
});
return eval;
}
} }
...@@ -14,4 +14,9 @@ public class SortType implements Type { ...@@ -14,4 +14,9 @@ public class SortType implements Type {
public String symbol() { public String symbol() {
return sort.toString(); return sort.toString();
} }
@Override
public String interpreterSort() {
return symbol();
}
} }
package edu.kit.iti.formal.psdbg.interpreter.data;
import de.uka.ilkd.key.logic.NamespaceSet;
import de.uka.ilkd.key.logic.Term;
import de.uka.ilkd.key.logic.sort.Sort;
import de.uka.ilkd.key.pp.LogicPrinter;
import lombok.Data;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Data
public class TermValue {
@Nonnull
private Sort keySort = Sort.ANY;
private String termRepr;
@Nullable
private Term term;
/**
* Stores the local namespace, e.g. bounded variables.
*/
@Nullable
private NamespaceSet ns;
public TermValue() {
}
public TermValue(String text) {
termRepr = text;
}
public String getTermRepr(){
if(term!=null){
//TODO the better method
return LogicPrinter.quickPrintTerm(term, null, false,false);
}
else{
return termRepr;
}
}
public TermValue copy() {
TermValue tv = new TermValue();
tv.keySort = keySort;
tv.termRepr=termRepr;
tv.term=term;
tv.ns = ns.copy();
return tv;
}
}
...@@ -10,20 +10,15 @@ import java.util.Map; ...@@ -10,20 +10,15 @@ import java.util.Map;
* @author grebing * @author grebing
*/ */
public class ScriptCommandNotApplicableException extends InterpreterRuntimeException { public class ScriptCommandNotApplicableException extends InterpreterRuntimeException {
public ScriptCommandNotApplicableException(Exception e) {
super(e);
}
public ScriptCommandNotApplicableException(Exception e, RuleCommand c) { public ScriptCommandNotApplicableException(Exception e, RuleCommand c) {
System.out.println("Call " + c.getName() + " was not applicable"); System.out.println("Call " + c.getName() + " was not applicable");
} }
public ScriptCommandNotApplicableException(Exception e, RuleCommand c, Map<String, String> params) { public ScriptCommandNotApplicableException(Exception e, RuleCommand c, Map<String, Object> params) {
super(createMessage(c, params), e); super(createMessage(c, params), e);
} }
private static String createMessage(RuleCommand c, Map<String, String> params) { private static String createMessage(RuleCommand c, Map<String, Object> params) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Call " + c.getName() + " with parameters "); sb.append("Call " + c.getName() + " with parameters ");
for (String s : params.keySet()) { for (String s : params.keySet()) {
......
...@@ -6,6 +6,7 @@ import de.uka.ilkd.key.macros.scripts.EngineState; ...@@ -6,6 +6,7 @@ import de.uka.ilkd.key.macros.scripts.EngineState;
import de.uka.ilkd.key.macros.scripts.ProofScriptCommand; import de.uka.ilkd.key.macros.scripts.ProofScriptCommand;
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 edu.kit.iti.formal.psdbg.ValueInjector;
import edu.kit.iti.formal.psdbg.interpreter.Interpreter; import edu.kit.iti.formal.psdbg.interpreter.Interpreter;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
...@@ -14,12 +15,14 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; ...@@ -14,12 +15,14 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Value;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableList;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Collection; import java.util.Collection;
...@@ -63,16 +66,16 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -63,16 +66,16 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
State<KeyData> state = interpreter.getCurrentState(); State<KeyData> state = interpreter.getCurrentState();
GoalNode<KeyData> expandedNode = state.getSelectedGoalNode(); GoalNode<KeyData> expandedNode = state.getSelectedGoalNode();
KeyData kd = expandedNode.getData(); KeyData kd = expandedNode.getData();
Map<String, String> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
params.asMap().forEach((k, v) -> { params.asMap().forEach((k, v) -> {
// System.out.println("v.getData().toString() = " + v.getData().toString()); map.put(k.getIdentifier(), v.getData());
map.put(k.getIdentifier(), v.getData().toString());
} }
); );
try { try {
EngineState estate = new EngineState(kd.getProof()); EngineState estate = new EngineState(kd.getProof());
estate.setGoal(kd.getNode()); estate.setGoal(kd.getNode());
Object cc = c.evaluateArguments(estate, map); //exception? ValueInjector vi = ValueInjector.createDefault(kd.getNode());
Object cc = vi.inject(c, getParameterInstance(c), map);
AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl(); AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl();
c.execute(uiControl, cc, estate); c.execute(uiControl, cc, estate);
//what happens if this is empty -> meaning proof is closed //what happens if this is empty -> meaning proof is closed
...@@ -104,6 +107,13 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -104,6 +107,13 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
} }
} }
private <T> T getParameterInstance(ProofScriptCommand c) throws NoSuchMethodException, IllegalAccessException,
InstantiationException {
Method method = c.getClass().getMethod("evaluateArguments", EngineState.class, Map.class);
Class rtclazz = method.getReturnType();
return (T) rtclazz.newInstance();
}
@Override @Override
public String getHelp(CallStatement call) { public String getHelp(CallStatement call) {
ProofScriptCommand c = commands.get(call.getCommand()); ProofScriptCommand c = commands.get(call.getCommand());
......
...@@ -16,6 +16,7 @@ import de.uka.ilkd.key.proof.rulefilter.TacletFilter; ...@@ -16,6 +16,7 @@ import de.uka.ilkd.key.proof.rulefilter.TacletFilter;
import de.uka.ilkd.key.rule.Rule; import de.uka.ilkd.key.rule.Rule;
import de.uka.ilkd.key.rule.Taclet; import de.uka.ilkd.key.rule.Taclet;
import de.uka.ilkd.key.rule.TacletApp; import de.uka.ilkd.key.rule.TacletApp;
import edu.kit.iti.formal.psdbg.ValueInjector;
import edu.kit.iti.formal.psdbg.interpreter.Interpreter; import edu.kit.iti.formal.psdbg.interpreter.Interpreter;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
...@@ -23,6 +24,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.State; ...@@ -23,6 +24,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.ScriptCommandNotApplicableException; import edu.kit.iti.formal.psdbg.interpreter.exceptions.ScriptCommandNotApplicableException;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import edu.kit.iti.formal.psdbg.parser.data.Value;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -103,14 +105,16 @@ public class RuleCommandHandler implements CommandHandler<KeyData> { ...@@ -103,14 +105,16 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
State<KeyData> state = interpreter.getCurrentState(); State<KeyData> state = interpreter.getCurrentState();
GoalNode<KeyData> expandedNode = state.getSelectedGoalNode(); GoalNode<KeyData> expandedNode = state.getSelectedGoalNode();
KeyData kd = expandedNode.getData(); KeyData kd = expandedNode.getData();
Map<String, String> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
params.asMap().forEach((k, v) -> map.put(k.getIdentifier(), v.getData().toString())); params.asMap().forEach((k, v) -> map.put(k.getIdentifier(), v.getData()));
LOGGER.info("Execute {} with {}", call, map); LOGGER.info("Execute {} with {}", call, map);
try { try {
map.put("#2", call.getCommand()); map.put("#2", call.getCommand());
EngineState estate = new EngineState(kd.getProof()); EngineState estate = new EngineState(kd.getProof());
estate.setGoal(kd.getNode()); estate.setGoal(kd.getNode());
RuleCommand.Parameters cc = c.evaluateArguments(estate, map); //reflection exception RuleCommand.Parameters cc = new RuleCommand.Parameters();
ValueInjector valueInjector = ValueInjector.createDefault(kd.getNode());
cc = valueInjector.inject(c, cc, map);
AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl(); AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl();
c.execute(uiControl, cc, estate);