public Predicate exec(Prolog engine) {
   // '$variants_subset'([],A,[],[],[]):-!
   Term a1, a2, a3, a4, a5;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   a5 = engine.aregs[5];
   cont = engine.cont;
   // '$variants_subset'([],A,[],[],[]):-['$neck_cut']
   a1 = a1.dereference();
   if (a1.isSymbol()) {
     if (!a1.equals(s1)) return engine.fail();
   } else if (a1.isVariable()) {
     ((VariableTerm) a1).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a3 = a3.dereference();
   if (a3.isSymbol()) {
     if (!a3.equals(s1)) return engine.fail();
   } else if (a3.isVariable()) {
     ((VariableTerm) a3).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a4 = a4.dereference();
   if (a4.isSymbol()) {
     if (!a4.equals(s1)) return engine.fail();
   } else if (a4.isVariable()) {
     ((VariableTerm) a4).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a5 = a5.dereference();
   if (a5.isSymbol()) {
     if (!a5.equals(s1)) return engine.fail();
   } else if (a5.isVariable()) {
     ((VariableTerm) a5).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   return cont;
 }
 public Predicate exec(Prolog engine) {
   // '$set_prolog_flag0'(no,A,B,C):-!,illarg(permission(modify,flag,A,D),set_prolog_flag(A,B),E)
   Term a1, a2, a3, a4, a5, a6;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   cont = engine.cont;
   // '$set_prolog_flag0'(no,A,B,C):-['$neck_cut',illarg(permission(modify,flag,A,D),set_prolog_flag(A,B),E)]
   a1 = a1.dereference();
   if (a1.isSymbol()) {
     if (!a1.equals(s1)) return engine.fail();
   } else if (a1.isVariable()) {
     ((VariableTerm) a1).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   Term[] y1 = {s3, s4, a2, new VariableTerm(engine)};
   a5 = new StructureTerm(s2, y1);
   Term[] y2 = {a2, a3};
   a6 = new StructureTerm(s5, y2);
   return new PRED_illarg_3(a5, a6, new VariableTerm(engine), cont);
 }
Esempio n. 3
0
 public Predicate exec(Prolog engine) {
   // '$mem_pair'(A=B,[C=D|E]):-A==C,!,B=D
   Term a1, a2, a3, a4, a5, a6, a7, a8;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   cont = engine.cont;
   // '$mem_pair'(A=B,[C=D|E]):-['$get_level'(F),'$equality_of_term'(A,C),'$cut'(F),'$unify'(B,D)]
   a1 = a1.dereference();
   if (a1.isStructure()) {
     if (!s1.equals(((StructureTerm) a1).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a1).args();
     a3 = args[0];
     a4 = args[1];
   } else if (a1.isVariable()) {
     a3 = new VariableTerm(engine);
     a4 = new VariableTerm(engine);
     Term[] args = {a3, a4};
     ((VariableTerm) a1).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a2 = a2.dereference();
   if (a2.isList()) {
     Term[] args = {((ListTerm) a2).car(), ((ListTerm) a2).cdr()};
     a5 = args[0];
   } else if (a2.isVariable()) {
     a5 = new VariableTerm(engine);
     ((VariableTerm) a2).bind(new ListTerm(a5, new VariableTerm(engine)), engine.trail);
   } else {
     return engine.fail();
   }
   a5 = a5.dereference();
   if (a5.isStructure()) {
     if (!s1.equals(((StructureTerm) a5).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a5).args();
     a6 = args[0];
     a7 = args[1];
   } else if (a5.isVariable()) {
     a6 = new VariableTerm(engine);
     a7 = new VariableTerm(engine);
     Term[] args = {a6, a7};
     ((VariableTerm) a5).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a8 = new VariableTerm(engine);
   // START inline expansion of $get_level(a(8))
   if (!a8.unify(new IntegerTerm(engine.B0), engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of $equality_of_term(a(3),a(6))
   a3 = a3.dereference();
   a6 = a6.dereference();
   if (!a3.equals(a6)) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of $cut(a(8))
   a8 = a8.dereference();
   if (!a8.isInteger()) {
     throw new IllegalTypeException("integer", a8);
   } else {
     engine.cut(((IntegerTerm) a8).intValue());
   }
   // END inline expansion
   // START inline expansion of $unify(a(4),a(7))
   if (!a4.unify(a7, engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   return cont;
 }