package jp.ac.kobe_u.cs.prolog.builtin;
import jp.ac.kobe_u.cs.prolog.lang.IntegerTerm;
import jp.ac.kobe_u.cs.prolog.lang.Predicate;
import jp.ac.kobe_u.cs.prolog.lang.Prolog;
import jp.ac.kobe_u.cs.prolog.lang.StructureTerm;
import jp.ac.kobe_u.cs.prolog.lang.SymbolTerm;
import jp.ac.kobe_u.cs.prolog.lang.Term;
import jp.ac.kobe_u.cs.prolog.lang.VariableTerm;
/*
This file is generated by Prolog Cafe.
PLEASE DO NOT EDIT!
*/
/**
<code>setof/3</code> defined in builtins.pl<br>
@author Mutsunori Banbara (banbara@kobe-u.ac.jp)
@author Naoyuki Tamura (tamura@kobe-u.ac.jp)
@version 1.0
*/
public class PRED_setof_3 extends Predicate {
static SymbolTerm s1 = SymbolTerm.makeSymbol("type", 1);
static SymbolTerm s2 = SymbolTerm.makeSymbol("callable");
static Term[] s3 = {s2};
static StructureTerm s4 = new StructureTerm(s1, s3);
static SymbolTerm s5 = SymbolTerm.makeSymbol("setof", 3);
static IntegerTerm si6 = new IntegerTerm(2);
static Predicate _setof_3_sub_1 = new PRED_setof_3_sub_1();
static Predicate _setof_3_1 = new PRED_setof_3_1();
static Predicate _setof_3_2 = new PRED_setof_3_2();
public Term arg1, arg2, arg3;
public PRED_setof_3(Term a1, Term a2, Term a3, Predicate cont) {
arg1 = a1;
arg2 = a2;
arg3 = a3;
this.cont = cont;
}
public PRED_setof_3(){}
public void setArgument(Term[] args, Predicate cont) {
arg1 = args[0];
arg2 = args[1];
arg3 = args[2];
this.cont = cont;
}
public int arity() { return 3; }
public String toString() {
return "setof(" + arg1 + "," + arg2 + "," + arg3 + ")";
}
public Predicate exec(Prolog engine) {
engine.aregs[1] = arg1;
engine.aregs[2] = arg2;
engine.aregs[3] = arg3;
engine.cont = cont;
engine.setB0();
return engine.jtry(_setof_3_1, _setof_3_sub_1);
}
}
class PRED_setof_3_sub_1 extends PRED_setof_3 {
public Predicate exec(Prolog engine) {
return engine.trust(_setof_3_2);
}
}
class PRED_setof_3_1 extends PRED_setof_3 {
public Predicate exec(Prolog engine) {
// setof(A,B,C):-callable(B),!,'$bagof'(A,B,D),sort(D,C)
Term a1, a2, a3, a4, a5;
Predicate p1, p2, p3;
Predicate cont;
a1 = engine.aregs[1];
a2 = engine.aregs[2];
a3 = engine.aregs[3];
cont = engine.cont;
// setof(A,B,C):-['$get_level'(D),callable(B),'$cut'(D),'$bagof'(A,B,E),sort(E,C)]
a4 = new VariableTerm(engine);
//START inline expansion of $get_level(a(4))
if (! a4.unify(new IntegerTerm(engine.B0), engine.trail)) {
return engine.fail();
}
//END inline expansion
a5 = new VariableTerm(engine);
p1 = new PRED_sort_2(a5, a3, cont);
p2 = new PRED_$bagof_3(a1, a2, a5, p1);
p3 = new PRED_$cut_1(a4, p2);
return new PRED_callable_1(a2, p3);
}
}
class PRED_setof_3_2 extends PRED_setof_3 {
public Predicate exec(Prolog engine) {
// setof(A,B,C):-illarg(type(callable),setof(A,B,C),2)
Term a1, a2, a3, a4;
Predicate cont;
a1 = engine.aregs[1];
a2 = engine.aregs[2];
a3 = engine.aregs[3];
cont = engine.cont;
// setof(A,B,C):-[illarg(type(callable),setof(A,B,C),2)]
Term[] y1 = {a1, a2, a3};
a4 = new StructureTerm(s5, y1);
return new PRED_illarg_3(s4, a4, si6, cont);
}
}