当前位置: 首页>>代码示例>>C#>>正文


C# YieldProlog.Variable类代码示例

本文整理汇总了C#中OpenSim.Region.ScriptEngine.Shared.YieldProlog.Variable的典型用法代码示例。如果您正苦于以下问题:C# Variable类的具体用法?C# Variable怎么用?C# Variable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Variable类属于OpenSim.Region.ScriptEngine.Shared.YieldProlog命名空间,在下文中一共展示了Variable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: read_term3

 public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
 {
     Variable SaveInput = new Variable();
     Variable Answer = new Variable();
     Variable Variables = new Variable();
     foreach (bool l1 in read_termOptions(Options, Variables))
     {
         foreach (bool l2 in YP.current_input(SaveInput))
         {
             try
             {
                 YP.see(Input);
                 foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
                 {
                     foreach (bool l4 in remove_pos(Answer, Term))
                         yield return false;
                 }
             }
             finally
             {
                 YP.see(SaveInput);
             }
         }
     }
 }
开发者ID:nhede,项目名称:Aurora-Sim-Optional-Modules,代码行数:25,代码来源:Parser.cs

示例2: read_term2

 public static IEnumerable<bool> read_term2(object Term, object Options)
 {
     Variable Answer = new Variable();
     Variable Variables = new Variable();
     foreach (bool l1 in read_termOptions(Options, Variables))
     {
         foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
         {
             foreach (bool l3 in remove_pos(Answer, Term))
                 yield return false;
         }
     }
 }
开发者ID:nhede,项目名称:Aurora-Sim-Optional-Modules,代码行数:13,代码来源:Parser.cs

