/** * Creates a new {@link UserSpecCallAction}, which will focus the agent's * attention to a certain module when executed. * * @param spec * the user spec action that should be called. * @param parameters * the parameters, exactly as used at the caller's side. These * still have to be substituted at runtime against the actual * variable values at that time and then renamed into the space * of the {@link #actionSpec}. */ public UserSpecCallAction(UserSpecAction spec, List<Term> parameters, SourceInfo info) { super(spec.getName(), info); for (Term term : parameters) { addParameter(term); } this.actionSpec = spec; }
@Override public Action convert(UserSpecAction action) throws MSTTranslationException { LinkedList<Parameter> parameters = new LinkedList<>(); for (Term term : action.getParameters()) { parameters.add(convert(term)); } return new Action(action.getName(), parameters); }
@Override public UserSpecAction applySubst(Substitution substitution) { // Apply substitution to action parameters, pre- and post-condition. List<Term> parameters = new ArrayList<>(getParameters().size()); for (Term parameter : getParameters()) { parameters.add(parameter.applySubst(substitution)); } ActionPreCondition precondition = (getFullPreCondition() == null) ? null : getFullPreCondition().applySubst(substitution); ActionPostCondition positivePostcondition = (getPositivePostcondition() == null) ? null : getPositivePostcondition().applySubst(substitution); ActionPostCondition negativePostcondition = (getNegativePostcondition() == null) ? null : getNegativePostcondition().applySubst(substitution); return new UserSpecAction(getName(), parameters, isExternal(), precondition, positivePostcondition, negativePostcondition, getSourceInfo()); }