Example #1
0
File: Map.java Project: rla/llj
  @SuppressWarnings("unchecked")
  @Predicate(name = "map_set", arity = 3)
  public AbstractGoal putMap(JavaCallGoal goal) throws Exception {
    ((java.util.Map<Object, Object>) goal.getArg(0)).put(goal.getArg(1), goal.getArg(2));

    return goal.G;
  }
Example #2
0
File: Term.java Project: rla/llj
  @Predicate(name = "arg", arity = 3)
  public AbstractGoal arg(JavaCallGoal goal) throws Exception {
    // FIXME check overflow???
    int arg = (int) goal.getLongArg(0);
    RuntimeStruct term = goal.getStructArg(1);

    return goal.unify(2, term.data[arg]);
  }
Example #3
0
File: Term.java Project: rla/llj
  @Predicate(name = "copy_term", arity = 2)
  public AbstractGoal copyTerm(JavaCallGoal goal) throws Exception {
    Object left = RuntimeVariable.copyTerm(goal.getArg(0));
    if (!goal.Q.unify(left, goal.getArg(1))) {
      return goal.Q.backtrack();
    }

    return goal.G;
  }
Example #4
0
File: Term.java Project: rla/llj
  @Predicate(name = "functor_ioo", arity = 3)
  public AbstractGoal functor_ioo(JavaCallGoal goal) throws Exception {
    RuntimeStruct struct = goal.getStructArg(0);
    Integer arity = struct.data.length - 1;
    String functor = (String) struct.data[0];

    if (goal.Q.unify(goal.getArg(1), functor) && goal.Q.unify(goal.getArg(2), arity)) {
      return goal.G;
    } else {
      return goal.Q.backtrack();
    }
  }
Example #5
0
File: Map.java Project: rla/llj
  @SuppressWarnings("unchecked")
  @Predicate(name = "map_get", arity = 3)
  public AbstractGoal getMap(JavaCallGoal goal) throws Exception {
    Object a3 = goal.getArg(2);
    Object o = ((java.util.Map<Object, Object>) goal.getArg(0)).get(goal.getArg(1));

    if (goal.Q.unify(a3, o)) {
      return goal.G;
    } else {
      return goal.Q.backtrack();
    }
  }
Example #6
0
File: Term.java Project: rla/llj
  /** Assumes that the first argument is certanly variable. */
  @Predicate(name = "functor_vii", arity = 3)
  public AbstractGoal functor_vii(JavaCallGoal goal) throws Exception {
    // FIXME check overflow?
    Integer arity = (int) goal.getLongArg(2);
    String functor = (String) goal.getStringArg(1);

    Object[] data = new Object[arity + 1];
    for (int i = 0; i < arity; i++) {
      data[i + 1] = new RuntimeVariable();
    }
    data[0] = functor;

    goal.setVar(0, new RuntimeStruct(data));

    return goal.G;
  }
Example #7
0
File: Term.java Project: rla/llj
 @Predicate(name = "functor", arity = 3)
 public AbstractGoal functor(JavaCallGoal goal) throws Exception {
   if (goal.getArg(0).getClass() == RuntimeVariable.class) {
     return functor_vii(goal);
   } else {
     return functor_ioo(goal);
   }
 }
Example #8
0
File: Term.java Project: rla/llj
 @Predicate(name = "var", arity = 1)
 public AbstractGoal var(JavaCallGoal goal) throws Exception {
   Object a1 = goal.getArg(0);
   if (a1.getClass() == RuntimeVariable.class) {
     return goal.G;
   } else {
     return goal.Q.backtrack();
   }
 }
Example #9
0
File: Map.java Project: rla/llj
  @Predicate(name = "map_new", arity = 1)
  public AbstractGoal newMap(JavaCallGoal goal) throws Exception {
    goal.setVar(0, new HashMap<Object, Object>());

    return goal.G;
  }