aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs5651
1 files changed, 5651 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
new file mode 100644
index 0000000..f2f8145
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
@@ -0,0 +1,5651 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.IO;
33using System.Collections;
34using System.Collections.Generic;
35using System.Text;
36using System.CodeDom.Compiler;
37
38namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
39{
40 public class YPCompiler
41 {
42 private class CompilerState
43 {
44 public IndexedAnswers _pred = new IndexedAnswers();
45 public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>();
46 public int _gensymCounter;
47 public bool _useFinalCutCode;
48 public Variable _finalCutCode;
49 public bool _codeUsesYield;
50 public Atom _determinism;
51 // a list of '='(Name, Variable)
52 public List<object> _variableNames;
53
54 // Make these static functions that explicitly take the State so Prolog can call it.
55
56 /// <summary>
57 /// Make a new CompilerState and bind it to State.
58 /// </summary>
59 /// <param name="State"></param>
60 /// <returns></returns>
61 public static IEnumerable<bool> make(object State)
62 {
63 return YP.unify(State, new CompilerState());
64 }
65
66 public static void assertPred(object State, object Pred, object Determinism)
67 {
68 State = YP.getValue(State);
69 object functorName = YP.getFunctorName(Pred);
70 object[] functorArgs = YP.getFunctorArgs(Pred);
71 // Debug: Should check if it's already asserted and is the same.
72 ((CompilerState)State)._pred.addAnswer
73 (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) });
74 }
75
76 public static void assertModuleForNameArity(object State, object Name, object Arity, object Module)
77 {
78 State = YP.getValue(State);
79 Name = YP.getValue(Name);
80 Arity = YP.getValue(Arity);
81 Module = YP.getValue(Module);
82 // If the Module Atom comes from the parser, it always has null _declaringClass.
83 if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int)
84 {
85 // Replace a previous entry if it exists.
86 ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] =
87 (Atom)Module;
88 }
89 }
90
91 public static void startFunction(object State, object Head)
92 {
93 State = YP.getValue(State);
94 ((CompilerState)State)._gensymCounter = 0;
95 ((CompilerState)State)._useFinalCutCode = false;
96 ((CompilerState)State)._finalCutCode = new Variable();
97 ((CompilerState)State)._codeUsesYield = false;
98 if (CompilerState.isDetNoneOut(State, Head))
99 ((CompilerState)State)._determinism = Atom.a("detNoneOut");
100 else if (CompilerState.isSemidetNoneOut(State, Head))
101 ((CompilerState)State)._determinism = Atom.a("semidetNoneOut");
102 else
103 ((CompilerState)State)._determinism = Atom.a("nondet");
104 }
105
106 public static void setCodeUsesYield(object State)
107 {
108 State = YP.getValue(State);
109 ((CompilerState)State)._codeUsesYield = true;
110 }
111
112 public static bool codeUsesYield(object State)
113 {
114 State = YP.getValue(State);
115 return ((CompilerState)State)._codeUsesYield;
116 }
117
118 public static bool determinismEquals(object State, object Term)
119 {
120 State = YP.getValue(State);
121 return YP.termEqual(((CompilerState)State)._determinism, Term);
122 }
123
124 /// <summary>
125 /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule.
126 /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc.
127 /// </summary>
128 /// <param name="State"></param>
129 /// <param name="rule"></param>
130 /// <param name="variableNameSuggestions"></param>
131 public static void newVariableNames(object State, object Rule, object VariableNameSuggestions)
132 {
133 State = YP.getValue(State);
134 List<Variable> variablesSet = new List<Variable>();
135 YP.addUniqueVariables(Rule, variablesSet);
136
137 ((CompilerState)State)._variableNames = new List<object>();
138 int xCounter = 0;
139 foreach (Variable variable in variablesSet)
140 ((CompilerState)State)._variableNames.Add
141 (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter),
142 variable));
143 }
144
145 private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter)
146 {
147 // Debug: should require named variables to start with _ or capital. Should
148 // check for duplicates and clashes with keywords.
149 for (object element = YP.getValue(variableNameSuggestions);
150 element is Functor2 && ((Functor2)element)._name == Atom.DOT;
151 element = YP.getValue(((Functor2)element)._arg2))
152 {
153 object suggestionPair = YP.getValue(((Functor2)element)._arg1);
154 if (sameVariable(variable, ((Functor2)suggestionPair)._arg2))
155 {
156 Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1);
157 if (suggestion.Equals(Atom.a("Atom")))
158 suggestion = Atom.a("Atom_1");
159 if (suggestion.Equals(Atom.a("Variable")))
160 suggestion = Atom.a("Variable_1");
161 if (suggestion.Equals(Atom.a("Functor")))
162 suggestion = Atom.a("Functor_1");
163 return suggestion;
164 }
165 }
166
167 return Atom.a("x" + xCounter);
168 }
169
170 /// <summary>
171 /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames
172 /// for variable.
173 /// </summary>
174 /// <param name="variable">a Variable</param>
175 /// <param name="State"></param>
176 /// <param name="Result">the assigned Name</param>
177 public static IEnumerable<bool> getVariableName(object State, object variable, object Result)
178 {
179 State = YP.getValue(State);
180 foreach (object variableInfo in ((CompilerState)State)._variableNames)
181 {
182 if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("=")))
183 {
184 if (sameVariable(variable, ((Functor2)variableInfo)._arg2))
185 return YP.unify(Result, ((Functor2)variableInfo)._arg1);
186 }
187 }
188
189 // We set up names for all unique variables, so this should never happen.
190 throw new PrologException(Atom.a("Can't find entry in _variableNames"));
191 }
192
193 public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList)
194 {
195 State = YP.getValue(State);
196 return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames));
197 }
198
199 public static IEnumerable<bool> gensym(object State, object Base, object Symbol)
200 {
201 State = YP.getValue(State);
202 return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter));
203 }
204
205 public static bool isDetNoneOut(object State, object Term)
206 {
207 State = YP.getValue(State);
208 object functorName = YP.getFunctorName(Term);
209 object[] functorArgs = YP.getFunctorArgs(Term);
210
211 Variable pred = new Variable();
212 foreach (bool l1 in ((CompilerState)State)._pred.match
213 (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") }))
214 {
215 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
216 {
217 return true;
218 }
219 }
220
221 return false;
222 }
223
224 public static bool isSemidetNoneOut(object State, object Term)
225 {
226 State = YP.getValue(State);
227 object functorName = YP.getFunctorName(Term);
228 object[] functorArgs = YP.getFunctorArgs(Term);
229
230 Variable pred = new Variable();
231 foreach (bool l1 in ((CompilerState)State)._pred.match
232 (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") }))
233 {
234 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
235 {
236 return true;
237 }
238 }
239
240 return false;
241 }
242
243 /// <summary>
244 /// Return false if any of args is out, otherwise true.
245 /// args is an array of ::(Type,Mode) where Mode is in or out.
246 /// </summary>
247 /// <param name="args"></param>
248 /// <returns></returns>
249 private static bool isNoneOut(object[] args)
250 {
251 foreach (object arg in args)
252 {
253 if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") &&
254 ((Functor2)arg)._arg2 == Atom.a("out"))
255 return false;
256 }
257 return true;
258 }
259
260 public static bool nameArityHasModule(object State, object Name, object Arity, object Module)
261 {
262 State = YP.getValue(State);
263 Name = YP.getValue(Name);
264 Arity = YP.getValue(Arity);
265 Module = YP.getValue(Module);
266 if (Name is Atom && Arity is int)
267 {
268 Atom FoundModule;
269 if (!((CompilerState)State)._moduleForNameArity.TryGetValue
270 (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule))
271 return false;
272 return FoundModule == Module;
273 }
274 return false;
275 }
276 }
277
278 /// <summary>
279 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
280 /// to return an anonymous YP.IClause for the Head and Body of a rule clause.
281 /// </summary>
282 /// <param name="Head">a prolog term such as new Functor2("test1", X, Y).
283 /// Note that the name of the head is ignored.
284 /// </param>
285 /// <param name="Body">a prolog term such as
286 /// new Functor2(",", new Functor1(Atom.a("test2", Atom.a("")), X),
287 /// new Functor2("=", Y, X)).
288 /// This may not be null. (For a head-only clause, set the Body to Atom.a("true").
289 /// </param>
290 /// <param name="declaringClass">if not null, the code is compiled as a subclass of this class
291 /// to resolve references to the default module Atom.a("")</param>
292 /// <returns>a new YP.IClause object on which you can call match(object[] args) where
293 /// args length is the arity of the Head</returns>
294 public static YP.IClause compileAnonymousClause(object Head, object Body, Type declaringClass)
295 {
296 object[] args = YP.getFunctorArgs(Head);
297 // compileAnonymousFunction wants "function".
298 object Rule = new Functor2(Atom.RULE, Functor.make("function", args), Body);
299 object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL));
300
301 StringWriter functionCode = new StringWriter();
302 Variable SaveOutputStream = new Variable();
303 foreach (bool l1 in YP.current_output(SaveOutputStream))
304 {
305 try
306 {
307 YP.tell(functionCode);
308 Variable FunctionCode = new Variable();
309 foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode))
310 {
311 if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass")))
312 // Ignore getDeclaringClass since we have access to the one passed in.
313 continue;
314
315 // Debug: should check if FunctionCode is a single call.
316 convertFunctionCSharp(FunctionCode);
317 }
318 YP.told();
319 }
320 finally
321 {
322 // Restore after calling tell.
323 YP.tell(SaveOutputStream.getValue());
324 }
325 }
326 return YPCompiler.compileAnonymousFunction
327 (functionCode.ToString(), args.Length, declaringClass);
328 }
329
330 /// <summary>
331 /// Use CodeDomProvider to compile the functionCode and return a YP.IClause.
332 /// The function name must be "function" and have nArgs arguments.
333 /// </summary>
334 /// <param name="functionCode">the code for the iterator, such as
335 /// "public static IEnumerable<bool> function() { yield return false; }"
336 /// </param>
337 /// <param name="nArgs">the number of args in the function</param>
338 /// <param name="declaringClass">if not null, then use the functionCode inside a class which
339 /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't
340 /// have to be qualified</param>
341 /// <returns>a new YP.IClause object on which you can call match(object[] args) where
342 /// args length is nArgs</returns>
343 public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass)
344 {
345 CompilerParameters parameters = new CompilerParameters();
346 // This gets the location of the System assembly.
347 parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location);
348 // This gets the location of this assembly which also has YieldProlog.YP, etc.
349 parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location);
350 if (declaringClass != null)
351 parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location);
352 parameters.GenerateInMemory = true;
353
354 StringBuilder sourceCode = new StringBuilder();
355 sourceCode.Append(@"
356using System;
357using System.Collections.Generic;
358using YieldProlog;
359
360namespace Temporary {
361 public class Temporary : YP.IClause {
362 public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" {
363");
364 sourceCode.Append(functionCode);
365 // Basically, match applies the args to function.
366 sourceCode.Append(@"
367 }
368 public IEnumerable<bool> match(object[] args) {
369 return Inner.function(");
370 if (nArgs >= 1)
371 sourceCode.Append("args[0]");
372 for (int i = 1; i < nArgs; ++i)
373 sourceCode.Append(", args[" + i + "]");
374 sourceCode.Append(@");
375 }
376 }
377}
378");
379
380 CompilerResults results = CodeDomProvider.CreateProvider
381 ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString());
382 if (results.Errors.Count > 0)
383 throw new Exception("Error evaluating code: " + results.Errors[0]);
384
385 // Return a new Temporary.Temporary object.
386 return (YP.IClause)results.CompiledAssembly.GetType
387 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
388 }
389
390 // Compiler output follows.
391
392 public class YPInnerClass { }
393 public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
394
395 public static void repeatWrite(object arg1, object N)
396 {
397 {
398 object _Value = arg1;
399 if (YP.termEqual(N, 0))
400 {
401 return;
402 }
403 }
404 {
405 object Value = arg1;
406 Variable NextN = new Variable();
407 YP.write(Value);
408 foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1)))
409 {
410 repeatWrite(Value, NextN);
411 return;
412 }
413 }
414 }
415
416 public static bool sameVariable(object Variable1, object Variable2)
417 {
418 {
419 if (YP.var(Variable1))
420 {
421 if (YP.var(Variable2))
422 {
423 if (YP.termEqual(Variable1, Variable2))
424 {
425 return true;
426 }
427 }
428 }
429 }
430 return false;
431 }
432
433 public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
434 {
435 {
436 Variable State = new Variable();
437 foreach (bool l2 in CompilerState.make(State))
438 {
439 CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det"));
440 CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
441 CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
442 CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
443 CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
444 CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
445 CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
446 CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
447 CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
448 CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
449 CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
450 CompilerState.assertPred(State, new Functor1(@"compound", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
451 CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
452 CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
453 CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
454 CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
455 CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
456 CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
457 processCompilerDirectives(RuleList, State);
458 foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass")))
459 {
460 yield return false;
461 }
462 foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
463 {
464 yield return false;
465 }
466 }
467 }
468 }
469
470 public static void processCompilerDirectives(object arg1, object arg2)
471 {
472 {
473 object _State = arg2;
474 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
475 {
476 return;
477 }
478 }
479 {
480 object State = arg2;
481 Variable Pred = new Variable();
482 Variable Determinism = new Variable();
483 Variable x3 = new Variable();
484 Variable RestRules = new Variable();
485 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules)))
486 {
487 CompilerState.assertPred(State, Pred, Determinism);
488 processCompilerDirectives(RestRules, State);
489 return;
490 }
491 }
492 {
493 object State = arg2;
494 Variable Module = new Variable();
495 Variable PredicateList = new Variable();
496 Variable x3 = new Variable();
497 Variable RestRules = new Variable();
498 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules)))
499 {
500 foreach (bool l3 in importPredicateList(State, Module, PredicateList))
501 {
502 processCompilerDirectives(RestRules, State);
503 return;
504 }
505 }
506 }
507 {
508 object State = arg2;
509 Variable x1 = new Variable();
510 Variable x2 = new Variable();
511 Variable RestRules = new Variable();
512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules)))
513 {
514 processCompilerDirectives(RestRules, State);
515 return;
516 }
517 }
518 {
519 object State = arg2;
520 Variable Head = new Variable();
521 Variable _Body = new Variable();
522 Variable x3 = new Variable();
523 Variable RestRules = new Variable();
524 Variable Name = new Variable();
525 Variable Arity = new Variable();
526 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules)))
527 {
528 foreach (bool l3 in YP.functor(Head, Name, Arity))
529 {
530 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
531 processCompilerDirectives(RestRules, State);
532 return;
533 }
534 }
535 }
536 {
537 object State = arg2;
538 Variable Fact = new Variable();
539 Variable x2 = new Variable();
540 Variable RestRules = new Variable();
541 Variable Name = new Variable();
542 Variable Arity = new Variable();
543 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules)))
544 {
545 foreach (bool l3 in YP.functor(Fact, Name, Arity))
546 {
547 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
548 processCompilerDirectives(RestRules, State);
549 return;
550 }
551 }
552 }
553 {
554 object State = arg2;
555 Variable x1 = new Variable();
556 Variable RestRules = new Variable();
557 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules)))
558 {
559 processCompilerDirectives(RestRules, State);
560 return;
561 }
562 }
563 }
564
565 public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
566 {
567 {
568 object _State = arg1;
569 object _Module = arg2;
570 foreach (bool l2 in YP.unify(arg3, Atom.NIL))
571 {
572 yield return true;
573 yield break;
574 }
575 }
576 {
577 object State = arg1;
578 object Module = arg2;
579 Variable Name = new Variable();
580 Variable Arity = new Variable();
581 Variable Rest = new Variable();
582 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest)))
583 {
584 CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
585 foreach (bool l3 in importPredicateList(State, Module, Rest))
586 {
587 yield return true;
588 yield break;
589 }
590 }
591 }
592 {
593 object State = arg1;
594 object Module = arg2;
595 Variable x3 = new Variable();
596 Variable Rest = new Variable();
597 foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
598 {
599 foreach (bool l3 in importPredicateList(State, Module, Rest))
600 {
601 yield return true;
602 yield break;
603 }
604 }
605 }
606 }
607
608 public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode)
609 {
610 {
611 Variable SamePredicateRuleList = new Variable();
612 Variable RestRules = new Variable();
613 foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules))
614 {
615 if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL))
616 {
617 foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode))
618 {
619 yield return false;
620 }
621 foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode))
622 {
623 yield return false;
624 }
625 }
626 }
627 }
628 }
629
630 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
631 {
632 {
633 Variable FirstRule = new Variable();
634 Variable x5 = new Variable();
635 Variable x6 = new Variable();
636 Variable x7 = new Variable();
637 Variable Head = new Variable();
638 Variable x9 = new Variable();
639 Variable ArgAssignments = new Variable();
640 Variable Calls = new Variable();
641 Variable Rule = new Variable();
642 Variable VariableNameSuggestions = new Variable();
643 Variable ClauseBag = new Variable();
644 Variable Name = new Variable();
645 Variable ArgsList = new Variable();
646 Variable FunctionArgNames = new Variable();
647 Variable MergedArgName = new Variable();
648 Variable ArgName = new Variable();
649 Variable MergedArgNames = new Variable();
650 Variable FunctionArgs = new Variable();
651 Variable BodyCode = new Variable();
652 Variable ReturnType = new Variable();
653 Variable BodyWithReturn = new Variable();
654 foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList))
655 {
656 foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7)))
657 {
658 goto cutIf1;
659 }
660 foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule))
661 {
662 CompilerState.startFunction(State, Head);
663 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
664 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
665 {
666 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
667 {
668 findallAnswers3.add();
669 }
670 }
671 foreach (bool l4 in findallAnswers3.result(ClauseBag))
672 {
673 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
674 {
675 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
676 {
677 FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
678 foreach (bool l7 in member(ArgName, FunctionArgNames))
679 {
680 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
681 {
682 findallAnswers4.add();
683 goto cutIf5;
684 }
685 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
686 {
687 findallAnswers4.add();
688 }
689 cutIf5:
690 { }
691 }
692 foreach (bool l7 in findallAnswers4.result(MergedArgNames))
693 {
694 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
695 {
696 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
697 {
698 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
699 {
700 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
701 {
702 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
703 {
704 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
705 {
706 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
707 {
708 yield return false;
709 }
710 }
711 goto cutIf7;
712 }
713 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
714 {
715 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
716 {
717 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
718 {
719 yield return false;
720 }
721 }
722 goto cutIf8;
723 }
724 if (CompilerState.codeUsesYield(State))
725 {
726 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
727 {
728 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
729 {
730 yield return false;
731 }
732 }
733 goto cutIf9;
734 }
735 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))
736 {
737 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
738 {
739 yield return false;
740 }
741 }
742 cutIf9:
743 cutIf8:
744 cutIf7:
745 { }
746 }
747 goto cutIf6;
748 }
749 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
750 {
751 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
752 {
753 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
754 {
755 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
756 {
757 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
758 {
759 yield return false;
760 }
761 }
762 goto cutIf11;
763 }
764 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
765 {
766 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
767 {
768 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
769 {
770 yield return false;
771 }
772 }
773 goto cutIf12;
774 }
775 if (CompilerState.codeUsesYield(State))
776 {
777 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
778 {
779 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
780 {
781 yield return false;
782 }
783 }
784 goto cutIf13;
785 }
786 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))
787 {
788 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
789 {
790 yield return false;
791 }
792 }
793 cutIf13:
794 cutIf12:
795 cutIf11:
796 { }
797 }
798 goto cutIf10;
799 }
800 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
801 {
802 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
803 {
804 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
805 {
806 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
807 {
808 yield return false;
809 }
810 }
811 goto cutIf14;
812 }
813 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
814 {
815 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
816 {
817 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
818 {
819 yield return false;
820 }
821 }
822 goto cutIf15;
823 }
824 if (CompilerState.codeUsesYield(State))
825 {
826 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
827 {
828 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
829 {
830 yield return false;
831 }
832 }
833 goto cutIf16;
834 }
835 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))
836 {
837 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
838 {
839 yield return false;
840 }
841 }
842 cutIf16:
843 cutIf15:
844 cutIf14:
845 { }
846 }
847 cutIf10:
848 cutIf6:
849 { }
850 }
851 }
852 }
853 }
854 }
855 }
856 goto cutIf2;
857 }
858 foreach (bool l3 in YP.unify(Head, FirstRule))
859 {
860 CompilerState.startFunction(State, Head);
861 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
862 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
863 {
864 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
865 {
866 findallAnswers17.add();
867 }
868 }
869 foreach (bool l4 in findallAnswers17.result(ClauseBag))
870 {
871 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
872 {
873 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
874 {
875 FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
876 foreach (bool l7 in member(ArgName, FunctionArgNames))
877 {
878 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
879 {
880 findallAnswers18.add();
881 goto cutIf19;
882 }
883 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
884 {
885 findallAnswers18.add();
886 }
887 cutIf19:
888 { }
889 }
890 foreach (bool l7 in findallAnswers18.result(MergedArgNames))
891 {
892 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
893 {
894 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
895 {
896 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
897 {
898 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
899 {
900 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
901 {
902 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
903 {
904 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
905 {
906 yield return false;
907 }
908 }
909 goto cutIf21;
910 }
911 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
912 {
913 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
914 {
915 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
916 {
917 yield return false;
918 }
919 }
920 goto cutIf22;
921 }
922 if (CompilerState.codeUsesYield(State))
923 {
924 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
925 {
926 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
927 {
928 yield return false;
929 }
930 }
931 goto cutIf23;
932 }
933 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))
934 {
935 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
936 {
937 yield return false;
938 }
939 }
940 cutIf23:
941 cutIf22:
942 cutIf21:
943 { }
944 }
945 goto cutIf20;
946 }
947 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
948 {
949 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
950 {
951 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
952 {
953 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
954 {
955 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
956 {
957 yield return false;
958 }
959 }
960 goto cutIf25;
961 }
962 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
963 {
964 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
965 {
966 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
967 {
968 yield return false;
969 }
970 }
971 goto cutIf26;
972 }
973 if (CompilerState.codeUsesYield(State))
974 {
975 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
976 {
977 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
978 {
979 yield return false;
980 }
981 }
982 goto cutIf27;
983 }
984 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))
985 {
986 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
987 {
988 yield return false;
989 }
990 }
991 cutIf27:
992 cutIf26:
993 cutIf25:
994 { }
995 }
996 goto cutIf24;
997 }
998 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
999 {
1000 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1001 {
1002 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
1003 {
1004 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1005 {
1006 yield return false;
1007 }
1008 }
1009 goto cutIf28;
1010 }
1011 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1012 {
1013 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1014 {
1015 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1016 {
1017 yield return false;
1018 }
1019 }
1020 goto cutIf29;
1021 }
1022 if (CompilerState.codeUsesYield(State))
1023 {
1024 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1025 {
1026 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1027 {
1028 yield return false;
1029 }
1030 }
1031 goto cutIf30;
1032 }
1033 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))
1034 {
1035 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1036 {
1037 yield return false;
1038 }
1039 }
1040 cutIf30:
1041 cutIf29:
1042 cutIf28:
1043 { }
1044 }
1045 cutIf24:
1046 cutIf20:
1047 { }
1048 }
1049 }
1050 }
1051 }
1052 }
1053 }
1054 }
1055 cutIf2:
1056 cutIf1:
1057 { }
1058 }
1059 }
1060 }
1061
1062 public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3)
1063 {
1064 {
1065 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1066 {
1067 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1068 {
1069 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1070 {
1071 yield return true;
1072 yield break;
1073 }
1074 }
1075 }
1076 }
1077 {
1078 Variable First = new Variable();
1079 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL)))
1080 {
1081 foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL)))
1082 {
1083 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1084 {
1085 yield return true;
1086 yield break;
1087 }
1088 }
1089 }
1090 }
1091 {
1092 object SamePredicateRuleList = arg2;
1093 object RestRules = arg3;
1094 Variable First = new Variable();
1095 Variable Rest = new Variable();
1096 Variable FirstRule = new Variable();
1097 Variable x6 = new Variable();
1098 Variable SecondRule = new Variable();
1099 Variable x8 = new Variable();
1100 Variable x9 = new Variable();
1101 Variable FirstHead = new Variable();
1102 Variable x11 = new Variable();
1103 Variable SecondHead = new Variable();
1104 Variable x13 = new Variable();
1105 Variable Name = new Variable();
1106 Variable Arity = new Variable();
1107 Variable RestSamePredicates = new Variable();
1108 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1109 {
1110 foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First))
1111 {
1112 foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest))
1113 {
1114 foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule))
1115 {
1116 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1117 {
1118 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1119 {
1120 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1121 {
1122 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1123 {
1124 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1125 {
1126 yield return true;
1127 yield break;
1128 }
1129 }
1130 goto cutIf3;
1131 }
1132 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1133 {
1134 foreach (bool l9 in YP.unify(RestRules, Rest))
1135 {
1136 yield return true;
1137 yield break;
1138 }
1139 }
1140 cutIf3:
1141 { }
1142 }
1143 goto cutIf2;
1144 }
1145 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1146 {
1147 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1148 {
1149 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1150 {
1151 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1152 {
1153 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1154 {
1155 yield return true;
1156 yield break;
1157 }
1158 }
1159 goto cutIf4;
1160 }
1161 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1162 {
1163 foreach (bool l9 in YP.unify(RestRules, Rest))
1164 {
1165 yield return true;
1166 yield break;
1167 }
1168 }
1169 cutIf4:
1170 { }
1171 }
1172 }
1173 cutIf2:
1174 goto cutIf1;
1175 }
1176 foreach (bool l5 in YP.unify(FirstHead, FirstRule))
1177 {
1178 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1179 {
1180 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1181 {
1182 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1183 {
1184 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1185 {
1186 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1187 {
1188 yield return true;
1189 yield break;
1190 }
1191 }
1192 goto cutIf6;
1193 }
1194 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1195 {
1196 foreach (bool l9 in YP.unify(RestRules, Rest))
1197 {
1198 yield return true;
1199 yield break;
1200 }
1201 }
1202 cutIf6:
1203 { }
1204 }
1205 goto cutIf5;
1206 }
1207 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1208 {
1209 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1210 {
1211 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1212 {
1213 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1214 {
1215 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1216 {
1217 yield return true;
1218 yield break;
1219 }
1220 }
1221 goto cutIf7;
1222 }
1223 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1224 {
1225 foreach (bool l9 in YP.unify(RestRules, Rest))
1226 {
1227 yield return true;
1228 yield break;
1229 }
1230 }
1231 cutIf7:
1232 { }
1233 }
1234 }
1235 cutIf5:
1236 { }
1237 }
1238 cutIf1:
1239 { }
1240 }
1241 }
1242 }
1243 }
1244 }
1245
1246 public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3)
1247 {
1248 {
1249 object _MergedArgNames = arg2;
1250 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1251 {
1252 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1253 {
1254 yield return true;
1255 yield break;
1256 }
1257 }
1258 }
1259 {
1260 object MergedArgNames = arg2;
1261 Variable ArgAssignments = new Variable();
1262 Variable Calls = new Variable();
1263 Variable Rest = new Variable();
1264 Variable ClauseCode = new Variable();
1265 Variable RestResults = new Variable();
1266 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest)))
1267 {
1268 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults)))
1269 {
1270 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
1271 {
1272 foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults))
1273 {
1274 yield return true;
1275 yield break;
1276 }
1277 }
1278 }
1279 }
1280 }
1281 }
1282
1283 public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4)
1284 {
1285 {
1286 object _MergedArgNames = arg3;
1287 Variable In = new Variable();
1288 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1289 {
1290 foreach (bool l3 in YP.unify(arg2, In))
1291 {
1292 foreach (bool l4 in YP.unify(arg4, In))
1293 {
1294 yield return true;
1295 yield break;
1296 }
1297 }
1298 }
1299 }
1300 {
1301 object In = arg2;
1302 object MergedArgNames = arg3;
1303 object ClauseCode = arg4;
1304 Variable VariableName = new Variable();
1305 Variable ArgName = new Variable();
1306 Variable RestArgAssignments = new Variable();
1307 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments)))
1308 {
1309 foreach (bool l3 in member(VariableName, MergedArgNames))
1310 {
1311 foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode))
1312 {
1313 yield return true;
1314 yield break;
1315 }
1316 goto cutIf1;
1317 }
1318 foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode))
1319 {
1320 yield return true;
1321 yield break;
1322 }
1323 cutIf1:
1324 { }
1325 }
1326 }
1327 }
1328
1329 public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName)
1330 {
1331 {
1332 object _ArgName = arg1;
1333 foreach (bool l2 in YP.unify(arg2, Atom.NIL))
1334 {
1335 if (YP.nonvar(VariableName))
1336 {
1337 yield return true;
1338 yield break;
1339 }
1340 }
1341 }
1342 {
1343 object ArgName = arg1;
1344 Variable ArgAssignments = new Variable();
1345 Variable _Calls = new Variable();
1346 Variable RestClauseBag = new Variable();
1347 foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag)))
1348 {
1349 foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments))
1350 {
1351 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
1352 {
1353 yield return false;
1354 }
1355 }
1356 }
1357 }
1358 }
1359
1360 public static IEnumerable<bool> maplist_arg(object arg1, object arg2)
1361 {
1362 {
1363 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1364 {
1365 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1366 {
1367 yield return true;
1368 yield break;
1369 }
1370 }
1371 }
1372 {
1373 Variable First = new Variable();
1374 Variable Rest = new Variable();
1375 Variable RestResults = new Variable();
1376 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1377 {
1378 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults)))
1379 {
1380 foreach (bool l4 in maplist_arg(Rest, RestResults))
1381 {
1382 yield return true;
1383 yield break;
1384 }
1385 }
1386 }
1387 }
1388 }
1389
1390 public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3)
1391 {
1392 {
1393 object _StartArgNumber = arg2;
1394 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1395 {
1396 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1397 {
1398 yield return true;
1399 yield break;
1400 }
1401 }
1402 }
1403 {
1404 object StartArgNumber = arg2;
1405 Variable x1 = new Variable();
1406 Variable Rest = new Variable();
1407 Variable ArgName = new Variable();
1408 Variable RestFunctionArgs = new Variable();
1409 Variable NumberCodes = new Variable();
1410 Variable NumberAtom = new Variable();
1411 Variable NextArgNumber = new Variable();
1412 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest)))
1413 {
1414 foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs)))
1415 {
1416 foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes))
1417 {
1418 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1419 {
1420 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1421 {
1422 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
1423 {
1424 foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs))
1425 {
1426 yield return true;
1427 yield break;
1428 }
1429 }
1430 }
1431 }
1432 }
1433 }
1434 }
1435 }
1436 }
1437
1438 public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls)
1439 {
1440 {
1441 Variable Head = new Variable();
1442 Variable Body = new Variable();
1443 Variable x8 = new Variable();
1444 Variable HeadArgs = new Variable();
1445 Variable CompiledHeadArgs = new Variable();
1446 Variable BodyCode = new Variable();
1447 Variable VariableNamesList = new Variable();
1448 Variable ArgUnifications = new Variable();
1449 foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule))
1450 {
1451 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
1452 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
1453 {
1454 foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs))
1455 {
1456 foreach (bool l5 in compileRuleBody(Body, State, BodyCode))
1457 {
1458 foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList))
1459 {
1460 foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications))
1461 {
1462 foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls))
1463 {
1464 yield return true;
1465 yield break;
1466 }
1467 }
1468 }
1469 }
1470 }
1471 }
1472 }
1473 }
1474 {
1475 foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls))
1476 {
1477 yield return true;
1478 yield break;
1479 }
1480 }
1481 }
1482
1483 public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1484 {
1485 {
1486 object x1 = arg2;
1487 object x2 = arg3;
1488 object x3 = arg4;
1489 Variable BodyCode = new Variable();
1490 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1491 {
1492 foreach (bool l3 in YP.unify(arg5, BodyCode))
1493 {
1494 foreach (bool l4 in YP.unify(arg6, BodyCode))
1495 {
1496 yield return true;
1497 yield break;
1498 }
1499 }
1500 }
1501 }
1502 {
1503 object Index = arg3;
1504 object AllHeadArgs = arg4;
1505 object BodyCode = arg5;
1506 object ArgUnifications = arg6;
1507 Variable HeadArg = new Variable();
1508 Variable RestHeadArgs = new Variable();
1509 Variable x3 = new Variable();
1510 Variable RestCompiledHeadArgs = new Variable();
1511 Variable _ArgIndex1 = new Variable();
1512 Variable NextIndex = new Variable();
1513 foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs)))
1514 {
1515 foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs)))
1516 {
1517 foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1))
1518 {
1519 foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1)))
1520 {
1521 foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications))
1522 {
1523 yield return true;
1524 yield break;
1525 }
1526 }
1527 }
1528 }
1529 }
1530 }
1531 {
1532 object Index = arg3;
1533 object AllHeadArgs = arg4;
1534 object BodyCode = arg5;
1535 Variable _HeadArg = new Variable();
1536 Variable RestHeadArgs = new Variable();
1537 Variable CompiledHeadArg = new Variable();
1538 Variable RestCompiledHeadArgs = new Variable();
1539 Variable ArgName = new Variable();
1540 Variable RestArgUnifications = new Variable();
1541 Variable NumberCodes = new Variable();
1542 Variable NumberAtom = new Variable();
1543 Variable NextIndex = new Variable();
1544 foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs)))
1545 {
1546 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
1547 {
1548 foreach (bool l4 in YP.unify(arg6, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(new Functor1(@"var", ArgName), new ListPair(CompiledHeadArg, Atom.NIL))), RestArgUnifications), Atom.NIL)))
1549 {
1550 foreach (bool l5 in YP.number_codes(Index, NumberCodes))
1551 {
1552 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
1553 {
1554 foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1555 {
1556 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
1557 {
1558 foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications))
1559 {
1560 yield return true;
1561 yield break;
1562 }
1563 }
1564 }
1565 }
1566 }
1567 }
1568 }
1569 }
1570 }
1571 }
1572
1573 public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1574 {
1575 {
1576 object _HeadArgs = arg2;
1577 Variable ArgAssignmentsIn = new Variable();
1578 Variable DeclarationsIn = new Variable();
1579 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1580 {
1581 foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn))
1582 {
1583 foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn))
1584 {
1585 foreach (bool l5 in YP.unify(arg5, DeclarationsIn))
1586 {
1587 foreach (bool l6 in YP.unify(arg6, DeclarationsIn))
1588 {
1589 yield return true;
1590 yield break;
1591 }
1592 }
1593 }
1594 }
1595 }
1596 }
1597 {
1598 object HeadArgs = arg2;
1599 object ArgAssignmentsIn = arg3;
1600 object ArgAssignmentsOut = arg4;
1601 object DeclarationsIn = arg5;
1602 object DeclarationsOut = arg6;
1603 Variable VariableName = new Variable();
1604 Variable Var = new Variable();
1605 Variable RestVariableNames = new Variable();
1606 Variable ArgIndex1 = new Variable();
1607 Variable NumberCodes = new Variable();
1608 Variable NumberAtom = new Variable();
1609 Variable ArgName = new Variable();
1610 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames)))
1611 {
1612 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
1613 {
1614 foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes))
1615 {
1616 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1617 {
1618 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1619 {
1620 foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1621 {
1622 yield return true;
1623 yield break;
1624 }
1625 }
1626 }
1627 }
1628 }
1629 }
1630 }
1631 {
1632 object HeadArgs = arg2;
1633 object ArgAssignmentsIn = arg3;
1634 object ArgAssignmentsOut = arg4;
1635 object DeclarationsIn = arg5;
1636 Variable VariableName = new Variable();
1637 Variable _Var = new Variable();
1638 Variable RestVariableNames = new Variable();
1639 Variable DeclarationsOut = new Variable();
1640 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames)))
1641 {
1642 foreach (bool l3 in YP.unify(arg6, new ListPair(new Functor3(@"declare", Atom.a(@"Variable"), VariableName, new Functor2(@"new", Atom.a(@"Variable"), Atom.NIL)), DeclarationsOut)))
1643 {
1644 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1645 {
1646 yield return true;
1647 yield break;
1648 }
1649 }
1650 }
1651 }
1652 }
1653
1654 public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3)
1655 {
1656 {
1657 Variable FirstHeadArgs = new Variable();
1658 Variable RestHeadArgs = new Variable();
1659 Variable x4 = new Variable();
1660 foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs)))
1661 {
1662 foreach (bool l3 in YP.unify(arg3, 1))
1663 {
1664 if (sameVariable(Var, FirstHeadArgs))
1665 {
1666 foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4))
1667 {
1668 goto cutIf1;
1669 }
1670 yield return false;
1671 cutIf1:
1672 yield break;
1673 }
1674 }
1675 }
1676 }
1677 {
1678 object Index = arg3;
1679 Variable x2 = new Variable();
1680 Variable RestHeadArgs = new Variable();
1681 Variable RestIndex = new Variable();
1682 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs)))
1683 {
1684 foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex))
1685 {
1686 foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex)))
1687 {
1688 yield return true;
1689 yield break;
1690 }
1691 }
1692 }
1693 }
1694 }
1695
1696 public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3)
1697 {
1698 {
1699 object A = arg1;
1700 object State = arg2;
1701 object PseudoCode = arg3;
1702 if (YP.var(A))
1703 {
1704 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode))
1705 {
1706 yield return true;
1707 yield break;
1708 }
1709 }
1710 }
1711 {
1712 object State = arg2;
1713 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1714 {
1715 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1716 {
1717 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1718 {
1719 yield return true;
1720 yield break;
1721 }
1722 }
1723 }
1724 }
1725 {
1726 object State = arg2;
1727 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1728 {
1729 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1730 {
1731 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1732 {
1733 yield return true;
1734 yield break;
1735 }
1736 }
1737 }
1738 }
1739 {
1740 object State = arg2;
1741 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1742 {
1743 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL))))
1744 {
1745 CompilerState.setCodeUsesYield(State);
1746 yield return true;
1747 yield break;
1748 }
1749 }
1750 }
1751 {
1752 object _State = arg2;
1753 Variable Name = new Variable();
1754 foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
1755 {
1756 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
1757 {
1758 yield return true;
1759 yield break;
1760 }
1761 }
1762 }
1763 {
1764 object State = arg2;
1765 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1766 {
1767 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1768 {
1769 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1770 {
1771 yield return true;
1772 yield break;
1773 }
1774 }
1775 }
1776 }
1777 {
1778 object State = arg2;
1779 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1780 {
1781 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1782 {
1783 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1784 {
1785 yield return true;
1786 yield break;
1787 }
1788 }
1789 }
1790 }
1791 {
1792 object State = arg2;
1793 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1794 {
1795 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
1796 {
1797 CompilerState.setCodeUsesYield(State);
1798 yield return true;
1799 yield break;
1800 }
1801 }
1802 }
1803 {
1804 object State = arg2;
1805 object PseudoCode = arg3;
1806 Variable A = new Variable();
1807 Variable B = new Variable();
1808 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
1809 {
1810 if (YP.var(A))
1811 {
1812 foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
1813 {
1814 yield return true;
1815 yield break;
1816 }
1817 }
1818 }
1819 }
1820 {
1821 object State = arg2;
1822 object PseudoCode = arg3;
1823 Variable A = new Variable();
1824 Variable T = new Variable();
1825 Variable B = new Variable();
1826 Variable C = new Variable();
1827 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C)))
1828 {
1829 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode))
1830 {
1831 yield return true;
1832 yield break;
1833 }
1834 }
1835 }
1836 {
1837 object State = arg2;
1838 object PseudoCode = arg3;
1839 Variable A = new Variable();
1840 Variable B = new Variable();
1841 Variable C = new Variable();
1842 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C)))
1843 {
1844 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode))
1845 {
1846 yield return true;
1847 yield break;
1848 }
1849 }
1850 }
1851 {
1852 object State = arg2;
1853 Variable A = new Variable();
1854 Variable B = new Variable();
1855 Variable ACode = new Variable();
1856 Variable BCode = new Variable();
1857 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1858 {
1859 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL)))
1860 {
1861 if (CompilerState.isSemidetNoneOut(State, A))
1862 {
1863 foreach (bool l5 in compileFunctorCall(A, State, ACode))
1864 {
1865 foreach (bool l6 in compileRuleBody(B, State, BCode))
1866 {
1867 yield return true;
1868 yield break;
1869 }
1870 }
1871 }
1872 }
1873 }
1874 }
1875 {
1876 object State = arg2;
1877 object PseudoCode = arg3;
1878 Variable A = new Variable();
1879 Variable B = new Variable();
1880 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1881 {
1882 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode))
1883 {
1884 yield return true;
1885 yield break;
1886 }
1887 }
1888 }
1889 {
1890 object State = arg2;
1891 object PseudoCode = arg3;
1892 Variable A = new Variable();
1893 Variable B = new Variable();
1894 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B)))
1895 {
1896 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode))
1897 {
1898 yield return true;
1899 yield break;
1900 }
1901 }
1902 }
1903 {
1904 object State = arg2;
1905 object PseudoCode = arg3;
1906 Variable A = new Variable();
1907 Variable T = new Variable();
1908 Variable B = new Variable();
1909 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B)))
1910 {
1911 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode))
1912 {
1913 yield return true;
1914 yield break;
1915 }
1916 }
1917 }
1918 {
1919 object State = arg2;
1920 object PseudoCode = arg3;
1921 Variable A = new Variable();
1922 Variable B = new Variable();
1923 Variable C = new Variable();
1924 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C)))
1925 {
1926 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode))
1927 {
1928 yield return true;
1929 yield break;
1930 }
1931 }
1932 }
1933 {
1934 object State = arg2;
1935 object PseudoCode = arg3;
1936 Variable A = new Variable();
1937 Variable ACode = new Variable();
1938 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A)))
1939 {
1940 foreach (bool l3 in compileRuleBody(A, State, ACode))
1941 {
1942 foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode))
1943 {
1944 yield return true;
1945 yield break;
1946 }
1947 }
1948 }
1949 }
1950 {
1951 object State = arg2;
1952 object PseudoCode = arg3;
1953 Variable Name = new Variable();
1954 Variable A = new Variable();
1955 Variable ACode = new Variable();
1956 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A)))
1957 {
1958 foreach (bool l3 in compileRuleBody(A, State, ACode))
1959 {
1960 foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode))
1961 {
1962 yield return true;
1963 yield break;
1964 }
1965 }
1966 }
1967 }
1968 {
1969 object _State = arg2;
1970 Variable x1 = new Variable();
1971 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1)))
1972 {
1973 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1974 {
1975 yield return true;
1976 yield break;
1977 }
1978 }
1979 }
1980 {
1981 object State = arg2;
1982 object PseudoCode = arg3;
1983 Variable A = new Variable();
1984 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A)))
1985 {
1986 foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
1987 {
1988 yield return true;
1989 yield break;
1990 }
1991 }
1992 }
1993 {
1994 object State = arg2;
1995 Variable A = new Variable();
1996 Variable Term = new Variable();
1997 Variable B = new Variable();
1998 Variable ACode = new Variable();
1999 Variable TermCode = new Variable();
2000 Variable BCode = new Variable();
2001 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B)))
2002 {
2003 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(ACode, new ListPair(TermCode, Atom.NIL))), BCode), Atom.NIL)))
2004 {
2005 foreach (bool l4 in compileTerm(A, State, ACode))
2006 {
2007 foreach (bool l5 in compileExpression(Term, State, TermCode))
2008 {
2009 foreach (bool l6 in compileRuleBody(B, State, BCode))
2010 {
2011 yield return true;
2012 yield break;
2013 }
2014 }
2015 }
2016 }
2017 }
2018 }
2019 {
2020 object State = arg2;
2021 Variable A = new Variable();
2022 Variable B = new Variable();
2023 Variable ACode = new Variable();
2024 Variable BCode = new Variable();
2025 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2026 {
2027 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2028 {
2029 if (CompilerState.isDetNoneOut(State, A))
2030 {
2031 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2032 {
2033 foreach (bool l6 in compileRuleBody(B, State, BCode))
2034 {
2035 yield return true;
2036 yield break;
2037 }
2038 }
2039 }
2040 }
2041 }
2042 }
2043 {
2044 object State = arg2;
2045 Variable A = new Variable();
2046 Variable B = new Variable();
2047 Variable ACode = new Variable();
2048 Variable BCode = new Variable();
2049 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2050 {
2051 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
2052 {
2053 if (CompilerState.isSemidetNoneOut(State, A))
2054 {
2055 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2056 {
2057 foreach (bool l6 in compileRuleBody(B, State, BCode))
2058 {
2059 yield return true;
2060 yield break;
2061 }
2062 }
2063 }
2064 }
2065 }
2066 }
2067 {
2068 object State = arg2;
2069 Variable ACode = new Variable();
2070 Variable B = new Variable();
2071 Variable BCode = new Variable();
2072 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
2073 {
2074 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2075 {
2076 foreach (bool l4 in compileRuleBody(B, State, BCode))
2077 {
2078 yield return true;
2079 yield break;
2080 }
2081 }
2082 }
2083 }
2084 {
2085 object State = arg2;
2086 Variable A = new Variable();
2087 Variable B = new Variable();
2088 Variable FunctionName = new Variable();
2089 Variable X1Code = new Variable();
2090 Variable X2Code = new Variable();
2091 Variable BCode = new Variable();
2092 Variable Name = new Variable();
2093 Variable X1 = new Variable();
2094 Variable X2 = new Variable();
2095 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2096 {
2097 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor2(@"call", FunctionName, new ListPair(X1Code, new ListPair(X2Code, Atom.NIL))), BCode), Atom.NIL)))
2098 {
2099 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL)))))
2100 {
2101 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
2102 {
2103 foreach (bool l6 in compileExpression(X1, State, X1Code))
2104 {
2105 foreach (bool l7 in compileExpression(X2, State, X2Code))
2106 {
2107 foreach (bool l8 in compileRuleBody(B, State, BCode))
2108 {
2109 yield return true;
2110 yield break;
2111 }
2112 }
2113 }
2114 }
2115 }
2116 }
2117 }
2118 }
2119 {
2120 object State = arg2;
2121 object PseudoCode = arg3;
2122 Variable A = new Variable();
2123 Variable B = new Variable();
2124 Variable C = new Variable();
2125 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
2126 {
2127 foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
2128 {
2129 yield return true;
2130 yield break;
2131 }
2132 }
2133 }
2134 {
2135 object State = arg2;
2136 object PseudoCode = arg3;
2137 Variable Template = new Variable();
2138 Variable Goal = new Variable();
2139 Variable Bag = new Variable();
2140 Variable B = new Variable();
2141 Variable TemplateCode = new Variable();
2142 Variable FindallAnswers = new Variable();
2143 Variable GoalAndAddCode = new Variable();
2144 Variable BagCode = new Variable();
2145 Variable BCode = new Variable();
2146 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B)))
2147 {
2148 foreach (bool l3 in compileTerm(Template, State, TemplateCode))
2149 {
2150 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers))
2151 {
2152 foreach (bool l5 in compileRuleBody(new Functor2(@",", Goal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
2153 {
2154 foreach (bool l6 in compileTerm(Bag, State, BagCode))
2155 {
2156 foreach (bool l7 in compileRuleBody(B, State, BCode))
2157 {
2158 foreach (bool l8 in append(new ListPair(new Functor3(@"declare", Atom.a(@"FindallAnswers"), FindallAnswers, new Functor2(@"new", Atom.a(@"FindallAnswers"), new ListPair(TemplateCode, Atom.NIL))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"result"), new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
2159 {
2160 yield return true;
2161 yield break;
2162 }
2163 }
2164 }
2165 }
2166 }
2167 }
2168 }
2169 }
2170 {
2171 object State = arg2;
2172 object PseudoCode = arg3;
2173 Variable Template = new Variable();
2174 Variable Goal = new Variable();
2175 Variable Bag = new Variable();
2176 Variable B = new Variable();
2177 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B)))
2178 {
2179 foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode))
2180 {
2181 yield return true;
2182 yield break;
2183 }
2184 }
2185 }
2186 {
2187 object State = arg2;
2188 object PseudoCode = arg3;
2189 Variable Template = new Variable();
2190 Variable Goal = new Variable();
2191 Variable Bag = new Variable();
2192 Variable B = new Variable();
2193 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B)))
2194 {
2195 foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode))
2196 {
2197 yield return true;
2198 yield break;
2199 }
2200 }
2201 }
2202 {
2203 object State = arg2;
2204 Variable A = new Variable();
2205 Variable B = new Variable();
2206 Variable ATermCode = new Variable();
2207 Variable BCode = new Variable();
2208 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B)))
2209 {
2210 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL)))
2211 {
2212 foreach (bool l4 in compileTerm(A, State, ATermCode))
2213 {
2214 foreach (bool l5 in compileRuleBody(B, State, BCode))
2215 {
2216 yield return true;
2217 yield break;
2218 }
2219 }
2220 }
2221 }
2222 }
2223 {
2224 object State = arg2;
2225 Variable A = new Variable();
2226 Variable B = new Variable();
2227 Variable ATermCode = new Variable();
2228 Variable BCode = new Variable();
2229 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"asserta", A), B)))
2230 {
2231 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2232 {
2233 foreach (bool l4 in compileTerm(A, State, ATermCode))
2234 {
2235 foreach (bool l5 in compileRuleBody(B, State, BCode))
2236 {
2237 yield return true;
2238 yield break;
2239 }
2240 }
2241 }
2242 }
2243 }
2244 {
2245 object State = arg2;
2246 Variable A = new Variable();
2247 Variable B = new Variable();
2248 Variable ATermCode = new Variable();
2249 Variable BCode = new Variable();
2250 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assertz", A), B)))
2251 {
2252 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2253 {
2254 foreach (bool l4 in compileTerm(A, State, ATermCode))
2255 {
2256 foreach (bool l5 in compileRuleBody(B, State, BCode))
2257 {
2258 yield return true;
2259 yield break;
2260 }
2261 }
2262 }
2263 }
2264 }
2265 {
2266 object State = arg2;
2267 object PseudoCode = arg3;
2268 Variable A = new Variable();
2269 Variable B = new Variable();
2270 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assert", A), B)))
2271 {
2272 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"assertz", A), B), State, PseudoCode))
2273 {
2274 yield return true;
2275 yield break;
2276 }
2277 }
2278 }
2279 {
2280 object State = arg2;
2281 Variable Goal = new Variable();
2282 Variable Catcher = new Variable();
2283 Variable Handler = new Variable();
2284 Variable B = new Variable();
2285 Variable CatchGoal = new Variable();
2286 Variable GoalTermCode = new Variable();
2287 Variable BCode = new Variable();
2288 Variable CatcherTermCode = new Variable();
2289 Variable HandlerAndBCode = new Variable();
2290 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"catch", Goal, Catcher, Handler), B)))
2291 {
2292 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3(@"declare", Atom.a(@"YP.Catch"), CatchGoal, new Functor2(@"new", Atom.a(@"YP.Catch"), new ListPair(new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2(@"foreach", new Functor1(@"var", CatchGoal), BCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", CatchGoal), Atom.a(@"unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL)))))
2293 {
2294 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal))
2295 {
2296 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode))
2297 {
2298 foreach (bool l6 in compileTerm(Catcher, State, CatcherTermCode))
2299 {
2300 foreach (bool l7 in compileRuleBody(B, State, BCode))
2301 {
2302 foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode))
2303 {
2304 yield return true;
2305 yield break;
2306 }
2307 }
2308 }
2309 }
2310 }
2311 }
2312 }
2313 }
2314 {
2315 object State = arg2;
2316 Variable A = new Variable();
2317 Variable B = new Variable();
2318 Variable ACode = new Variable();
2319 Variable BCode = new Variable();
2320 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2321 {
2322 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL)))
2323 {
2324 foreach (bool l4 in compileFunctorCall(A, State, ACode))
2325 {
2326 foreach (bool l5 in compileRuleBody(B, State, BCode))
2327 {
2328 yield return true;
2329 yield break;
2330 }
2331 }
2332 }
2333 }
2334 }
2335 {
2336 object State = arg2;
2337 object PseudoCode = arg3;
2338 Variable A = new Variable();
2339 Variable B = new Variable();
2340 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2341 {
2342 if (YP.var(A))
2343 {
2344 foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode))
2345 {
2346 yield return true;
2347 yield break;
2348 }
2349 }
2350 }
2351 }
2352 {
2353 object State = arg2;
2354 Variable A = new Variable();
2355 Variable T = new Variable();
2356 Variable B = new Variable();
2357 Variable CutIfLabel = new Variable();
2358 Variable Code = new Variable();
2359 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B)))
2360 {
2361 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL)))
2362 {
2363 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel))
2364 {
2365 foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code))
2366 {
2367 yield return true;
2368 yield break;
2369 }
2370 }
2371 }
2372 }
2373 }
2374 {
2375 object State = arg2;
2376 object PseudoCode = arg3;
2377 Variable A = new Variable();
2378 Variable B = new Variable();
2379 Variable ACode = new Variable();
2380 Variable BCode = new Variable();
2381 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2382 {
2383 foreach (bool l3 in compileRuleBody(A, State, ACode))
2384 {
2385 foreach (bool l4 in compileRuleBody(B, State, BCode))
2386 {
2387 foreach (bool l5 in append(ACode, BCode, PseudoCode))
2388 {
2389 yield return true;
2390 yield break;
2391 }
2392 }
2393 }
2394 }
2395 }
2396 {
2397 object A = arg1;
2398 object State = arg2;
2399 object PseudoCode = arg3;
2400 foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode))
2401 {
2402 yield return true;
2403 yield break;
2404 }
2405 }
2406 }
2407
2408 public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode)
2409 {
2410 {
2411 Variable TemplateCode = new Variable();
2412 Variable GoalTermCode = new Variable();
2413 Variable UnqualifiedGoal = new Variable();
2414 Variable BagofAnswers = new Variable();
2415 Variable GoalAndAddCode = new Variable();
2416 Variable BagCode = new Variable();
2417 Variable BCode = new Variable();
2418 foreach (bool l2 in compileTerm(Template, State, TemplateCode))
2419 {
2420 foreach (bool l3 in compileTerm(Goal, State, GoalTermCode))
2421 {
2422 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
2423 {
2424 foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers))
2425 {
2426 foreach (bool l6 in compileRuleBody(new Functor2(@",", UnqualifiedGoal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
2427 {
2428 foreach (bool l7 in compileTerm(Bag, State, BagCode))
2429 {
2430 foreach (bool l8 in compileRuleBody(B, State, BCode))
2431 {
2432 foreach (bool l9 in append(new ListPair(new Functor3(@"declare", Atom.a(@"BagofAnswers"), BagofAnswers, new Functor2(@"new", Atom.a(@"BagofAnswers"), new ListPair(TemplateCode, new ListPair(GoalTermCode, Atom.NIL)))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), ResultMethod, new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
2433 {
2434 yield return true;
2435 yield break;
2436 }
2437 }
2438 }
2439 }
2440 }
2441 }
2442 }
2443 }
2444 }
2445 }
2446
2447 public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2)
2448 {
2449 {
2450 object Goal = arg1;
2451 foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal)))
2452 {
2453 if (YP.var(Goal))
2454 {
2455 yield return true;
2456 yield break;
2457 }
2458 }
2459 }
2460 {
2461 object UnqualifiedGoal = arg2;
2462 Variable x1 = new Variable();
2463 Variable Goal = new Variable();
2464 foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal)))
2465 {
2466 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
2467 {
2468 yield return true;
2469 yield break;
2470 }
2471 }
2472 }
2473 {
2474 Variable UnqualifiedGoal = new Variable();
2475 foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal))
2476 {
2477 foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal))
2478 {
2479 yield return true;
2480 yield break;
2481 }
2482 }
2483 }
2484 }
2485
2486 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
2487 {
2488 {
2489 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:=")))
2490 {
2491 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal")))
2492 {
2493 yield return true;
2494 yield break;
2495 }
2496 }
2497 }
2498 {
2499 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\=")))
2500 {
2501 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual")))
2502 {
2503 yield return true;
2504 yield break;
2505 }
2506 }
2507 }
2508 {
2509 foreach (bool l2 in YP.unify(arg1, Atom.a(@">")))
2510 {
2511 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan")))
2512 {
2513 yield return true;
2514 yield break;
2515 }
2516 }
2517 }
2518 {
2519 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<")))
2520 {
2521 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan")))
2522 {
2523 yield return true;
2524 yield break;
2525 }
2526 }
2527 }
2528 {
2529 foreach (bool l2 in YP.unify(arg1, Atom.a(@">=")))
2530 {
2531 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual")))
2532 {
2533 yield return true;
2534 yield break;
2535 }
2536 }
2537 }
2538 {
2539 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<")))
2540 {
2541 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual")))
2542 {
2543 yield return true;
2544 yield break;
2545 }
2546 }
2547 }
2548 }
2549
2550 public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object PseudoCode)
2551 {
2552 {
2553 Variable FunctorName = new Variable();
2554 Variable FunctorArgs = new Variable();
2555 Variable x6 = new Variable();
2556 Variable Arity = new Variable();
2557 Variable CompiledArgs = new Variable();
2558 Variable FunctionName = new Variable();
2559 foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs)))
2560 {
2561 foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
2562 {
2563 foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
2564 {
2565 foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
2566 {
2567 if (YP.termEqual(FunctionName, Atom.NIL))
2568 {
2569 foreach (bool l7 in YP.unify(PseudoCode, new Functor2(@"call", Atom.a(@"YP.matchDynamic"), new ListPair(new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", FunctorName), Atom.NIL)), new ListPair(new Functor1(@"objectArray", CompiledArgs), Atom.NIL)))))
2570 {
2571 yield return true;
2572 yield break;
2573 }
2574 goto cutIf1;
2575 }
2576 foreach (bool l6 in YP.unify(PseudoCode, new Functor2(@"call", FunctionName, CompiledArgs)))
2577 {
2578 yield return true;
2579 yield break;
2580 }
2581 cutIf1:
2582 { }
2583 }
2584 }
2585 }
2586 }
2587 }
2588 }
2589
2590 public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4)
2591 {
2592 {
2593 object x1 = arg1;
2594 object Name = arg2;
2595 object Arity = arg3;
2596 object FunctionName = arg4;
2597 foreach (bool l2 in functorCallYPFunctionName(Name, Arity, FunctionName))
2598 {
2599 yield return true;
2600 yield break;
2601 }
2602 }
2603 {
2604 object State = arg1;
2605 object Arity = arg3;
2606 Variable Name = new Variable();
2607 foreach (bool l2 in YP.unify(arg2, Name))
2608 {
2609 foreach (bool l3 in YP.unify(arg4, Name))
2610 {
2611 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
2612 {
2613 yield return true;
2614 yield break;
2615 }
2616 }
2617 }
2618 }
2619 {
2620 object _State = arg1;
2621 object _Arity = arg3;
2622 Variable Name = new Variable();
2623 foreach (bool l2 in YP.unify(arg2, Name))
2624 {
2625 foreach (bool l3 in YP.unify(arg4, Name))
2626 {
2627 foreach (bool l4 in Atom.module(Name, Atom.a(@"")))
2628 {
2629 yield return true;
2630 yield break;
2631 }
2632 }
2633 }
2634 }
2635 {
2636 object _State = arg1;
2637 object Name = arg2;
2638 object Arity = arg3;
2639 foreach (bool l2 in YP.unify(arg4, Atom.NIL))
2640 {
2641 foreach (bool l3 in Atom.module(Name, Atom.NIL))
2642 {
2643 yield return true;
2644 yield break;
2645 }
2646 }
2647 }
2648 {
2649 object _State = arg1;
2650 object Name = arg2;
2651 object Arity = arg3;
2652 object x4 = arg4;
2653 Variable Module = new Variable();
2654 Variable Message = new Variable();
2655 foreach (bool l2 in Atom.module(Name, Module))
2656 {
2657 foreach (bool l3 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message))
2658 {
2659 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message));
2660 yield return true;
2661 yield break;
2662 }
2663 }
2664 }
2665 {
2666 object _State = arg1;
2667 object Name = arg2;
2668 object _Arity = arg3;
2669 object x4 = arg4;
2670 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), Name), Atom.a(@"Term is not callable")));
2671 yield return true;
2672 yield break;
2673 }
2674 }
2675
2676 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3)
2677 {
2678 {
2679 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=")))
2680 {
2681 foreach (bool l3 in YP.unify(arg2, 2))
2682 {
2683 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify")))
2684 {
2685 yield return true;
2686 yield break;
2687 }
2688 }
2689 }
2690 }
2691 {
2692 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=..")))
2693 {
2694 foreach (bool l3 in YP.unify(arg2, 2))
2695 {
2696 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ")))
2697 {
2698 yield return true;
2699 yield break;
2700 }
2701 }
2702 }
2703 }
2704 {
2705 foreach (bool l2 in YP.unify(arg1, Atom.a(@"var")))
2706 {
2707 foreach (bool l3 in YP.unify(arg2, 1))
2708 {
2709 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var")))
2710 {
2711 yield return true;
2712 yield break;
2713 }
2714 }
2715 }
2716 }
2717 {
2718 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar")))
2719 {
2720 foreach (bool l3 in YP.unify(arg2, 1))
2721 {
2722 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar")))
2723 {
2724 yield return true;
2725 yield break;
2726 }
2727 }
2728 }
2729 }
2730 {
2731 foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg")))
2732 {
2733 foreach (bool l3 in YP.unify(arg2, 3))
2734 {
2735 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg")))
2736 {
2737 yield return true;
2738 yield break;
2739 }
2740 }
2741 }
2742 }
2743 {
2744 foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor")))
2745 {
2746 foreach (bool l3 in YP.unify(arg2, 3))
2747 {
2748 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor")))
2749 {
2750 yield return true;
2751 yield break;
2752 }
2753 }
2754 }
2755 }
2756 {
2757 foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat")))
2758 {
2759 foreach (bool l3 in YP.unify(arg2, 0))
2760 {
2761 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat")))
2762 {
2763 yield return true;
2764 yield break;
2765 }
2766 }
2767 }
2768 }
2769 {
2770 foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code")))
2771 {
2772 foreach (bool l3 in YP.unify(arg2, 1))
2773 {
2774 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code")))
2775 {
2776 yield return true;
2777 yield break;
2778 }
2779 }
2780 }
2781 }
2782 {
2783 foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op")))
2784 {
2785 foreach (bool l3 in YP.unify(arg2, 3))
2786 {
2787 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op")))
2788 {
2789 yield return true;
2790 yield break;
2791 }
2792 }
2793 }
2794 }
2795 {
2796 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length")))
2797 {
2798 foreach (bool l3 in YP.unify(arg2, 2))
2799 {
2800 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length")))
2801 {
2802 yield return true;
2803 yield break;
2804 }
2805 }
2806 }
2807 }
2808 {
2809 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat")))
2810 {
2811 foreach (bool l3 in YP.unify(arg2, 3))
2812 {
2813 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat")))
2814 {
2815 yield return true;
2816 yield break;
2817 }
2818 }
2819 }
2820 }
2821 {
2822 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom")))
2823 {
2824 foreach (bool l3 in YP.unify(arg2, 5))
2825 {
2826 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom")))
2827 {
2828 yield return true;
2829 yield break;
2830 }
2831 }
2832 }
2833 }
2834 {
2835 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes")))
2836 {
2837 foreach (bool l3 in YP.unify(arg2, 2))
2838 {
2839 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes")))
2840 {
2841 yield return true;
2842 yield break;
2843 }
2844 }
2845 }
2846 }
2847 {
2848 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes")))
2849 {
2850 foreach (bool l3 in YP.unify(arg2, 2))
2851 {
2852 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes")))
2853 {
2854 yield return true;
2855 yield break;
2856 }
2857 }
2858 }
2859 }
2860 {
2861 foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term")))
2862 {
2863 foreach (bool l3 in YP.unify(arg2, 2))
2864 {
2865 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term")))
2866 {
2867 yield return true;
2868 yield break;
2869 }
2870 }
2871 }
2872 }
2873 {
2874 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort")))
2875 {
2876 foreach (bool l3 in YP.unify(arg2, 2))
2877 {
2878 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort")))
2879 {
2880 yield return true;
2881 yield break;
2882 }
2883 }
2884 }
2885 }
2886 {
2887 // Manually included : script_event for callback to LSL/C#
2888
2889 //object x1 = arg1;
2890 foreach (bool l2 in YP.unify(arg1, Atom.a(@"script_event")))
2891 {
2892 foreach (bool l3 in YP.unify(arg2, 2))
2893 {
2894 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.script_event")))
2895 {
2896 yield return true;
2897 yield break;
2898 }
2899 }
2900 }
2901 }
2902 {
2903 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl")))
2904 {
2905 foreach (bool l3 in YP.unify(arg2, 0))
2906 {
2907 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl")))
2908 {
2909 yield return true;
2910 yield break;
2911 }
2912 }
2913 }
2914 }
2915 {
2916 foreach (bool l2 in YP.unify(arg1, Atom.a(@"write")))
2917 {
2918 foreach (bool l3 in YP.unify(arg2, 1))
2919 {
2920 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write")))
2921 {
2922 yield return true;
2923 yield break;
2924 }
2925 }
2926 }
2927 }
2928 {
2929 foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code")))
2930 {
2931 foreach (bool l3 in YP.unify(arg2, 1))
2932 {
2933 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code")))
2934 {
2935 yield return true;
2936 yield break;
2937 }
2938 }
2939 }
2940 }
2941 {
2942 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom")))
2943 {
2944 foreach (bool l3 in YP.unify(arg2, 1))
2945 {
2946 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom")))
2947 {
2948 yield return true;
2949 yield break;
2950 }
2951 }
2952 }
2953 }
2954 {
2955 foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer")))
2956 {
2957 foreach (bool l3 in YP.unify(arg2, 1))
2958 {
2959 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer")))
2960 {
2961 yield return true;
2962 yield break;
2963 }
2964 }
2965 }
2966 }
2967 {
2968 foreach (bool l2 in YP.unify(arg1, Atom.a(@"float")))
2969 {
2970 foreach (bool l3 in YP.unify(arg2, 1))
2971 {
2972 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.isFloat")))
2973 {
2974 yield return true;
2975 yield break;
2976 }
2977 }
2978 }
2979 }
2980 {
2981 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number")))
2982 {
2983 foreach (bool l3 in YP.unify(arg2, 1))
2984 {
2985 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number")))
2986 {
2987 yield return true;
2988 yield break;
2989 }
2990 }
2991 }
2992 }
2993 {
2994 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic")))
2995 {
2996 foreach (bool l3 in YP.unify(arg2, 1))
2997 {
2998 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic")))
2999 {
3000 yield return true;
3001 yield break;
3002 }
3003 }
3004 }
3005 }
3006 {
3007 foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound")))
3008 {
3009 foreach (bool l3 in YP.unify(arg2, 1))
3010 {
3011 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound")))
3012 {
3013 yield return true;
3014 yield break;
3015 }
3016 }
3017 }
3018 }
3019 {
3020 foreach (bool l2 in YP.unify(arg1, Atom.a(@"==")))
3021 {
3022 foreach (bool l3 in YP.unify(arg2, 2))
3023 {
3024 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual")))
3025 {
3026 yield return true;
3027 yield break;
3028 }
3029 }
3030 }
3031 }
3032 {
3033 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\==")))
3034 {
3035 foreach (bool l3 in YP.unify(arg2, 2))
3036 {
3037 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual")))
3038 {
3039 yield return true;
3040 yield break;
3041 }
3042 }
3043 }
3044 }
3045 {
3046 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<")))
3047 {
3048 foreach (bool l3 in YP.unify(arg2, 2))
3049 {
3050 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan")))
3051 {
3052 yield return true;
3053 yield break;
3054 }
3055 }
3056 }
3057 }
3058 {
3059 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<")))
3060 {
3061 foreach (bool l3 in YP.unify(arg2, 2))
3062 {
3063 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual")))
3064 {
3065 yield return true;
3066 yield break;
3067 }
3068 }
3069 }
3070 }
3071 {
3072 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>")))
3073 {
3074 foreach (bool l3 in YP.unify(arg2, 2))
3075 {
3076 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan")))
3077 {
3078 yield return true;
3079 yield break;
3080 }
3081 }
3082 }
3083 }
3084 {
3085 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>=")))
3086 {
3087 foreach (bool l3 in YP.unify(arg2, 2))
3088 {
3089 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual")))
3090 {
3091 yield return true;
3092 yield break;
3093 }
3094 }
3095 }
3096 }
3097 {
3098 foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw")))
3099 {
3100 foreach (bool l3 in YP.unify(arg2, 1))
3101 {
3102 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
3103 {
3104 yield return true;
3105 yield break;
3106 }
3107 }
3108 }
3109 }
3110 }
3111
3112 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
3113 {
3114 {
3115 object Term = arg1;
3116 object State = arg2;
3117 Variable VariableName = new Variable();
3118 foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName)))
3119 {
3120 if (YP.var(Term))
3121 {
3122 foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName))
3123 {
3124 yield return true;
3125 yield break;
3126 }
3127 }
3128 }
3129 }
3130 {
3131 object _State = arg2;
3132 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3133 {
3134 foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL"))))
3135 {
3136 yield return true;
3137 yield break;
3138 }
3139 }
3140 }
3141 {
3142 object Term = arg1;
3143 object State = arg2;
3144 object Code = arg3;
3145 Variable ModuleCode = new Variable();
3146 if (YP.atom(Term))
3147 {
3148 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
3149 {
3150 foreach (bool l4 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), new ListPair(ModuleCode, Atom.NIL)))))
3151 {
3152 yield return true;
3153 yield break;
3154 }
3155 goto cutIf1;
3156 }
3157 foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL))))
3158 {
3159 yield return true;
3160 yield break;
3161 }
3162 cutIf1:
3163 { }
3164 }
3165 }
3166 {
3167 object State = arg2;
3168 Variable First = new Variable();
3169 Variable Rest = new Variable();
3170 Variable Arg1 = new Variable();
3171 Variable Arg2 = new Variable();
3172 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3173 {
3174 foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3175 {
3176 foreach (bool l4 in compileTerm(First, State, Arg1))
3177 {
3178 foreach (bool l5 in compileTerm(Rest, State, Arg2))
3179 {
3180 yield return true;
3181 yield break;
3182 }
3183 }
3184 }
3185 }
3186 }
3187 {
3188 object Term = arg1;
3189 object State = arg2;
3190 object Result = arg3;
3191 Variable Name = new Variable();
3192 Variable TermArgs = new Variable();
3193 Variable x6 = new Variable();
3194 Variable Arity = new Variable();
3195 Variable ModuleCode = new Variable();
3196 Variable NameCode = new Variable();
3197 Variable X1 = new Variable();
3198 Variable Arg1 = new Variable();
3199 Variable X2 = new Variable();
3200 Variable Arg2 = new Variable();
3201 Variable X3 = new Variable();
3202 Variable Arg3 = new Variable();
3203 Variable Args = new Variable();
3204 foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs)))
3205 {
3206 if (YP.termEqual(TermArgs, Atom.NIL))
3207 {
3208 foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name)))
3209 {
3210 yield return true;
3211 yield break;
3212 }
3213 goto cutIf2;
3214 }
3215 foreach (bool l3 in YP.functor(Term, x6, Arity))
3216 {
3217 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
3218 {
3219 foreach (bool l5 in YP.unify(NameCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Name), new ListPair(ModuleCode, Atom.NIL)))))
3220 {
3221 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3222 {
3223 foreach (bool l7 in compileTerm(X1, State, Arg1))
3224 {
3225 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3226 {
3227 yield return true;
3228 yield break;
3229 }
3230 }
3231 goto cutIf4;
3232 }
3233 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3234 {
3235 foreach (bool l7 in compileTerm(X1, State, Arg1))
3236 {
3237 foreach (bool l8 in compileTerm(X2, State, Arg2))
3238 {
3239 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3240 {
3241 yield return true;
3242 yield break;
3243 }
3244 }
3245 }
3246 goto cutIf5;
3247 }
3248 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3249 {
3250 foreach (bool l7 in compileTerm(X1, State, Arg1))
3251 {
3252 foreach (bool l8 in compileTerm(X2, State, Arg2))
3253 {
3254 foreach (bool l9 in compileTerm(X3, State, Arg3))
3255 {
3256 foreach (bool l10 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
3257 {
3258 yield return true;
3259 yield break;
3260 }
3261 }
3262 }
3263 }
3264 }
3265 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
3266 {
3267 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3268 {
3269 yield return true;
3270 yield break;
3271 }
3272 }
3273 cutIf5:
3274 cutIf4:
3275 { }
3276 }
3277 goto cutIf3;
3278 }
3279 foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name)))
3280 {
3281 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3282 {
3283 foreach (bool l6 in compileTerm(X1, State, Arg1))
3284 {
3285 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3286 {
3287 yield return true;
3288 yield break;
3289 }
3290 }
3291 goto cutIf6;
3292 }
3293 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3294 {
3295 foreach (bool l6 in compileTerm(X1, State, Arg1))
3296 {
3297 foreach (bool l7 in compileTerm(X2, State, Arg2))
3298 {
3299 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3300 {
3301 yield return true;
3302 yield break;
3303 }
3304 }
3305 }
3306 goto cutIf7;
3307 }
3308 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3309 {
3310 foreach (bool l6 in compileTerm(X1, State, Arg1))
3311 {
3312 foreach (bool l7 in compileTerm(X2, State, Arg2))
3313 {
3314 foreach (bool l8 in compileTerm(X3, State, Arg3))
3315 {
3316 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
3317 {
3318 yield return true;
3319 yield break;
3320 }
3321 }
3322 }
3323 }
3324 }
3325 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
3326 {
3327 foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3328 {
3329 yield return true;
3330 yield break;
3331 }
3332 }
3333 cutIf7:
3334 cutIf6:
3335 { }
3336 }
3337 cutIf3:
3338 { }
3339 }
3340 cutIf2:
3341 { }
3342 }
3343 }
3344 }
3345
3346 public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode)
3347 {
3348 {
3349 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
3350 {
3351 foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL))))
3352 {
3353 yield return true;
3354 yield break;
3355 }
3356 }
3357 }
3358 }
3359
3360 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
3361 {
3362 {
3363 object _State = arg2;
3364 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3365 {
3366 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
3367 {
3368 yield return true;
3369 yield break;
3370 }
3371 }
3372 }
3373 {
3374 object State = arg2;
3375 Variable First = new Variable();
3376 Variable Rest = new Variable();
3377 Variable FirstResult = new Variable();
3378 Variable RestResults = new Variable();
3379 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3380 {
3381 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
3382 {
3383 foreach (bool l4 in compileTerm(First, State, FirstResult))
3384 {
3385 foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults))
3386 {
3387 yield return true;
3388 yield break;
3389 }
3390 }
3391 }
3392 }
3393 }
3394 }
3395
3396 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
3397 {
3398 {
3399 Variable Name = new Variable();
3400 Variable TermArgs = new Variable();
3401 Variable X1 = new Variable();
3402 Variable FunctionName = new Variable();
3403 Variable Arg1 = new Variable();
3404 Variable x9 = new Variable();
3405 Variable X2 = new Variable();
3406 Variable Arg2 = new Variable();
3407 Variable x12 = new Variable();
3408 Variable Arity = new Variable();
3409 if (YP.nonvar(Term))
3410 {
3411 foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
3412 {
3413 if (YP.atom(Name))
3414 {
3415 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3416 {
3417 foreach (bool l6 in unaryFunction(Name, FunctionName))
3418 {
3419 foreach (bool l7 in compileExpression(X1, State, Arg1))
3420 {
3421 foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL))))
3422 {
3423 yield return true;
3424 yield break;
3425 }
3426 }
3427 goto cutIf1;
3428 }
3429 }
3430 foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
3431 {
3432 foreach (bool l6 in compileTerm(Term, State, Result))
3433 {
3434 yield return true;
3435 yield break;
3436 }
3437 goto cutIf2;
3438 }
3439 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3440 {
3441 foreach (bool l6 in binaryFunction(Name, FunctionName))
3442 {
3443 foreach (bool l7 in compileExpression(X1, State, Arg1))
3444 {
3445 foreach (bool l8 in compileExpression(X2, State, Arg2))
3446 {
3447 foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3448 {
3449 yield return true;
3450 yield break;
3451 }
3452 }
3453 }
3454 goto cutIf3;
3455 }
3456 }
3457 foreach (bool l5 in YP.functor(Term, x12, Arity))
3458 {
3459 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Not an expression function")));
3460 yield return false;
3461 }
3462 cutIf3:
3463 cutIf2:
3464 cutIf1:
3465 { }
3466 }
3467 }
3468 }
3469 }
3470 {
3471 foreach (bool l2 in compileTerm(Term, State, Result))
3472 {
3473 yield return true;
3474 yield break;
3475 }
3476 }
3477 }
3478
3479 public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
3480 {
3481 {
3482 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3483 {
3484 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate")))
3485 {
3486 yield return true;
3487 yield break;
3488 }
3489 }
3490 }
3491 {
3492 foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs")))
3493 {
3494 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs")))
3495 {
3496 yield return true;
3497 yield break;
3498 }
3499 }
3500 }
3501 {
3502 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign")))
3503 {
3504 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign")))
3505 {
3506 yield return true;
3507 yield break;
3508 }
3509 }
3510 }
3511 {
3512 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3513 {
3514 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor")))
3515 {
3516 yield return true;
3517 yield break;
3518 }
3519 }
3520 }
3521 {
3522 foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate")))
3523 {
3524 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate")))
3525 {
3526 yield return true;
3527 yield break;
3528 }
3529 }
3530 }
3531 {
3532 foreach (bool l2 in YP.unify(arg1, Atom.a(@"round")))
3533 {
3534 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round")))
3535 {
3536 yield return true;
3537 yield break;
3538 }
3539 }
3540 }
3541 {
3542 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3543 {
3544 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling")))
3545 {
3546 yield return true;
3547 yield break;
3548 }
3549 }
3550 }
3551 {
3552 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin")))
3553 {
3554 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin")))
3555 {
3556 yield return true;
3557 yield break;
3558 }
3559 }
3560 }
3561 {
3562 foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos")))
3563 {
3564 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos")))
3565 {
3566 yield return true;
3567 yield break;
3568 }
3569 }
3570 }
3571 {
3572 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan")))
3573 {
3574 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan")))
3575 {
3576 yield return true;
3577 yield break;
3578 }
3579 }
3580 }
3581 {
3582 foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp")))
3583 {
3584 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp")))
3585 {
3586 yield return true;
3587 yield break;
3588 }
3589 }
3590 }
3591 {
3592 foreach (bool l2 in YP.unify(arg1, Atom.a(@"log")))
3593 {
3594 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log")))
3595 {
3596 yield return true;
3597 yield break;
3598 }
3599 }
3600 }
3601 {
3602 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt")))
3603 {
3604 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt")))
3605 {
3606 yield return true;
3607 yield break;
3608 }
3609 }
3610 }
3611 {
3612 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\")))
3613 {
3614 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement")))
3615 {
3616 yield return true;
3617 yield break;
3618 }
3619 }
3620 }
3621 }
3622
3623 public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
3624 {
3625 {
3626 foreach (bool l2 in YP.unify(arg1, Atom.a(@"+")))
3627 {
3628 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add")))
3629 {
3630 yield return true;
3631 yield break;
3632 }
3633 }
3634 }
3635 {
3636 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3637 {
3638 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract")))
3639 {
3640 yield return true;
3641 yield break;
3642 }
3643 }
3644 }
3645 {
3646 foreach (bool l2 in YP.unify(arg1, Atom.a(@"*")))
3647 {
3648 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply")))
3649 {
3650 yield return true;
3651 yield break;
3652 }
3653 }
3654 }
3655 {
3656 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/")))
3657 {
3658 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide")))
3659 {
3660 yield return true;
3661 yield break;
3662 }
3663 }
3664 }
3665 {
3666 foreach (bool l2 in YP.unify(arg1, Atom.a(@"//")))
3667 {
3668 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide")))
3669 {
3670 yield return true;
3671 yield break;
3672 }
3673 }
3674 }
3675 {
3676 foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod")))
3677 {
3678 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod")))
3679 {
3680 yield return true;
3681 yield break;
3682 }
3683 }
3684 }
3685 {
3686 foreach (bool l2 in YP.unify(arg1, Atom.a(@"**")))
3687 {
3688 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow")))
3689 {
3690 yield return true;
3691 yield break;
3692 }
3693 }
3694 }
3695 {
3696 foreach (bool l2 in YP.unify(arg1, Atom.a(@">>")))
3697 {
3698 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight")))
3699 {
3700 yield return true;
3701 yield break;
3702 }
3703 }
3704 }
3705 {
3706 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<")))
3707 {
3708 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft")))
3709 {
3710 yield return true;
3711 yield break;
3712 }
3713 }
3714 }
3715 {
3716 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\")))
3717 {
3718 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd")))
3719 {
3720 yield return true;
3721 yield break;
3722 }
3723 }
3724 }
3725 {
3726 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/")))
3727 {
3728 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr")))
3729 {
3730 yield return true;
3731 yield break;
3732 }
3733 }
3734 }
3735 {
3736 foreach (bool l2 in YP.unify(arg1, Atom.a(@"min")))
3737 {
3738 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min")))
3739 {
3740 yield return true;
3741 yield break;
3742 }
3743 }
3744 }
3745 {
3746 foreach (bool l2 in YP.unify(arg1, Atom.a(@"max")))
3747 {
3748 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max")))
3749 {
3750 yield return true;
3751 yield break;
3752 }
3753 }
3754 }
3755 }
3756
3757 public static void convertFunctionCSharp(object arg1)
3758 {
3759 {
3760 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
3761 {
3762 YP.write(Atom.a(@"public class YPInnerClass {}"));
3763 YP.nl();
3764 YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
3765 YP.nl();
3766 YP.nl();
3767 return;
3768 }
3769 }
3770 {
3771 Variable ReturnType = new Variable();
3772 Variable Name = new Variable();
3773 Variable ArgList = new Variable();
3774 Variable Body = new Variable();
3775 Variable Level = new Variable();
3776 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body })))
3777 {
3778 YP.write(Atom.a(@"public static "));
3779 YP.write(ReturnType);
3780 YP.write(Atom.a(@" "));
3781 YP.write(Name);
3782 YP.write(Atom.a(@"("));
3783 convertArgListCSharp(ArgList);
3784 YP.write(Atom.a(@") {"));
3785 YP.nl();
3786 foreach (bool l3 in YP.unify(Level, 1))
3787 {
3788 convertStatementListCSharp(Body, Level);
3789 YP.write(Atom.a(@"}"));
3790 YP.nl();
3791 YP.nl();
3792 return;
3793 }
3794 }
3795 }
3796 }
3797
3798 public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2)
3799 {
3800 {
3801 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3802 {
3803 yield return true;
3804 yield break;
3805 }
3806 }
3807 }
3808
3809 public static void convertStatementListCSharp(object arg1, object Level)
3810 {
3811 {
3812 Variable Name = new Variable();
3813 Variable Body = new Variable();
3814 Variable RestStatements = new Variable();
3815 Variable NewStatements = new Variable();
3816 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
3817 {
3818 foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements))
3819 {
3820 convertStatementListCSharp(NewStatements, Level);
3821 return;
3822 }
3823 }
3824 }
3825 {
3826 Variable Type = new Variable();
3827 Variable Name = new Variable();
3828 Variable Expression = new Variable();
3829 Variable RestStatements = new Variable();
3830 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements)))
3831 {
3832 convertIndentationCSharp(Level);
3833 YP.write(Type);
3834 YP.write(Atom.a(@" "));
3835 YP.write(Name);
3836 YP.write(Atom.a(@" = "));
3837 convertExpressionCSharp(Expression);
3838 YP.write(Atom.a(@";"));
3839 YP.nl();
3840 convertStatementListCSharp(RestStatements, Level);
3841 return;
3842 }
3843 }
3844 {
3845 Variable Name = new Variable();
3846 Variable Expression = new Variable();
3847 Variable RestStatements = new Variable();
3848 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
3849 {
3850 convertIndentationCSharp(Level);
3851 YP.write(Name);
3852 YP.write(Atom.a(@" = "));
3853 convertExpressionCSharp(Expression);
3854 YP.write(Atom.a(@";"));
3855 YP.nl();
3856 convertStatementListCSharp(RestStatements, Level);
3857 return;
3858 }
3859 }
3860 {
3861 Variable RestStatements = new Variable();
3862 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
3863 {
3864 convertIndentationCSharp(Level);
3865 YP.write(Atom.a(@"yield return true;"));
3866 YP.nl();
3867 convertStatementListCSharp(RestStatements, Level);
3868 return;
3869 }
3870 }
3871 {
3872 Variable RestStatements = new Variable();
3873 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
3874 {
3875 convertIndentationCSharp(Level);
3876 YP.write(Atom.a(@"yield return false;"));
3877 YP.nl();
3878 convertStatementListCSharp(RestStatements, Level);
3879 return;
3880 }
3881 }
3882 {
3883 Variable RestStatements = new Variable();
3884 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
3885 {
3886 convertIndentationCSharp(Level);
3887 YP.write(Atom.a(@"yield break;"));
3888 YP.nl();
3889 convertStatementListCSharp(RestStatements, Level);
3890 return;
3891 }
3892 }
3893 {
3894 Variable RestStatements = new Variable();
3895 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
3896 {
3897 convertIndentationCSharp(Level);
3898 YP.write(Atom.a(@"return;"));
3899 YP.nl();
3900 convertStatementListCSharp(RestStatements, Level);
3901 return;
3902 }
3903 }
3904 {
3905 Variable RestStatements = new Variable();
3906 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
3907 {
3908 convertIndentationCSharp(Level);
3909 YP.write(Atom.a(@"return true;"));
3910 YP.nl();
3911 convertStatementListCSharp(RestStatements, Level);
3912 return;
3913 }
3914 }
3915 {
3916 Variable RestStatements = new Variable();
3917 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
3918 {
3919 convertIndentationCSharp(Level);
3920 YP.write(Atom.a(@"return false;"));
3921 YP.nl();
3922 convertStatementListCSharp(RestStatements, Level);
3923 return;
3924 }
3925 }
3926 {
3927 Variable Name = new Variable();
3928 Variable RestStatements = new Variable();
3929 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements)))
3930 {
3931 convertIndentationCSharp(Level);
3932 YP.write(Name);
3933 YP.write(Atom.a(@":"));
3934 YP.nl();
3935 if (YP.termEqual(RestStatements, Atom.NIL))
3936 {
3937 convertIndentationCSharp(Level);
3938 YP.write(Atom.a(@"{}"));
3939 YP.nl();
3940 convertStatementListCSharp(RestStatements, Level);
3941 return;
3942 goto cutIf1;
3943 }
3944 convertStatementListCSharp(RestStatements, Level);
3945 return;
3946 cutIf1:
3947 { }
3948 }
3949 }
3950 {
3951 Variable Name = new Variable();
3952 Variable RestStatements = new Variable();
3953 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
3954 {
3955 convertIndentationCSharp(Level);
3956 YP.write(Atom.a(@"goto "));
3957 YP.write(Name);
3958 YP.write(Atom.a(@";"));
3959 YP.nl();
3960 convertStatementListCSharp(RestStatements, Level);
3961 return;
3962 }
3963 }
3964 {
3965 Variable Name = new Variable();
3966 Variable ArgList = new Variable();
3967 Variable RestStatements = new Variable();
3968 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
3969 {
3970 convertIndentationCSharp(Level);
3971 YP.write(Name);
3972 YP.write(Atom.a(@"("));
3973 convertArgListCSharp(ArgList);
3974 YP.write(Atom.a(@");"));
3975 YP.nl();
3976 convertStatementListCSharp(RestStatements, Level);
3977 return;
3978 }
3979 }
3980 {
3981 Variable Obj = new Variable();
3982 Variable Name = new Variable();
3983 Variable ArgList = new Variable();
3984 Variable RestStatements = new Variable();
3985 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
3986 {
3987 convertIndentationCSharp(Level);
3988 YP.write(Obj);
3989 YP.write(Atom.a(@"."));
3990 YP.write(Name);
3991 YP.write(Atom.a(@"("));
3992 convertArgListCSharp(ArgList);
3993 YP.write(Atom.a(@");"));
3994 YP.nl();
3995 convertStatementListCSharp(RestStatements, Level);
3996 return;
3997 }
3998 }
3999 {
4000 Variable Body = new Variable();
4001 Variable RestStatements = new Variable();
4002 Variable NextLevel = new Variable();
4003 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4004 {
4005 convertIndentationCSharp(Level);
4006 YP.write(Atom.a(@"{"));
4007 YP.nl();
4008 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4009 {
4010 convertStatementListCSharp(Body, NextLevel);
4011 convertIndentationCSharp(Level);
4012 YP.write(Atom.a(@"}"));
4013 YP.nl();
4014 convertStatementListCSharp(RestStatements, Level);
4015 return;
4016 }
4017 }
4018 }
4019 {
4020 Variable Expression = new Variable();
4021 Variable Body = new Variable();
4022 Variable RestStatements = new Variable();
4023 Variable NextLevel = new Variable();
4024 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4025 {
4026 convertIndentationCSharp(Level);
4027 YP.write(Atom.a(@"if ("));
4028 convertExpressionCSharp(Expression);
4029 YP.write(Atom.a(@") {"));
4030 YP.nl();
4031 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4032 {
4033 convertStatementListCSharp(Body, NextLevel);
4034 convertIndentationCSharp(Level);
4035 YP.write(Atom.a(@"}"));
4036 YP.nl();
4037 convertStatementListCSharp(RestStatements, Level);
4038 return;
4039 }
4040 }
4041 }
4042 {
4043 Variable Expression = new Variable();
4044 Variable Body = new Variable();
4045 Variable RestStatements = new Variable();
4046 Variable NextLevel = new Variable();
4047 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4048 {
4049 convertIndentationCSharp(Level);
4050 YP.write(Atom.a(@"foreach (bool l"));
4051 YP.write(Level);
4052 YP.write(Atom.a(@" in "));
4053 convertExpressionCSharp(Expression);
4054 YP.write(Atom.a(@") {"));
4055 YP.nl();
4056 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4057 {
4058 convertStatementListCSharp(Body, NextLevel);
4059 convertIndentationCSharp(Level);
4060 YP.write(Atom.a(@"}"));
4061 YP.nl();
4062 convertStatementListCSharp(RestStatements, Level);
4063 return;
4064 }
4065 }
4066 }
4067 {
4068 Variable Expression = new Variable();
4069 Variable RestStatements = new Variable();
4070 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
4071 {
4072 convertIndentationCSharp(Level);
4073 YP.write(Atom.a(@"throw "));
4074 convertExpressionCSharp(Expression);
4075 YP.write(Atom.a(@";"));
4076 YP.nl();
4077 convertStatementListCSharp(RestStatements, Level);
4078 return;
4079 }
4080 }
4081 }
4082
4083 public static void convertIndentationCSharp(object Level)
4084 {
4085 {
4086 Variable N = new Variable();
4087 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4088 {
4089 repeatWrite(Atom.a(@" "), N);
4090 return;
4091 }
4092 }
4093 }
4094
4095 public static void convertArgListCSharp(object arg1)
4096 {
4097 {
4098 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4099 {
4100 return;
4101 }
4102 }
4103 {
4104 Variable Head = new Variable();
4105 Variable Tail = new Variable();
4106 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4107 {
4108 convertExpressionCSharp(Head);
4109 if (YP.termNotEqual(Tail, Atom.NIL))
4110 {
4111 YP.write(Atom.a(@", "));
4112 convertArgListCSharp(Tail);
4113 return;
4114 goto cutIf1;
4115 }
4116 convertArgListCSharp(Tail);
4117 return;
4118 cutIf1:
4119 { }
4120 }
4121 }
4122 }
4123
4124 public static void convertExpressionCSharp(object arg1)
4125 {
4126 {
4127 Variable X = new Variable();
4128 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4129 {
4130 YP.write(Atom.a(@"object "));
4131 YP.write(X);
4132 return;
4133 }
4134 }
4135 {
4136 Variable Name = new Variable();
4137 Variable ArgList = new Variable();
4138 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4139 {
4140 YP.write(Name);
4141 YP.write(Atom.a(@"("));
4142 convertArgListCSharp(ArgList);
4143 YP.write(Atom.a(@")"));
4144 return;
4145 }
4146 }
4147 {
4148 Variable Obj = new Variable();
4149 Variable Name = new Variable();
4150 Variable ArgList = new Variable();
4151 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4152 {
4153 YP.write(Obj);
4154 YP.write(Atom.a(@"."));
4155 YP.write(Name);
4156 YP.write(Atom.a(@"("));
4157 convertArgListCSharp(ArgList);
4158 YP.write(Atom.a(@")"));
4159 return;
4160 }
4161 }
4162 {
4163 Variable Name = new Variable();
4164 Variable ArgList = new Variable();
4165 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4166 {
4167 YP.write(Atom.a(@"new "));
4168 YP.write(Name);
4169 YP.write(Atom.a(@"("));
4170 convertArgListCSharp(ArgList);
4171 YP.write(Atom.a(@")"));
4172 return;
4173 }
4174 }
4175 {
4176 Variable Name = new Variable();
4177 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4178 {
4179 YP.write(Name);
4180 return;
4181 }
4182 }
4183 {
4184 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4185 {
4186 YP.write(Atom.a(@"null"));
4187 return;
4188 }
4189 }
4190 {
4191 Variable X = new Variable();
4192 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4193 {
4194 YP.write(Atom.a(@"!("));
4195 convertExpressionCSharp(X);
4196 YP.write(Atom.a(@")"));
4197 return;
4198 }
4199 }
4200 {
4201 Variable X = new Variable();
4202 Variable Y = new Variable();
4203 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4204 {
4205 YP.write(Atom.a(@"("));
4206 convertExpressionCSharp(X);
4207 YP.write(Atom.a(@") && ("));
4208 convertExpressionCSharp(Y);
4209 YP.write(Atom.a(@")"));
4210 return;
4211 }
4212 }
4213 {
4214 Variable ArgList = new Variable();
4215 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4216 {
4217 YP.write(Atom.a(@"new object[] {"));
4218 convertArgListCSharp(ArgList);
4219 YP.write(Atom.a(@"}"));
4220 return;
4221 }
4222 }
4223 {
4224 Variable X = new Variable();
4225 Variable Codes = new Variable();
4226 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4227 {
4228 if (YP.atom(X))
4229 {
4230 YP.write(Atom.a(@"@"""));
4231 foreach (bool l4 in YP.atom_codes(X, Codes))
4232 {
4233 convertStringCodesCSharp(Codes);
4234 YP.write(Atom.a(@""""));
4235 return;
4236 }
4237 }
4238 }
4239 }
4240 {
4241 Variable X = new Variable();
4242 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4243 {
4244 YP.write(X);
4245 return;
4246 }
4247 }
4248 }
4249
4250 public static void convertStringCodesCSharp(object arg1)
4251 {
4252 {
4253 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4254 {
4255 return;
4256 }
4257 }
4258 {
4259 Variable Code = new Variable();
4260 Variable RestCodes = new Variable();
4261 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4262 {
4263 if (YP.termEqual(Code, 34))
4264 {
4265 YP.put_code(34);
4266 YP.put_code(Code);
4267 convertStringCodesCSharp(RestCodes);
4268 return;
4269 goto cutIf1;
4270 }
4271 YP.put_code(Code);
4272 convertStringCodesCSharp(RestCodes);
4273 return;
4274 cutIf1:
4275 { }
4276 }
4277 }
4278 }
4279
4280 public static void convertFunctionJavascript(object arg1)
4281 {
4282 {
4283 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4284 {
4285 YP.write(Atom.a(@"function getDeclaringClass() { return null; }"));
4286 YP.nl();
4287 return;
4288 }
4289 }
4290 {
4291 Variable x1 = new Variable();
4292 Variable Name = new Variable();
4293 Variable ArgList = new Variable();
4294 Variable Body = new Variable();
4295 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4296 {
4297 YP.write(Atom.a(@"function "));
4298 YP.write(Name);
4299 YP.write(Atom.a(@"("));
4300 convertArgListJavascript(ArgList);
4301 YP.write(Atom.a(@") {"));
4302 YP.nl();
4303 convertStatementListJavascript(Body, 1);
4304 YP.write(Atom.a(@"}"));
4305 YP.nl();
4306 YP.nl();
4307 return;
4308 }
4309 }
4310 }
4311
4312 public static void convertStatementListJavascript(object arg1, object arg2)
4313 {
4314 {
4315 object x1 = arg2;
4316 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4317 {
4318 return;
4319 }
4320 }
4321 {
4322 object Level = arg2;
4323 Variable Name = new Variable();
4324 Variable Body = new Variable();
4325 Variable RestStatements = new Variable();
4326 Variable NextLevel = new Variable();
4327 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4328 {
4329 convertIndentationJavascript(Level);
4330 YP.write(Name);
4331 YP.write(Atom.a(@":"));
4332 YP.nl();
4333 convertIndentationJavascript(Level);
4334 YP.write(Atom.a(@"{"));
4335 YP.nl();
4336 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4337 {
4338 convertStatementListJavascript(Body, NextLevel);
4339 convertIndentationJavascript(Level);
4340 YP.write(Atom.a(@"}"));
4341 YP.nl();
4342 convertStatementListJavascript(RestStatements, Level);
4343 return;
4344 }
4345 }
4346 }
4347 {
4348 object Level = arg2;
4349 Variable _Type = new Variable();
4350 Variable Name = new Variable();
4351 Variable Expression = new Variable();
4352 Variable RestStatements = new Variable();
4353 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
4354 {
4355 convertIndentationJavascript(Level);
4356 YP.write(Atom.a(@"var "));
4357 YP.write(Name);
4358 YP.write(Atom.a(@" = "));
4359 convertExpressionJavascript(Expression);
4360 YP.write(Atom.a(@";"));
4361 YP.nl();
4362 convertStatementListJavascript(RestStatements, Level);
4363 return;
4364 }
4365 }
4366 {
4367 object Level = arg2;
4368 Variable Name = new Variable();
4369 Variable Expression = new Variable();
4370 Variable RestStatements = new Variable();
4371 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
4372 {
4373 convertIndentationJavascript(Level);
4374 YP.write(Name);
4375 YP.write(Atom.a(@" = "));
4376 convertExpressionJavascript(Expression);
4377 YP.write(Atom.a(@";"));
4378 YP.nl();
4379 convertStatementListJavascript(RestStatements, Level);
4380 return;
4381 }
4382 }
4383 {
4384 object Level = arg2;
4385 Variable RestStatements = new Variable();
4386 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
4387 {
4388 convertIndentationJavascript(Level);
4389 YP.write(Atom.a(@"yield true;"));
4390 YP.nl();
4391 convertStatementListJavascript(RestStatements, Level);
4392 return;
4393 }
4394 }
4395 {
4396 object Level = arg2;
4397 Variable RestStatements = new Variable();
4398 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
4399 {
4400 convertIndentationJavascript(Level);
4401 YP.write(Atom.a(@"yield false;"));
4402 YP.nl();
4403 convertStatementListJavascript(RestStatements, Level);
4404 return;
4405 }
4406 }
4407 {
4408 object Level = arg2;
4409 Variable RestStatements = new Variable();
4410 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
4411 {
4412 convertIndentationJavascript(Level);
4413 YP.write(Atom.a(@"return;"));
4414 YP.nl();
4415 convertStatementListJavascript(RestStatements, Level);
4416 return;
4417 }
4418 }
4419 {
4420 object Level = arg2;
4421 Variable RestStatements = new Variable();
4422 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
4423 {
4424 convertIndentationJavascript(Level);
4425 YP.write(Atom.a(@"return;"));
4426 YP.nl();
4427 convertStatementListJavascript(RestStatements, Level);
4428 return;
4429 }
4430 }
4431 {
4432 object Level = arg2;
4433 Variable RestStatements = new Variable();
4434 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
4435 {
4436 convertIndentationJavascript(Level);
4437 YP.write(Atom.a(@"return true;"));
4438 YP.nl();
4439 convertStatementListJavascript(RestStatements, Level);
4440 return;
4441 }
4442 }
4443 {
4444 object Level = arg2;
4445 Variable RestStatements = new Variable();
4446 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
4447 {
4448 convertIndentationJavascript(Level);
4449 YP.write(Atom.a(@"return false;"));
4450 YP.nl();
4451 convertStatementListJavascript(RestStatements, Level);
4452 return;
4453 }
4454 }
4455 {
4456 object Level = arg2;
4457 Variable Name = new Variable();
4458 Variable RestStatements = new Variable();
4459 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
4460 {
4461 convertIndentationJavascript(Level);
4462 YP.write(Atom.a(@"break "));
4463 YP.write(Name);
4464 YP.write(Atom.a(@";"));
4465 YP.nl();
4466 convertStatementListJavascript(RestStatements, Level);
4467 return;
4468 }
4469 }
4470 {
4471 object Level = arg2;
4472 Variable Name = new Variable();
4473 Variable ArgList = new Variable();
4474 Variable RestStatements = new Variable();
4475 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
4476 {
4477 convertIndentationJavascript(Level);
4478 YP.write(Name);
4479 YP.write(Atom.a(@"("));
4480 convertArgListJavascript(ArgList);
4481 YP.write(Atom.a(@");"));
4482 YP.nl();
4483 convertStatementListJavascript(RestStatements, Level);
4484 return;
4485 }
4486 }
4487 {
4488 object Level = arg2;
4489 Variable Obj = new Variable();
4490 Variable Name = new Variable();
4491 Variable ArgList = new Variable();
4492 Variable RestStatements = new Variable();
4493 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
4494 {
4495 convertIndentationJavascript(Level);
4496 YP.write(Obj);
4497 YP.write(Atom.a(@"."));
4498 YP.write(Name);
4499 YP.write(Atom.a(@"("));
4500 convertArgListJavascript(ArgList);
4501 YP.write(Atom.a(@");"));
4502 YP.nl();
4503 convertStatementListJavascript(RestStatements, Level);
4504 return;
4505 }
4506 }
4507 {
4508 object Level = arg2;
4509 Variable Body = new Variable();
4510 Variable RestStatements = new Variable();
4511 Variable NextLevel = new Variable();
4512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4513 {
4514 convertIndentationJavascript(Level);
4515 YP.write(Atom.a(@"{"));
4516 YP.nl();
4517 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4518 {
4519 convertStatementListJavascript(Body, NextLevel);
4520 convertIndentationJavascript(Level);
4521 YP.write(Atom.a(@"}"));
4522 YP.nl();
4523 convertStatementListJavascript(RestStatements, Level);
4524 return;
4525 }
4526 }
4527 }
4528 {
4529 object Level = arg2;
4530 Variable Expression = new Variable();
4531 Variable Body = new Variable();
4532 Variable RestStatements = new Variable();
4533 Variable NextLevel = new Variable();
4534 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4535 {
4536 convertIndentationJavascript(Level);
4537 YP.write(Atom.a(@"if ("));
4538 convertExpressionJavascript(Expression);
4539 YP.write(Atom.a(@") {"));
4540 YP.nl();
4541 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4542 {
4543 convertStatementListJavascript(Body, NextLevel);
4544 convertIndentationJavascript(Level);
4545 YP.write(Atom.a(@"}"));
4546 YP.nl();
4547 convertStatementListJavascript(RestStatements, Level);
4548 return;
4549 }
4550 }
4551 }
4552 {
4553 object Level = arg2;
4554 Variable Expression = new Variable();
4555 Variable Body = new Variable();
4556 Variable RestStatements = new Variable();
4557 Variable NextLevel = new Variable();
4558 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4559 {
4560 convertIndentationJavascript(Level);
4561 YP.write(Atom.a(@"for each (var l"));
4562 YP.write(Level);
4563 YP.write(Atom.a(@" in "));
4564 convertExpressionJavascript(Expression);
4565 YP.write(Atom.a(@") {"));
4566 YP.nl();
4567 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4568 {
4569 convertStatementListJavascript(Body, NextLevel);
4570 convertIndentationJavascript(Level);
4571 YP.write(Atom.a(@"}"));
4572 YP.nl();
4573 convertStatementListJavascript(RestStatements, Level);
4574 return;
4575 }
4576 }
4577 }
4578 {
4579 object Level = arg2;
4580 Variable Expression = new Variable();
4581 Variable RestStatements = new Variable();
4582 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
4583 {
4584 convertIndentationJavascript(Level);
4585 YP.write(Atom.a(@"throw "));
4586 convertExpressionJavascript(Expression);
4587 YP.write(Atom.a(@";"));
4588 YP.nl();
4589 convertStatementListJavascript(RestStatements, Level);
4590 return;
4591 }
4592 }
4593 }
4594
4595 public static void convertIndentationJavascript(object Level)
4596 {
4597 {
4598 Variable N = new Variable();
4599 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4600 {
4601 repeatWrite(Atom.a(@" "), N);
4602 return;
4603 }
4604 }
4605 }
4606
4607 public static void convertArgListJavascript(object arg1)
4608 {
4609 {
4610 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4611 {
4612 return;
4613 }
4614 }
4615 {
4616 Variable Head = new Variable();
4617 Variable Tail = new Variable();
4618 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4619 {
4620 convertExpressionJavascript(Head);
4621 if (YP.termNotEqual(Tail, Atom.NIL))
4622 {
4623 YP.write(Atom.a(@", "));
4624 convertArgListJavascript(Tail);
4625 return;
4626 goto cutIf1;
4627 }
4628 convertArgListJavascript(Tail);
4629 return;
4630 cutIf1:
4631 { }
4632 }
4633 }
4634 }
4635
4636 public static void convertExpressionJavascript(object arg1)
4637 {
4638 {
4639 Variable X = new Variable();
4640 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4641 {
4642 YP.write(X);
4643 return;
4644 }
4645 }
4646 {
4647 Variable Name = new Variable();
4648 Variable ArgList = new Variable();
4649 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4650 {
4651 YP.write(Name);
4652 YP.write(Atom.a(@"("));
4653 convertArgListJavascript(ArgList);
4654 YP.write(Atom.a(@")"));
4655 return;
4656 }
4657 }
4658 {
4659 Variable Obj = new Variable();
4660 Variable Name = new Variable();
4661 Variable ArgList = new Variable();
4662 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4663 {
4664 YP.write(Obj);
4665 YP.write(Atom.a(@"."));
4666 YP.write(Name);
4667 YP.write(Atom.a(@"("));
4668 convertArgListJavascript(ArgList);
4669 YP.write(Atom.a(@")"));
4670 return;
4671 }
4672 }
4673 {
4674 Variable Name = new Variable();
4675 Variable ArgList = new Variable();
4676 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4677 {
4678 YP.write(Atom.a(@"new "));
4679 YP.write(Name);
4680 YP.write(Atom.a(@"("));
4681 convertArgListJavascript(ArgList);
4682 YP.write(Atom.a(@")"));
4683 return;
4684 }
4685 }
4686 {
4687 Variable Name = new Variable();
4688 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4689 {
4690 YP.write(Name);
4691 return;
4692 }
4693 }
4694 {
4695 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4696 {
4697 YP.write(Atom.a(@"null"));
4698 return;
4699 }
4700 }
4701 {
4702 Variable X = new Variable();
4703 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4704 {
4705 YP.write(Atom.a(@"!("));
4706 convertExpressionJavascript(X);
4707 YP.write(Atom.a(@")"));
4708 return;
4709 }
4710 }
4711 {
4712 Variable X = new Variable();
4713 Variable Y = new Variable();
4714 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4715 {
4716 YP.write(Atom.a(@"("));
4717 convertExpressionJavascript(X);
4718 YP.write(Atom.a(@") && ("));
4719 convertExpressionJavascript(Y);
4720 YP.write(Atom.a(@")"));
4721 return;
4722 }
4723 }
4724 {
4725 Variable ArgList = new Variable();
4726 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4727 {
4728 YP.write(Atom.a(@"["));
4729 convertArgListJavascript(ArgList);
4730 YP.write(Atom.a(@"]"));
4731 return;
4732 }
4733 }
4734 {
4735 Variable X = new Variable();
4736 Variable Codes = new Variable();
4737 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4738 {
4739 if (YP.atom(X))
4740 {
4741 YP.write(Atom.a(@""""));
4742 foreach (bool l4 in YP.atom_codes(X, Codes))
4743 {
4744 convertStringCodesJavascript(Codes);
4745 YP.write(Atom.a(@""""));
4746 return;
4747 }
4748 }
4749 }
4750 }
4751 {
4752 Variable X = new Variable();
4753 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4754 {
4755 YP.write(X);
4756 return;
4757 }
4758 }
4759 }
4760
4761 public static void convertStringCodesJavascript(object arg1)
4762 {
4763 {
4764 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4765 {
4766 return;
4767 }
4768 }
4769 {
4770 Variable Code = new Variable();
4771 Variable RestCodes = new Variable();
4772 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4773 {
4774 if (YP.termEqual(Code, 34))
4775 {
4776 YP.put_code(92);
4777 YP.put_code(Code);
4778 convertStringCodesJavascript(RestCodes);
4779 return;
4780 goto cutIf1;
4781 }
4782 if (YP.termEqual(Code, 92))
4783 {
4784 YP.put_code(92);
4785 YP.put_code(Code);
4786 convertStringCodesJavascript(RestCodes);
4787 return;
4788 goto cutIf1;
4789 }
4790 YP.put_code(Code);
4791 convertStringCodesJavascript(RestCodes);
4792 return;
4793 cutIf1:
4794 { }
4795 }
4796 }
4797 }
4798
4799 public static void convertFunctionPython(object arg1)
4800 {
4801 {
4802 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4803 {
4804 YP.write(Atom.a(@"def getDeclaringClass():"));
4805 YP.nl();
4806 YP.write(Atom.a(@" return None"));
4807 YP.nl();
4808 YP.nl();
4809 return;
4810 }
4811 }
4812 {
4813 Variable x1 = new Variable();
4814 Variable Name = new Variable();
4815 Variable ArgList = new Variable();
4816 Variable Body = new Variable();
4817 Variable Level = new Variable();
4818 Variable HasBreakableBlock = new Variable();
4819 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4820 {
4821 YP.write(Atom.a(@"def "));
4822 YP.write(Name);
4823 YP.write(Atom.a(@"("));
4824 convertArgListPython(ArgList);
4825 YP.write(Atom.a(@"):"));
4826 YP.nl();
4827 foreach (bool l3 in YP.unify(Level, 1))
4828 {
4829 if (hasBreakableBlockPython(Body))
4830 {
4831 foreach (bool l5 in YP.unify(HasBreakableBlock, 1))
4832 {
4833 if (YP.termEqual(HasBreakableBlock, 1))
4834 {
4835 convertIndentationPython(Level);
4836 YP.write(Atom.a(@"doBreak = False"));
4837 YP.nl();
4838 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
4839 {
4840 YP.nl();
4841 return;
4842 }
4843 goto cutIf2;
4844 }
4845 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4846 {
4847 YP.nl();
4848 return;
4849 }
4850 cutIf2:
4851 { }
4852 }
4853 goto cutIf1;
4854 }
4855 foreach (bool l4 in YP.unify(HasBreakableBlock, 0))
4856 {
4857 if (YP.termEqual(HasBreakableBlock, 1))
4858 {
4859 convertIndentationPython(Level);
4860 YP.write(Atom.a(@"doBreak = False"));
4861 YP.nl();
4862 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4863 {
4864 YP.nl();
4865 return;
4866 }
4867 goto cutIf3;
4868 }
4869 foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock))
4870 {
4871 YP.nl();
4872 return;
4873 }
4874 cutIf3:
4875 { }
4876 }
4877 cutIf1:
4878 { }
4879 }
4880 }
4881 }
4882 }
4883
4884 public static bool hasBreakableBlockPython(object arg1)
4885 {
4886 {
4887 Variable _Name = new Variable();
4888 Variable _Body = new Variable();
4889 Variable _RestStatements = new Variable();
4890 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements)))
4891 {
4892 return true;
4893 }
4894 }
4895 {
4896 Variable Body = new Variable();
4897 Variable _RestStatements = new Variable();
4898 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements)))
4899 {
4900 if (hasBreakableBlockPython(Body))
4901 {
4902 return true;
4903 }
4904 }
4905 }
4906 {
4907 Variable _Expression = new Variable();
4908 Variable Body = new Variable();
4909 Variable _RestStatements = new Variable();
4910 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements)))
4911 {
4912 if (hasBreakableBlockPython(Body))
4913 {
4914 return true;
4915 }
4916 }
4917 }
4918 {
4919 Variable _Expression = new Variable();
4920 Variable Body = new Variable();
4921 Variable _RestStatements = new Variable();
4922 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements)))
4923 {
4924 if (hasBreakableBlockPython(Body))
4925 {
4926 return true;
4927 }
4928 }
4929 }
4930 {
4931 Variable x1 = new Variable();
4932 Variable RestStatements = new Variable();
4933 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements)))
4934 {
4935 if (hasBreakableBlockPython(RestStatements))
4936 {
4937 return true;
4938 }
4939 }
4940 }
4941 return false;
4942 }
4943
4944 public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3)
4945 {
4946 {
4947 object x1 = arg2;
4948 object x2 = arg3;
4949 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4950 {
4951 yield return true;
4952 yield break;
4953 }
4954 }
4955 {
4956 object Level = arg2;
4957 object HasBreakableBlock = arg3;
4958 Variable Name = new Variable();
4959 Variable Body = new Variable();
4960 Variable RestStatements = new Variable();
4961 Variable NextLevel = new Variable();
4962 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4963 {
4964 convertIndentationPython(Level);
4965 YP.write(Name);
4966 YP.write(Atom.a(@" = False"));
4967 YP.nl();
4968 convertIndentationPython(Level);
4969 YP.write(Atom.a(@"for _ in [1]:"));
4970 YP.nl();
4971 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4972 {
4973 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
4974 {
4975 convertIndentationPython(Level);
4976 YP.write(Atom.a(@"if "));
4977 YP.write(Name);
4978 YP.write(Atom.a(@":"));
4979 YP.nl();
4980 convertIndentationPython(NextLevel);
4981 YP.write(Atom.a(@"doBreak = False"));
4982 YP.nl();
4983 convertIndentationPython(Level);
4984 YP.write(Atom.a(@"if doBreak:"));
4985 YP.nl();
4986 convertIndentationPython(NextLevel);
4987 YP.write(Atom.a(@"break"));
4988 YP.nl();
4989 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
4990 {
4991 yield return true;
4992 yield break;
4993 }
4994 }
4995 }
4996 }
4997 }
4998 {
4999 object Level = arg2;
5000 object HasBreakableBlock = arg3;
5001 Variable _Type = new Variable();
5002 Variable Name = new Variable();
5003 Variable Expression = new Variable();
5004 Variable RestStatements = new Variable();
5005 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
5006 {
5007 convertIndentationPython(Level);
5008 YP.write(Name);
5009 YP.write(Atom.a(@" = "));
5010 convertExpressionPython(Expression);
5011 YP.nl();
5012 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5013 {
5014 yield return true;
5015 yield break;
5016 }
5017 }
5018 }
5019 {
5020 object Level = arg2;
5021 object HasBreakableBlock = arg3;
5022 Variable Name = new Variable();
5023 Variable Expression = new Variable();
5024 Variable RestStatements = new Variable();
5025 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
5026 {
5027 convertIndentationPython(Level);
5028 YP.write(Name);
5029 YP.write(Atom.a(@" = "));
5030 convertExpressionPython(Expression);
5031 YP.nl();
5032 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5033 {
5034 yield return true;
5035 yield break;
5036 }
5037 }
5038 }
5039 {
5040 object Level = arg2;
5041 object HasBreakableBlock = arg3;
5042 Variable RestStatements = new Variable();
5043 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
5044 {
5045 convertIndentationPython(Level);
5046 YP.write(Atom.a(@"yield True"));
5047 YP.nl();
5048 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5049 {
5050 yield return true;
5051 yield break;
5052 }
5053 }
5054 }
5055 {
5056 object Level = arg2;
5057 object HasBreakableBlock = arg3;
5058 Variable RestStatements = new Variable();
5059 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
5060 {
5061 convertIndentationPython(Level);
5062 YP.write(Atom.a(@"yield False"));
5063 YP.nl();
5064 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5065 {
5066 yield return true;
5067 yield break;
5068 }
5069 }
5070 }
5071 {
5072 object Level = arg2;
5073 object HasBreakableBlock = arg3;
5074 Variable RestStatements = new Variable();
5075 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
5076 {
5077 convertIndentationPython(Level);
5078 YP.write(Atom.a(@"return"));
5079 YP.nl();
5080 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5081 {
5082 yield return true;
5083 yield break;
5084 }
5085 }
5086 }
5087 {
5088 object Level = arg2;
5089 object HasBreakableBlock = arg3;
5090 Variable RestStatements = new Variable();
5091 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
5092 {
5093 convertIndentationPython(Level);
5094 YP.write(Atom.a(@"return"));
5095 YP.nl();
5096 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5097 {
5098 yield return true;
5099 yield break;
5100 }
5101 }
5102 }
5103 {
5104 object Level = arg2;
5105 object HasBreakableBlock = arg3;
5106 Variable RestStatements = new Variable();
5107 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
5108 {
5109 convertIndentationPython(Level);
5110 YP.write(Atom.a(@"return True"));
5111 YP.nl();
5112 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5113 {
5114 yield return true;
5115 yield break;
5116 }
5117 }
5118 }
5119 {
5120 object Level = arg2;
5121 object HasBreakableBlock = arg3;
5122 Variable RestStatements = new Variable();
5123 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
5124 {
5125 convertIndentationPython(Level);
5126 YP.write(Atom.a(@"return False"));
5127 YP.nl();
5128 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5129 {
5130 yield return true;
5131 yield break;
5132 }
5133 }
5134 }
5135 {
5136 object Level = arg2;
5137 object HasBreakableBlock = arg3;
5138 Variable Name = new Variable();
5139 Variable RestStatements = new Variable();
5140 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
5141 {
5142 convertIndentationPython(Level);
5143 YP.write(Name);
5144 YP.write(Atom.a(@" = True"));
5145 YP.nl();
5146 convertIndentationPython(Level);
5147 YP.write(Atom.a(@"doBreak = True"));
5148 YP.nl();
5149 convertIndentationPython(Level);
5150 YP.write(Atom.a(@"break"));
5151 YP.nl();
5152 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5153 {
5154 yield return true;
5155 yield break;
5156 }
5157 }
5158 }
5159 {
5160 object Level = arg2;
5161 object HasBreakableBlock = arg3;
5162 Variable Name = new Variable();
5163 Variable ArgList = new Variable();
5164 Variable RestStatements = new Variable();
5165 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
5166 {
5167 convertIndentationPython(Level);
5168 YP.write(Name);
5169 YP.write(Atom.a(@"("));
5170 convertArgListPython(ArgList);
5171 YP.write(Atom.a(@")"));
5172 YP.nl();
5173 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5174 {
5175 yield return true;
5176 yield break;
5177 }
5178 }
5179 }
5180 {
5181 object Level = arg2;
5182 object HasBreakableBlock = arg3;
5183 Variable Obj = new Variable();
5184 Variable Name = new Variable();
5185 Variable ArgList = new Variable();
5186 Variable RestStatements = new Variable();
5187 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
5188 {
5189 convertIndentationPython(Level);
5190 YP.write(Obj);
5191 YP.write(Atom.a(@"."));
5192 YP.write(Name);
5193 YP.write(Atom.a(@"("));
5194 convertArgListPython(ArgList);
5195 YP.write(Atom.a(@")"));
5196 YP.nl();
5197 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5198 {
5199 yield return true;
5200 yield break;
5201 }
5202 }
5203 }
5204 {
5205 object Level = arg2;
5206 object HasBreakableBlock = arg3;
5207 Variable Body = new Variable();
5208 Variable RestStatements = new Variable();
5209 Variable NextLevel = new Variable();
5210 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
5211 {
5212 if (YP.termEqual(HasBreakableBlock, 1))
5213 {
5214 convertIndentationPython(Level);
5215 YP.write(Atom.a(@"for _ in [1]:"));
5216 YP.nl();
5217 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
5218 {
5219 foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5220 {
5221 if (YP.termEqual(HasBreakableBlock, 1))
5222 {
5223 if (YP.greaterThan(Level, 1))
5224 {
5225 convertIndentationPython(Level);
5226 YP.write(Atom.a(@"if doBreak:"));
5227 YP.nl();
5228 convertIndentationPython(NextLevel);
5229 YP.write(Atom.a(@"break"));
5230 YP.nl();
5231 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5232 {
5233 yield return true;
5234 yield break;
5235 }
5236 goto cutIf3;
5237 }
5238 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5239 {
5240 yield return true;
5241 yield break;
5242 }
5243 cutIf3:
5244 goto cutIf2;
5245 }
5246 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5247 {
5248 yield return true;
5249 yield break;
5250 }
5251 cutIf2:
5252 { }
5253 }
5254 }
5255 goto cutIf1;
5256 }
5257 foreach (bool l3 in YP.unify(NextLevel, Level))
5258 {
5259 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5260 {
5261 if (YP.termEqual(HasBreakableBlock, 1))
5262 {
5263 if (YP.greaterThan(Level, 1))
5264 {
5265 convertIndentationPython(Level);
5266 YP.write(Atom.a(@"if doBreak:"));
5267 YP.nl();
5268 convertIndentationPython(NextLevel);
5269 YP.write(Atom.a(@"break"));
5270 YP.nl();
5271 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5272 {
5273 yield return true;
5274 yield break;
5275 }
5276 goto cutIf5;
5277 }
5278 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5279 {
5280 yield return true;
5281 yield break;
5282 }
5283 cutIf5:
5284 goto cutIf4;
5285 }
5286 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5287 {
5288 yield return true;
5289 yield break;
5290 }
5291 cutIf4:
5292 { }
5293 }
5294 }
5295 cutIf1:
5296 { }
5297 }
5298 }
5299 {
5300 object Level = arg2;
5301 object HasBreakableBlock = arg3;
5302 Variable Expression = new Variable();
5303 Variable Body = new Variable();
5304 Variable RestStatements = new Variable();
5305 Variable NextLevel = new Variable();
5306 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
5307 {
5308 convertIndentationPython(Level);
5309 YP.write(Atom.a(@"if "));
5310 convertExpressionPython(Expression);
5311 YP.write(Atom.a(@":"));
5312 YP.nl();
5313 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5314 {
5315 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5316 {
5317 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5318 {
5319 yield return true;
5320 yield break;
5321 }
5322 }
5323 }
5324 }
5325 }
5326 {
5327 object Level = arg2;
5328 object HasBreakableBlock = arg3;
5329 Variable Expression = new Variable();
5330 Variable Body = new Variable();
5331 Variable RestStatements = new Variable();
5332 Variable NextLevel = new Variable();
5333 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
5334 {
5335 convertIndentationPython(Level);
5336 YP.write(Atom.a(@"for l"));
5337 YP.write(Level);
5338 YP.write(Atom.a(@" in "));
5339 convertExpressionPython(Expression);
5340 YP.write(Atom.a(@":"));
5341 YP.nl();
5342 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5343 {
5344 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5345 {
5346 if (YP.termEqual(HasBreakableBlock, 1))
5347 {
5348 convertIndentationPython(Level);
5349 YP.write(Atom.a(@"if doBreak:"));
5350 YP.nl();
5351 convertIndentationPython(NextLevel);
5352 YP.write(Atom.a(@"break"));
5353 YP.nl();
5354 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5355 {
5356 yield return true;
5357 yield break;
5358 }
5359 goto cutIf6;
5360 }
5361 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5362 {
5363 yield return true;
5364 yield break;
5365 }
5366 cutIf6:
5367 { }
5368 }
5369 }
5370 }
5371 }
5372 {
5373 object Level = arg2;
5374 object HasBreakableBlock = arg3;
5375 Variable Expression = new Variable();
5376 Variable RestStatements = new Variable();
5377 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
5378 {
5379 convertIndentationPython(Level);
5380 YP.write(Atom.a(@"raise "));
5381 convertExpressionPython(Expression);
5382 YP.nl();
5383 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5384 {
5385 yield return true;
5386 yield break;
5387 }
5388 }
5389 }
5390 }
5391
5392 public static void convertIndentationPython(object Level)
5393 {
5394 {
5395 Variable N = new Variable();
5396 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
5397 {
5398 repeatWrite(Atom.a(@" "), N);
5399 return;
5400 }
5401 }
5402 }
5403
5404 public static void convertArgListPython(object arg1)
5405 {
5406 {
5407 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5408 {
5409 return;
5410 }
5411 }
5412 {
5413 Variable Head = new Variable();
5414 Variable Tail = new Variable();
5415 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
5416 {
5417 convertExpressionPython(Head);
5418 if (YP.termNotEqual(Tail, Atom.NIL))
5419 {
5420 YP.write(Atom.a(@", "));
5421 convertArgListPython(Tail);
5422 return;
5423 goto cutIf1;
5424 }
5425 convertArgListPython(Tail);
5426 return;
5427 cutIf1:
5428 { }
5429 }
5430 }
5431 }
5432
5433 public static void convertExpressionPython(object arg1)
5434 {
5435 {
5436 Variable X = new Variable();
5437 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
5438 {
5439 YP.write(X);
5440 return;
5441 }
5442 }
5443 {
5444 Variable Name = new Variable();
5445 Variable ArgList = new Variable();
5446 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
5447 {
5448 YP.write(Name);
5449 YP.write(Atom.a(@"("));
5450 convertArgListPython(ArgList);
5451 YP.write(Atom.a(@")"));
5452 return;
5453 }
5454 }
5455 {
5456 Variable Obj = new Variable();
5457 Variable Name = new Variable();
5458 Variable ArgList = new Variable();
5459 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
5460 {
5461 YP.write(Obj);
5462 YP.write(Atom.a(@"."));
5463 YP.write(Name);
5464 YP.write(Atom.a(@"("));
5465 convertArgListPython(ArgList);
5466 YP.write(Atom.a(@")"));
5467 return;
5468 }
5469 }
5470 {
5471 Variable Name = new Variable();
5472 Variable ArgList = new Variable();
5473 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
5474 {
5475 YP.write(Name);
5476 YP.write(Atom.a(@"("));
5477 convertArgListPython(ArgList);
5478 YP.write(Atom.a(@")"));
5479 return;
5480 }
5481 }
5482 {
5483 Variable Name = new Variable();
5484 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
5485 {
5486 YP.write(Name);
5487 return;
5488 }
5489 }
5490 {
5491 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
5492 {
5493 YP.write(Atom.a(@"None"));
5494 return;
5495 }
5496 }
5497 {
5498 Variable X = new Variable();
5499 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
5500 {
5501 YP.write(Atom.a(@"not ("));
5502 convertExpressionPython(X);
5503 YP.write(Atom.a(@")"));
5504 return;
5505 }
5506 }
5507 {
5508 Variable X = new Variable();
5509 Variable Y = new Variable();
5510 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
5511 {
5512 YP.write(Atom.a(@"("));
5513 convertExpressionPython(X);
5514 YP.write(Atom.a(@") and ("));
5515 convertExpressionPython(Y);
5516 YP.write(Atom.a(@")"));
5517 return;
5518 }
5519 }
5520 {
5521 Variable ArgList = new Variable();
5522 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
5523 {
5524 YP.write(Atom.a(@"["));
5525 convertArgListPython(ArgList);
5526 YP.write(Atom.a(@"]"));
5527 return;
5528 }
5529 }
5530 {
5531 Variable X = new Variable();
5532 Variable Codes = new Variable();
5533 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5534 {
5535 if (YP.atom(X))
5536 {
5537 YP.write(Atom.a(@""""));
5538 foreach (bool l4 in YP.atom_codes(X, Codes))
5539 {
5540 convertStringCodesPython(Codes);
5541 YP.write(Atom.a(@""""));
5542 return;
5543 }
5544 }
5545 }
5546 }
5547 {
5548 Variable X = new Variable();
5549 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5550 {
5551 YP.write(X);
5552 return;
5553 }
5554 }
5555 }
5556
5557 public static void convertStringCodesPython(object arg1)
5558 {
5559 {
5560 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5561 {
5562 return;
5563 }
5564 }
5565 {
5566 Variable Code = new Variable();
5567 Variable RestCodes = new Variable();
5568 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
5569 {
5570 if (YP.termEqual(Code, 34))
5571 {
5572 YP.put_code(92);
5573 YP.put_code(Code);
5574 convertStringCodesPython(RestCodes);
5575 return;
5576 goto cutIf1;
5577 }
5578 if (YP.termEqual(Code, 92))
5579 {
5580 YP.put_code(92);
5581 YP.put_code(Code);
5582 convertStringCodesPython(RestCodes);
5583 return;
5584 goto cutIf1;
5585 }
5586 YP.put_code(Code);
5587 convertStringCodesPython(RestCodes);
5588 return;
5589 cutIf1:
5590 { }
5591 }
5592 }
5593 }
5594
5595 public static IEnumerable<bool> member(object X, object arg2)
5596 {
5597 {
5598 Variable x2 = new Variable();
5599 foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2)))
5600 {
5601 yield return false;
5602 }
5603 }
5604 {
5605 Variable x2 = new Variable();
5606 Variable Rest = new Variable();
5607 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest)))
5608 {
5609 foreach (bool l3 in member(X, Rest))
5610 {
5611 yield return false;
5612 }
5613 }
5614 }
5615 }
5616
5617 public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
5618 {
5619 {
5620 Variable List = new Variable();
5621 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5622 {
5623 foreach (bool l3 in YP.unify(arg2, List))
5624 {
5625 foreach (bool l4 in YP.unify(arg3, List))
5626 {
5627 yield return false;
5628 }
5629 }
5630 }
5631 }
5632 {
5633 object List2 = arg2;
5634 Variable X = new Variable();
5635 Variable List1 = new Variable();
5636 Variable List12 = new Variable();
5637 foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
5638 {
5639 foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
5640 {
5641 foreach (bool l4 in append(List1, List2, List12))
5642 {
5643 yield return false;
5644 }
5645 }
5646 }
5647 }
5648 }
5649
5650 }
5651}