示例3: makeCopy

 public object makeCopy(Variable.CopyStore copyStore)
 {
     // Atom does not contain variables that need to be copied.
     return this;
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:5,代码来源:Atom.cs

示例4: compileSamePredicateFunction

 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 })))
                                                         {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:101,代码来源:YPCompiler.cs

示例5: importPredicateList

 public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
 {
     {
         object _State = arg1;
         object _Module = arg2;
         foreach (bool l2 in YP.unify(arg3, Atom.NIL))
         {
             yield return true;
             yield break;
         }
     }
     {
         object State = arg1;
         object Module = arg2;
         Variable Name = new Variable();
         Variable Arity = new Variable();
         Variable Rest = new Variable();
         foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2("/", Name, Arity), Rest)))
         {
             CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
             foreach (bool l3 in importPredicateList(State, Module, Rest))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object State = arg1;
         object Module = arg2;
         Variable x3 = new Variable();
         Variable Rest = new Variable();
         foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
         {
             foreach (bool l3 in importPredicateList(State, Module, Rest))
             {
                 yield return true;
                 yield break;
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:42,代码来源:YPCompiler.cs

示例6: append

 public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
 {
     {
         Variable List = new Variable();
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             foreach (bool l3 in YP.unify(arg2, List))
             {
                 foreach (bool l4 in YP.unify(arg3, List))
                 {
                     yield return false;
                 }
             }
         }
     }
     {
         object List2 = arg2;
         Variable X = new Variable();
         Variable List1 = new Variable();
         Variable List12 = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
         {
             foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
             {
                 foreach (bool l4 in append(List1, List2, List12))
                 {
                     yield return false;
                 }
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:32,代码来源:YPCompiler.cs

示例7: putCStringCode

 public static IEnumerable<bool> putCStringCode(object Code)
 {
     {
         Variable HexDigit = new Variable();
         Variable HexChar = new Variable();
         if (YP.lessThanOrEqual(Code, 31))
         {
             if (YP.lessThanOrEqual(Code, 15))
             {
                 YP.write(Atom.a("\\u000"));
                 foreach (bool l4 in YP.unify(HexDigit, Code))
                 {
                     if (YP.lessThanOrEqual(HexDigit, 9))
                     {
                         foreach (bool l6 in YP.unify(HexChar, YP.add(HexDigit, 48)))
                         {
                             YP.put_code(HexChar);
                             yield return true;
                             yield break;
                         }
                         goto cutIf2;
                     }
                     foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 55)))
                     {
                         YP.put_code(HexChar);
                         yield return true;
                         yield break;
                     }
                 cutIf2:
                     { }
                 }
                 goto cutIf1;
             }
             YP.write(Atom.a("\\u001"));
             foreach (bool l3 in YP.unify(HexDigit, YP.subtract(Code, 16)))
             {
                 if (YP.lessThanOrEqual(HexDigit, 9))
                 {
                     foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 48)))
                     {
                         YP.put_code(HexChar);
                         yield return true;
                         yield break;
                     }
                     goto cutIf3;
                 }
                 foreach (bool l4 in YP.unify(HexChar, YP.add(HexDigit, 55)))
                 {
                     YP.put_code(HexChar);
                     yield return true;
                     yield break;
                 }
             cutIf3:
                 { }
             }
         cutIf1:
             { }
         }
     }
     {
         if (YP.termEqual(Code, 34))
         {
             YP.put_code(92);
             YP.put_code(34);
             yield return true;
             yield break;
         }
     }
     {
         if (YP.termEqual(Code, 92))
         {
             YP.put_code(92);
             YP.put_code(92);
             yield return true;
             yield break;
         }
     }
     {
         YP.put_code(Code);
         yield return true;
         yield break;
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:83,代码来源:YPCompiler.cs

示例8: convertExpressionPython

 public static void convertExpressionPython(object arg1)
 {
     {
         Variable X = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
         {
             YP.write(X);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
         {
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable _FunctorArgs = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
         {
             convertExpressionPython(new Functor2("call", Name, ArgList));
             return;
         }
     }
     {
         Variable Obj = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
         {
             YP.write(Obj);
             YP.write(Atom.a("."));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
         {
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
         {
             YP.write(Name);
             return;
         }
     }
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
         {
             YP.write(Atom.a("None"));
             return;
         }
     }
     {
         Variable X = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
         {
             YP.write(Atom.a("not ("));
             convertExpressionPython(X);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable X = new Variable();
         Variable Y = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
         {
             YP.write(Atom.a("("));
             convertExpressionPython(X);
             YP.write(Atom.a(") and ("));
             convertExpressionPython(Y);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:101,代码来源:YPCompiler.cs

示例9: convertStatementListJavascript

 public static void convertStatementListJavascript(object arg1, object arg2)
 {
     {
         object x1 = arg2;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Name);
             YP.write(Atom.a(":"));
             YP.nl();
             convertIndentationJavascript(Level);
             YP.write(Atom.a("{"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListJavascript(Body, NextLevel);
                 convertIndentationJavascript(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListJavascript(RestStatements, Level);
                 return;
             }
         }
     }
     {
         object Level = arg2;
         Variable _Type = new Variable();
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", _Type, Name, Expression), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("var "));
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("yield true;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("yield false;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
         {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:101,代码来源:YPCompiler.cs

示例10: convertFunctionJavascript

 public static void convertFunctionJavascript(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
         {
             YP.write(Atom.a("function getDeclaringClass() { return null; }"));
             YP.nl();
             YP.nl();
             return;
         }
     }
     {
         Variable x1 = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable Body = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { x1, Name, ArgList, Body })))
         {
             YP.write(Atom.a("function "));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListJavascript(ArgList);
             YP.write(Atom.a(") {"));
             YP.nl();
             convertStatementListJavascript(Body, 1);
             YP.write(Atom.a("}"));
             YP.nl();
             YP.nl();
             return;
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:32,代码来源:YPCompiler.cs

示例11: convertStatementListCSharp

 public static void convertStatementListCSharp(object arg1, object Level)
 {
     {
         Variable Name = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NewStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
         {
             foreach (bool l3 in append(Body, new ListPair(new Functor1("label", Name), RestStatements), NewStatements))
             {
                 convertStatementListCSharp(NewStatements, Level);
                 return;
             }
         }
     }
     {
         Variable Type = new Variable();
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", Type, Name, Expression), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Type);
             YP.write(Atom.a(" "));
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield return true;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield return false;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield break;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("return;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
         {
             convertIndentationCSharp(Level);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:101,代码来源:YPCompiler.cs

示例12: convertFunctionCSharp

 public static void convertFunctionCSharp(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
         {
             YP.write(Atom.a("public class YPInnerClass {}"));
             YP.nl();
             YP.write(Atom.a("public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
             YP.nl();
             YP.nl();
             return;
         }
     }
     {
         Variable ReturnType = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable Body = new Variable();
         Variable Level = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { ReturnType, Name, ArgList, Body })))
         {
             YP.write(Atom.a("public static "));
             YP.write(ReturnType);
             YP.write(Atom.a(" "));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListCSharp(ArgList);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(Level, 1))
             {
                 convertStatementListCSharp(Body, Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 YP.nl();
                 return;
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:40,代码来源:YPCompiler.cs

示例13: getSimpleIterator

        /// <summary>
        /// If the functor with name and args can be called directly as determined by
        ///   functorCallFunctionName, then call it and return its iterator.  If the predicate is
        ///   dynamic and undefined, or if static and the method cannot be found, return
        ///   the result of YP.unknownPredicate.
        /// This returns null if the functor has a special form than needs to be compiled 
        ///   (including ,/2 and ;/2).
        /// </summary>
        /// <param name="name"></param>
        /// <param name="args"></param>
        /// <param name="declaringClass">used to resolve references to the default 
        /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
        ///   null, this throws a PrologException for existence_error</param>
        /// <returns></returns>
        public static IEnumerable<bool> getSimpleIterator(Atom name, object[] args, Type declaringClass)
        {
            CompilerState state = new CompilerState();
            Variable FunctionName = new Variable();
            foreach (bool l1 in functorCallFunctionName(state, name, args.Length, FunctionName))
            {
                Atom functionNameAtom = ((Atom)FunctionName.getValue());
                if (functionNameAtom == Atom.NIL)
                    // name is for a dynamic predicate.
                    return YP.matchDynamic(name, args);

                string methodName = functionNameAtom._name;
                // Set the default for the method to call.
                Type methodClass = declaringClass;

                bool checkMode = false;
                if (methodName.StartsWith("YP."))
                {
                    // Assume we only check mode in calls to standard Prolog predicates in YP.
                    checkMode = true;

                    // Use the method in class YP.
                    methodName = methodName.Substring(3);
                    methodClass = typeof(YP);
                }
                if (methodName.Contains("."))
                    // We don't support calling inner classes, etc.
                    return null;

                if (methodClass == null)
                    return YP.unknownPredicate
                        (name, args.Length,
                         "Cannot find predicate function for: " + name + "/" + args.Length + 
                         " because declaringClass is null.  Set declaringClass to the class containing " +
                         methodName);
                try
                {
                    if (checkMode)
                    {
                        assertYPPred(state);
                        object functor = Functor.make(name, args);
                        if (CompilerState.isDetNoneOut(state, functor))
                        {
                            methodClass.InvokeMember
                                (methodName, BindingFlags.InvokeMethod, null, null, args);
                            return YP.succeed();
                        }
                        if (CompilerState.isSemidetNoneOut(state, functor))
                        {
                            if ((bool)methodClass.InvokeMember
                                 (methodName, BindingFlags.InvokeMethod, null, null, args))
                                return YP.succeed();
                            else
                                return YP.fail();
                        }

                    }
                    return (IEnumerable<bool>)methodClass.InvokeMember
                      (methodName, BindingFlags.InvokeMethod, null, null, args);
                }
                catch (TargetInvocationException exception)
                {
                    throw exception.InnerException;
                }
                catch (MissingMethodException)
                {
                    return YP.unknownPredicate
                        (name, args.Length,
                         "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length + 
                         " in " + methodClass.FullName);
                }
            }

            return null;
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:89,代码来源:YPCompiler.cs

示例14: compileExpression

 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
 {
     {
         Variable Name = new Variable();
         Variable TermArgs = new Variable();
         Variable X1 = new Variable();
         Variable FunctionName = new Variable();
         Variable Arg1 = new Variable();
         Variable x9 = new Variable();
         Variable X2 = new Variable();
         Variable Arg2 = new Variable();
         Variable x12 = new Variable();
         Variable Arity = new Variable();
         if (YP.nonvar(Term))
         {
             foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
             {
                 if (YP.atom(Name))
                 {
                     foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
                     {
                         foreach (bool l6 in unaryFunction(Name, FunctionName))
                         {
                             foreach (bool l7 in compileExpression(X1, State, Arg1))
                             {
                                 foreach (bool l8 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, Atom.NIL))))
                                 {
                                     yield return true;
                                     yield break;
                                 }
                             }
                             goto cutIf1;
                         }
                     }
                     foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
                     {
                         foreach (bool l6 in compileTerm(Term, State, Result))
                         {
                             yield return true;
                             yield break;
                         }
                         goto cutIf2;
                     }
                     foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
                     {
                         foreach (bool l6 in binaryFunction(Name, FunctionName))
                         {
                             foreach (bool l7 in compileExpression(X1, State, Arg1))
                             {
                                 foreach (bool l8 in compileExpression(X2, State, Arg2))
                                 {
                                     foreach (bool l9 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
                                     {
                                         yield return true;
                                         yield break;
                                     }
                                 }
                             }
                             goto cutIf3;
                         }
                     }
                     foreach (bool l5 in YP.functor(Term, x12, Arity))
                     {
                         YP.throwException(new Functor2("error", new Functor2("type_error", Atom.a("evaluable"), new Functor2("/", Name, Arity)), Atom.a("Not an expression function")));
                         yield return false;
                     }
                 cutIf3:
                 cutIf2:
                 cutIf1:
                     { }
                 }
             }
         }
     }
     {
         foreach (bool l2 in compileTerm(Term, State, Result))
         {
             yield return true;
             yield break;
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:82,代码来源:YPCompiler.cs

示例15: maplist_compileTerm

 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
 {
     {
         object _State = arg2;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             foreach (bool l3 in YP.unify(arg3, Atom.NIL))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object State = arg2;
         Variable First = new Variable();
         Variable Rest = new Variable();
         Variable FirstResult = new Variable();
         Variable RestResults = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
         {
             foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
             {
                 if (YP.nonvar(Rest))
                 {
                     foreach (bool l5 in compileTerm(First, State, FirstResult))
                 {
                         foreach (bool l6 in maplist_compileTerm(Rest, State, RestResults))
                     {
                         yield return true;
                         yield break;
                     }
                 }
             }
         }
     }
 }
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:38,代码来源:YPCompiler.cs


注:本文中的OpenSim.Region.ScriptEngine.Shared.YieldProlog.Variable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。