gerrit_owners.PRED_member_2 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gerrit-owners Show documentation
Show all versions of gerrit-owners Show documentation
Gerrit Plugin that provides a Prolog predicate for enabling per directory code review requirements.
The newest version!
package gerrit_owners;
/*
member/2 defined in src/main/prolog/gerrit_owners.pl
This file is generated by Prolog Cafe.
PLEASE DO NOT EDIT!
*/
import com.googlecode.prolog_cafe.lang.*;
import com.googlecode.prolog_cafe.builtin.*;
import static gerrit_owners.PRED_member_2.*;
final class PRED_member_2 extends Predicate.P2 {
static final Operation member_2_top = new PRED_member_2_top();
static final Operation member_2_sub_1 = new PRED_member_2_sub_1();
static final Operation member_2_1 = new PRED_member_2_1();
static final Operation member_2_2 = new PRED_member_2_2();
public PRED_member_2(Term a1, Term a2, Operation cont) {
this.arg1 = a1;
this.arg2 = a2;
this.cont = cont;
}
@Override
public Operation exec(Prolog engine) {
engine.areg1 = arg1;
engine.areg2 = arg2;
engine.cont = cont;
return member_2_top;
}
}
final class PRED_member_2_top extends Operation {
@Override
public Operation exec(Prolog engine) {
engine.setB0();
return engine.jtry2(member_2_1, member_2_sub_1);
}
}
final class PRED_member_2_sub_1 extends Operation {
@Override
public Operation exec(Prolog engine) {
return engine.trust(member_2_2);
}
}
final class PRED_member_2_1 extends Operation {
@Override
public Operation exec(Prolog engine) {
// member(A,[A|B]):-true
Term a1, a2;
Operation cont;
a1 = engine.areg1;
a2 = engine.areg2;
cont = engine.cont;
// member(A,[A|B]):-[]
a2 = a2.dereference();
if (a2.isList()){
Term[] args = {((ListTerm)a2).car(), ((ListTerm)a2).cdr()};
if (! a1.unify(args[0], engine.trail))
return engine.fail();
} else if (a2.isVariable()){
((VariableTerm) a2).bind(new ListTerm(a1, new VariableTerm(engine)), engine.trail);
} else {
return engine.fail();
}
return cont;
}
}
final class PRED_member_2_2 extends Operation {
@Override
public Operation exec(Prolog engine) {
// member(A,[B|C]):-member(A,C)
Term a1, a2, a3;
Operation cont;
a1 = engine.areg1;
a2 = engine.areg2;
cont = engine.cont;
// member(A,[B|C]):-[member(A,C)]
a2 = a2.dereference();
if (a2.isList()){
Term[] args = {((ListTerm)a2).car(), ((ListTerm)a2).cdr()};
a3 = args[1];
} else if (a2.isVariable()){
a3 = new VariableTerm(engine);
((VariableTerm) a2).bind(new ListTerm(new VariableTerm(engine), a3), engine.trail);
} else {
return engine.fail();
}
engine.areg1 = a1;
engine.areg2 = a3;
engine.cont = cont;
return member_2_top;
}
}