Skip to content

Commit

Permalink
enhancement: use more specific type for action result term
Browse files Browse the repository at this point in the history
  • Loading branch information
madmike200590 committed Oct 30, 2024
1 parent ec18c5e commit 6ed327d
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package at.ac.tuwien.kr.alpha.core.actions;

import at.ac.tuwien.kr.alpha.api.grounder.Substitution;
import at.ac.tuwien.kr.alpha.api.programs.actions.Action;
import at.ac.tuwien.kr.alpha.api.programs.terms.ActionResultTerm;
import at.ac.tuwien.kr.alpha.api.programs.terms.Term;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import at.ac.tuwien.kr.alpha.api.programs.terms.Term;
import at.ac.tuwien.kr.alpha.api.programs.terms.FunctionTerm;
import at.ac.tuwien.kr.alpha.api.grounder.Substitution;
import at.ac.tuwien.kr.alpha.api.programs.actions.Action;

public class ActionExecutionServiceImpl implements ActionExecutionService {

private final ActionImplementationProvider actionProvider;
Expand All @@ -18,6 +18,8 @@ public ActionExecutionServiceImpl(ActionImplementationProvider implementationPro
this.actionProvider = implementationProvider;
}

// TODO possible bug: For two identical rules, the action should only be executed once - test this.
// Note that there may be more answers to this: Formally, a program is a *set* of rules, i.e. duplicate rules are not allowed.
@Override
public ActionWitness execute(String actionName, int sourceRuleId, Substitution sourceRuleInstance, List<Term> inputTerms) {
ActionInput actInput = new ActionInput(actionName, sourceRuleId, sourceRuleInstance, inputTerms);
Expand All @@ -26,7 +28,7 @@ public ActionWitness execute(String actionName, int sourceRuleId, Substitution s

private ActionWitness execute(ActionInput input) {
Action action = actionProvider.getSupportedActions().get(input.name);
FunctionTerm result = action.execute(input.inputTerms);
ActionResultTerm<?> result = action.execute(input.inputTerms);
return new ActionWitness(input.sourceRule, input.instance, input.name, input.inputTerms, result);
}

Expand Down

0 comments on commit 6ed327d

Please sign in to comment.