// disable warning on l1, don't see how we can
        // code this differently
        #pragma warning disable 0168, 0219

        /// <summary>
        /// This is a simplified findall when the goal is a single call.
        /// </summary>
        /// <param name="Template"></param>
        /// <param name="goal"></param>
        /// <param name="Bag"></param>
        /// <returns></returns>
        public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
        {
            FindallAnswers findallAnswers = new FindallAnswers(Template);
            foreach (bool l1 in goal)
                findallAnswers.add();
            return findallAnswers.result(Bag);
        }
        /// <summary>
        /// Like findall, except return an array of the results.
        /// </summary>
        /// <param name="template"></param>
        /// <param name="goal"></param>
        /// <returns></returns>
        public static List <object> findallArray(object Template, IEnumerable <bool> goal)
        {
            FindallAnswers findallAnswers = new FindallAnswers(Template);

            foreach (bool l1 in goal)
            {
                findallAnswers.add();
            }
            return(findallAnswers.resultArray());
        }
        // disable warning on l1, don't see how we can
        // code this differently
        #pragma warning disable 0168, 0219

        /// <summary>
        /// This is a simplified findall when the goal is a single call.
        /// </summary>
        /// <param name="Template"></param>
        /// <param name="goal"></param>
        /// <param name="Bag"></param>
        /// <returns></returns>
        public static IEnumerable <bool> findall(object Template, IEnumerable <bool> goal, object Bag)
        {
            FindallAnswers findallAnswers = new FindallAnswers(Template);

            foreach (bool l1 in goal)
            {
                findallAnswers.add();
            }
            return(findallAnswers.result(Bag));
        }
Exemplo n.º 4
0
 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
 {
     {
         Variable FirstRule = new Variable();
         Variable x5 = new Variable();
         Variable x6 = new Variable();
         Variable x7 = new Variable();
         Variable Head = new Variable();
         Variable x9 = new Variable();
         Variable ArgAssignments = new Variable();
         Variable Calls = new Variable();
         Variable Rule = new Variable();
         Variable VariableNameSuggestions = new Variable();
         Variable ClauseBag = new Variable();
         Variable Name = new Variable();
         Variable ArgsList = new Variable();
         Variable FunctionArgNames = new Variable();
         Variable MergedArgName = new Variable();
         Variable ArgName = new Variable();
         Variable MergedArgNames = new Variable();
         Variable FunctionArgs = new Variable();
         Variable BodyCode = new Variable();
         Variable ReturnType = new Variable();
         Variable BodyWithReturn = new Variable();
         foreach (bool l2 in YP.unify(new ListPair(new Functor2("f", FirstRule, x5), x6), SamePredicateRuleList))
         {
             foreach (bool l3 in YP.unify(FirstRule, new Functor1(":-", x7)))
             {
                 goto cutIf1;
             }
             foreach (bool l3 in YP.unify(new Functor2(":-", Head, x9), FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers3.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers3.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers4.add();
                                     goto cutIf5;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers4.add();
                                 }
                             cutIf5:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers4.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf7;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf8;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf9;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf9:
                                             cutIf8:
                                             cutIf7:
                                                 { }
                                             }
                                             goto cutIf6;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf11;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf12;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf13;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf13:
                                             cutIf12:
                                             cutIf11:
                                                 { }
                                             }
                                             goto cutIf10;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf14;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf15;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf16;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf16:
                                         cutIf15:
                                         cutIf14:
                                             { }
                                         }
                                     cutIf10:
                                     cutIf6:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 goto cutIf2;
             }
             foreach (bool l3 in YP.unify(Head, FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers17.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers17.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers18.add();
                                     goto cutIf19;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers18.add();
                                 }
                             cutIf19:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers18.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf21;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf22;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf23;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf23:
                                             cutIf22:
                                             cutIf21:
                                                 { }
                                             }
                                             goto cutIf20;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf25;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf26;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf27;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf27:
                                             cutIf26:
                                             cutIf25:
                                                 { }
                                             }
                                             goto cutIf24;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf28;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf29;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf30;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf30:
                                         cutIf29:
                                         cutIf28:
                                             { }
                                         }
                                     cutIf24:
                                     cutIf20:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         cutIf2:
         cutIf1:
             { }
         }
     }
 }
Exemplo n.º 5
0
        // static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }

        public static IEnumerable<bool> parseInput(object TermList)
        {
            {
                Variable TermAndVariables = new Variable();
                FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
                foreach (bool l2 in parseInputHelper(TermAndVariables))
                {
                    findallAnswers1.add();
                }
                foreach (bool l2 in findallAnswers1.result(TermList))
                {
                    yield return false;
                }
            }
        }
 /// <summary>
 /// Like findall, except return an array of the results.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="goal"></param>
 /// <returns></returns>
 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
 {
     FindallAnswers findallAnswers = new FindallAnswers(Template);
     foreach (bool l1 in goal)
         findallAnswers.add();
     return findallAnswers.resultArray();
 }