예제 #1
0
파일: Term.java 프로젝트: 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;
  }
예제 #2
0
파일: Term.java 프로젝트: 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();
    }
  }
예제 #3
0
파일: Map.java 프로젝트: 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();
    }
  }
예제 #4
0
파일: Term.java 프로젝트: 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();
   }
 }