public Predicate exec(Prolog engine) {
   // '$dummy_9_builtins.pl'(A):-atom(A),!,fail
   Term a1, a2;
   Predicate cont;
   a1 = engine.aregs[1];
   cont = engine.cont;
   // '$dummy_9_builtins.pl'(A):-['$get_level'(B),atom(A),'$cut'(B),fail]
   a2 = new VariableTerm(engine);
   // START inline expansion of $get_level(a(2))
   if (!a2.unify(new IntegerTerm(engine.B0), engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of atom(a(1))
   a1 = a1.dereference();
   if (!a1.isSymbol()) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of $cut(a(2))
   a2 = a2.dereference();
   if (!a2.isInteger()) {
     throw new IllegalTypeException("integer", a2);
   } else {
     engine.cut(((IntegerTerm) a2).intValue());
   }
   // END inline expansion
   // START inline expansion of fail
   return engine.fail();
   // END inline expansion
 }
Beispiel #2
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;
 }