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