Ejemplo n.º 1
0
  public List<LSDBinding> getFreshBindingsForConclusion() {

    ArrayList<LSDBinding> bindings = new ArrayList<LSDBinding>();
    ArrayList<LSDVariable> variables = new ArrayList<LSDVariable>();
    ArrayList<LSDVariable> constHolders = new ArrayList<LSDVariable>();
    for (int i = 0; i < this.getTypes().length; i++) {

      char type = this.getTypes()[i];
      LSDVariable nextVar = null;
      if (i == this.getKeyArgument()) {
        nextVar = LSDVariable.newFreeVariable(variables, type);
        variables.add(nextVar);
      } else {
        nextVar = LSDVariable.newConstantHolder(constHolders, type);
        constHolders.add(nextVar);
      }
      bindings.add(new LSDBinding(nextVar));
    }
    return bindings;
  }
Ejemplo n.º 2
0
  private LSDPredicate(String pred, char[] types) throws LSDInvalidTypeException {
    this.types = types;

    //
    for (int i = 0; i < types.length; i++) {
      if (!LSDVariable.isValidType(types[i])) throw new LSDInvalidTypeException();
    }
    this.predName = pred;
    if (pred.indexOf("before_") != -1) {
      this.kind = BEFORE;
    } else if (pred.indexOf("after_") != -1) {
      this.kind = AFTER;
    } else if (pred.indexOf("deleted_") != -1) {
      this.kind = DELETED;
    } else if (pred.indexOf("added_") != -1) {
      this.kind = ADDED;
    } else if (pred.indexOf("modified_") != -1) {
      this.kind = MODIFIED;
    } else {
      this.kind = UNDEFINED;
    }
    level = setLevel(pred, types);
    // check
  }