use of suite.lp.doer.BinderFactory in project suite by stupidsing.
the class SewingProverImpl method compileCpsCallPredicate.
private Cps compileCpsCallPredicate(BinderFactory bf, Node node, Cps cpsx) {
Prototype prototype = Prototype.of(node);
if (rules.containsKey(prototype)) {
Clone_ f = bf.cloner(node);
Cps cps;
if (isHasCutByPrototype.get(prototype)) {
Mutable<Trampoline> mtr = getTrampolineByPrototype(prototype);
Trampoline rem = rt -> {
rt.cont(cpsx);
return fail;
};
cps = rt -> {
IList<Trampoline> rems = rt.rems;
rt.rems = IList.cons(fail, IList.end());
new Runtime(rt, rt_ -> {
rt_.query = f.apply(rt.env);
rt_.rems = rems;
rt_.pushRem(rem);
return mtr.get();
}).trampoline();
return null;
};
} else {
Mutable<Cps> mcps = getCpsByPrototype(prototype);
cps = rt -> {
Cps cps0 = rt.cps;
rt.cps = rt_ -> {
rt.cps = cps0;
return cpsx;
};
rt.query = f.apply(rt.env);
return mcps.get();
};
}
return cps;
} else
return Fail.t("cannot find predicate " + prototype);
}
Aggregations