aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs107
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs1184
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs2253
4 files changed, 2541 insertions, 1121 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
index e1efda8..bba7d03 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
@@ -39,6 +39,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
39 /// </summary> 39 /// </summary>
40 public class IndexedAnswers : YP.IClause 40 public class IndexedAnswers : YP.IClause
41 { 41 {
42 private int _arity;
42 // addAnswer adds the answer here and indexes it later. 43 // addAnswer adds the answer here and indexes it later.
43 private List<object[]> _allAnswers = new List<object[]>(); 44 private List<object[]> _allAnswers = new List<object[]>();
44 // The key has the arity of answers with non-null values for each indexed arg. The value 45 // The key has the arity of answers with non-null values for each indexed arg. The value
@@ -49,17 +50,43 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
49 private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>(); 50 private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>();
50 private const int MAX_INDEX_ARGS = 31; 51 private const int MAX_INDEX_ARGS = 31;
51 52
52 public IndexedAnswers() 53 public IndexedAnswers(int arity)
53 { 54 {
55 _arity = arity;
54 } 56 }
55 57
56 /// <summary> 58 /// <summary>
59 /// Append the answer to the list and update the indexes, if any.
57 /// Elements of answer must be ground, since arguments with unbound variables make this 60 /// Elements of answer must be ground, since arguments with unbound variables make this
58 /// into a dynamic rule which we don't index. 61 /// into a dynamic rule which we don't index.
59 /// </summary> 62 /// </summary>
60 /// <param name="answer"></param> 63 /// <param name="answer"></param>
61 public void addAnswer(object[] answer) 64 public void addAnswer(object[] answer)
62 { 65 {
66 addOrPrependAnswer(answer, false);
67 }
68
69 /// <summary>
70 /// Prepend the answer to the list and clear the indexes so that they must be re-computed
71 /// on the next call to match. (Only addAnswer will maintain the indexes while adding answers.)
72 /// Elements of answer must be ground, since arguments with unbound variables make this
73 /// into a dynamic rule which we don't index.
74 /// </summary>
75 /// <param name="answer"></param>
76 public void prependAnswer(object[] answer)
77 {
78 addOrPrependAnswer(answer, true);
79 }
80
81 /// <summary>
82 /// Do the work of addAnswer or prependAnswer.
83 /// </summary>
84 /// <param name="answer"></param>
85 private void addOrPrependAnswer(object[] answer, bool prepend)
86 {
87 if (answer.Length != _arity)
88 return;
89
63 // Store a copy of the answer array. 90 // Store a copy of the answer array.
64 object[] answerCopy = new object[answer.Length]; 91 object[] answerCopy = new object[answer.Length];
65 Variable.CopyStore copyStore = new Variable.CopyStore(); 92 Variable.CopyStore copyStore = new Variable.CopyStore();
@@ -69,12 +96,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
69 throw new InvalidOperationException 96 throw new InvalidOperationException
70 ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() + 97 ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() +
71 " unbound variables"); 98 " unbound variables");
72 _allAnswers.Add(answerCopy);
73 99
74 // If match has already indexed answers for a signature, we need to add 100 if (prepend)
75 // this to the existing indexed answers. 101 {
76 foreach (int signature in _gotAnswersForSignature.Keys) 102 _allAnswers.Insert(0, answerCopy);
77 indexAnswerForSignature(answerCopy, signature); 103 clearIndexes();
104 }
105 else
106 {
107 _allAnswers.Add(answerCopy);
108 // If match has already indexed answers for a signature, we need to add
109 // this to the existing indexed answers.
110 foreach (int signature in _gotAnswersForSignature.Keys)
111 indexAnswerForSignature(answerCopy, signature);
112 }
78 } 113 }
79 114
80 private void indexAnswerForSignature(object[] answer, int signature) 115 private void indexAnswerForSignature(object[] answer, int signature)
@@ -119,6 +154,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
119 154
120 public IEnumerable<bool> match(object[] arguments) 155 public IEnumerable<bool> match(object[] arguments)
121 { 156 {
157 if (arguments.Length != _arity)
158 yield break;
159
122 // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for 160 // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for
123 // each non-null index arg. 161 // each non-null index arg.
124 HashedList indexArgs = new HashedList(arguments.Length); 162 HashedList indexArgs = new HashedList(arguments.Length);
@@ -166,6 +204,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
166 204
167 // Find matches in answers. 205 // Find matches in answers.
168 IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length]; 206 IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length];
207 // Debug: If the caller asserts another answer into this same predicate during yield, the iterator
208 // over clauses will be corrupted. Should we take the time to copy answers?
169 foreach (object[] answer in answers) 209 foreach (object[] answer in answers)
170 { 210 {
171 bool gotMatch = true; 211 bool gotMatch = true;
@@ -201,6 +241,59 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
201 } 241 }
202 } 242 }
203 243
244 public IEnumerable<bool> clause(object Head, object Body)
245 {
246 Head = YP.getValue(Head);
247 if (Head is Variable)
248 throw new PrologException("instantiation_error", "Head is an unbound variable");
249 object[] arguments = YP.getFunctorArgs(Head);
250
251 // We always match Head from _allAnswers, and the Body is Atom.a("true").
252 foreach (bool l1 in YP.unify(Body, Atom.a("true")))
253 {
254 // The caller can assert another answer into this same predicate during yield, so we have to
255 // make a copy of the answers.
256 foreach (object[] answer in _allAnswers.ToArray())
257 {
258 foreach (bool l2 in YP.unifyArrays(arguments, answer))
259 yield return false;
260 }
261 }
262 }
263
264 public IEnumerable<bool> retract(object Head, object Body)
265 {
266 Head = YP.getValue(Head);
267 if (Head is Variable)
268 throw new PrologException("instantiation_error", "Head is an unbound variable");
269 object[] arguments = YP.getFunctorArgs(Head);
270
271 // We always match Head from _allAnswers, and the Body is Atom.a("true").
272 foreach (bool l1 in YP.unify(Body, Atom.a("true")))
273 {
274 // The caller can assert another answer into this same predicate during yield, so we have to
275 // make a copy of the answers.
276 foreach (object[] answer in _allAnswers.ToArray())
277 {
278 foreach (bool l2 in YP.unifyArrays(arguments, answer))
279 {
280 _allAnswers.Remove(answer);
281 clearIndexes();
282 yield return false;
283 }
284 }
285 }
286 }
287
288 /// <summary>
289 /// After retracting or prepending an answer in _allAnswers, the indexes are invalid, so clear them.
290 /// </summary>
291 private void clearIndexes()
292 {
293 _indexedAnswers.Clear();
294 _gotAnswersForSignature.Clear();
295 }
296
204 /// <summary> 297 /// <summary>
205 /// A HashedList extends an ArrayList with methods to get a hash and to check equality 298 /// A HashedList extends an ArrayList with methods to get a hash and to check equality
206 /// based on the elements of the list. 299 /// based on the elements of the list.
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs
index 2a23fe1..9a1f00d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs
@@ -1,20 +1,20 @@
1/* 1/*
2 * Copyright (C) 2007-2008, Jeff Thompson 2 * Copyright (C) 2007-2008, Jeff Thompson
3 * 3 *
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright 11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors 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 15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission. 16 * without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -43,7 +43,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
43 /// Create a PrologException with the given Term. The printable exception message is the full Term. 43 /// Create a PrologException with the given Term. The printable exception message is the full Term.
44 /// </summary> 44 /// </summary>
45 /// <param name="Term">the term of the exception</param> 45 /// <param name="Term">the term of the exception</param>
46 /// </param>
47 public PrologException(object Term) 46 public PrologException(object Term)
48 : base(YP.getValue(Term).ToString()) 47 : base(YP.getValue(Term).ToString())
49 { 48 {
@@ -54,18 +53,107 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
54 /// Create a PrologException where the Term is error(ErrorTerm, Message). 53 /// Create a PrologException where the Term is error(ErrorTerm, Message).
55 /// This uses YP.makeCopy to copy the ErrorTerm and Message so that they are valid after unbinding. 54 /// This uses YP.makeCopy to copy the ErrorTerm and Message so that they are valid after unbinding.
56 /// </summary> 55 /// </summary>
57 /// <param name="ErrorTerm">the term of the exception</param> 56 /// <param name="ErrorTerm">the error term of the error</param>
58 /// <param name="Messsage">the message, converted to a string, to use as the printable exception message 57 /// <param name="Messsage">the message term of the error. If this is a string, it is converted to an
58 /// Atom so it can be used by Prolog code.
59 /// Message, converted to a string, is use as the printable exception message.
59 /// </param> 60 /// </param>
60 public PrologException(object ErrorTerm, object Message) 61 public PrologException(object ErrorTerm, object Message)
61 : base(YP.getValue(Message).ToString()) 62 : base(YP.getValue(Message).ToString())
62 { 63 {
64 if (Message is string)
65 Message = Atom.a((string)Message);
63 _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore()); 66 _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore());
64 } 67 }
65 68
66 public object Term 69 public class TypeErrorInfo
70 {
71 public readonly Atom _Type;
72 public readonly object _Culprit;
73 public readonly object _Message;
74
75 public TypeErrorInfo(Atom Type, object Culprit, object Message)
76 {
77 _Type = Type;
78 _Culprit = Culprit;
79 _Message = Message;
80 }
81 }
82 /// <summary>
83 /// Return the TypeErrorInfo for this exception, or null if _term does not match
84 /// error(type_error(Type, Culprit), Message).
85 /// </summary>
86 /// <returns></returns>
87 public TypeErrorInfo getTypeErrorInfo()
88 {
89 if (!(_term is Functor2 && ((Functor2)_term)._name._name == "error"))
90 return null;
91 object errorTerm = ((Functor2)_term)._arg1;
92 if (!(errorTerm is Functor2 && ((Functor2)errorTerm)._name._name == "type_error"))
93 return null;
94 if (!(((Functor2)errorTerm)._arg1 is Atom))
95 return null;
96 return new TypeErrorInfo
97 ((Atom)((Functor2)errorTerm)._arg1, ((Functor2)errorTerm)._arg2, ((Functor2)_term)._arg2);
98 }
99
100 public class ExistenceErrorInfo
101 {
102 public readonly Atom _Type;
103 public readonly object _Culprit;
104 public readonly object _Message;
105
106 public ExistenceErrorInfo(Atom Type, object Culprit, object Message)
107 {
108 _Type = Type;
109 _Culprit = Culprit;
110 _Message = Message;
111 }
112
113 /// <summary>
114 /// If _Type is procedure and _Culprit is name/artity, return the name. Otherwise return null.
115 /// </summary>
116 /// <returns></returns>
117 public object getProcedureName()
118 {
119 if (!(_Type._name == "procedure" &&
120 _Culprit is Functor2 && ((Functor2)_Culprit)._name == Atom.SLASH))
121 return null;
122 return ((Functor2)_Culprit)._arg1;
123 }
124
125 /// <summary>
126 /// If _Type is procedure and _Culprit is name/arity and arity is an integer, return the arity.
127 /// Otherwise return -1.
128 /// </summary>
129 /// <returns></returns>
130 public int getProcedureArity()
131 {
132 if (!(_Type._name == "procedure" &&
133 _Culprit is Functor2 && ((Functor2)_Culprit)._name == Atom.SLASH))
134 return -1;
135 if (!(((Functor2)_Culprit)._arg2 is int))
136 return -1;
137 return (int)((Functor2)_Culprit)._arg2;
138 }
139 }
140 /// <summary>
141 /// Return the ExistenceErrorInfo for this exception, or null if _term does not match
142 /// error(existence_error(Type, Culprit), Message). If the returned ExistenceErrorInfo _Culprit is
143 /// procedure, you can use its getProcedureName and getProcedureArity.
144 /// </summary>
145 /// <returns></returns>
146 public ExistenceErrorInfo getExistenceErrorInfo()
67 { 147 {
68 get { return _term; } 148 if (!(_term is Functor2 && ((Functor2)_term)._name._name == "error"))
149 return null;
150 object errorTerm = ((Functor2)_term)._arg1;
151 if (!(errorTerm is Functor2 && ((Functor2)errorTerm)._name._name == "existence_error"))
152 return null;
153 if (!(((Functor2)errorTerm)._arg1 is Atom))
154 return null;
155 return new ExistenceErrorInfo
156 ((Atom)((Functor2)errorTerm)._arg1, ((Functor2)errorTerm)._arg2, ((Functor2)_term)._arg2);
69 } 157 }
70 } 158 }
71} 159}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
index 31f007f..6c981bb 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
@@ -1,20 +1,20 @@
1/* 1/*
2 * Copyright (C) 2007-2008, Jeff Thompson 2 * Copyright (C) 2007-2008, Jeff Thompson
3 * 3 *
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright 11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors 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 15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission. 16 * without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -33,6 +33,9 @@ using System.Collections;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using System.IO; 34using System.IO;
35using System.Reflection; 35using System.Reflection;
36using System.Net.Sockets;
37using System.Text;
38using System.Text.RegularExpressions;
36 39
37namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog 40namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
38{ 41{
@@ -48,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
48 new Dictionary<NameArity, List<IClause>>(); 51 new Dictionary<NameArity, List<IClause>>();
49 private static TextWriter _outputStream = System.Console.Out; 52 private static TextWriter _outputStream = System.Console.Out;
50 private static TextReader _inputStream = System.Console.In; 53 private static TextReader _inputStream = System.Console.In;
51 private static List<object[]> _operatorTable = null; 54 private static IndexedAnswers _operatorTable = null;
52 55
53 /// <summary> 56 /// <summary>
54 /// An IClause is used so that dynamic predicates can call match. 57 /// An IClause is used so that dynamic predicates can call match.
@@ -56,6 +59,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
56 public interface IClause 59 public interface IClause
57 { 60 {
58 IEnumerable<bool> match(object[] args); 61 IEnumerable<bool> match(object[] args);
62 IEnumerable<bool> clause(object Head, object Body);
59 } 63 }
60 64
61 public static object getValue(object value) 65 public static object getValue(object value)
@@ -120,7 +124,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
120 /// <summary> 124 /// <summary>
121 /// Convert term to an int. 125 /// Convert term to an int.
122 /// If term is a single-element List, use its first element 126 /// If term is a single-element List, use its first element
123 /// (to handle the char types like "a"). If can't convert, throw an exception. 127 /// (to handle the char types like "a").
128 /// If can't convert, throw a PrologException for type_error evaluable (because this is only
129 /// called from arithmetic functions).
124 /// </summary> 130 /// </summary>
125 /// <param name="term"></param> 131 /// <param name="term"></param>
126 /// <returns></returns> 132 /// <returns></returns>
@@ -131,14 +137,30 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
131 YP.getValue(((Functor2)term)._arg2) == Atom.NIL) 137 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
132 // Assume it is a char type like "a". 138 // Assume it is a char type like "a".
133 term = YP.getValue(((Functor2)term)._arg1); 139 term = YP.getValue(((Functor2)term)._arg1);
140 if (term is Variable)
141 throw new PrologException(Atom.a("instantiation_error"),
142 "Expected a number but the argument is an unbound variable");
134 143
135 return (int)term; 144 try
145 {
146 return (int)term;
147 }
148 catch (InvalidCastException)
149 {
150 throw new PrologException
151 (new Functor2
152 ("type_error", Atom.a("evaluable"),
153 new Functor2(Atom.SLASH, getFunctorName(term), getFunctorArgs(term).Length)),
154 "Term must be an integer");
155 }
136 } 156 }
137 157
138 /// <summary> 158 /// <summary>
139 /// Convert term to a double. This may convert an int to a double, etc. 159 /// Convert term to a double. This may convert an int to a double, etc.
140 /// If term is a single-element List, use its first element 160 /// If term is a single-element List, use its first element
141 /// (to handle the char types like "a"). If can't convert, throw an exception. 161 /// (to handle the char types like "a").
162 /// If can't convert, throw a PrologException for type_error evaluable (because this is only
163 /// called from arithmetic functions).
142 /// </summary> 164 /// </summary>
143 /// <param name="term"></param> 165 /// <param name="term"></param>
144 /// <returns></returns> 166 /// <returns></returns>
@@ -153,7 +175,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
153 throw new PrologException(Atom.a("instantiation_error"), 175 throw new PrologException(Atom.a("instantiation_error"),
154 "Expected a number but the argument is an unbound variable"); 176 "Expected a number but the argument is an unbound variable");
155 177
156 return Convert.ToDouble(term); 178 try
179 {
180 return Convert.ToDouble(term);
181 }
182 catch (InvalidCastException)
183 {
184 throw new PrologException
185 (new Functor2
186 ("type_error", Atom.a("evaluable"),
187 new Functor2(Atom.SLASH, getFunctorName(term), getFunctorArgs(term).Length)),
188 "Term must be an integer");
189 }
157 } 190 }
158 191
159 /// <summary> 192 /// <summary>
@@ -260,6 +293,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
260 return Math.Sign(convertDouble(x)); 293 return Math.Sign(convertDouble(x));
261 } 294 }
262 295
296 // Use toFloat instead of float because it is a reserved keyword.
297 public static object toFloat(object x)
298 {
299 return convertDouble(x);
300 }
301
263 /// <summary> 302 /// <summary>
264 /// The ISO standard returns an int. 303 /// The ISO standard returns an int.
265 /// </summary> 304 /// </summary>
@@ -485,8 +524,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
485 return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); 524 return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
486 } 525 }
487 526
488
489
490 /// <summary> 527 /// <summary>
491 /// Use YP.unify to unify each of the elements of the two arrays, and yield 528 /// Use YP.unify to unify each of the elements of the two arrays, and yield
492 /// once if they all unify. 529 /// once if they all unify.
@@ -579,12 +616,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
579 { 616 {
580 object[] args = ListPair.toArray(ArgList); 617 object[] args = ListPair.toArray(ArgList);
581 if (args == null) 618 if (args == null)
582 throw new Exception("Expected a list. Got: " + ArgList.getValue()); 619 throw new PrologException
620 (new Functor2("type_error", Atom.a("list"), ArgList),
621 "Expected a list. Got: " + ArgList.getValue());
583 if (args.Length == 0) 622 if (args.Length == 0)
584 // Return the Name, even if it is not an Atom. 623 // Return the Name, even if it is not an Atom.
585 return YP.unify(Term, Name); 624 return YP.unify(Term, Name);
586 if (!atom(Name)) 625 if (!atom(Name))
587 throw new Exception("Expected an atom. Got: " + Name.getValue()); 626 throw new PrologException
627 (new Functor2("type_error", Atom.a("atom"), Name),
628 "Expected an atom. Got: " + Name.getValue());
588 629
589 return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args)); 630 return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args));
590 } 631 }
@@ -598,7 +639,45 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
598 FunctorName = YP.getValue(FunctorName); 639 FunctorName = YP.getValue(FunctorName);
599 Arity = YP.getValue(Arity); 640 Arity = YP.getValue(Arity);
600 641
601 if (!(Term is Variable)) 642 if (Term is Variable)
643 {
644 if (FunctorName is Variable)
645 throw new PrologException(Atom.a("instantiation_error"),
646 "Arg 2 FunctorName is an unbound variable");
647 if (Arity is Variable)
648 throw new PrologException(Atom.a("instantiation_error"),
649 "Arg 3 Arity is an unbound variable");
650 if (!(Arity is int))
651 throw new PrologException
652 (new Functor2("type_error", Atom.a("integer"), Arity), "Arity is not an integer");
653 if (!YP.atomic(FunctorName))
654 throw new PrologException
655 (new Functor2("type_error", Atom.a("atomic"), FunctorName), "FunctorName is not atomic");
656
657 if ((int)Arity < 0)
658 throw new PrologException
659 (new Functor2("domain_error", Atom.a("not_less_than_zero"), Arity),
660 "Arity may not be less than zero");
661 else if ((int)Arity == 0)
662 {
663 // Just unify Term with the atomic FunctorName.
664 foreach (bool l1 in YP.unify(Term, FunctorName))
665 yield return false;
666 }
667 else
668 {
669 if (!(FunctorName is Atom))
670 throw new PrologException
671 (new Functor2("type_error", Atom.a("atom"), FunctorName), "FunctorName is not an atom");
672 // Construct a functor with unbound variables.
673 object[] args = new object[(int)Arity];
674 for (int i = 0; i < args.Length; ++i)
675 args[i] = new Variable();
676 foreach (bool l1 in YP.unify(Term, Functor.make((Atom)FunctorName, args)))
677 yield return false;
678 }
679 }
680 else
602 { 681 {
603 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term))) 682 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term)))
604 { 683 {
@@ -606,27 +685,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
606 yield return false; 685 yield return false;
607 } 686 }
608 } 687 }
609 else
610 throw new NotImplementedException("Debug: must finish functor/3");
611 } 688 }
612 689
613 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value) 690 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value)
614 { 691 {
615 if (YP.var(ArgNumber)) 692 if (var(ArgNumber))
616 throw new NotImplementedException("Debug: must finish arg/3"); 693 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 ArgNumber is an unbound variable");
617 else 694 int argNumberInt;
695 if (!getInt(ArgNumber, out argNumberInt))
696 throw new PrologException
697 (new Functor2("type_error", Atom.a("integer"), ArgNumber), "Arg 1 ArgNumber must be integer");
698 if (argNumberInt < 0)
699 throw new PrologException
700 (new Functor2("domain_error", Atom.a("not_less_than_zero"), argNumberInt),
701 "ArgNumber may not be less than zero");
702
703 if (YP.var(Term))
704 throw new PrologException(Atom.a("instantiation_error"),
705 "Arg 2 Term is an unbound variable");
706 if (!YP.compound(Term))
707 throw new PrologException
708 (new Functor2("type_error", Atom.a("compound"), Term), "Arg 2 Term must be compound");
709
710 object[] termArgs = YP.getFunctorArgs(Term);
711 // Silently fail if argNumberInt is out of range.
712 if (argNumberInt >= 1 && argNumberInt <= termArgs.Length)
618 { 713 {
619 int argNumberInt = convertInt(ArgNumber); 714 // The first ArgNumber is at 1, not 0.
620 if (argNumberInt < 0) 715 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
621 throw new Exception("ArgNumber must be non-negative"); 716 yield return false;
622 object[] termArgs = YP.getFunctorArgs(Term);
623 // Silently fail if argNumberInt is out of range.
624 if (argNumberInt >= 1 && argNumberInt <= termArgs.Length)
625 {
626 // The first ArgNumber is at 1, not 0.
627 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
628 yield return false;
629 }
630 } 717 }
631 } 718 }
632 719
@@ -656,8 +743,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
656 if (term1TypeCode == -2) 743 if (term1TypeCode == -2)
657 { 744 {
658 // Variable. 745 // Variable.
659 // We always check for equality first because we want to be sure 746 // We always check for equality first because we want to be sure
660 // that less than returns false if the terms are equal, in 747 // that less than returns false if the terms are equal, in
661 // case that the less than check really behaves like less than or equal. 748 // case that the less than check really behaves like less than or equal.
662 if ((Variable)Term1 != (Variable)Term2) 749 if ((Variable)Term1 != (Variable)Term2)
663 // The hash code should be unique to a Variable object. 750 // The hash code should be unique to a Variable object.
@@ -700,8 +787,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
700 } 787 }
701 788
702 /// <summary> 789 /// <summary>
703 /// Type code is -2 if term is a Variable, 0 if it is an Atom, 790 /// Type code is -2 if term is a Variable, 0 if it is an Atom,
704 /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3, 791 /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3,
705 /// 4 if it is Functor. 792 /// 4 if it is Functor.
706 /// Otherwise, type code is -1. 793 /// Otherwise, type code is -1.
707 /// This does not call YP.getValue(term). 794 /// This does not call YP.getValue(term).
@@ -769,133 +856,446 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
769 if (_operatorTable == null) 856 if (_operatorTable == null)
770 { 857 {
771 // Initialize. 858 // Initialize.
772 _operatorTable = new List<object[]>(); 859 _operatorTable = new IndexedAnswers(3);
773 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") }); 860 _operatorTable.addAnswer(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") });
774 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") }); 861 _operatorTable.addAnswer(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") });
775 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") }); 862 _operatorTable.addAnswer(new object[] { 1200, Atom.a("fx"), Atom.a(":-") });
776 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") }); 863 _operatorTable.addAnswer(new object[] { 1200, Atom.a("fx"), Atom.a("?-") });
777 _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") }); 864 _operatorTable.addAnswer(new object[] { 1100, Atom.a("xfy"), Atom.a(";") });
778 _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") }); 865 _operatorTable.addAnswer(new object[] { 1050, Atom.a("xfy"), Atom.a("->") });
779 _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") }); 866 _operatorTable.addAnswer(new object[] { 1000, Atom.a("xfy"), Atom.a(",") });
780 _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") }); 867 _operatorTable.addAnswer(new object[] { 900, Atom.a("fy"), Atom.a("\\+") });
781 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") }); 868 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=") });
782 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") }); 869 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") });
783 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") }); 870 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("==") });
784 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") }); 871 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") });
785 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") }); 872 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@<") });
786 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") }); 873 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") });
787 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") }); 874 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@>") });
788 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") }); 875 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") });
789 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") }); 876 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=..") });
790 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") }); 877 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("is") });
791 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") }); 878 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") });
792 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") }); 879 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") });
793 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") }); 880 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("<") });
794 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") }); 881 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=<") });
795 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") }); 882 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a(">") });
796 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") }); 883 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a(">=") });
797 _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") }); 884 _operatorTable.addAnswer(new object[] { 600, Atom.a("xfy"), Atom.a(":") });
798 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") }); 885 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("+") });
799 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") }); 886 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("-") });
800 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") }); 887 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") });
801 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") }); 888 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") });
802 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") }); 889 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("*") });
803 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") }); 890 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("/") });
804 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") }); 891 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("//") });
805 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") }); 892 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("rem") });
806 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") }); 893 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("mod") });
807 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") }); 894 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("<<") });
808 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") }); 895 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a(">>") });
809 _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") }); 896 _operatorTable.addAnswer(new object[] { 200, Atom.a("xfx"), Atom.a("**") });
810 _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") }); 897 _operatorTable.addAnswer(new object[] { 200, Atom.a("xfy"), Atom.a("^") });
811 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") }); 898 _operatorTable.addAnswer(new object[] { 200, Atom.a("fy"), Atom.a("-") });
812 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") }); 899 _operatorTable.addAnswer(new object[] { 200, Atom.a("fy"), Atom.a("\\") });
813 // Debug: This is hacked in to run the Prolog test suite until we implement op/3. 900 // Debug: This is hacked in to run the Prolog test suite until we implement op/3.
814 _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); 901 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
815 } 902 }
816 903
817 object[] args = new object[] { Priority, Specifier, Operator }; 904 foreach (bool l1 in _operatorTable.match(new object[] { Priority, Specifier, Operator }))
818 foreach (object[] answer in _operatorTable) 905 yield return false;
819 {
820 foreach (bool l1 in YP.unifyArrays(args, answer))
821 yield return false;
822 }
823 } 906 }
824 907
825 public static IEnumerable<bool> atom_length(object atom, object Length) 908 public static IEnumerable<bool> atom_length(object atom, object Length)
826 { 909 {
827 return YP.unify(Length, ((Atom)YP.getValue(atom))._name.Length); 910 atom = YP.getValue(atom);
911 Length = YP.getValue(Length);
912 if (atom is Variable)
913 throw new PrologException(Atom.a("instantiation_error"),
914 "Expected atom(Arg1) but it is an unbound variable");
915 if (!(atom is Atom))
916 throw new PrologException
917 (new Functor2("type_error", Atom.a("atom"), atom), "Arg 1 Atom is not an atom");
918 if (!(Length is Variable))
919 {
920 if (!(Length is int))
921 throw new PrologException
922 (new Functor2("type_error", Atom.a("integer"), Length), "Length must be var or integer");
923 if ((int)Length < 0)
924 throw new PrologException
925 (new Functor2("domain_error", Atom.a("not_less_than_zero"), Length),
926 "Length must not be less than zero");
927 }
928 return YP.unify(Length, ((Atom)atom)._name.Length);
828 } 929 }
829 930
830 public static IEnumerable<bool> atom_concat(object Start, object End, object Whole) 931 public static IEnumerable<bool> atom_concat(object Start, object End, object Whole)
831 { 932 {
832 // Debug: Should implement for var(Start) which is a kind of search.
833 // Debug: Should we try to preserve the _declaringClass? 933 // Debug: Should we try to preserve the _declaringClass?
834 return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name + 934 Start = YP.getValue(Start);
835 ((Atom)YP.getValue(End))._name)); 935 End = YP.getValue(End);
936 Whole = YP.getValue(Whole);
937 if (Whole is Variable)
938 {
939 if (Start is Variable)
940 throw new PrologException(Atom.a("instantiation_error"),
941 "Arg 1 Start and arg 3 Whole are both var");
942 if (End is Variable)
943 throw new PrologException(Atom.a("instantiation_error"),
944 "Arg 2 End and arg 3 Whole are both var");
945 if (!(Start is Atom))
946 throw new PrologException
947 (new Functor2("type_error", Atom.a("atom"), Start), "Arg 1 Start is not an atom");
948 if (!(End is Atom))
949 throw new PrologException
950 (new Functor2("type_error", Atom.a("atom"), End), "Arg 2 End is not an atom");
951
952 foreach (bool l1 in YP.unify(Whole, Atom.a(((Atom)Start)._name + ((Atom)End)._name)))
953 yield return false;
954 }
955 else
956 {
957 if (!(Whole is Atom))
958 throw new PrologException
959 (new Functor2("type_error", Atom.a("atom"), Whole), "Arg 3 Whole is not an atom");
960 bool gotStartLength = false;
961 int startLength = 0;
962 if (!(Start is Variable))
963 {
964 if (!(Start is Atom))
965 throw new PrologException
966 (new Functor2("type_error", Atom.a("atom"), Start), "Arg 1 Start is not var or atom");
967 startLength = ((Atom)Start)._name.Length;
968 gotStartLength = true;
969 }
970
971 bool gotEndLength = false;
972 int endLength = 0;
973 if (!(End is Variable))
974 {
975 if (!(End is Atom))
976 throw new PrologException
977 (new Functor2("type_error", Atom.a("atom"), End), "Arg 2 End is not var or atom");
978 endLength = ((Atom)End)._name.Length;
979 gotEndLength = true;
980 }
981
982 // We are doing a search through all possible Start and End which concatenate to Whole.
983 string wholeString = ((Atom)Whole)._name;
984 for (int i = 0; i <= wholeString.Length; ++i)
985 {
986 // If we got either startLength or endLength, we know the lengths have to match so check
987 // the lengths instead of constructing an Atom to do it.
988 if (gotStartLength && startLength != i)
989 continue;
990 if (gotEndLength && endLength != wholeString.Length - i)
991 continue;
992 foreach (bool l1 in YP.unify(Start, Atom.a(wholeString.Substring(0, i))))
993 {
994 foreach (bool l2 in YP.unify(End, Atom.a(wholeString.Substring(i, wholeString.Length - i))))
995 yield return false;
996 }
997 }
998 }
836 } 999 }
837 1000
838 public static IEnumerable<bool> sub_atom 1001 public static IEnumerable<bool> sub_atom
839 (object atom, object Before, object Length, object After, object Sub_atom) 1002 (object atom, object Before, object Length, object After, object Sub_atom)
840 { 1003 {
841 // Debug: Should implement for var(atom) which is a kind of search.
842 // Debug: Should we try to preserve the _declaringClass? 1004 // Debug: Should we try to preserve the _declaringClass?
843 Atom atomAtom = (Atom)YP.getValue(atom); 1005 atom = YP.getValue(atom);
844 int beforeInt = YP.convertInt(Before); 1006 Before = YP.getValue(Before);
845 int lengthInt = YP.convertInt(Length); 1007 Length = YP.getValue(Length);
846 if (beforeInt < 0) 1008 After = YP.getValue(After);
847 throw new Exception("Before must be non-negative"); 1009 Sub_atom = YP.getValue(Sub_atom);
848 if (lengthInt < 0) 1010 if (atom is Variable)
849 throw new Exception("Length must be non-negative"); 1011 throw new PrologException(Atom.a("instantiation_error"),
850 int afterInt = atomAtom._name.Length - (beforeInt + lengthInt); 1012 "Expected atom(Arg1) but it is an unbound variable");
851 if (afterInt >= 0) 1013 if (!(atom is Atom))
852 { 1014 throw new PrologException
853 foreach (bool l1 in YP.unify(After, afterInt)) 1015 (new Functor2("type_error", Atom.a("atom"), atom), "Arg 1 Atom is not an atom");
1016 if (!(Sub_atom is Variable))
1017 {
1018 if (!(Sub_atom is Atom))
1019 throw new PrologException
1020 (new Functor2("type_error", Atom.a("atom"), Sub_atom), "Sub_atom is not var or atom");
1021 }
1022
1023 bool beforeIsInt = false;
1024 bool lengthIsInt = false;
1025 bool afterIsInt = false;
1026 if (!(Before is Variable))
1027 {
1028 if (!(Before is int))
1029 throw new PrologException
1030 (new Functor2("type_error", Atom.a("integer"), Before), "Before must be var or integer");
1031 beforeIsInt = true;
1032 if ((int)Before < 0)
1033 throw new PrologException
1034 (new Functor2("domain_error", Atom.a("not_less_than_zero"), Before),
1035 "Before must not be less than zero");
1036 }
1037 if (!(Length is Variable))
1038 {
1039 if (!(Length is int))
1040 throw new PrologException
1041 (new Functor2("type_error", Atom.a("integer"), Length), "Length must be var or integer");
1042 lengthIsInt = true;
1043 if ((int)Length < 0)
1044 throw new PrologException
1045 (new Functor2("domain_error", Atom.a("not_less_than_zero"), Length),
1046 "Length must not be less than zero");
1047 }
1048 if (!(After is Variable))
1049 {
1050 if (!(After is int))
1051 throw new PrologException
1052 (new Functor2("type_error", Atom.a("integer"), After), "After must be var or integer");
1053 afterIsInt = true;
1054 if ((int)After < 0)
1055 throw new PrologException
1056 (new Functor2("domain_error", Atom.a("not_less_than_zero"), After),
1057 "After must not be less than zero");
1058 }
1059
1060 Atom atomAtom = (Atom)atom;
1061 int atomLength = atomAtom._name.Length;
1062 if (beforeIsInt && lengthIsInt)
1063 {
1064 // Special case: the caller is just trying to extract a substring, so do it quickly.
1065 int xAfter = atomLength - (int)Before - (int)Length;
1066 if (xAfter >= 0)
854 { 1067 {
855 foreach (bool l2 in YP.unify 1068 foreach (bool l1 in YP.unify(After, xAfter))
856 (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt)))) 1069 {
857 yield return false; 1070 foreach (bool l2 in YP.unify
1071 (Sub_atom, Atom.a(atomAtom._name.Substring((int)Before, (int)Length))))
1072 yield return false;
1073 }
1074 }
1075 }
1076 else if (afterIsInt && lengthIsInt)
1077 {
1078 // Special case: the caller is just trying to extract a substring, so do it quickly.
1079 int xBefore = atomLength - (int)After - (int)Length;
1080 if (xBefore >= 0)
1081 {
1082 foreach (bool l1 in YP.unify(Before, xBefore))
1083 {
1084 foreach (bool l2 in YP.unify
1085 (Sub_atom, Atom.a(atomAtom._name.Substring(xBefore, (int)Length))))
1086 yield return false;
1087 }
1088 }
1089 }
1090 else
1091 {
1092 // We are underconstrained and doing a search, so go through all possibilities.
1093 for (int xBefore = 0; xBefore <= atomLength; ++xBefore)
1094 {
1095 foreach (bool l1 in YP.unify(Before, xBefore))
1096 {
1097 for (int xLength = 0; xLength <= (atomLength - xBefore); ++xLength)
1098 {
1099 foreach (bool l2 in YP.unify(Length, xLength))
1100 {
1101 foreach (bool l3 in YP.unify(After, atomLength - (xBefore + xLength)))
1102 {
1103 foreach (bool l4 in YP.unify
1104 (Sub_atom, Atom.a(atomAtom._name.Substring(xBefore, xLength))))
1105 yield return false;
1106 }
1107 }
1108 }
1109 }
858 } 1110 }
859 } 1111 }
860 } 1112 }
861 1113
1114 public static IEnumerable<bool> atom_chars(object atom, object List)
1115 {
1116 atom = YP.getValue(atom);
1117 List = YP.getValue(List);
1118
1119 if (atom is Variable)
1120 {
1121 if (List is Variable)
1122 throw new PrologException(Atom.a("instantiation_error"),
1123 "Arg 1 Atom and arg 2 List are both unbound variables");
1124 object[] codeArray = ListPair.toArray(List);
1125 if (codeArray == null)
1126 throw new PrologException
1127 (new Functor2("type_error", Atom.a("list"), List), "Arg 2 List is not a list");
1128
1129 char[] charArray = new char[codeArray.Length];
1130 for (int i = 0; i < codeArray.Length; ++i)
1131 {
1132 object listAtom = YP.getValue(codeArray[i]);
1133 if (listAtom is Variable)
1134 throw new PrologException(Atom.a("instantiation_error"),
1135 "Arg 2 List has an element which is an unbound variable");
1136 if (!(listAtom is Atom && ((Atom)listAtom)._name.Length == 1))
1137 throw new PrologException
1138 (new Functor2("type_error", Atom.a("character"), listAtom),
1139 "Arg 2 List has an element which is not a one character atom");
1140 charArray[i] = ((Atom)listAtom)._name[0];
1141 }
1142 return YP.unify(atom, Atom.a(new String(charArray)));
1143 }
1144 else
1145 {
1146 if (!(atom is Atom))
1147 throw new PrologException
1148 (new Functor2("type_error", Atom.a("atom"), atom), "Arg 1 Atom is not var or atom");
1149
1150 string atomString = ((Atom)atom)._name;
1151 object charList = Atom.NIL;
1152 // Start from the back to make the list.
1153 for (int i = atomString.Length - 1; i >= 0; --i)
1154 charList = new ListPair(Atom.a(atomString.Substring(i, 1)), charList);
1155 return YP.unify(List, charList);
1156 }
1157 }
1158
862 public static IEnumerable<bool> atom_codes(object atom, object List) 1159 public static IEnumerable<bool> atom_codes(object atom, object List)
863 { 1160 {
864 atom = YP.getValue(atom); 1161 atom = YP.getValue(atom);
865 List = YP.getValue(List); 1162 List = YP.getValue(List);
866 1163
867 if (nonvar(atom)) 1164 if (atom is Variable)
868 { 1165 {
869 string name = ((Atom)atom)._name; 1166 if (List is Variable)
1167 throw new PrologException(Atom.a("instantiation_error"),
1168 "Arg 1 Atom and arg 2 List are both unbound variables");
1169 object[] codeArray = ListPair.toArray(List);
1170 if (codeArray == null)
1171 throw new PrologException
1172 (new Functor2("type_error", Atom.a("list"), List), "Arg 2 List is not a list");
1173
1174 char[] charArray = new char[codeArray.Length];
1175 for (int i = 0; i < codeArray.Length; ++i)
1176 {
1177 int codeInt;
1178 if (!getInt(codeArray[i], out codeInt) || codeInt < 0)
1179 throw new PrologException
1180 (new Functor1("representation_error", Atom.a("character_code")),
1181 "Element of Arg 2 List is not a character code");
1182 charArray[i] = (char)codeInt;
1183 }
1184 return YP.unify(atom, Atom.a(new String(charArray)));
1185 }
1186 else
1187 {
1188 if (!(atom is Atom))
1189 throw new PrologException
1190 (new Functor2("type_error", Atom.a("atom"), atom), "Arg 1 Atom is not var or atom");
1191
1192 string atomString = ((Atom)atom)._name;
870 object codeList = Atom.NIL; 1193 object codeList = Atom.NIL;
871 // Start from the back to make the list. 1194 // Start from the back to make the list.
872 for (int i = name.Length - 1; i >= 0; --i) 1195 for (int i = atomString.Length - 1; i >= 0; --i)
873 codeList = new ListPair((int)name[i], codeList); 1196 codeList = new ListPair((int)atomString[i], codeList);
874 return YP.unify(List, codeList); 1197 return YP.unify(List, codeList);
875 } 1198 }
1199 }
1200
1201 public static IEnumerable<bool> number_chars(object Number, object List)
1202 {
1203 Number = YP.getValue(Number);
1204 List = YP.getValue(List);
1205
1206 if (Number is Variable)
876 { 1207 {
1208 if (List is Variable)
1209 throw new PrologException(Atom.a("instantiation_error"),
1210 "Arg 1 Number and arg 2 List are both unbound variables");
877 object[] codeArray = ListPair.toArray(List); 1211 object[] codeArray = ListPair.toArray(List);
1212 if (codeArray == null)
1213 throw new PrologException
1214 (new Functor2("type_error", Atom.a("list"), List), "Arg 2 List is not a list");
1215
878 char[] charArray = new char[codeArray.Length]; 1216 char[] charArray = new char[codeArray.Length];
879 for (int i = 0; i < codeArray.Length; ++i) 1217 for (int i = 0; i < codeArray.Length; ++i)
880 charArray[i] = (char)YP.convertInt(codeArray[i]); 1218 {
881 return YP.unify(atom, Atom.a(new String(charArray))); 1219 object listAtom = YP.getValue(codeArray[i]);
1220 if (listAtom is Variable)
1221 throw new PrologException(Atom.a("instantiation_error"),
1222 "Arg 2 List has an element which is an unbound variable");
1223 if (!(listAtom is Atom && ((Atom)listAtom)._name.Length == 1))
1224 throw new PrologException
1225 (new Functor2("type_error", Atom.a("character"), listAtom),
1226 "Arg 2 List has an element which is not a one character atom");
1227 charArray[i] = ((Atom)listAtom)._name[0];
1228 }
1229 return YP.unify(Number, parseNumberString(charArray));
1230 }
1231 else
1232 {
1233 string numberString = null;
1234 // Try converting to an int first.
1235 int intNumber;
1236 if (YP.getInt(Number, out intNumber))
1237 numberString = intNumber.ToString();
1238 else
1239 {
1240 if (!YP.number(Number))
1241 throw new PrologException
1242 (new Functor2("type_error", Atom.a("number"), Number),
1243 "Arg 1 Number is not var or number");
1244 // We just checked, so convertDouble shouldn't throw an exception.
1245 numberString = YP.doubleToString(YP.convertDouble(Number));
1246 }
1247
1248 object charList = Atom.NIL;
1249 // Start from the back to make the list.
1250 for (int i = numberString.Length - 1; i >= 0; --i)
1251 charList = new ListPair(Atom.a(numberString.Substring(i, 1)), charList);
1252 return YP.unify(List, charList);
882 } 1253 }
883 } 1254 }
884 1255
885 public static IEnumerable<bool> number_codes(object number, object List) 1256 public static IEnumerable<bool> number_codes(object Number, object List)
886 { 1257 {
887 number = YP.getValue(number); 1258 Number = YP.getValue(Number);
888 List = YP.getValue(List); 1259 List = YP.getValue(List);
889 1260
890 if (nonvar(number)) 1261 if (Number is Variable)
1262 {
1263 if (List is Variable)
1264 throw new PrologException(Atom.a("instantiation_error"),
1265 "Arg 1 Number and arg 2 List are both unbound variables");
1266 object[] codeArray = ListPair.toArray(List);
1267 if (codeArray == null)
1268 throw new PrologException
1269 (new Functor2("type_error", Atom.a("list"), List), "Arg 2 List is not a list");
1270
1271 char[] charArray = new char[codeArray.Length];
1272 for (int i = 0; i < codeArray.Length; ++i)
1273 {
1274 int codeInt;
1275 if (!getInt(codeArray[i], out codeInt) || codeInt < 0)
1276 throw new PrologException
1277 (new Functor1("representation_error", Atom.a("character_code")),
1278 "Element of Arg 2 List is not a character code");
1279 charArray[i] = (char)codeInt;
1280 }
1281 return YP.unify(Number, parseNumberString(charArray));
1282 }
1283 else
891 { 1284 {
892 string numberString = null; 1285 string numberString = null;
893 // Try converting to an int first. 1286 // Try converting to an int first.
894 int intNumber; 1287 int intNumber;
895 if (YP.getInt(number, out intNumber)) 1288 if (YP.getInt(Number, out intNumber))
896 numberString = intNumber.ToString(); 1289 numberString = intNumber.ToString();
897 else 1290 else
898 numberString = YP.doubleToString(YP.convertDouble(number)); 1291 {
1292 if (!YP.number(Number))
1293 throw new PrologException
1294 (new Functor2("type_error", Atom.a("number"), Number),
1295 "Arg 1 Number is not var or number");
1296 // We just checked, so convertDouble shouldn't throw an exception.
1297 numberString = YP.doubleToString(YP.convertDouble(Number));
1298 }
899 1299
900 object codeList = Atom.NIL; 1300 object codeList = Atom.NIL;
901 // Start from the back to make the list. 1301 // Start from the back to make the list.
@@ -903,20 +1303,92 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
903 codeList = new ListPair((int)numberString[i], codeList); 1303 codeList = new ListPair((int)numberString[i], codeList);
904 return YP.unify(List, codeList); 1304 return YP.unify(List, codeList);
905 } 1305 }
1306 }
1307
1308 /// <summary>
1309 /// Used by number_chars and number_codes. Return the number in charArray or
1310 /// throw an exception if can't parse.
1311 /// </summary>
1312 /// <param name="numberString"></param>
1313 /// <returns></returns>
1314 private static object parseNumberString(char[] charArray)
1315 {
1316 string numberString = new String(charArray);
1317 if (charArray.Length == 3 && numberString.StartsWith("0'"))
1318 // This is a char code.
1319 return (int)charArray[2];
1320 if (numberString.StartsWith("0x"))
906 { 1321 {
907 object[] codeArray = ListPair.toArray(List);
908 char[] charArray = new char[codeArray.Length];
909 for (int i = 0; i < codeArray.Length; ++i)
910 charArray[i] = (char)YP.convertInt(codeArray[i]);
911 String numberString = new String(charArray);
912 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
913 try 1322 try
914 { 1323 {
915 // Try an int first. 1324 return Int32.Parse
916 return YP.unify(number, Convert.ToInt32(numberString)); 1325 (numberString.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier);
917 } 1326 }
918 catch (FormatException) { } 1327 catch (FormatException)
919 return YP.unify(number, Convert.ToDouble(numberString)); 1328 {
1329 throw new PrologException
1330 (new Functor1("syntax_error", Atom.a("number_format: " + numberString)),
1331 "Arg 2 List is not a list for a hexadecimal number");
1332 }
1333 }
1334 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
1335 try
1336 {
1337 // Try an int first.
1338 return Convert.ToInt32(numberString);
1339 }
1340 catch (FormatException) { }
1341 try
1342 {
1343 return Convert.ToDouble(numberString);
1344 }
1345 catch (FormatException)
1346 {
1347 throw new PrologException
1348 (new Functor1("syntax_error", Atom.a("number_format: " + numberString)),
1349 "Arg 2 List is not a list for a number");
1350 }
1351 }
1352
1353 public static IEnumerable<bool> char_code(object Char, object Code)
1354 {
1355 Char = YP.getValue(Char);
1356 Code = YP.getValue(Code);
1357
1358 int codeInt = 0;
1359 if (!(Code is Variable))
1360 {
1361 // Get codeInt now so we type check it whether or not Char is Variable.
1362 if (!getInt(Code, out codeInt))
1363 throw new PrologException
1364 (new Functor2("type_error", Atom.a("integer"), Code),
1365 "Arg 2 Code is not var or a character code");
1366 if (codeInt < 0)
1367 throw new PrologException
1368 (new Functor1("representation_error", Atom.a("character_code")),
1369 "Arg 2 Code is not a character code");
1370 }
1371
1372 if (Char is Variable)
1373 {
1374 if (Code is Variable)
1375 throw new PrologException(Atom.a("instantiation_error"),
1376 "Arg 1 Char and arg 2 Code are both unbound variables");
1377
1378 return YP.unify(Char, Atom.a(new String(new char[] {(char)codeInt} )));
1379 }
1380 else
1381 {
1382 if (!(Char is Atom) || ((Atom)Char)._name.Length != 1)
1383 throw new PrologException
1384 (new Functor2("type_error", Atom.a("character"), Char),
1385 "Arg 1 Char is not var or one-character atom");
1386
1387 if (Code is Variable)
1388 return YP.unify(Code, (int)((Atom)Char)._name[0]);
1389 else
1390 // Use codeInt to handle whether Code is supplied as, e.g., 97 or 0'a .
1391 return YP.unify(codeInt, (int)((Atom)Char)._name[0]);
920 } 1392 }
921 } 1393 }
922 1394
@@ -1092,7 +1564,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1092 } 1564 }
1093 1565
1094 /// <summary> 1566 /// <summary>
1095 /// Format x as a string, making sure that it will parse as an int later. I.e., for 1.0, don't just 1567 /// Format x as a string, making sure that it won't parse as an int later. I.e., for 1.0, don't just
1096 /// use "1" which will parse as an int. 1568 /// use "1" which will parse as an int.
1097 /// </summary> 1569 /// </summary>
1098 /// <param name="x"></param> 1570 /// <param name="x"></param>
@@ -1117,7 +1589,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1117 1589
1118 public static void put_code(object x) 1590 public static void put_code(object x)
1119 { 1591 {
1120 _outputStream.Write((char)YP.convertInt(x)); 1592 if (var(x))
1593 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 is an unbound variable");
1594 int xInt;
1595 if (!getInt(x, out xInt))
1596 throw new PrologException
1597 (new Functor2("type_error", Atom.a("integer"), x), "Arg 1 must be integer");
1598 _outputStream.Write((char)xInt);
1121 } 1599 }
1122 1600
1123 public static void nl() 1601 public static void nl()
@@ -1153,6 +1631,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1153 { 1631 {
1154 Head = YP.getValue(((Functor2)TermCopy)._arg1); 1632 Head = YP.getValue(((Functor2)TermCopy)._arg1);
1155 Body = YP.getValue(((Functor2)TermCopy)._arg2); 1633 Body = YP.getValue(((Functor2)TermCopy)._arg2);
1634 if (Head is Variable)
1635 throw new PrologException("instantiation_error", "Head to assert is an unbound variable");
1636 if (Body is Variable)
1637 throw new PrologException("instantiation_error", "Body to assert is an unbound variable");
1156 } 1638 }
1157 else 1639 else
1158 { 1640 {
@@ -1166,7 +1648,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1166 throw new PrologException 1648 throw new PrologException
1167 (new Functor2("type_error", Atom.a("callable"), Head), "Term to assert is not callable"); 1649 (new Functor2("type_error", Atom.a("callable"), Head), "Term to assert is not callable");
1168 object[] args = getFunctorArgs(Head); 1650 object[] args = getFunctorArgs(Head);
1169 if (!isDynamic(name, args.Length)) 1651 if (isSystemPredicate(name, args.Length))
1170 throw new PrologException 1652 throw new PrologException
1171 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"), 1653 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"),
1172 new Functor2(Atom.SLASH, name, args.Length)), 1654 new Functor2(Atom.SLASH, name, args.Length)),
@@ -1174,17 +1656,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1174 1656
1175 if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true")) 1657 if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true"))
1176 { 1658 {
1177 // Debug: Until IndexedAnswers supports prepend, compile the fact so we can prepend it below. 1659 // This is a fact with no unbound variables
1178 if (!prepend) 1660 // assertFact and prependFact use IndexedAnswers, so don't we don't need to compile.
1179 { 1661 if (prepend)
1180 // This is a fact with no unbound variables 1662 prependFact(name, args);
1181 // assertFact uses IndexedAnswers, so don't we don't need to compile. 1663 else
1182 assertFact(name, args); 1664 assertFact(name, args);
1183 return; 1665
1184 } 1666 return;
1185 } 1667 }
1186 1668
1187 IClause clause = YPCompiler.compileAnonymousClause(Head, Body, declaringClass); 1669 IClause clause = YPCompiler.compileAnonymousClause(Head, Body, declaringClass);
1670 // We expect clause to be a ClauseHeadAndBody (from Compiler.compileAnonymousFunction)
1671 // so we can set the Head and Body.
1672 if (clause is ClauseHeadAndBody)
1673 ((ClauseHeadAndBody)clause).setHeadAndBody(Head, Body);
1188 1674
1189 // Add the clause to the entry in _predicatesStore. 1675 // Add the clause to the entry in _predicatesStore.
1190 NameArity nameArity = new NameArity(name, args.Length); 1676 NameArity nameArity = new NameArity(name, args.Length);
@@ -1199,15 +1685,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1199 clauses.Add(clause); 1685 clauses.Add(clause);
1200 } 1686 }
1201 1687
1202 private static bool isDynamic(Atom name, int arity) 1688 private static bool isSystemPredicate(Atom name, int arity)
1203 { 1689 {
1204 if (arity == 2 && (name == Atom.a(",") || name == Atom.a(";") || name == Atom.DOT)) 1690 if (arity == 2 && (name == Atom.a(",") || name == Atom.a(";") || name == Atom.DOT))
1205 return false; 1691 return true;
1206 // Use the same mapping to static predicates in YP as the compiler. 1692 // Use the same mapping to static predicates in YP as the compiler.
1207 foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable())) 1693 foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable()))
1208 return false; 1694 return true;
1209 // Debug: Do we need to check if name._module is null? 1695 // Debug: Do we need to check if name._module is null?
1210 return true; 1696 return false;
1211 } 1697 }
1212 1698
1213 /// <summary> 1699 /// <summary>
@@ -1224,22 +1710,55 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1224 IndexedAnswers indexedAnswers; 1710 IndexedAnswers indexedAnswers;
1225 if (!_predicatesStore.TryGetValue(nameArity, out clauses)) 1711 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1226 { 1712 {
1227 // Create an IndexedAnswers as the first clause of the predicate. 1713 // Create an IndexedAnswers as the only clause of the predicate.
1228 _predicatesStore[nameArity] = (clauses = new List<IClause>()); 1714 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1229 clauses.Add(indexedAnswers = new IndexedAnswers()); 1715 clauses.Add(indexedAnswers = new IndexedAnswers(values.Length));
1230 } 1716 }
1231 else 1717 else
1232 { 1718 {
1233 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers; 1719 indexedAnswers = null;
1720 if (clauses.Count >= 1)
1721 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers;
1234 if (indexedAnswers == null) 1722 if (indexedAnswers == null)
1235 // The latest clause is not an IndexedAnswers, so add one. 1723 // The latest clause is not an IndexedAnswers, so add one.
1236 clauses.Add(indexedAnswers = new IndexedAnswers()); 1724 clauses.Add(indexedAnswers = new IndexedAnswers(values.Length));
1237 } 1725 }
1238 1726
1239 indexedAnswers.addAnswer(values); 1727 indexedAnswers.addAnswer(values);
1240 } 1728 }
1241 1729
1242 /// <summary> 1730 /// <summary>
1731 /// Assert values, prepending to the front of the set of facts for the predicate with the
1732 /// name and with arity values.Length.
1733 /// </summary>
1734 /// <param name="name">must be an Atom</param>
1735 /// <param name="values">the array of arguments to the fact predicate.
1736 /// It is an error if an value has an unbound variable.</param>
1737 public static void prependFact(Atom name, object[] values)
1738 {
1739 NameArity nameArity = new NameArity(name, values.Length);
1740 List<IClause> clauses;
1741 IndexedAnswers indexedAnswers;
1742 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1743 {
1744 // Create an IndexedAnswers as the only clause of the predicate.
1745 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1746 clauses.Add(indexedAnswers = new IndexedAnswers(values.Length));
1747 }
1748 else
1749 {
1750 indexedAnswers = null;
1751 if (clauses.Count >= 1)
1752 indexedAnswers = clauses[0] as IndexedAnswers;
1753 if (indexedAnswers == null)
1754 // The first clause is not an IndexedAnswers, so prepend one.
1755 clauses.Insert(0, indexedAnswers = new IndexedAnswers(values.Length));
1756 }
1757
1758 indexedAnswers.prependAnswer(values);
1759 }
1760
1761 /// <summary>
1243 /// Match all clauses of the dynamic predicate with the name and with arity 1762 /// Match all clauses of the dynamic predicate with the name and with arity
1244 /// arguments.Length. 1763 /// arguments.Length.
1245 /// It is an error if the predicate is not defined. 1764 /// It is an error if the predicate is not defined.
@@ -1251,9 +1770,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1251 { 1770 {
1252 List<IClause> clauses; 1771 List<IClause> clauses;
1253 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) 1772 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1254 throw new UndefinedPredicateException 1773 throw new PrologException
1255 ("Undefined fact: " + name + "/" + arguments.Length, name, 1774 (new Functor2
1256 arguments.Length); 1775 (Atom.a("existence_error"), Atom.a("procedure"),
1776 new Functor2(Atom.SLASH, name, arguments.Length)),
1777 "Undefined predicate: " + name + "/" + arguments.Length);
1257 1778
1258 if (clauses.Count == 1) 1779 if (clauses.Count == 1)
1259 // Usually there is only one clause, so return it without needing to wrap it in an iterator. 1780 // Usually there is only one clause, so return it without needing to wrap it in an iterator.
@@ -1271,7 +1792,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1271 /// <returns></returns> 1792 /// <returns></returns>
1272 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) 1793 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments)
1273 { 1794 {
1274 // Debug: If the clause asserts another clause into this same predicate, the iterator 1795 // Debug: If the caller asserts another clause into this same predicate during yield, the iterator
1275 // over clauses will be corrupted. Should we take the time to copy clauses? 1796 // over clauses will be corrupted. Should we take the time to copy clauses?
1276 foreach (IClause clause in clauses) 1797 foreach (IClause clause in clauses)
1277 { 1798 {
@@ -1297,16 +1818,122 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1297 return matchDynamic(name, arguments); 1818 return matchDynamic(name, arguments);
1298 } 1819 }
1299 1820
1821 public static IEnumerable<bool> clause(object Head, object Body)
1822 {
1823 Head = getValue(Head);
1824 Body = getValue(Body);
1825 if (Head is Variable)
1826 throw new PrologException("instantiation_error", "Head is an unbound variable");
1827
1828 Atom name = getFunctorName(Head) as Atom;
1829 if (name == null)
1830 // name is a non-Atom, such as a number.
1831 throw new PrologException
1832 (new Functor2("type_error", Atom.a("callable"), Head), "Head is not callable");
1833 object[] args = getFunctorArgs(Head);
1834 if (isSystemPredicate(name, args.Length))
1835 throw new PrologException
1836 (new Functor3("permission_error", Atom.a("access"), Atom.a("private_procedure"),
1837 new Functor2(Atom.SLASH, name, args.Length)),
1838 "clause cannot access private predicate " + name + "/" + args.Length);
1839 if (!(Body is Variable) && !(YP.getFunctorName(Body) is Atom))
1840 throw new PrologException
1841 (new Functor2("type_error", Atom.a("callable"), Body), "Body is not callable");
1842
1843 List<IClause> clauses;
1844 if (!_predicatesStore.TryGetValue(new NameArity(name, args.Length), out clauses))
1845 yield break;
1846 // The caller can assert another clause into this same predicate during yield, so we have to
1847 // make a copy of the clauses.
1848 foreach (IClause predicateClause in clauses.ToArray())
1849 {
1850 foreach (bool l1 in predicateClause.clause(Head, Body))
1851 yield return false;
1852 }
1853 }
1854
1855 public static IEnumerable<bool> retract(object Term)
1856 {
1857 Term = getValue(Term);
1858 if (Term is Variable)
1859 throw new PrologException("instantiation_error", "Term to retract is an unbound variable");
1860
1861 object Head, Body;
1862 if (Term is Functor2 && ((Functor2)Term)._name == Atom.RULE)
1863 {
1864 Head = YP.getValue(((Functor2)Term)._arg1);
1865 Body = YP.getValue(((Functor2)Term)._arg2);
1866 }
1867 else
1868 {
1869 Head = Term;
1870 Body = Atom.a("true");
1871 }
1872 if (Head is Variable)
1873 throw new PrologException("instantiation_error", "Head is an unbound variable");
1874
1875 Atom name = getFunctorName(Head) as Atom;
1876 if (name == null)
1877 // name is a non-Atom, such as a number.
1878 throw new PrologException
1879 (new Functor2("type_error", Atom.a("callable"), Head), "Head is not callable");
1880 object[] args = getFunctorArgs(Head);
1881 if (isSystemPredicate(name, args.Length))
1882 throw new PrologException
1883 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"),
1884 new Functor2(Atom.SLASH, name, args.Length)),
1885 "clause cannot access private predicate " + name + "/" + args.Length);
1886 if (!(Body is Variable) && !(YP.getFunctorName(Body) is Atom))
1887 throw new PrologException
1888 (new Functor2("type_error", Atom.a("callable"), Body), "Body is not callable");
1889
1890 List<IClause> clauses;
1891 if (!_predicatesStore.TryGetValue(new NameArity(name, args.Length), out clauses))
1892 yield break;
1893 // The caller can assert another clause into this same predicate during yield, so we have to
1894 // make a copy of the clauses.
1895 foreach (IClause predicateClause in clauses.ToArray())
1896 {
1897 if (predicateClause is IndexedAnswers)
1898 {
1899 // IndexedAnswers handles its own retract. Even if it removes all of its
1900 // answers, it is OK to leave it empty as one of the elements in clauses.
1901 foreach (bool l1 in ((IndexedAnswers)predicateClause).retract(Head, Body))
1902 yield return false;
1903 }
1904 else
1905 {
1906 foreach (bool l1 in predicateClause.clause(Head, Body))
1907 {
1908 clauses.Remove(predicateClause);
1909 yield return false;
1910 }
1911 }
1912 }
1913 }
1914
1300 /// <summary> 1915 /// <summary>
1301 /// This actually searches all clauses, not just 1916 /// This is deprecated for backward compatibility. You should use retractall.
1302 /// the ones defined with assertFact, but we keep the name for
1303 /// backwards compatibility.
1304 /// </summary> 1917 /// </summary>
1305 /// <param name="name">must be an Atom</param> 1918 /// <param name="name">must be an Atom</param>
1306 /// <param name="arguments">an array of arity number of arguments</param> 1919 /// <param name="arguments">an array of arity number of arguments</param>
1307 public static void retractFact(Atom name, object[] arguments) 1920 public static void retractFact(Atom name, object[] arguments)
1308 { 1921 {
1309 NameArity nameArity = new NameArity(name, arguments.Length); 1922 retractall(Functor.make(name, arguments));
1923 }
1924
1925 /// <summary>
1926 /// Retract all dynamic clauses which unify with Head. If this matches all clauses in a predicate,
1927 /// the predicate is still defined. To completely remove the predicate, see abolish.
1928 /// </summary>
1929 /// <param name="Head"></param>
1930 public static void retractall(object Head)
1931 {
1932 object name = YP.getFunctorName(Head);
1933 object[] arguments = getFunctorArgs(Head);
1934 if (!(name is Atom))
1935 return;
1936 NameArity nameArity = new NameArity((Atom)name, arguments.Length);
1310 List<IClause> clauses; 1937 List<IClause> clauses;
1311 if (!_predicatesStore.TryGetValue(nameArity, out clauses)) 1938 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1312 // Can't find, so ignore. 1939 // Can't find, so ignore.
@@ -1315,11 +1942,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1315 foreach (object arg in arguments) 1942 foreach (object arg in arguments)
1316 { 1943 {
1317 if (!YP.var(arg)) 1944 if (!YP.var(arg))
1318 throw new InvalidOperationException("All arguments must be unbound"); 1945 throw new InvalidOperationException
1946 ("Until matching retractall is supported, all arguments must be unbound to retract all clauses");
1319 } 1947 }
1320 // Set to a fresh empty IndexedAnswers. 1948 // Clear all clauses.
1321 _predicatesStore[nameArity] = (clauses = new List<IClause>()); 1949 _predicatesStore[nameArity] = new List<IClause>();
1322 clauses.Add(new IndexedAnswers());
1323 } 1950 }
1324 1951
1325 public static IEnumerable<bool> current_predicate(object NameSlashArity) 1952 public static IEnumerable<bool> current_predicate(object NameSlashArity)
@@ -1328,57 +1955,99 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1328 // First check if Name and Arity are nonvar so we can do a direct lookup. 1955 // First check if Name and Arity are nonvar so we can do a direct lookup.
1329 if (YP.ground(NameSlashArity)) 1956 if (YP.ground(NameSlashArity))
1330 { 1957 {
1331 if (NameSlashArity is Functor2) 1958 Functor2 NameArityFunctor = NameSlashArity as Functor2;
1959 if (!(NameArityFunctor != null && NameArityFunctor._name == Atom.SLASH))
1960 throw new PrologException
1961 (new Functor2("type_error", Atom.a("predicate_indicator"), NameSlashArity),
1962 "Must be a name/arity predicate indicator");
1963 object name = YP.getValue(NameArityFunctor._arg1);
1964 object arity = YP.getValue(NameArityFunctor._arg2);
1965 if (name is Variable || arity is Variable)
1966 throw new PrologException
1967 ("instantiation_error", "Predicate indicator name or arity is an unbound variable");
1968 if (!(name is Atom && arity is int))
1969 throw new PrologException
1970 (new Functor2("type_error", Atom.a("predicate_indicator"), NameSlashArity),
1971 "Must be a name/arity predicate indicator");
1972 if ((int)arity < 0)
1973 throw new PrologException
1974 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
1975 "Arity may not be less than zero");
1976
1977 if (_predicatesStore.ContainsKey(new NameArity((Atom)name, (int)arity)))
1978 // The predicate is defined.
1979 yield return false;
1980 }
1981 else
1982 {
1983 foreach (NameArity key in _predicatesStore.Keys)
1332 { 1984 {
1333 Functor2 NameArityFunctor = (Functor2)NameSlashArity; 1985 foreach (bool l1 in YP.unify
1334 if (NameArityFunctor._name == Atom.SLASH) 1986 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity))
1335 { 1987 yield return false;
1336 if (_predicatesStore.ContainsKey(new NameArity
1337 ((Atom)YP.getValue(NameArityFunctor._arg1),
1338 (int)YP.getValue(NameArityFunctor._arg2))))
1339 // The predicate is defined.
1340 yield return false;
1341 }
1342 } 1988 }
1343 yield break;
1344 } 1989 }
1990 }
1345 1991
1346 foreach (NameArity key in _predicatesStore.Keys) 1992 public static void abolish(object NameSlashArity)
1347 { 1993 {
1348 foreach (bool l1 in YP.unify 1994 NameSlashArity = YP.getValue(NameSlashArity);
1349 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity)) 1995 if (NameSlashArity is Variable)
1350 yield return false; 1996 throw new PrologException
1351 } 1997 ("instantiation_error", "Predicate indicator is an unbound variable");
1998 Functor2 NameArityFunctor = NameSlashArity as Functor2;
1999 if (!(NameArityFunctor != null && NameArityFunctor._name == Atom.SLASH))
2000 throw new PrologException
2001 (new Functor2("type_error", Atom.a("predicate_indicator"), NameSlashArity),
2002 "Must be a name/arity predicate indicator");
2003 object name = YP.getValue(NameArityFunctor._arg1);
2004 object arity = YP.getValue(NameArityFunctor._arg2);
2005 if (name is Variable || arity is Variable)
2006 throw new PrologException
2007 ("instantiation_error", "Predicate indicator name or arity is an unbound variable");
2008 if (!(name is Atom))
2009 throw new PrologException
2010 (new Functor2("type_error", Atom.a("atom"), name),
2011 "Predicate indicator name must be an atom");
2012 if (!(arity is int))
2013 throw new PrologException
2014 (new Functor2("type_error", Atom.a("integer"), arity),
2015 "Predicate indicator arity must be an integer");
2016 if ((int)arity < 0)
2017 throw new PrologException
2018 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
2019 "Arity may not be less than zero");
2020
2021 if (isSystemPredicate((Atom)name, (int)arity))
2022 throw new PrologException
2023 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"),
2024 new Functor2(Atom.SLASH, name, arity)),
2025 "Abolish cannot modify static predicate " + name + "/" + arity);
2026 _predicatesStore.Remove(new NameArity((Atom)name, (int)arity));
1352 } 2027 }
1353 2028
1354 /// <summary> 2029 /// <summary>
1355 /// Use YP.getFunctorName(Goal) and invoke the static method of this name in the 2030 /// If Goal is a simple predicate, call YP.getFunctorName(Goal) using arguments from
1356 /// declaringClass, using arguments from YP.getFunctorArgs(Goal). 2031 /// YP.getFunctorArgs(Goal). If not found, this throws a PrologException for existence_error.
1357 /// Note that Goal must be a simple functor, not a complex expression. 2032 /// Otherwise, compile the goal as a single clause predicate and invoke it.
1358 /// If not found, this throws UndefinedPredicateException.
1359 /// </summary> 2033 /// </summary>
1360 /// <param name="Goal"></param> 2034 /// <param name="Goal"></param>
1361 /// <param name="contextClass">the class for looking up default function references</param> 2035 /// <param name="declaringClass">if not null, used to resolve references to the default
2036 /// module Atom.a("")</param>
1362 /// <returns></returns> 2037 /// <returns></returns>
1363 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) 2038 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass)
1364 { 2039 {
1365 Goal = YP.getValue(Goal);
1366 if (Goal is Variable)
1367 throw new PrologException("instantiation_error", "Goal to call is an unbound variable");
1368#if true
1369 List<Variable> variableSetList = new List<Variable>();
1370 addUniqueVariables(Goal, variableSetList);
1371 Variable[] variableSet = variableSetList.ToArray();
1372
1373 // Use Atom.F since it is ignored.
1374 return YPCompiler.compileAnonymousClause
1375 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1376#else
1377 Atom name; 2040 Atom name;
1378 object[] args; 2041 object[] args;
1379 while (true) 2042 while (true)
1380 { 2043 {
1381 name = (Atom)YP.getFunctorName(Goal); 2044 Goal = YP.getValue(Goal);
2045 if (Goal is Variable)
2046 throw new PrologException("instantiation_error", "Goal to call is an unbound variable");
2047 name = YP.getFunctorName(Goal) as Atom;
2048 if (name == null)
2049 throw new PrologException
2050 (new Functor2("type_error", Atom.a("callable"), Goal), "Goal to call is not callable");
1382 args = YP.getFunctorArgs(Goal); 2051 args = YP.getFunctorArgs(Goal);
1383 if (name == Atom.HAT && args.Length == 2) 2052 if (name == Atom.HAT && args.Length == 2)
1384 // Assume this is called from a bagof operation. Skip the leading qualifiers. 2053 // Assume this is called from a bagof operation. Skip the leading qualifiers.
@@ -1386,22 +2055,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1386 else 2055 else
1387 break; 2056 break;
1388 } 2057 }
1389 try 2058
1390 { 2059 IEnumerable<bool> simpleIterator = YPCompiler.getSimpleIterator(name, args, declaringClass);
1391 return (IEnumerable<bool>)declaringClass.InvokeMember 2060 if (simpleIterator != null)
1392 (name._name, BindingFlags.InvokeMethod, null, null, args); 2061 // We don't need to compile since the goal is a simple predicate which we call directly.
1393 } 2062 return simpleIterator;
1394 catch (TargetInvocationException exception) 2063
1395 { 2064 // Compile the goal as a clause.
1396 throw exception.InnerException; 2065 List<Variable> variableSetList = new List<Variable>();
1397 } 2066 addUniqueVariables(Goal, variableSetList);
1398 catch (MissingMethodException) 2067 Variable[] variableSet = variableSetList.ToArray();
1399 { 2068
1400 throw new UndefinedPredicateException 2069 // Use Atom.F since it is ignored.
1401 ("Cannot find predicate function: " + name + "/" + args.Length + " in " + 2070 return YPCompiler.compileAnonymousClause
1402 declaringClass.FullName, name, args.Length); 2071 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1403 }
1404#endif
1405 } 2072 }
1406 2073
1407 public static void throwException(object Term) 2074 public static void throwException(object Term)
@@ -1415,12 +2082,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1415 /// <param name="script_event"></param> 2082 /// <param name="script_event"></param>
1416 /// <param name="script_params"></param> 2083 /// <param name="script_params"></param>
1417 /// <returns></returns> 2084 /// <returns></returns>
1418 public static void script_event(object script_event, object script_params) 2085 public static IEnumerable<bool> script_event(object script_event, object script_params)
1419 { 2086 {
1420 // string function = ((Atom)YP.getValue(script_event))._name; 2087 // string function = ((Atom)YP.getValue(script_event))._name;
1421 object[] array = ListPair.toArray(script_params); 2088 object[] array = ListPair.toArray(script_params);
1422 if (array == null) 2089 if (array == null)
1423 return; // YP.fail(); 2090 yield return false; // return; // YP.fail();
1424 if (array.Length > 1) 2091 if (array.Length > 1)
1425 { 2092 {
1426 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue 2093 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue
@@ -1428,8 +2095,76 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1428 // sortArray(array); 2095 // sortArray(array);
1429 } 2096 }
1430 //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); 2097 //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
2098 yield return false;
2099 }
2100
2101 /* Non-prolog-ish functions for inline coding */
2102 public static string regexString(string inData, string inPattern, string presep,string postsep)
2103 {
2104 //string str=cycMessage;
2105 //string strMatch = @"\. \#\$(.*)\)";
2106 string results = "";
2107 for (Match m = Regex.Match(inData,inPattern); m.Success; m=m.NextMatch())
2108 {
2109 //Console.WriteLine( m );
2110 results += presep+ m + postsep;
2111 }
2112 return results;
1431 } 2113 }
1432 2114
2115 public static string cycComm(object msgobj)
2116 {
2117 string cycInputString = msgobj.ToString();
2118 string cycOutputString="";
2119 TcpClient socketForServer;
2120
2121 try
2122 {
2123 socketForServer = new TcpClient("localHost", 3601);
2124 }
2125 catch
2126 {
2127 Console.WriteLine("Failed to connect to server at {0}:999", "localhost");
2128 return "";
2129 }
2130
2131 NetworkStream networkStream = socketForServer.GetStream();
2132
2133 System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
2134
2135 System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);
2136
2137 try
2138 {
2139 // read the data from the host and display it
2140
2141 {
2142
2143 streamWriter.WriteLine(cycInputString);
2144 streamWriter.Flush();
2145
2146 cycOutputString = streamReader.ReadLine();
2147 Console.WriteLine("Cycoutput:" + cycOutputString);
2148 //streamWriter.WriteLine("Client Message");
2149 //Console.WriteLine("Client Message");
2150 streamWriter.Flush();
2151 }
2152
2153 }
2154 catch
2155 {
2156 Console.WriteLine("Exception reading from Server");
2157 return "";
2158 }
2159 // tidy up
2160 networkStream.Close();
2161 return cycOutputString;
2162
2163 }
2164 //public static void throwException(object Term)
2165 //{
2166 // throw new PrologException(Term);
2167 //}
1433 /// <summary> 2168 /// <summary>
1434 /// An enumerator that does zero loops. 2169 /// An enumerator that does zero loops.
1435 /// </summary> 2170 /// </summary>
@@ -1644,5 +2379,32 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1644 } 2379 }
1645 } 2380 }
1646 #pragma warning restore 0168 2381 #pragma warning restore 0168
2382 /// <summary>
2383 /// A ClauseHeadAndBody is used in Compiler.compileAnonymousFunction as a base class
2384 /// in order to implement YP.IClause. After creating the object, you must call setHeadAndBody.
2385 /// </summary>
2386 public class ClauseHeadAndBody
2387 {
2388 private object _Head;
2389 private object _Body;
2390
2391 public void setHeadAndBody(object Head, object Body)
2392 {
2393 _Head = Head;
2394 _Body = Body;
2395 }
2396
2397 public IEnumerable<bool> clause(object Head, object Body)
2398 {
2399 if (_Head == null || _Body == null)
2400 yield break;
2401
2402 foreach (bool l1 in YP.unify(Head, _Head))
2403 {
2404 foreach (bool l2 in YP.unify(Body, _Body))
2405 yield return false;
2406 }
2407 }
2408 }
1647 } 2409 }
1648} 2410}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
index 8a22388..93b5a1b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
@@ -1,20 +1,20 @@
1/* 1/*
2 * Copyright (C) 2007-2008, Jeff Thompson 2 * Copyright (C) 2007-2008, Jeff Thompson
3 * 3 *
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright 11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors 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 15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission. 16 * without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -34,6 +34,7 @@ using System.Collections;
34using System.Collections.Generic; 34using System.Collections.Generic;
35using System.Text; 35using System.Text;
36using System.CodeDom.Compiler; 36using System.CodeDom.Compiler;
37using System.Reflection;
37 38
38namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog 39namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
39{ 40{
@@ -41,7 +42,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
41 { 42 {
42 private class CompilerState 43 private class CompilerState
43 { 44 {
44 public IndexedAnswers _pred = new IndexedAnswers(); 45 public IndexedAnswers _pred = new IndexedAnswers(4);
45 public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>(); 46 public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>();
46 public int _gensymCounter; 47 public int _gensymCounter;
47 public bool _useFinalCutCode; 48 public bool _useFinalCutCode;
@@ -81,11 +82,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
81 Module = YP.getValue(Module); 82 Module = YP.getValue(Module);
82 // If the Module Atom comes from the parser, it always has null _declaringClass. 83 // 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 if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int)
84 {
85 // Replace a previous entry if it exists. 85 // Replace a previous entry if it exists.
86 ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] = 86 ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] =
87 (Atom)Module; 87 (Atom)Module;
88 }
89 } 88 }
90 89
91 public static void startFunction(object State, object Head) 90 public static void startFunction(object State, object Head)
@@ -204,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
204 203
205 // disable warning on l1, don't see how we can 204 // disable warning on l1, don't see how we can
206 // code this differently 205 // code this differently
207 #pragma warning disable 0168 206 #pragma warning disable 0168,0164,0162
208 public static bool isDetNoneOut(object State, object Term) 207 public static bool isDetNoneOut(object State, object Term)
209 { 208 {
210 State = YP.getValue(State); 209 State = YP.getValue(State);
@@ -242,7 +241,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
242 241
243 return false; 242 return false;
244 } 243 }
245 #pragma warning restore 0168 244 #pragma warning restore 0168,0164,0162
246 245
247 /// <summary> 246 /// <summary>
248 /// Return false if any of args is out, otherwise true. 247 /// Return false if any of args is out, otherwise true.
@@ -281,7 +280,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
281 280
282 // disable warning on l1, don't see how we can 281 // disable warning on l1, don't see how we can
283 // code this differently 282 // code this differently
284 #pragma warning disable 0168, 0219 283 #pragma warning disable 0168, 0219,0164,0162
285 284
286 /// <summary> 285 /// <summary>
287 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction 286 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
@@ -313,15 +312,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
313 try 312 try
314 { 313 {
315 YP.tell(functionCode); 314 YP.tell(functionCode);
316 Variable FunctionCode = new Variable(); 315 Variable PseudoCode = new Variable();
317 foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode)) 316 foreach (bool l2 in makeFunctionPseudoCode(RuleList, PseudoCode))
318 { 317 {
319 if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) 318 if (YP.termEqual(PseudoCode, Atom.a("getDeclaringClass")))
320 // Ignore getDeclaringClass since we have access to the one passed in. 319 // Ignore getDeclaringClass since we have access to the one passed in.
321 continue; 320 continue;
322 321
323 // Debug: should check if FunctionCode is a single call. 322 convertFunctionCSharp(PseudoCode);
324 convertFunctionCSharp(FunctionCode);
325 } 323 }
326 YP.told(); 324 YP.told();
327 } 325 }
@@ -336,7 +334,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
336 } 334 }
337 335
338 /// <summary> 336 /// <summary>
339 /// Use CodeDomProvider to compile the functionCode and return a YP.IClause. 337 /// Use CodeDomProvider to compile the functionCode and return a YP.ClauseHeadAndBody
338 /// which implements YP.IClause.
340 /// The function name must be "function" and have nArgs arguments. 339 /// The function name must be "function" and have nArgs arguments.
341 /// </summary> 340 /// </summary>
342 /// <param name="functionCode">the code for the iterator, such as 341 /// <param name="functionCode">the code for the iterator, such as
@@ -366,8 +365,16 @@ using System.Collections.Generic;
366using YieldProlog; 365using YieldProlog;
367 366
368namespace Temporary { 367namespace Temporary {
369 public class Temporary : YP.IClause { 368 public class Temporary : YP.ClauseHeadAndBody, YP.IClause {");
370 public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" { 369 if (declaringClass == null)
370 // We don't extend a class with getDeclaringClass, so define it.
371 sourceCode.Append(@"
372 public class Inner {
373 public static System.Type getDeclaringClass() { return null; }
374");
375 else
376 sourceCode.Append(@"
377 public class Inner : " + declaringClass.FullName + @" {
371"); 378");
372 sourceCode.Append(functionCode); 379 sourceCode.Append(functionCode);
373 // Basically, match applies the args to function. 380 // Basically, match applies the args to function.
@@ -395,6 +402,102 @@ namespace Temporary {
395 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null); 402 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
396 } 403 }
397 404
405 /// <summary>
406 /// If the functor with name and args can be called directly as determined by
407 /// functorCallFunctionName, then call it and return its iterator. If the predicate is
408 /// dynamic and undefined, or if static and the method cannot be found, throw
409 /// a PrologException for existence_error.
410 /// This returns null if the functor has a special form than needs to be compiled
411 /// (including ,/2 and ;/2).
412 /// </summary>
413 /// <param name="name"></param>
414 /// <param name="args"></param>
415 /// <param name="declaringClass">used to resolve references to the default
416 /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
417 /// null, this throws a PrologException for existence_error</param>
418 /// <returns></returns>
419 public static IEnumerable<bool> getSimpleIterator(Atom name, object[] args, Type declaringClass)
420 {
421 CompilerState state = new CompilerState();
422 Variable FunctionName = new Variable();
423 foreach (bool l1 in functorCallFunctionName(state, name, args.Length, FunctionName))
424 {
425 Atom functionNameAtom = ((Atom)FunctionName.getValue());
426 if (functionNameAtom == Atom.NIL)
427 {
428 // name is for a dynamic predicate.
429 return YP.matchDynamic(name, args);
430 }
431
432 // Set the default for the method to call.
433 string methodName = functionNameAtom._name;
434 Type methodClass = declaringClass;
435
436 bool checkMode = false;
437 if (methodName.StartsWith("YP."))
438 {
439 // Assume we only check mode in calls to standard Prolog predicates in YP.
440 checkMode = true;
441
442 // Use the method in class YP.
443 methodName = methodName.Substring(3);
444 methodClass = typeof(YP);
445 }
446 if (methodName.Contains("."))
447 // We don't support calling inner classes, etc.
448 return null;
449
450 if (methodClass == null)
451 throw new PrologException
452 (new Functor2
453 (Atom.a("existence_error"), Atom.a("procedure"),
454 new Functor2(Atom.a("/"), name, args.Length)),
455 "Cannot find predicate function for: " + name + "/" + args.Length +
456 " because declaringClass is null. Set declaringClass to the class containing " +
457 methodName);
458 try
459 {
460 if (checkMode)
461 {
462 assertYPPred(state);
463 object functor = Functor.make(name, args);
464 if (CompilerState.isDetNoneOut(state, functor))
465 {
466 methodClass.InvokeMember
467 (methodName, BindingFlags.InvokeMethod, null, null, args);
468 return YP.succeed();
469 }
470 if (CompilerState.isSemidetNoneOut(state, functor))
471 {
472 if ((bool)methodClass.InvokeMember
473 (methodName, BindingFlags.InvokeMethod, null, null, args))
474 return YP.succeed();
475 else
476 return YP.fail();
477 }
478
479 }
480 return (IEnumerable<bool>)methodClass.InvokeMember
481 (methodName, BindingFlags.InvokeMethod, null, null, args);
482 }
483 catch (TargetInvocationException exception)
484 {
485 throw exception.InnerException;
486 }
487 catch (MissingMethodException)
488 {
489 throw new PrologException
490 (new Functor2
491 (Atom.a("existence_error"), Atom.a("procedure"),
492 new Functor2(Atom.a("/"), name, args.Length)),
493 "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length +
494 " in " + methodClass.FullName);
495 }
496 }
497
498 return null;
499 }
500
398 // Compiler output follows. 501 // Compiler output follows.
399 502
400 public class YPInnerClass { } 503 public class YPInnerClass { }
@@ -403,7 +506,7 @@ namespace Temporary {
403 public static void repeatWrite(object arg1, object N) 506 public static void repeatWrite(object arg1, object N)
404 { 507 {
405 { 508 {
406 // object _Value = arg1; 509 object _Value = arg1;
407 if (YP.termEqual(N, 0)) 510 if (YP.termEqual(N, 0))
408 { 511 {
409 return; 512 return;
@@ -444,26 +547,9 @@ namespace Temporary {
444 Variable State = new Variable(); 547 Variable State = new Variable();
445 foreach (bool l2 in CompilerState.make(State)) 548 foreach (bool l2 in CompilerState.make(State))
446 { 549 {
447 CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det")); 550 assertYPPred(State);
448 CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
449 CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
450 CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
451 CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
452 CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
453 CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
454 CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
455 CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
456 CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
457 CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
458 CompilerState.assertPred(State, new Functor1(@"compound", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
459 CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
460 CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
461 CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
462 CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
463 CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
464 CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
465 processCompilerDirectives(RuleList, State); 551 processCompilerDirectives(RuleList, State);
466 foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass"))) 552 foreach (bool l3 in YP.unify(FunctionCode, Atom.a("getDeclaringClass")))
467 { 553 {
468 yield return false; 554 yield return false;
469 } 555 }
@@ -475,10 +561,37 @@ namespace Temporary {
475 } 561 }
476 } 562 }
477 563
564 public static void assertYPPred(object State)
565 {
566 {
567 CompilerState.assertPred(State, Atom.a("nl"), Atom.a("det"));
568 CompilerState.assertPred(State, new Functor1("write", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
569 CompilerState.assertPred(State, new Functor1("put_code", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
570 CompilerState.assertPred(State, new Functor1("throw", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
571 CompilerState.assertPred(State, new Functor1("abolish", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
572 CompilerState.assertPred(State, new Functor1("retractall", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
573 CompilerState.assertPred(State, new Functor1("var", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
574 CompilerState.assertPred(State, new Functor1("nonvar", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
575 CompilerState.assertPred(State, new Functor1("atom", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
576 CompilerState.assertPred(State, new Functor1("integer", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
577 CompilerState.assertPred(State, new Functor1("float", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
578 CompilerState.assertPred(State, new Functor1("number", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
579 CompilerState.assertPred(State, new Functor1("atomic", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
580 CompilerState.assertPred(State, new Functor1("compound", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
581 CompilerState.assertPred(State, new Functor2("==", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
582 CompilerState.assertPred(State, new Functor2("\\==", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
583 CompilerState.assertPred(State, new Functor2("@<", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
584 CompilerState.assertPred(State, new Functor2("@=<", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
585 CompilerState.assertPred(State, new Functor2("@>", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
586 CompilerState.assertPred(State, new Functor2("@>=", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
587 return;
588 }
589 }
590
478 public static void processCompilerDirectives(object arg1, object arg2) 591 public static void processCompilerDirectives(object arg1, object arg2)
479 { 592 {
480 { 593 {
481 // object _State = arg2; 594 object _State = arg2;
482 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 595 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
483 { 596 {
484 return; 597 return;
@@ -490,7 +603,7 @@ namespace Temporary {
490 Variable Determinism = new Variable(); 603 Variable Determinism = new Variable();
491 Variable x3 = new Variable(); 604 Variable x3 = new Variable();
492 Variable RestRules = new Variable(); 605 Variable RestRules = new Variable();
493 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules))) 606 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", new Functor1("pred", new Functor2("is", Pred, Determinism))), x3), RestRules)))
494 { 607 {
495 CompilerState.assertPred(State, Pred, Determinism); 608 CompilerState.assertPred(State, Pred, Determinism);
496 processCompilerDirectives(RestRules, State); 609 processCompilerDirectives(RestRules, State);
@@ -503,7 +616,7 @@ namespace Temporary {
503 Variable PredicateList = new Variable(); 616 Variable PredicateList = new Variable();
504 Variable x3 = new Variable(); 617 Variable x3 = new Variable();
505 Variable RestRules = new Variable(); 618 Variable RestRules = new Variable();
506 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules))) 619 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", new Functor2("import", Module, PredicateList)), x3), RestRules)))
507 { 620 {
508 foreach (bool l3 in importPredicateList(State, Module, PredicateList)) 621 foreach (bool l3 in importPredicateList(State, Module, PredicateList))
509 { 622 {
@@ -517,7 +630,7 @@ namespace Temporary {
517 Variable x1 = new Variable(); 630 Variable x1 = new Variable();
518 Variable x2 = new Variable(); 631 Variable x2 = new Variable();
519 Variable RestRules = new Variable(); 632 Variable RestRules = new Variable();
520 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules))) 633 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", x1), x2), RestRules)))
521 { 634 {
522 processCompilerDirectives(RestRules, State); 635 processCompilerDirectives(RestRules, State);
523 return; 636 return;
@@ -531,11 +644,11 @@ namespace Temporary {
531 Variable RestRules = new Variable(); 644 Variable RestRules = new Variable();
532 Variable Name = new Variable(); 645 Variable Name = new Variable();
533 Variable Arity = new Variable(); 646 Variable Arity = new Variable();
534 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules))) 647 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor2(":-", Head, _Body), x3), RestRules)))
535 { 648 {
536 foreach (bool l3 in YP.functor(Head, Name, Arity)) 649 foreach (bool l3 in YP.functor(Head, Name, Arity))
537 { 650 {
538 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); 651 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
539 processCompilerDirectives(RestRules, State); 652 processCompilerDirectives(RestRules, State);
540 return; 653 return;
541 } 654 }
@@ -548,11 +661,11 @@ namespace Temporary {
548 Variable RestRules = new Variable(); 661 Variable RestRules = new Variable();
549 Variable Name = new Variable(); 662 Variable Name = new Variable();
550 Variable Arity = new Variable(); 663 Variable Arity = new Variable();
551 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules))) 664 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", Fact, x2), RestRules)))
552 { 665 {
553 foreach (bool l3 in YP.functor(Fact, Name, Arity)) 666 foreach (bool l3 in YP.functor(Fact, Name, Arity))
554 { 667 {
555 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); 668 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
556 processCompilerDirectives(RestRules, State); 669 processCompilerDirectives(RestRules, State);
557 return; 670 return;
558 } 671 }
@@ -587,7 +700,7 @@ namespace Temporary {
587 Variable Name = new Variable(); 700 Variable Name = new Variable();
588 Variable Arity = new Variable(); 701 Variable Arity = new Variable();
589 Variable Rest = new Variable(); 702 Variable Rest = new Variable();
590 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest))) 703 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2("/", Name, Arity), Rest)))
591 { 704 {
592 CompilerState.assertModuleForNameArity(State, Name, Arity, Module); 705 CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
593 foreach (bool l3 in importPredicateList(State, Module, Rest)) 706 foreach (bool l3 in importPredicateList(State, Module, Rest))
@@ -659,17 +772,17 @@ namespace Temporary {
659 Variable BodyCode = new Variable(); 772 Variable BodyCode = new Variable();
660 Variable ReturnType = new Variable(); 773 Variable ReturnType = new Variable();
661 Variable BodyWithReturn = new Variable(); 774 Variable BodyWithReturn = new Variable();
662 foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList)) 775 foreach (bool l2 in YP.unify(new ListPair(new Functor2("f", FirstRule, x5), x6), SamePredicateRuleList))
663 { 776 {
664 foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7))) 777 foreach (bool l3 in YP.unify(FirstRule, new Functor1(":-", x7)))
665 { 778 {
666 goto cutIf1; 779 goto cutIf1;
667 } 780 }
668 foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule)) 781 foreach (bool l3 in YP.unify(new Functor2(":-", Head, x9), FirstRule))
669 { 782 {
670 CompilerState.startFunction(State, Head); 783 CompilerState.startFunction(State, Head);
671 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); 784 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
672 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) 785 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
673 { 786 {
674 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) 787 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
675 { 788 {
@@ -703,26 +816,26 @@ namespace Temporary {
703 { 816 {
704 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) 817 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
705 { 818 {
706 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 819 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
707 { 820 {
708 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) 821 foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
709 { 822 {
710 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 823 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
711 { 824 {
712 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 825 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
713 { 826 {
714 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 827 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
715 { 828 {
716 yield return false; 829 yield return false;
717 } 830 }
718 } 831 }
719 goto cutIf7; 832 goto cutIf7;
720 } 833 }
721 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 834 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
722 { 835 {
723 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 836 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
724 { 837 {
725 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 838 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
726 { 839 {
727 yield return false; 840 yield return false;
728 } 841 }
@@ -733,16 +846,16 @@ namespace Temporary {
733 { 846 {
734 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 847 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
735 { 848 {
736 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 849 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
737 { 850 {
738 yield return false; 851 yield return false;
739 } 852 }
740 } 853 }
741 goto cutIf9; 854 goto cutIf9;
742 } 855 }
743 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 856 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
744 { 857 {
745 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 858 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
746 { 859 {
747 yield return false; 860 yield return false;
748 } 861 }
@@ -754,26 +867,26 @@ namespace Temporary {
754 } 867 }
755 goto cutIf6; 868 goto cutIf6;
756 } 869 }
757 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 870 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
758 { 871 {
759 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) 872 foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
760 { 873 {
761 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 874 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
762 { 875 {
763 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 876 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
764 { 877 {
765 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 878 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
766 { 879 {
767 yield return false; 880 yield return false;
768 } 881 }
769 } 882 }
770 goto cutIf11; 883 goto cutIf11;
771 } 884 }
772 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 885 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
773 { 886 {
774 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 887 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
775 { 888 {
776 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 889 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
777 { 890 {
778 yield return false; 891 yield return false;
779 } 892 }
@@ -784,16 +897,16 @@ namespace Temporary {
784 { 897 {
785 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 898 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
786 { 899 {
787 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 900 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
788 { 901 {
789 yield return false; 902 yield return false;
790 } 903 }
791 } 904 }
792 goto cutIf13; 905 goto cutIf13;
793 } 906 }
794 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 907 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
795 { 908 {
796 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 909 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
797 { 910 {
798 yield return false; 911 yield return false;
799 } 912 }
@@ -805,24 +918,24 @@ namespace Temporary {
805 } 918 }
806 goto cutIf10; 919 goto cutIf10;
807 } 920 }
808 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) 921 foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
809 { 922 {
810 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 923 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
811 { 924 {
812 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 925 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
813 { 926 {
814 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 927 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
815 { 928 {
816 yield return false; 929 yield return false;
817 } 930 }
818 } 931 }
819 goto cutIf14; 932 goto cutIf14;
820 } 933 }
821 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 934 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
822 { 935 {
823 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 936 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
824 { 937 {
825 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 938 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
826 { 939 {
827 yield return false; 940 yield return false;
828 } 941 }
@@ -833,16 +946,16 @@ namespace Temporary {
833 { 946 {
834 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 947 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
835 { 948 {
836 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 949 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
837 { 950 {
838 yield return false; 951 yield return false;
839 } 952 }
840 } 953 }
841 goto cutIf16; 954 goto cutIf16;
842 } 955 }
843 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 956 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
844 { 957 {
845 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 958 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
846 { 959 {
847 yield return false; 960 yield return false;
848 } 961 }
@@ -866,8 +979,8 @@ namespace Temporary {
866 foreach (bool l3 in YP.unify(Head, FirstRule)) 979 foreach (bool l3 in YP.unify(Head, FirstRule))
867 { 980 {
868 CompilerState.startFunction(State, Head); 981 CompilerState.startFunction(State, Head);
869 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); 982 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
870 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) 983 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
871 { 984 {
872 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) 985 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
873 { 986 {
@@ -901,26 +1014,26 @@ namespace Temporary {
901 { 1014 {
902 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) 1015 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
903 { 1016 {
904 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1017 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
905 { 1018 {
906 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) 1019 foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
907 { 1020 {
908 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1021 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
909 { 1022 {
910 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 1023 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
911 { 1024 {
912 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1025 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
913 { 1026 {
914 yield return false; 1027 yield return false;
915 } 1028 }
916 } 1029 }
917 goto cutIf21; 1030 goto cutIf21;
918 } 1031 }
919 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1032 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
920 { 1033 {
921 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1034 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
922 { 1035 {
923 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1036 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
924 { 1037 {
925 yield return false; 1038 yield return false;
926 } 1039 }
@@ -931,16 +1044,16 @@ namespace Temporary {
931 { 1044 {
932 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1045 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
933 { 1046 {
934 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1047 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
935 { 1048 {
936 yield return false; 1049 yield return false;
937 } 1050 }
938 } 1051 }
939 goto cutIf23; 1052 goto cutIf23;
940 } 1053 }
941 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 1054 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
942 { 1055 {
943 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1056 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
944 { 1057 {
945 yield return false; 1058 yield return false;
946 } 1059 }
@@ -952,26 +1065,26 @@ namespace Temporary {
952 } 1065 }
953 goto cutIf20; 1066 goto cutIf20;
954 } 1067 }
955 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1068 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
956 { 1069 {
957 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) 1070 foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
958 { 1071 {
959 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1072 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
960 { 1073 {
961 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 1074 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
962 { 1075 {
963 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1076 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
964 { 1077 {
965 yield return false; 1078 yield return false;
966 } 1079 }
967 } 1080 }
968 goto cutIf25; 1081 goto cutIf25;
969 } 1082 }
970 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1083 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
971 { 1084 {
972 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1085 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
973 { 1086 {
974 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1087 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
975 { 1088 {
976 yield return false; 1089 yield return false;
977 } 1090 }
@@ -982,16 +1095,16 @@ namespace Temporary {
982 { 1095 {
983 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1096 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
984 { 1097 {
985 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1098 foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
986 { 1099 {
987 yield return false; 1100 yield return false;
988 } 1101 }
989 } 1102 }
990 goto cutIf27; 1103 goto cutIf27;
991 } 1104 }
992 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 1105 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
993 { 1106 {
994 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1107 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
995 { 1108 {
996 yield return false; 1109 yield return false;
997 } 1110 }
@@ -1003,24 +1116,24 @@ namespace Temporary {
1003 } 1116 }
1004 goto cutIf24; 1117 goto cutIf24;
1005 } 1118 }
1006 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) 1119 foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
1007 { 1120 {
1008 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1121 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
1009 { 1122 {
1010 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) 1123 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
1011 { 1124 {
1012 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1125 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1013 { 1126 {
1014 yield return false; 1127 yield return false;
1015 } 1128 }
1016 } 1129 }
1017 goto cutIf28; 1130 goto cutIf28;
1018 } 1131 }
1019 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1132 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
1020 { 1133 {
1021 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 1134 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1022 { 1135 {
1023 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1136 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1024 { 1137 {
1025 yield return false; 1138 yield return false;
1026 } 1139 }
@@ -1031,16 +1144,16 @@ namespace Temporary {
1031 { 1144 {
1032 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 1145 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1033 { 1146 {
1034 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1147 foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1035 { 1148 {
1036 yield return false; 1149 yield return false;
1037 } 1150 }
1038 } 1151 }
1039 goto cutIf30; 1152 goto cutIf30;
1040 } 1153 }
1041 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) 1154 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
1042 { 1155 {
1043 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) 1156 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1044 { 1157 {
1045 yield return false; 1158 yield return false;
1046 } 1159 }
@@ -1115,13 +1228,13 @@ namespace Temporary {
1115 Variable RestSamePredicates = new Variable(); 1228 Variable RestSamePredicates = new Variable();
1116 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 1229 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1117 { 1230 {
1118 foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First)) 1231 foreach (bool l3 in YP.unify(new Functor2("f", FirstRule, x6), First))
1119 { 1232 {
1120 foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest)) 1233 foreach (bool l4 in YP.unify(new ListPair(new Functor2("f", SecondRule, x8), x9), Rest))
1121 { 1234 {
1122 foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule)) 1235 foreach (bool l5 in YP.unify(new Functor2(":-", FirstHead, x11), FirstRule))
1123 { 1236 {
1124 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) 1237 foreach (bool l6 in YP.unify(new Functor2(":-", SecondHead, x13), SecondRule))
1125 { 1238 {
1126 foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) 1239 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1127 { 1240 {
@@ -1183,7 +1296,7 @@ namespace Temporary {
1183 } 1296 }
1184 foreach (bool l5 in YP.unify(FirstHead, FirstRule)) 1297 foreach (bool l5 in YP.unify(FirstHead, FirstRule))
1185 { 1298 {
1186 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) 1299 foreach (bool l6 in YP.unify(new Functor2(":-", SecondHead, x13), SecondRule))
1187 { 1300 {
1188 foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) 1301 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1189 { 1302 {
@@ -1271,9 +1384,9 @@ namespace Temporary {
1271 Variable Rest = new Variable(); 1384 Variable Rest = new Variable();
1272 Variable ClauseCode = new Variable(); 1385 Variable ClauseCode = new Variable();
1273 Variable RestResults = new Variable(); 1386 Variable RestResults = new Variable();
1274 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest))) 1387 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", ArgAssignments, Calls), Rest)))
1275 { 1388 {
1276 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults))) 1389 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1("blockScope", ClauseCode), RestResults)))
1277 { 1390 {
1278 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode)) 1391 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
1279 { 1392 {
@@ -1312,7 +1425,7 @@ namespace Temporary {
1312 Variable VariableName = new Variable(); 1425 Variable VariableName = new Variable();
1313 Variable ArgName = new Variable(); 1426 Variable ArgName = new Variable();
1314 Variable RestArgAssignments = new Variable(); 1427 Variable RestArgAssignments = new Variable();
1315 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments))) 1428 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", VariableName, ArgName), RestArgAssignments)))
1316 { 1429 {
1317 foreach (bool l3 in member(VariableName, MergedArgNames)) 1430 foreach (bool l3 in member(VariableName, MergedArgNames))
1318 { 1431 {
@@ -1323,7 +1436,7 @@ namespace Temporary {
1323 } 1436 }
1324 goto cutIf1; 1437 goto cutIf1;
1325 } 1438 }
1326 foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode)) 1439 foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3("declare", Atom.a("object"), VariableName, new Functor1("var", ArgName)), In), MergedArgNames, ClauseCode))
1327 { 1440 {
1328 yield return true; 1441 yield return true;
1329 yield break; 1442 yield break;
@@ -1352,9 +1465,9 @@ namespace Temporary {
1352 Variable ArgAssignments = new Variable(); 1465 Variable ArgAssignments = new Variable();
1353 Variable _Calls = new Variable(); 1466 Variable _Calls = new Variable();
1354 Variable RestClauseBag = new Variable(); 1467 Variable RestClauseBag = new Variable();
1355 foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag))) 1468 foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2("f", ArgAssignments, _Calls), RestClauseBag)))
1356 { 1469 {
1357 foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments)) 1470 foreach (bool l3 in member(new Functor2("f", VariableName, ArgName), ArgAssignments))
1358 { 1471 {
1359 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName)) 1472 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
1360 { 1473 {
@@ -1383,7 +1496,7 @@ namespace Temporary {
1383 Variable RestResults = new Variable(); 1496 Variable RestResults = new Variable();
1384 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 1497 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1385 { 1498 {
1386 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults))) 1499 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1("arg", First), RestResults)))
1387 { 1500 {
1388 foreach (bool l4 in maplist_arg(Rest, RestResults)) 1501 foreach (bool l4 in maplist_arg(Rest, RestResults))
1389 { 1502 {
@@ -1425,7 +1538,7 @@ namespace Temporary {
1425 { 1538 {
1426 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) 1539 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1427 { 1540 {
1428 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) 1541 foreach (bool l6 in YP.atom_concat(Atom.a("arg"), NumberAtom, ArgName))
1429 { 1542 {
1430 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1))) 1543 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
1431 { 1544 {
@@ -1454,7 +1567,7 @@ namespace Temporary {
1454 Variable BodyCode = new Variable(); 1567 Variable BodyCode = new Variable();
1455 Variable VariableNamesList = new Variable(); 1568 Variable VariableNamesList = new Variable();
1456 Variable ArgUnifications = new Variable(); 1569 Variable ArgUnifications = new Variable();
1457 foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule)) 1570 foreach (bool l2 in YP.unify(new Functor2(":-", Head, Body), Rule))
1458 { 1571 {
1459 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions); 1572 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
1460 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs))) 1573 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
@@ -1480,7 +1593,7 @@ namespace Temporary {
1480 } 1593 }
1481 } 1594 }
1482 { 1595 {
1483 foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls)) 1596 foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(":-", Rule, Atom.a("true")), VariableNameSuggestions, State, ArgAssignments, Calls))
1484 { 1597 {
1485 yield return true; 1598 yield return true;
1486 yield break; 1599 yield break;
@@ -1553,13 +1666,13 @@ namespace Temporary {
1553 { 1666 {
1554 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs))) 1667 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
1555 { 1668 {
1556 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))) 1669 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)))
1557 { 1670 {
1558 foreach (bool l5 in YP.number_codes(Index, NumberCodes)) 1671 foreach (bool l5 in YP.number_codes(Index, NumberCodes))
1559 { 1672 {
1560 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes)) 1673 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
1561 { 1674 {
1562 foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) 1675 foreach (bool l7 in YP.atom_concat(Atom.a("arg"), NumberAtom, ArgName))
1563 { 1676 {
1564 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1))) 1677 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
1565 { 1678 {
@@ -1615,7 +1728,7 @@ namespace Temporary {
1615 Variable NumberCodes = new Variable(); 1728 Variable NumberCodes = new Variable();
1616 Variable NumberAtom = new Variable(); 1729 Variable NumberAtom = new Variable();
1617 Variable ArgName = new Variable(); 1730 Variable ArgName = new Variable();
1618 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames))) 1731 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("=", VariableName, Var), RestVariableNames)))
1619 { 1732 {
1620 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1)) 1733 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
1621 { 1734 {
@@ -1623,9 +1736,9 @@ namespace Temporary {
1623 { 1736 {
1624 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) 1737 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1625 { 1738 {
1626 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) 1739 foreach (bool l6 in YP.atom_concat(Atom.a("arg"), NumberAtom, ArgName))
1627 { 1740 {
1628 foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) 1741 foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2("f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1629 { 1742 {
1630 yield return true; 1743 yield return true;
1631 yield break; 1744 yield break;
@@ -1645,9 +1758,9 @@ namespace Temporary {
1645 Variable _Var = new Variable(); 1758 Variable _Var = new Variable();
1646 Variable RestVariableNames = new Variable(); 1759 Variable RestVariableNames = new Variable();
1647 Variable DeclarationsOut = new Variable(); 1760 Variable DeclarationsOut = new Variable();
1648 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames))) 1761 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("=", VariableName, _Var), RestVariableNames)))
1649 { 1762 {
1650 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))) 1763 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)))
1651 { 1764 {
1652 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) 1765 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1653 { 1766 {
@@ -1709,7 +1822,7 @@ namespace Temporary {
1709 object PseudoCode = arg3; 1822 object PseudoCode = arg3;
1710 if (YP.var(A)) 1823 if (YP.var(A))
1711 { 1824 {
1712 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode)) 1825 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor1("call", A), Atom.a("true")), State, PseudoCode))
1713 { 1826 {
1714 yield return true; 1827 yield return true;
1715 yield break; 1828 yield break;
@@ -1718,25 +1831,14 @@ namespace Temporary {
1718 } 1831 }
1719 { 1832 {
1720 object State = arg2; 1833 object State = arg2;
1721 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) 1834 object PseudoCode = arg3;
1722 { 1835 Variable A = new Variable();
1723 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) 1836 Variable B = new Variable();
1724 { 1837 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
1725 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1726 {
1727 yield return true;
1728 yield break;
1729 }
1730 }
1731 }
1732 }
1733 {
1734 object State = arg2;
1735 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1736 { 1838 {
1737 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) 1839 if (YP.var(A))
1738 { 1840 {
1739 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1841 foreach (bool l4 in compileRuleBody(new Functor2(",", new Functor1("call", A), B), State, PseudoCode))
1740 { 1842 {
1741 yield return true; 1843 yield return true;
1742 yield break; 1844 yield break;
@@ -1746,81 +1848,44 @@ namespace Temporary {
1746 } 1848 }
1747 { 1849 {
1748 object State = arg2; 1850 object State = arg2;
1749 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) 1851 object PseudoCode = arg3;
1750 { 1852 Variable A = new Variable();
1751 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) 1853 Variable B = new Variable();
1752 { 1854 Variable ACode = new Variable();
1753 CompilerState.setCodeUsesYield(State); 1855 Variable BCode = new Variable();
1754 yield return true; 1856 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
1755 yield break;
1756 }
1757 }
1758 }
1759 {
1760 object _State = arg2;
1761 Variable Name = new Variable();
1762 foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
1763 {
1764 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
1765 {
1766 yield return true;
1767 yield break;
1768 }
1769 }
1770 }
1771 {
1772 object State = arg2;
1773 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1774 { 1857 {
1775 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) 1858 foreach (bool l3 in compileFunctorCall(A, State, ACode))
1776 { 1859 {
1777 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1860 if (CompilerState.isDetNoneOut(State, A))
1778 { 1861 {
1779 yield return true; 1862 foreach (bool l5 in compileRuleBody(B, State, BCode))
1780 yield break; 1863 {
1864 foreach (bool l6 in YP.unify(PseudoCode, new ListPair(ACode, BCode)))
1865 {
1866 yield return true;
1867 yield break;
1868 }
1869 }
1781 } 1870 }
1782 } 1871 if (CompilerState.isSemidetNoneOut(State, A))
1783 }
1784 }
1785 {
1786 object State = arg2;
1787 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1788 {
1789 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1790 {
1791 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1792 { 1872 {
1793 yield return true; 1873 foreach (bool l5 in compileRuleBody(B, State, BCode))
1794 yield break; 1874 {
1875 foreach (bool l6 in YP.unify(PseudoCode, new ListPair(new Functor2("if", ACode, BCode), Atom.NIL)))
1876 {
1877 yield return true;
1878 yield break;
1879 }
1880 }
1795 } 1881 }
1796 } 1882 foreach (bool l4 in compileRuleBody(B, State, BCode))
1797 }
1798 }
1799 {
1800 object State = arg2;
1801 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1802 {
1803 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
1804 {
1805 CompilerState.setCodeUsesYield(State);
1806 yield return true;
1807 yield break;
1808 }
1809 }
1810 }
1811 {
1812 object State = arg2;
1813 object PseudoCode = arg3;
1814 Variable A = new Variable();
1815 Variable B = new Variable();
1816 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
1817 {
1818 if (YP.var(A))
1819 {
1820 foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
1821 { 1883 {
1822 yield return true; 1884 foreach (bool l5 in YP.unify(PseudoCode, new ListPair(new Functor2("foreach", ACode, BCode), Atom.NIL)))
1823 yield break; 1885 {
1886 yield return true;
1887 yield break;
1888 }
1824 } 1889 }
1825 } 1890 }
1826 } 1891 }
@@ -1832,9 +1897,9 @@ namespace Temporary {
1832 Variable T = new Variable(); 1897 Variable T = new Variable();
1833 Variable B = new Variable(); 1898 Variable B = new Variable();
1834 Variable C = new Variable(); 1899 Variable C = new Variable();
1835 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C))) 1900 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2(";", new Functor2("->", A, T), B), C)))
1836 { 1901 {
1837 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode)) 1902 foreach (bool l3 in compileRuleBody(new Functor2(";", new Functor2("->", A, new Functor2(",", T, C)), new Functor2(",", B, C)), State, PseudoCode))
1838 { 1903 {
1839 yield return true; 1904 yield return true;
1840 yield break; 1905 yield break;
@@ -1847,9 +1912,9 @@ namespace Temporary {
1847 Variable A = new Variable(); 1912 Variable A = new Variable();
1848 Variable B = new Variable(); 1913 Variable B = new Variable();
1849 Variable C = new Variable(); 1914 Variable C = new Variable();
1850 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C))) 1915 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2(";", A, B), C)))
1851 { 1916 {
1852 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode)) 1917 foreach (bool l3 in compileRuleBody(new Functor2(";", new Functor2(",", A, C), new Functor2(",", B, C)), State, PseudoCode))
1853 { 1918 {
1854 yield return true; 1919 yield return true;
1855 yield break; 1920 yield break;
@@ -1862,9 +1927,9 @@ namespace Temporary {
1862 Variable B = new Variable(); 1927 Variable B = new Variable();
1863 Variable ACode = new Variable(); 1928 Variable ACode = new Variable();
1864 Variable BCode = new Variable(); 1929 Variable BCode = new Variable();
1865 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) 1930 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("\\+", A), B)))
1866 { 1931 {
1867 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL))) 1932 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("if", new Functor1("not", ACode), BCode), Atom.NIL)))
1868 { 1933 {
1869 if (CompilerState.isSemidetNoneOut(State, A)) 1934 if (CompilerState.isSemidetNoneOut(State, A))
1870 { 1935 {
@@ -1885,9 +1950,9 @@ namespace Temporary {
1885 object PseudoCode = arg3; 1950 object PseudoCode = arg3;
1886 Variable A = new Variable(); 1951 Variable A = new Variable();
1887 Variable B = new Variable(); 1952 Variable B = new Variable();
1888 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) 1953 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("\\+", A), B)))
1889 { 1954 {
1890 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode)) 1955 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor2(";", new Functor2("->", A, Atom.a("fail")), Atom.a("true")), B), State, PseudoCode))
1891 { 1956 {
1892 yield return true; 1957 yield return true;
1893 yield break; 1958 yield break;
@@ -1899,9 +1964,9 @@ namespace Temporary {
1899 object PseudoCode = arg3; 1964 object PseudoCode = arg3;
1900 Variable A = new Variable(); 1965 Variable A = new Variable();
1901 Variable B = new Variable(); 1966 Variable B = new Variable();
1902 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B))) 1967 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("once", A), B)))
1903 { 1968 {
1904 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode)) 1969 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor2(";", new Functor2("->", A, Atom.a("true")), Atom.a("fail")), B), State, PseudoCode))
1905 { 1970 {
1906 yield return true; 1971 yield return true;
1907 yield break; 1972 yield break;
@@ -1914,9 +1979,9 @@ namespace Temporary {
1914 Variable A = new Variable(); 1979 Variable A = new Variable();
1915 Variable T = new Variable(); 1980 Variable T = new Variable();
1916 Variable B = new Variable(); 1981 Variable B = new Variable();
1917 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B))) 1982 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2("->", A, T), B)))
1918 { 1983 {
1919 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode)) 1984 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor2(";", new Functor2("->", A, T), Atom.a("fail")), B), State, PseudoCode))
1920 { 1985 {
1921 yield return true; 1986 yield return true;
1922 yield break; 1987 yield break;
@@ -1929,9 +1994,9 @@ namespace Temporary {
1929 Variable A = new Variable(); 1994 Variable A = new Variable();
1930 Variable B = new Variable(); 1995 Variable B = new Variable();
1931 Variable C = new Variable(); 1996 Variable C = new Variable();
1932 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C))) 1997 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2("\\=", A, B), C)))
1933 { 1998 {
1934 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode)) 1999 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor1("\\+", new Functor2("=", A, B)), C), State, PseudoCode))
1935 { 2000 {
1936 yield return true; 2001 yield return true;
1937 yield break; 2002 yield break;
@@ -1943,11 +2008,11 @@ namespace Temporary {
1943 object PseudoCode = arg3; 2008 object PseudoCode = arg3;
1944 Variable A = new Variable(); 2009 Variable A = new Variable();
1945 Variable ACode = new Variable(); 2010 Variable ACode = new Variable();
1946 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A))) 2011 foreach (bool l2 in YP.unify(arg1, new Functor2(",", Atom.a("!"), A)))
1947 { 2012 {
1948 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2013 foreach (bool l3 in compileRuleBody(A, State, ACode))
1949 { 2014 {
1950 foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode)) 2015 foreach (bool l4 in append(ACode, new ListPair(Atom.a("yieldbreak"), Atom.NIL), PseudoCode))
1951 { 2016 {
1952 yield return true; 2017 yield return true;
1953 yield break; 2018 yield break;
@@ -1961,11 +2026,11 @@ namespace Temporary {
1961 Variable Name = new Variable(); 2026 Variable Name = new Variable();
1962 Variable A = new Variable(); 2027 Variable A = new Variable();
1963 Variable ACode = new Variable(); 2028 Variable ACode = new Variable();
1964 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A))) 2029 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("$CUTIF", Name), A)))
1965 { 2030 {
1966 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2031 foreach (bool l3 in compileRuleBody(A, State, ACode))
1967 { 2032 {
1968 foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode)) 2033 foreach (bool l4 in append(ACode, new ListPair(new Functor1("breakBlock", Name), Atom.NIL), PseudoCode))
1969 { 2034 {
1970 yield return true; 2035 yield return true;
1971 yield break; 2036 yield break;
@@ -1976,7 +2041,7 @@ namespace Temporary {
1976 { 2041 {
1977 object _State = arg2; 2042 object _State = arg2;
1978 Variable x1 = new Variable(); 2043 Variable x1 = new Variable();
1979 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1))) 2044 foreach (bool l2 in YP.unify(arg1, new Functor2(",", Atom.a("fail"), x1)))
1980 { 2045 {
1981 foreach (bool l3 in YP.unify(arg3, Atom.NIL)) 2046 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1982 { 2047 {
@@ -1989,7 +2054,7 @@ namespace Temporary {
1989 object State = arg2; 2054 object State = arg2;
1990 object PseudoCode = arg3; 2055 object PseudoCode = arg3;
1991 Variable A = new Variable(); 2056 Variable A = new Variable();
1992 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A))) 2057 foreach (bool l2 in YP.unify(arg1, new Functor2(",", Atom.a("true"), A)))
1993 { 2058 {
1994 foreach (bool l3 in compileRuleBody(A, State, PseudoCode)) 2059 foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
1995 { 2060 {
@@ -2006,9 +2071,9 @@ namespace Temporary {
2006 Variable ACode = new Variable(); 2071 Variable ACode = new Variable();
2007 Variable TermCode = new Variable(); 2072 Variable TermCode = new Variable();
2008 Variable BCode = new Variable(); 2073 Variable BCode = new Variable();
2009 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B))) 2074 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2("is", A, Term), B)))
2010 { 2075 {
2011 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))) 2076 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)))
2012 { 2077 {
2013 foreach (bool l4 in compileTerm(A, State, ACode)) 2078 foreach (bool l4 in compileTerm(A, State, ACode))
2014 { 2079 {
@@ -2026,58 +2091,10 @@ namespace Temporary {
2026 } 2091 }
2027 { 2092 {
2028 object State = arg2; 2093 object State = arg2;
2029 Variable A = new Variable();
2030 Variable B = new Variable();
2031 Variable ACode = new Variable(); 2094 Variable ACode = new Variable();
2032 Variable BCode = new Variable();
2033 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2034 {
2035 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2036 {
2037 if (CompilerState.isDetNoneOut(State, A))
2038 {
2039 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2040 {
2041 foreach (bool l6 in compileRuleBody(B, State, BCode))
2042 {
2043 yield return true;
2044 yield break;
2045 }
2046 }
2047 }
2048 }
2049 }
2050 }
2051 {
2052 object State = arg2;
2053 Variable A = new Variable();
2054 Variable B = new Variable(); 2095 Variable B = new Variable();
2055 Variable ACode = new Variable();
2056 Variable BCode = new Variable(); 2096 Variable BCode = new Variable();
2057 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) 2097 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("$DET_NONE_OUT", ACode), B)))
2058 {
2059 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
2060 {
2061 if (CompilerState.isSemidetNoneOut(State, A))
2062 {
2063 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2064 {
2065 foreach (bool l6 in compileRuleBody(B, State, BCode))
2066 {
2067 yield return true;
2068 yield break;
2069 }
2070 }
2071 }
2072 }
2073 }
2074 }
2075 {
2076 object State = arg2;
2077 Variable ACode = new Variable();
2078 Variable B = new Variable();
2079 Variable BCode = new Variable();
2080 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
2081 { 2098 {
2082 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) 2099 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2083 { 2100 {
@@ -2100,9 +2117,9 @@ namespace Temporary {
2100 Variable Name = new Variable(); 2117 Variable Name = new Variable();
2101 Variable X1 = new Variable(); 2118 Variable X1 = new Variable();
2102 Variable X2 = new Variable(); 2119 Variable X2 = new Variable();
2103 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) 2120 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
2104 { 2121 {
2105 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))) 2122 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)))
2106 { 2123 {
2107 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL))))) 2124 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL)))))
2108 { 2125 {
@@ -2127,21 +2144,6 @@ namespace Temporary {
2127 { 2144 {
2128 object State = arg2; 2145 object State = arg2;
2129 object PseudoCode = arg3; 2146 object PseudoCode = arg3;
2130 Variable A = new Variable();
2131 Variable B = new Variable();
2132 Variable C = new Variable();
2133 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
2134 {
2135 foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
2136 {
2137 yield return true;
2138 yield break;
2139 }
2140 }
2141 }
2142 {
2143 object State = arg2;
2144 object PseudoCode = arg3;
2145 Variable Template = new Variable(); 2147 Variable Template = new Variable();
2146 Variable Goal = new Variable(); 2148 Variable Goal = new Variable();
2147 Variable Bag = new Variable(); 2149 Variable Bag = new Variable();
@@ -2151,19 +2153,19 @@ namespace Temporary {
2151 Variable GoalAndAddCode = new Variable(); 2153 Variable GoalAndAddCode = new Variable();
2152 Variable BagCode = new Variable(); 2154 Variable BagCode = new Variable();
2153 Variable BCode = new Variable(); 2155 Variable BCode = new Variable();
2154 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B))) 2156 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("findall", Template, Goal, Bag), B)))
2155 { 2157 {
2156 foreach (bool l3 in compileTerm(Template, State, TemplateCode)) 2158 foreach (bool l3 in compileTerm(Template, State, TemplateCode))
2157 { 2159 {
2158 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers)) 2160 foreach (bool l4 in CompilerState.gensym(State, Atom.a("findallAnswers"), FindallAnswers))
2159 { 2161 {
2160 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)) 2162 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))
2161 { 2163 {
2162 foreach (bool l6 in compileTerm(Bag, State, BagCode)) 2164 foreach (bool l6 in compileTerm(Bag, State, BagCode))
2163 { 2165 {
2164 foreach (bool l7 in compileRuleBody(B, State, BCode)) 2166 foreach (bool l7 in compileRuleBody(B, State, BCode))
2165 { 2167 {
2166 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)) 2168 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))
2167 { 2169 {
2168 yield return true; 2170 yield return true;
2169 yield break; 2171 yield break;
@@ -2182,9 +2184,9 @@ namespace Temporary {
2182 Variable Goal = new Variable(); 2184 Variable Goal = new Variable();
2183 Variable Bag = new Variable(); 2185 Variable Bag = new Variable();
2184 Variable B = new Variable(); 2186 Variable B = new Variable();
2185 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B))) 2187 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("bagof", Template, Goal, Bag), B)))
2186 { 2188 {
2187 foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode)) 2189 foreach (bool l3 in compileBagof(Atom.a("result"), Template, Goal, Bag, B, State, PseudoCode))
2188 { 2190 {
2189 yield return true; 2191 yield return true;
2190 yield break; 2192 yield break;
@@ -2198,9 +2200,9 @@ namespace Temporary {
2198 Variable Goal = new Variable(); 2200 Variable Goal = new Variable();
2199 Variable Bag = new Variable(); 2201 Variable Bag = new Variable();
2200 Variable B = new Variable(); 2202 Variable B = new Variable();
2201 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B))) 2203 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("setof", Template, Goal, Bag), B)))
2202 { 2204 {
2203 foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode)) 2205 foreach (bool l3 in compileBagof(Atom.a("resultSet"), Template, Goal, Bag, B, State, PseudoCode))
2204 { 2206 {
2205 yield return true; 2207 yield return true;
2206 yield break; 2208 yield break;
@@ -2213,9 +2215,9 @@ namespace Temporary {
2213 Variable B = new Variable(); 2215 Variable B = new Variable();
2214 Variable ATermCode = new Variable(); 2216 Variable ATermCode = new Variable();
2215 Variable BCode = new Variable(); 2217 Variable BCode = new Variable();
2216 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B))) 2218 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("call", A), B)))
2217 { 2219 {
2218 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))) 2220 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)))
2219 { 2221 {
2220 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2222 foreach (bool l4 in compileTerm(A, State, ATermCode))
2221 { 2223 {
@@ -2234,9 +2236,9 @@ namespace Temporary {
2234 Variable B = new Variable(); 2236 Variable B = new Variable();
2235 Variable ATermCode = new Variable(); 2237 Variable ATermCode = new Variable();
2236 Variable BCode = new Variable(); 2238 Variable BCode = new Variable();
2237 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"asserta", A), B))) 2239 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("asserta", A), B)))
2238 { 2240 {
2239 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) 2241 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2240 { 2242 {
2241 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2243 foreach (bool l4 in compileTerm(A, State, ATermCode))
2242 { 2244 {
@@ -2255,9 +2257,9 @@ namespace Temporary {
2255 Variable B = new Variable(); 2257 Variable B = new Variable();
2256 Variable ATermCode = new Variable(); 2258 Variable ATermCode = new Variable();
2257 Variable BCode = new Variable(); 2259 Variable BCode = new Variable();
2258 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assertz", A), B))) 2260 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("assertz", A), B)))
2259 { 2261 {
2260 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) 2262 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2261 { 2263 {
2262 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2264 foreach (bool l4 in compileTerm(A, State, ATermCode))
2263 { 2265 {
@@ -2275,9 +2277,9 @@ namespace Temporary {
2275 object PseudoCode = arg3; 2277 object PseudoCode = arg3;
2276 Variable A = new Variable(); 2278 Variable A = new Variable();
2277 Variable B = new Variable(); 2279 Variable B = new Variable();
2278 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assert", A), B))) 2280 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("assert", A), B)))
2279 { 2281 {
2280 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"assertz", A), B), State, PseudoCode)) 2282 foreach (bool l3 in compileRuleBody(new Functor2(",", new Functor1("assertz", A), B), State, PseudoCode))
2281 { 2283 {
2282 yield return true; 2284 yield return true;
2283 yield break; 2285 yield break;
@@ -2295,11 +2297,11 @@ namespace Temporary {
2295 Variable BCode = new Variable(); 2297 Variable BCode = new Variable();
2296 Variable CatcherTermCode = new Variable(); 2298 Variable CatcherTermCode = new Variable();
2297 Variable HandlerAndBCode = new Variable(); 2299 Variable HandlerAndBCode = new Variable();
2298 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"catch", Goal, Catcher, Handler), B))) 2300 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("catch", Goal, Catcher, Handler), B)))
2299 { 2301 {
2300 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3(@"declare", Atom.a(@"YP.Catch"), CatchGoal, new Functor2(@"new", Atom.a(@"YP.Catch"), new ListPair(new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2(@"foreach", new Functor1(@"var", CatchGoal), BCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", CatchGoal), Atom.a(@"unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL))))) 2302 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3("declare", Atom.a("YP.Catch"), CatchGoal, new Functor2("new", Atom.a("YP.Catch"), new ListPair(new Functor2("call", Atom.a("YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2("foreach", new Functor1("var", CatchGoal), BCode), new ListPair(new Functor2("foreach", new Functor3("callMember", new Functor1("var", CatchGoal), Atom.a("unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL)))))
2301 { 2303 {
2302 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal)) 2304 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal))
2303 { 2305 {
2304 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode)) 2306 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode))
2305 { 2307 {
@@ -2307,7 +2309,7 @@ namespace Temporary {
2307 { 2309 {
2308 foreach (bool l7 in compileRuleBody(B, State, BCode)) 2310 foreach (bool l7 in compileRuleBody(B, State, BCode))
2309 { 2311 {
2310 foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode)) 2312 foreach (bool l8 in compileRuleBody(new Functor2(",", Handler, B), State, HandlerAndBCode))
2311 { 2313 {
2312 yield return true; 2314 yield return true;
2313 yield break; 2315 yield break;
@@ -2321,22 +2323,16 @@ namespace Temporary {
2321 } 2323 }
2322 { 2324 {
2323 object State = arg2; 2325 object State = arg2;
2326 object PseudoCode = arg3;
2324 Variable A = new Variable(); 2327 Variable A = new Variable();
2325 Variable B = new Variable(); 2328 Variable B = new Variable();
2326 Variable ACode = new Variable(); 2329 Variable C = new Variable();
2327 Variable BCode = new Variable(); 2330 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2(",", A, B), C)))
2328 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2329 { 2331 {
2330 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL))) 2332 foreach (bool l3 in compileRuleBody(new Functor2(",", A, new Functor2(",", B, C)), State, PseudoCode))
2331 { 2333 {
2332 foreach (bool l4 in compileFunctorCall(A, State, ACode)) 2334 yield return true;
2333 { 2335 yield break;
2334 foreach (bool l5 in compileRuleBody(B, State, BCode))
2335 {
2336 yield return true;
2337 yield break;
2338 }
2339 }
2340 } 2336 }
2341 } 2337 }
2342 } 2338 }
@@ -2345,11 +2341,11 @@ namespace Temporary {
2345 object PseudoCode = arg3; 2341 object PseudoCode = arg3;
2346 Variable A = new Variable(); 2342 Variable A = new Variable();
2347 Variable B = new Variable(); 2343 Variable B = new Variable();
2348 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) 2344 foreach (bool l2 in YP.unify(arg1, new Functor2(";", A, B)))
2349 { 2345 {
2350 if (YP.var(A)) 2346 if (YP.var(A))
2351 { 2347 {
2352 foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode)) 2348 foreach (bool l4 in compileRuleBody(new Functor2(";", new Functor1("call", A), B), State, PseudoCode))
2353 { 2349 {
2354 yield return true; 2350 yield return true;
2355 yield break; 2351 yield break;
@@ -2364,13 +2360,13 @@ namespace Temporary {
2364 Variable B = new Variable(); 2360 Variable B = new Variable();
2365 Variable CutIfLabel = new Variable(); 2361 Variable CutIfLabel = new Variable();
2366 Variable Code = new Variable(); 2362 Variable Code = new Variable();
2367 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B))) 2363 foreach (bool l2 in YP.unify(arg1, new Functor2(";", new Functor2("->", A, T), B)))
2368 { 2364 {
2369 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL))) 2365 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("breakableBlock", CutIfLabel, Code), Atom.NIL)))
2370 { 2366 {
2371 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel)) 2367 foreach (bool l4 in CompilerState.gensym(State, Atom.a("cutIf"), CutIfLabel))
2372 { 2368 {
2373 foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code)) 2369 foreach (bool l5 in compileRuleBody(new Functor2(";", new Functor2(",", A, new Functor2(",", new Functor1("$CUTIF", CutIfLabel), T)), B), State, Code))
2374 { 2370 {
2375 yield return true; 2371 yield return true;
2376 yield break; 2372 yield break;
@@ -2382,11 +2378,24 @@ namespace Temporary {
2382 { 2378 {
2383 object State = arg2; 2379 object State = arg2;
2384 object PseudoCode = arg3; 2380 object PseudoCode = arg3;
2381 Variable _B = new Variable();
2382 foreach (bool l2 in YP.unify(arg1, new Functor2(";", Atom.a("!"), _B)))
2383 {
2384 foreach (bool l3 in compileRuleBody(Atom.a("!"), State, PseudoCode))
2385 {
2386 yield return true;
2387 yield break;
2388 }
2389 }
2390 }
2391 {
2392 object State = arg2;
2393 object PseudoCode = arg3;
2385 Variable A = new Variable(); 2394 Variable A = new Variable();
2386 Variable B = new Variable(); 2395 Variable B = new Variable();
2387 Variable ACode = new Variable(); 2396 Variable ACode = new Variable();
2388 Variable BCode = new Variable(); 2397 Variable BCode = new Variable();
2389 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) 2398 foreach (bool l2 in YP.unify(arg1, new Functor2(";", A, B)))
2390 { 2399 {
2391 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2400 foreach (bool l3 in compileRuleBody(A, State, ACode))
2392 { 2401 {
@@ -2402,10 +2411,102 @@ namespace Temporary {
2402 } 2411 }
2403 } 2412 }
2404 { 2413 {
2414 object State = arg2;
2415 foreach (bool l2 in YP.unify(arg1, Atom.a("!")))
2416 {
2417 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("return"), Atom.NIL)))
2418 {
2419 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
2420 {
2421 yield return true;
2422 yield break;
2423 }
2424 }
2425 }
2426 }
2427 {
2428 object State = arg2;
2429 foreach (bool l2 in YP.unify(arg1, Atom.a("!")))
2430 {
2431 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("returntrue"), Atom.NIL)))
2432 {
2433 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
2434 {
2435 yield return true;
2436 yield break;
2437 }
2438 }
2439 }
2440 }
2441 {
2442 object State = arg2;
2443 foreach (bool l2 in YP.unify(arg1, Atom.a("!")))
2444 {
2445 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("yieldtrue"), new ListPair(Atom.a("yieldbreak"), Atom.NIL))))
2446 {
2447 CompilerState.setCodeUsesYield(State);
2448 yield return true;
2449 yield break;
2450 }
2451 }
2452 }
2453 {
2454 object _State = arg2;
2455 Variable Name = new Variable();
2456 foreach (bool l2 in YP.unify(arg1, new Functor1("$CUTIF", Name)))
2457 {
2458 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1("breakBlock", Name), Atom.NIL)))
2459 {
2460 yield return true;
2461 yield break;
2462 }
2463 }
2464 }
2465 {
2466 object State = arg2;
2467 foreach (bool l2 in YP.unify(arg1, Atom.a("true")))
2468 {
2469 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("return"), Atom.NIL)))
2470 {
2471 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
2472 {
2473 yield return true;
2474 yield break;
2475 }
2476 }
2477 }
2478 }
2479 {
2480 object State = arg2;
2481 foreach (bool l2 in YP.unify(arg1, Atom.a("true")))
2482 {
2483 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("returntrue"), Atom.NIL)))
2484 {
2485 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
2486 {
2487 yield return true;
2488 yield break;
2489 }
2490 }
2491 }
2492 }
2493 {
2494 object State = arg2;
2495 foreach (bool l2 in YP.unify(arg1, Atom.a("true")))
2496 {
2497 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("yieldfalse"), Atom.NIL)))
2498 {
2499 CompilerState.setCodeUsesYield(State);
2500 yield return true;
2501 yield break;
2502 }
2503 }
2504 }
2505 {
2405 object A = arg1; 2506 object A = arg1;
2406 object State = arg2; 2507 object State = arg2;
2407 object PseudoCode = arg3; 2508 object PseudoCode = arg3;
2408 foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode)) 2509 foreach (bool l2 in compileRuleBody(new Functor2(",", A, Atom.a("true")), State, PseudoCode))
2409 { 2510 {
2410 yield return true; 2511 yield return true;
2411 yield break; 2512 yield break;
@@ -2429,15 +2530,15 @@ namespace Temporary {
2429 { 2530 {
2430 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal)) 2531 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
2431 { 2532 {
2432 foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers)) 2533 foreach (bool l5 in CompilerState.gensym(State, Atom.a("bagofAnswers"), BagofAnswers))
2433 { 2534 {
2434 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)) 2535 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))
2435 { 2536 {
2436 foreach (bool l7 in compileTerm(Bag, State, BagCode)) 2537 foreach (bool l7 in compileTerm(Bag, State, BagCode))
2437 { 2538 {
2438 foreach (bool l8 in compileRuleBody(B, State, BCode)) 2539 foreach (bool l8 in compileRuleBody(B, State, BCode))
2439 { 2540 {
2440 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)) 2541 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))
2441 { 2542 {
2442 yield return true; 2543 yield return true;
2443 yield break; 2544 yield break;
@@ -2456,7 +2557,7 @@ namespace Temporary {
2456 { 2557 {
2457 { 2558 {
2458 object Goal = arg1; 2559 object Goal = arg1;
2459 foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal))) 2560 foreach (bool l2 in YP.unify(arg2, new Functor1("call", Goal)))
2460 { 2561 {
2461 if (YP.var(Goal)) 2562 if (YP.var(Goal))
2462 { 2563 {
@@ -2469,7 +2570,7 @@ namespace Temporary {
2469 object UnqualifiedGoal = arg2; 2570 object UnqualifiedGoal = arg2;
2470 Variable x1 = new Variable(); 2571 Variable x1 = new Variable();
2471 Variable Goal = new Variable(); 2572 Variable Goal = new Variable();
2472 foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal))) 2573 foreach (bool l2 in YP.unify(arg1, new Functor2("^", x1, Goal)))
2473 { 2574 {
2474 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal)) 2575 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
2475 { 2576 {
@@ -2494,9 +2595,9 @@ namespace Temporary {
2494 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2) 2595 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
2495 { 2596 {
2496 { 2597 {
2497 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:="))) 2598 foreach (bool l2 in YP.unify(arg1, Atom.a("=:=")))
2498 { 2599 {
2499 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal"))) 2600 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.equal")))
2500 { 2601 {
2501 yield return true; 2602 yield return true;
2502 yield break; 2603 yield break;
@@ -2504,9 +2605,9 @@ namespace Temporary {
2504 } 2605 }
2505 } 2606 }
2506 { 2607 {
2507 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\="))) 2608 foreach (bool l2 in YP.unify(arg1, Atom.a("=\\=")))
2508 { 2609 {
2509 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual"))) 2610 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.notEqual")))
2510 { 2611 {
2511 yield return true; 2612 yield return true;
2512 yield break; 2613 yield break;
@@ -2514,9 +2615,9 @@ namespace Temporary {
2514 } 2615 }
2515 } 2616 }
2516 { 2617 {
2517 foreach (bool l2 in YP.unify(arg1, Atom.a(@">"))) 2618 foreach (bool l2 in YP.unify(arg1, Atom.a(">")))
2518 { 2619 {
2519 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan"))) 2620 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.greaterThan")))
2520 { 2621 {
2521 yield return true; 2622 yield return true;
2522 yield break; 2623 yield break;
@@ -2524,9 +2625,9 @@ namespace Temporary {
2524 } 2625 }
2525 } 2626 }
2526 { 2627 {
2527 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<"))) 2628 foreach (bool l2 in YP.unify(arg1, Atom.a("<")))
2528 { 2629 {
2529 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan"))) 2630 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.lessThan")))
2530 { 2631 {
2531 yield return true; 2632 yield return true;
2532 yield break; 2633 yield break;
@@ -2534,9 +2635,9 @@ namespace Temporary {
2534 } 2635 }
2535 } 2636 }
2536 { 2637 {
2537 foreach (bool l2 in YP.unify(arg1, Atom.a(@">="))) 2638 foreach (bool l2 in YP.unify(arg1, Atom.a(">=")))
2538 { 2639 {
2539 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual"))) 2640 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.greaterThanOrEqual")))
2540 { 2641 {
2541 yield return true; 2642 yield return true;
2542 yield break; 2643 yield break;
@@ -2544,9 +2645,9 @@ namespace Temporary {
2544 } 2645 }
2545 } 2646 }
2546 { 2647 {
2547 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<"))) 2648 foreach (bool l2 in YP.unify(arg1, Atom.a("=<")))
2548 { 2649 {
2549 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual"))) 2650 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.lessThanOrEqual")))
2550 { 2651 {
2551 yield return true; 2652 yield return true;
2552 yield break; 2653 yield break;
@@ -2562,26 +2663,26 @@ namespace Temporary {
2562 Variable FunctorArgs = new Variable(); 2663 Variable FunctorArgs = new Variable();
2563 Variable x6 = new Variable(); 2664 Variable x6 = new Variable();
2564 Variable Arity = new Variable(); 2665 Variable Arity = new Variable();
2565 Variable CompiledArgs = new Variable();
2566 Variable FunctionName = new Variable(); 2666 Variable FunctionName = new Variable();
2667 Variable CompiledArgs = new Variable();
2567 foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs))) 2668 foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs)))
2568 { 2669 {
2569 foreach (bool l3 in YP.functor(Functor_1, x6, Arity)) 2670 foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
2570 { 2671 {
2571 foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) 2672 foreach (bool l4 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
2572 { 2673 {
2573 foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) 2674 foreach (bool l5 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
2574 { 2675 {
2575 if (YP.termEqual(FunctionName, Atom.NIL)) 2676 if (YP.termEqual(FunctionName, Atom.NIL))
2576 { 2677 {
2577 foreach (bool l7 in YP.unify(PseudoCode, new Functor2(@"call", Atom.a(@"YP.matchDynamic"), new ListPair(new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", FunctorName), Atom.NIL)), new ListPair(new Functor1(@"objectArray", CompiledArgs), Atom.NIL))))) 2678 foreach (bool l7 in YP.unify(PseudoCode, new Functor2("call", Atom.a("YP.matchDynamic"), new ListPair(new Functor2("call", Atom.a("Atom.a"), new ListPair(new Functor1("object", FunctorName), Atom.NIL)), new ListPair(new Functor1("objectArray", CompiledArgs), Atom.NIL)))))
2578 { 2679 {
2579 yield return true; 2680 yield return true;
2580 yield break; 2681 yield break;
2581 } 2682 }
2582 goto cutIf1; 2683 goto cutIf1;
2583 } 2684 }
2584 foreach (bool l6 in YP.unify(PseudoCode, new Functor2(@"call", FunctionName, CompiledArgs))) 2685 foreach (bool l6 in YP.unify(PseudoCode, new Functor3("functorCall", FunctionName, FunctorArgs, CompiledArgs)))
2585 { 2686 {
2586 yield return true; 2687 yield return true;
2587 yield break; 2688 yield break;
@@ -2598,6 +2699,16 @@ namespace Temporary {
2598 public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4) 2699 public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4)
2599 { 2700 {
2600 { 2701 {
2702 object _State = arg1;
2703 object Name = arg2;
2704 object Arity = arg3;
2705 object x4 = arg4;
2706 if (functorCallIsSpecialForm(Name, Arity))
2707 {
2708 yield break;
2709 }
2710 }
2711 {
2601 object x1 = arg1; 2712 object x1 = arg1;
2602 object Name = arg2; 2713 object Name = arg2;
2603 object Arity = arg3; 2714 object Arity = arg3;
@@ -2616,7 +2727,7 @@ namespace Temporary {
2616 { 2727 {
2617 foreach (bool l3 in YP.unify(arg4, Name)) 2728 foreach (bool l3 in YP.unify(arg4, Name))
2618 { 2729 {
2619 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) 2730 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a("")))
2620 { 2731 {
2621 yield return true; 2732 yield return true;
2622 yield break; 2733 yield break;
@@ -2632,7 +2743,7 @@ namespace Temporary {
2632 { 2743 {
2633 foreach (bool l3 in YP.unify(arg4, Name)) 2744 foreach (bool l3 in YP.unify(arg4, Name))
2634 { 2745 {
2635 foreach (bool l4 in Atom.module(Name, Atom.a(@""))) 2746 foreach (bool l4 in Atom.module(Name, Atom.a("")))
2636 { 2747 {
2637 yield return true; 2748 yield return true;
2638 yield break; 2749 yield break;
@@ -2643,7 +2754,7 @@ namespace Temporary {
2643 { 2754 {
2644 object _State = arg1; 2755 object _State = arg1;
2645 object Name = arg2; 2756 object Name = arg2;
2646 object Arity = arg3; 2757 object _Arity = arg3;
2647 foreach (bool l2 in YP.unify(arg4, Atom.NIL)) 2758 foreach (bool l2 in YP.unify(arg4, Atom.NIL))
2648 { 2759 {
2649 foreach (bool l3 in Atom.module(Name, Atom.NIL)) 2760 foreach (bool l3 in Atom.module(Name, Atom.NIL))
@@ -2662,33 +2773,137 @@ namespace Temporary {
2662 Variable Message = new Variable(); 2773 Variable Message = new Variable();
2663 foreach (bool l2 in Atom.module(Name, Module)) 2774 foreach (bool l2 in Atom.module(Name, Module))
2664 { 2775 {
2665 foreach (bool l3 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message)) 2776 foreach (bool l3 in YP.atom_concat(Atom.a("Not supporting calls to external module: "), Module, Message))
2666 { 2777 {
2667 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message)); 2778 YP.throwException(new Functor2("error", new Functor2("type_error", Atom.a("callable"), new Functor2("/", Name, Arity)), Message));
2668 yield return true; 2779 yield return true;
2669 yield break; 2780 yield break;
2670 } 2781 }
2671 } 2782 }
2672 } 2783 }
2673 { 2784 {
2674 object _State = arg1; 2785 object _State = arg1;
2675 object Name = arg2; 2786 object Name = arg2;
2676 object _Arity = arg3; 2787 object _Arity = arg3;
2677 object x4 = arg4; 2788 object x4 = arg4;
2678 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), Name), Atom.a(@"Term is not callable"))); 2789 YP.throwException(new Functor2("error", new Functor2("type_error", Atom.a("callable"), Name), Atom.a("Term is not callable")));
2679 yield return true; 2790 yield return true;
2680 yield break; 2791 yield break;
2681 } 2792 }
2682 } 2793 }
2683 2794
2795 public static bool functorCallIsSpecialForm(object Name, object Arity)
2796 {
2797 {
2798 Variable x3 = new Variable();
2799 if (YP.termEqual(Arity, 0))
2800 {
2801 if (YP.termEqual(Name, Atom.a("!")))
2802 {
2803 return true;
2804 }
2805 if (YP.termEqual(Name, Atom.a("fail")))
2806 {
2807 return true;
2808 }
2809 if (YP.termEqual(Name, Atom.a("true")))
2810 {
2811 return true;
2812 }
2813 }
2814 if (YP.termEqual(Arity, 1))
2815 {
2816 if (YP.termEqual(Name, Atom.a("\\+")))
2817 {
2818 return true;
2819 }
2820 if (YP.termEqual(Name, Atom.a("once")))
2821 {
2822 return true;
2823 }
2824 if (YP.termEqual(Name, Atom.a("$CUTIF")))
2825 {
2826 return true;
2827 }
2828 if (YP.termEqual(Name, Atom.a("$DET_NONE_OUT")))
2829 {
2830 return true;
2831 }
2832 if (YP.termEqual(Name, Atom.a("call")))
2833 {
2834 return true;
2835 }
2836 if (YP.termEqual(Name, Atom.a("asserta")))
2837 {
2838 return true;
2839 }
2840 if (YP.termEqual(Name, Atom.a("assertz")))
2841 {
2842 return true;
2843 }
2844 if (YP.termEqual(Name, Atom.a("assert")))
2845 {
2846 return true;
2847 }
2848 }
2849 if (YP.termEqual(Arity, 2))
2850 {
2851 if (YP.termEqual(Name, Atom.a(";")))
2852 {
2853 return true;
2854 }
2855 if (YP.termEqual(Name, Atom.a(",")))
2856 {
2857 return true;
2858 }
2859 if (YP.termEqual(Name, Atom.a("->")))
2860 {
2861 return true;
2862 }
2863 if (YP.termEqual(Name, Atom.a("\\=")))
2864 {
2865 return true;
2866 }
2867 if (YP.termEqual(Name, Atom.a("is")))
2868 {
2869 return true;
2870 }
2871 foreach (bool l3 in binaryExpressionConditional(Name, x3))
2872 {
2873 return true;
2874 }
2875 }
2876 if (YP.termEqual(Arity, 3))
2877 {
2878 if (YP.termEqual(Name, Atom.a("findall")))
2879 {
2880 return true;
2881 }
2882 if (YP.termEqual(Name, Atom.a("bagof")))
2883 {
2884 return true;
2885 }
2886 if (YP.termEqual(Name, Atom.a("setof")))
2887 {
2888 return true;
2889 }
2890 if (YP.termEqual(Name, Atom.a("catch")))
2891 {
2892 return true;
2893 }
2894 }
2895 }
2896 return false;
2897 }
2898
2684 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3) 2899 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3)
2685 { 2900 {
2686 { 2901 {
2687 foreach (bool l2 in YP.unify(arg1, Atom.a(@"="))) 2902 foreach (bool l2 in YP.unify(arg1, Atom.a("=")))
2688 { 2903 {
2689 foreach (bool l3 in YP.unify(arg2, 2)) 2904 foreach (bool l3 in YP.unify(arg2, 2))
2690 { 2905 {
2691 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify"))) 2906 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.unify")))
2692 { 2907 {
2693 yield return true; 2908 yield return true;
2694 yield break; 2909 yield break;
@@ -2697,11 +2912,11 @@ namespace Temporary {
2697 } 2912 }
2698 } 2913 }
2699 { 2914 {
2700 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=.."))) 2915 foreach (bool l2 in YP.unify(arg1, Atom.a("=..")))
2701 { 2916 {
2702 foreach (bool l3 in YP.unify(arg2, 2)) 2917 foreach (bool l3 in YP.unify(arg2, 2))
2703 { 2918 {
2704 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ"))) 2919 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.univ")))
2705 { 2920 {
2706 yield return true; 2921 yield return true;
2707 yield break; 2922 yield break;
@@ -2710,11 +2925,11 @@ namespace Temporary {
2710 } 2925 }
2711 } 2926 }
2712 { 2927 {
2713 foreach (bool l2 in YP.unify(arg1, Atom.a(@"var"))) 2928 foreach (bool l2 in YP.unify(arg1, Atom.a("var")))
2714 { 2929 {
2715 foreach (bool l3 in YP.unify(arg2, 1)) 2930 foreach (bool l3 in YP.unify(arg2, 1))
2716 { 2931 {
2717 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var"))) 2932 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.var")))
2718 { 2933 {
2719 yield return true; 2934 yield return true;
2720 yield break; 2935 yield break;
@@ -2723,11 +2938,11 @@ namespace Temporary {
2723 } 2938 }
2724 } 2939 }
2725 { 2940 {
2726 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar"))) 2941 foreach (bool l2 in YP.unify(arg1, Atom.a("nonvar")))
2727 { 2942 {
2728 foreach (bool l3 in YP.unify(arg2, 1)) 2943 foreach (bool l3 in YP.unify(arg2, 1))
2729 { 2944 {
2730 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar"))) 2945 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.nonvar")))
2731 { 2946 {
2732 yield return true; 2947 yield return true;
2733 yield break; 2948 yield break;
@@ -2736,11 +2951,11 @@ namespace Temporary {
2736 } 2951 }
2737 } 2952 }
2738 { 2953 {
2739 foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg"))) 2954 foreach (bool l2 in YP.unify(arg1, Atom.a("arg")))
2740 { 2955 {
2741 foreach (bool l3 in YP.unify(arg2, 3)) 2956 foreach (bool l3 in YP.unify(arg2, 3))
2742 { 2957 {
2743 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg"))) 2958 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.arg")))
2744 { 2959 {
2745 yield return true; 2960 yield return true;
2746 yield break; 2961 yield break;
@@ -2749,11 +2964,11 @@ namespace Temporary {
2749 } 2964 }
2750 } 2965 }
2751 { 2966 {
2752 foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor"))) 2967 foreach (bool l2 in YP.unify(arg1, Atom.a("functor")))
2753 { 2968 {
2754 foreach (bool l3 in YP.unify(arg2, 3)) 2969 foreach (bool l3 in YP.unify(arg2, 3))
2755 { 2970 {
2756 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor"))) 2971 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.functor")))
2757 { 2972 {
2758 yield return true; 2973 yield return true;
2759 yield break; 2974 yield break;
@@ -2762,11 +2977,11 @@ namespace Temporary {
2762 } 2977 }
2763 } 2978 }
2764 { 2979 {
2765 foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat"))) 2980 foreach (bool l2 in YP.unify(arg1, Atom.a("repeat")))
2766 { 2981 {
2767 foreach (bool l3 in YP.unify(arg2, 0)) 2982 foreach (bool l3 in YP.unify(arg2, 0))
2768 { 2983 {
2769 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat"))) 2984 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.repeat")))
2770 { 2985 {
2771 yield return true; 2986 yield return true;
2772 yield break; 2987 yield break;
@@ -2775,11 +2990,11 @@ namespace Temporary {
2775 } 2990 }
2776 } 2991 }
2777 { 2992 {
2778 foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code"))) 2993 foreach (bool l2 in YP.unify(arg1, Atom.a("get_code")))
2779 { 2994 {
2780 foreach (bool l3 in YP.unify(arg2, 1)) 2995 foreach (bool l3 in YP.unify(arg2, 1))
2781 { 2996 {
2782 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code"))) 2997 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.get_code")))
2783 { 2998 {
2784 yield return true; 2999 yield return true;
2785 yield break; 3000 yield break;
@@ -2788,11 +3003,11 @@ namespace Temporary {
2788 } 3003 }
2789 } 3004 }
2790 { 3005 {
2791 foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op"))) 3006 foreach (bool l2 in YP.unify(arg1, Atom.a("current_op")))
2792 { 3007 {
2793 foreach (bool l3 in YP.unify(arg2, 3)) 3008 foreach (bool l3 in YP.unify(arg2, 3))
2794 { 3009 {
2795 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op"))) 3010 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_op")))
2796 { 3011 {
2797 yield return true; 3012 yield return true;
2798 yield break; 3013 yield break;
@@ -2801,11 +3016,24 @@ namespace Temporary {
2801 } 3016 }
2802 } 3017 }
2803 { 3018 {
2804 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length"))) 3019 foreach (bool l2 in YP.unify(arg1, Atom.a("current_predicate")))
3020 {
3021 foreach (bool l3 in YP.unify(arg2, 1))
3022 {
3023 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_predicate")))
3024 {
3025 yield return true;
3026 yield break;
3027 }
3028 }
3029 }
3030 }
3031 {
3032 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_length")))
2805 { 3033 {
2806 foreach (bool l3 in YP.unify(arg2, 2)) 3034 foreach (bool l3 in YP.unify(arg2, 2))
2807 { 3035 {
2808 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length"))) 3036 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atom_length")))
2809 { 3037 {
2810 yield return true; 3038 yield return true;
2811 yield break; 3039 yield break;
@@ -2814,11 +3042,11 @@ namespace Temporary {
2814 } 3042 }
2815 } 3043 }
2816 { 3044 {
2817 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat"))) 3045 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_concat")))
2818 { 3046 {
2819 foreach (bool l3 in YP.unify(arg2, 3)) 3047 foreach (bool l3 in YP.unify(arg2, 3))
2820 { 3048 {
2821 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat"))) 3049 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atom_concat")))
2822 { 3050 {
2823 yield return true; 3051 yield return true;
2824 yield break; 3052 yield break;
@@ -2827,11 +3055,11 @@ namespace Temporary {
2827 } 3055 }
2828 } 3056 }
2829 { 3057 {
2830 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom"))) 3058 foreach (bool l2 in YP.unify(arg1, Atom.a("sub_atom")))
2831 { 3059 {
2832 foreach (bool l3 in YP.unify(arg2, 5)) 3060 foreach (bool l3 in YP.unify(arg2, 5))
2833 { 3061 {
2834 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom"))) 3062 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.sub_atom")))
2835 { 3063 {
2836 yield return true; 3064 yield return true;
2837 yield break; 3065 yield break;
@@ -2840,11 +3068,11 @@ namespace Temporary {
2840 } 3068 }
2841 } 3069 }
2842 { 3070 {
2843 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes"))) 3071 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_chars")))
2844 { 3072 {
2845 foreach (bool l3 in YP.unify(arg2, 2)) 3073 foreach (bool l3 in YP.unify(arg2, 2))
2846 { 3074 {
2847 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes"))) 3075 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atom_chars")))
2848 { 3076 {
2849 yield return true; 3077 yield return true;
2850 yield break; 3078 yield break;
@@ -2853,11 +3081,11 @@ namespace Temporary {
2853 } 3081 }
2854 } 3082 }
2855 { 3083 {
2856 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes"))) 3084 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_codes")))
2857 { 3085 {
2858 foreach (bool l3 in YP.unify(arg2, 2)) 3086 foreach (bool l3 in YP.unify(arg2, 2))
2859 { 3087 {
2860 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes"))) 3088 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atom_codes")))
2861 { 3089 {
2862 yield return true; 3090 yield return true;
2863 yield break; 3091 yield break;
@@ -2866,11 +3094,11 @@ namespace Temporary {
2866 } 3094 }
2867 } 3095 }
2868 { 3096 {
2869 foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term"))) 3097 foreach (bool l2 in YP.unify(arg1, Atom.a("char_code")))
2870 { 3098 {
2871 foreach (bool l3 in YP.unify(arg2, 2)) 3099 foreach (bool l3 in YP.unify(arg2, 2))
2872 { 3100 {
2873 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term"))) 3101 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.char_code")))
2874 { 3102 {
2875 yield return true; 3103 yield return true;
2876 yield break; 3104 yield break;
@@ -2879,11 +3107,50 @@ namespace Temporary {
2879 } 3107 }
2880 } 3108 }
2881 { 3109 {
2882 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort"))) 3110 foreach (bool l2 in YP.unify(arg1, Atom.a("number_chars")))
2883 { 3111 {
2884 foreach (bool l3 in YP.unify(arg2, 2)) 3112 foreach (bool l3 in YP.unify(arg2, 2))
2885 { 3113 {
2886 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort"))) 3114 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.number_chars")))
3115 {
3116 yield return true;
3117 yield break;
3118 }
3119 }
3120 }
3121 }
3122 {
3123 foreach (bool l2 in YP.unify(arg1, Atom.a("number_codes")))
3124 {
3125 foreach (bool l3 in YP.unify(arg2, 2))
3126 {
3127 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.number_codes")))
3128 {
3129 yield return true;
3130 yield break;
3131 }
3132 }
3133 }
3134 }
3135 {
3136 foreach (bool l2 in YP.unify(arg1, Atom.a("copy_term")))
3137 {
3138 foreach (bool l3 in YP.unify(arg2, 2))
3139 {
3140 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.copy_term")))
3141 {
3142 yield return true;
3143 yield break;
3144 }
3145 }
3146 }
3147 }
3148 {
3149 foreach (bool l2 in YP.unify(arg1, Atom.a("sort")))
3150 {
3151 foreach (bool l3 in YP.unify(arg2, 2))
3152 {
3153 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.sort")))
2887 { 3154 {
2888 yield return true; 3155 yield return true;
2889 yield break; 3156 yield break;
@@ -2908,11 +3175,24 @@ namespace Temporary {
2908 } 3175 }
2909 } 3176 }
2910 { 3177 {
2911 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl"))) 3178 foreach (bool l2 in YP.unify(arg1, Atom.a("nl")))
2912 { 3179 {
2913 foreach (bool l3 in YP.unify(arg2, 0)) 3180 foreach (bool l3 in YP.unify(arg2, 0))
2914 { 3181 {
2915 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl"))) 3182 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.nl")))
3183 {
3184 yield return true;
3185 yield break;
3186 }
3187 }
3188 }
3189 }
3190 {
3191 foreach (bool l2 in YP.unify(arg1, Atom.a("write")))
3192 {
3193 foreach (bool l3 in YP.unify(arg2, 1))
3194 {
3195 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.write")))
2916 { 3196 {
2917 yield return true; 3197 yield return true;
2918 yield break; 3198 yield break;
@@ -2921,11 +3201,24 @@ namespace Temporary {
2921 } 3201 }
2922 } 3202 }
2923 { 3203 {
2924 foreach (bool l2 in YP.unify(arg1, Atom.a(@"write"))) 3204 foreach (bool l2 in YP.unify(arg1, Atom.a("put_code")))
2925 { 3205 {
2926 foreach (bool l3 in YP.unify(arg2, 1)) 3206 foreach (bool l3 in YP.unify(arg2, 1))
2927 { 3207 {
2928 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write"))) 3208 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.put_code")))
3209 {
3210 yield return true;
3211 yield break;
3212 }
3213 }
3214 }
3215 }
3216 {
3217 foreach (bool l2 in YP.unify(arg1, Atom.a("clause")))
3218 {
3219 foreach (bool l3 in YP.unify(arg2, 2))
3220 {
3221 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.clause")))
2929 { 3222 {
2930 yield return true; 3223 yield return true;
2931 yield break; 3224 yield break;
@@ -2934,11 +3227,11 @@ namespace Temporary {
2934 } 3227 }
2935 } 3228 }
2936 { 3229 {
2937 foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code"))) 3230 foreach (bool l2 in YP.unify(arg1, Atom.a("retract")))
2938 { 3231 {
2939 foreach (bool l3 in YP.unify(arg2, 1)) 3232 foreach (bool l3 in YP.unify(arg2, 1))
2940 { 3233 {
2941 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code"))) 3234 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.retract")))
2942 { 3235 {
2943 yield return true; 3236 yield return true;
2944 yield break; 3237 yield break;
@@ -2947,11 +3240,11 @@ namespace Temporary {
2947 } 3240 }
2948 } 3241 }
2949 { 3242 {
2950 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom"))) 3243 foreach (bool l2 in YP.unify(arg1, Atom.a("abolish")))
2951 { 3244 {
2952 foreach (bool l3 in YP.unify(arg2, 1)) 3245 foreach (bool l3 in YP.unify(arg2, 1))
2953 { 3246 {
2954 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom"))) 3247 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.abolish")))
2955 { 3248 {
2956 yield return true; 3249 yield return true;
2957 yield break; 3250 yield break;
@@ -2960,11 +3253,11 @@ namespace Temporary {
2960 } 3253 }
2961 } 3254 }
2962 { 3255 {
2963 foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer"))) 3256 foreach (bool l2 in YP.unify(arg1, Atom.a("retractall")))
2964 { 3257 {
2965 foreach (bool l3 in YP.unify(arg2, 1)) 3258 foreach (bool l3 in YP.unify(arg2, 1))
2966 { 3259 {
2967 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer"))) 3260 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.retractall")))
2968 { 3261 {
2969 yield return true; 3262 yield return true;
2970 yield break; 3263 yield break;
@@ -2973,12 +3266,25 @@ namespace Temporary {
2973 } 3266 }
2974 } 3267 }
2975 { 3268 {
2976 foreach (bool l2 in YP.unify(arg1, Atom.a(@"float"))) 3269 foreach (bool l2 in YP.unify(arg1, Atom.a("atom")))
2977 { 3270 {
2978 foreach (bool l3 in YP.unify(arg2, 1)) 3271 foreach (bool l3 in YP.unify(arg2, 1))
2979 { 3272 {
2980 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.isFloat"))) 3273 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atom")))
3274 {
3275 yield return true;
3276 yield break;
3277 }
3278 }
3279 }
3280 }
3281 {
3282 foreach (bool l2 in YP.unify(arg1, Atom.a("integer")))
2981 { 3283 {
3284 foreach (bool l3 in YP.unify(arg2, 1))
3285 {
3286 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.integer")))
3287 {
2982 yield return true; 3288 yield return true;
2983 yield break; 3289 yield break;
2984 } 3290 }
@@ -2986,11 +3292,11 @@ namespace Temporary {
2986 } 3292 }
2987 } 3293 }
2988 { 3294 {
2989 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number"))) 3295 foreach (bool l2 in YP.unify(arg1, Atom.a("float")))
2990 { 3296 {
2991 foreach (bool l3 in YP.unify(arg2, 1)) 3297 foreach (bool l3 in YP.unify(arg2, 1))
2992 { 3298 {
2993 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number"))) 3299 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.isFloat")))
2994 { 3300 {
2995 yield return true; 3301 yield return true;
2996 yield break; 3302 yield break;
@@ -2999,11 +3305,11 @@ namespace Temporary {
2999 } 3305 }
3000 } 3306 }
3001 { 3307 {
3002 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic"))) 3308 foreach (bool l2 in YP.unify(arg1, Atom.a("number")))
3003 { 3309 {
3004 foreach (bool l3 in YP.unify(arg2, 1)) 3310 foreach (bool l3 in YP.unify(arg2, 1))
3005 { 3311 {
3006 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic"))) 3312 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.number")))
3007 { 3313 {
3008 yield return true; 3314 yield return true;
3009 yield break; 3315 yield break;
@@ -3012,11 +3318,11 @@ namespace Temporary {
3012 } 3318 }
3013 } 3319 }
3014 { 3320 {
3015 foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound"))) 3321 foreach (bool l2 in YP.unify(arg1, Atom.a("atomic")))
3016 { 3322 {
3017 foreach (bool l3 in YP.unify(arg2, 1)) 3323 foreach (bool l3 in YP.unify(arg2, 1))
3018 { 3324 {
3019 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound"))) 3325 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atomic")))
3020 { 3326 {
3021 yield return true; 3327 yield return true;
3022 yield break; 3328 yield break;
@@ -3025,11 +3331,11 @@ namespace Temporary {
3025 } 3331 }
3026 } 3332 }
3027 { 3333 {
3028 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=="))) 3334 foreach (bool l2 in YP.unify(arg1, Atom.a("compound")))
3029 { 3335 {
3030 foreach (bool l3 in YP.unify(arg2, 2)) 3336 foreach (bool l3 in YP.unify(arg2, 1))
3031 { 3337 {
3032 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual"))) 3338 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.compound")))
3033 { 3339 {
3034 yield return true; 3340 yield return true;
3035 yield break; 3341 yield break;
@@ -3038,11 +3344,11 @@ namespace Temporary {
3038 } 3344 }
3039 } 3345 }
3040 { 3346 {
3041 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\=="))) 3347 foreach (bool l2 in YP.unify(arg1, Atom.a("==")))
3042 { 3348 {
3043 foreach (bool l3 in YP.unify(arg2, 2)) 3349 foreach (bool l3 in YP.unify(arg2, 2))
3044 { 3350 {
3045 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual"))) 3351 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termEqual")))
3046 { 3352 {
3047 yield return true; 3353 yield return true;
3048 yield break; 3354 yield break;
@@ -3051,11 +3357,11 @@ namespace Temporary {
3051 } 3357 }
3052 } 3358 }
3053 { 3359 {
3054 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<"))) 3360 foreach (bool l2 in YP.unify(arg1, Atom.a("\\==")))
3055 { 3361 {
3056 foreach (bool l3 in YP.unify(arg2, 2)) 3362 foreach (bool l3 in YP.unify(arg2, 2))
3057 { 3363 {
3058 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan"))) 3364 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termNotEqual")))
3059 { 3365 {
3060 yield return true; 3366 yield return true;
3061 yield break; 3367 yield break;
@@ -3064,11 +3370,11 @@ namespace Temporary {
3064 } 3370 }
3065 } 3371 }
3066 { 3372 {
3067 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<"))) 3373 foreach (bool l2 in YP.unify(arg1, Atom.a("@<")))
3068 { 3374 {
3069 foreach (bool l3 in YP.unify(arg2, 2)) 3375 foreach (bool l3 in YP.unify(arg2, 2))
3070 { 3376 {
3071 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual"))) 3377 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termLessThan")))
3072 { 3378 {
3073 yield return true; 3379 yield return true;
3074 yield break; 3380 yield break;
@@ -3077,11 +3383,11 @@ namespace Temporary {
3077 } 3383 }
3078 } 3384 }
3079 { 3385 {
3080 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>"))) 3386 foreach (bool l2 in YP.unify(arg1, Atom.a("@=<")))
3081 { 3387 {
3082 foreach (bool l3 in YP.unify(arg2, 2)) 3388 foreach (bool l3 in YP.unify(arg2, 2))
3083 { 3389 {
3084 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan"))) 3390 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termLessThanOrEqual")))
3085 { 3391 {
3086 yield return true; 3392 yield return true;
3087 yield break; 3393 yield break;
@@ -3090,32 +3396,45 @@ namespace Temporary {
3090 } 3396 }
3091 } 3397 }
3092 { 3398 {
3093 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>="))) 3399 foreach (bool l2 in YP.unify(arg1, Atom.a("@>")))
3094 { 3400 {
3095 foreach (bool l3 in YP.unify(arg2, 2)) 3401 foreach (bool l3 in YP.unify(arg2, 2))
3096 { 3402 {
3097 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual"))) 3403 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termGreaterThan")))
3098 { 3404 {
3099 yield return true; 3405 yield return true;
3100 yield break; 3406 yield break;
3407 }
3408 }
3101 } 3409 }
3102 } 3410 }
3411 {
3412 foreach (bool l2 in YP.unify(arg1, Atom.a("@>=")))
3413 {
3414 foreach (bool l3 in YP.unify(arg2, 2))
3415 {
3416 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termGreaterThanOrEqual")))
3417 {
3418 yield return true;
3419 yield break;
3420 }
3421 }
3103 } 3422 }
3104 } 3423 }
3105 { 3424 {
3106 foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw"))) 3425 foreach (bool l2 in YP.unify(arg1, Atom.a("throw")))
3107 { 3426 {
3108 foreach (bool l3 in YP.unify(arg2, 1)) 3427 foreach (bool l3 in YP.unify(arg2, 1))
3109 {
3110 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
3111 { 3428 {
3112 yield return true; 3429 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.throwException")))
3113 yield break; 3430 {
3431 yield return true;
3432 yield break;
3433 }
3114 } 3434 }
3115 } 3435 }
3116 } 3436 }
3117 } 3437 }
3118 }
3119 3438
3120 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) 3439 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
3121 { 3440 {
@@ -3123,7 +3442,7 @@ namespace Temporary {
3123 object Term = arg1; 3442 object Term = arg1;
3124 object State = arg2; 3443 object State = arg2;
3125 Variable VariableName = new Variable(); 3444 Variable VariableName = new Variable();
3126 foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName))) 3445 foreach (bool l2 in YP.unify(arg3, new Functor1("var", VariableName)))
3127 { 3446 {
3128 if (YP.var(Term)) 3447 if (YP.var(Term))
3129 { 3448 {
@@ -3139,7 +3458,7 @@ namespace Temporary {
3139 object _State = arg2; 3458 object _State = arg2;
3140 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 3459 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3141 { 3460 {
3142 foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL")))) 3461 foreach (bool l3 in YP.unify(arg3, new Functor1("var", Atom.a("Atom.NIL"))))
3143 { 3462 {
3144 yield return true; 3463 yield return true;
3145 yield break; 3464 yield break;
@@ -3155,14 +3474,14 @@ namespace Temporary {
3155 { 3474 {
3156 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode)) 3475 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
3157 { 3476 {
3158 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))))) 3477 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)))))
3159 { 3478 {
3160 yield return true; 3479 yield return true;
3161 yield break; 3480 yield break;
3162 } 3481 }
3163 goto cutIf1; 3482 goto cutIf1;
3164 } 3483 }
3165 foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL)))) 3484 foreach (bool l3 in YP.unify(Code, new Functor2("call", Atom.a("Atom.a"), new ListPair(new Functor1("object", Term), Atom.NIL))))
3166 { 3485 {
3167 yield return true; 3486 yield return true;
3168 yield break; 3487 yield break;
@@ -3179,7 +3498,7 @@ namespace Temporary {
3179 Variable Arg2 = new Variable(); 3498 Variable Arg2 = new Variable();
3180 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 3499 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3181 { 3500 {
3182 foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) 3501 foreach (bool l3 in YP.unify(arg3, new Functor2("new", Atom.a("ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3183 { 3502 {
3184 foreach (bool l4 in compileTerm(First, State, Arg1)) 3503 foreach (bool l4 in compileTerm(First, State, Arg1))
3185 { 3504 {
@@ -3213,7 +3532,7 @@ namespace Temporary {
3213 { 3532 {
3214 if (YP.termEqual(TermArgs, Atom.NIL)) 3533 if (YP.termEqual(TermArgs, Atom.NIL))
3215 { 3534 {
3216 foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name))) 3535 foreach (bool l4 in YP.unify(Result, new Functor1("object", Name)))
3217 { 3536 {
3218 yield return true; 3537 yield return true;
3219 yield break; 3538 yield break;
@@ -3224,55 +3543,55 @@ namespace Temporary {
3224 { 3543 {
3225 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode)) 3544 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
3226 { 3545 {
3227 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))))) 3546 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)))))
3228 { 3547 {
3229 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) 3548 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3230 { 3549 {
3231 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3550 foreach (bool l7 in compileTerm(X1, State, Arg1))
3232 { 3551 {
3233 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) 3552 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3234 { 3553 {
3235 yield return true; 3554 yield return true;
3236 yield break; 3555 yield break;
3237 } 3556 }
3238 } 3557 }
3239 goto cutIf4; 3558 goto cutIf4;
3240 } 3559 }
3241 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) 3560 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3242 { 3561 {
3243 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3562 foreach (bool l7 in compileTerm(X1, State, Arg1))
3244 { 3563 {
3245 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3564 foreach (bool l8 in compileTerm(X2, State, Arg2))
3246 { 3565 {
3247 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3566 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3248 { 3567 {
3249 yield return true; 3568 yield return true;
3250 yield break; 3569 yield break;
3251 } 3570 }
3252 } 3571 }
3253 } 3572 }
3254 goto cutIf5; 3573 goto cutIf5;
3255 } 3574 }
3256 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3575 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3257 { 3576 {
3258 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3577 foreach (bool l7 in compileTerm(X1, State, Arg1))
3259 { 3578 {
3260 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3579 foreach (bool l8 in compileTerm(X2, State, Arg2))
3261 { 3580 {
3262 foreach (bool l9 in compileTerm(X3, State, Arg3)) 3581 foreach (bool l9 in compileTerm(X3, State, Arg3))
3263 { 3582 {
3264 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))))))) 3583 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)))))))
3265 { 3584 {
3266 yield return true; 3585 yield return true;
3267 yield break; 3586 yield break;
3268 } 3587 }
3269 } 3588 }
3270 } 3589 }
3271 } 3590 }
3272 } 3591 }
3273 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args)) 3592 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
3274 { 3593 {
3275 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) 3594 foreach (bool l7 in YP.unify(Result, new Functor2("new", Atom.a("Functor"), new ListPair(NameCode, new ListPair(new Functor1("objectArray", Args), Atom.NIL)))))
3276 { 3595 {
3277 yield return true; 3596 yield return true;
3278 yield break; 3597 yield break;
@@ -3282,15 +3601,15 @@ namespace Temporary {
3282 cutIf4: 3601 cutIf4:
3283 { } 3602 { }
3284 } 3603 }
3285 goto cutIf3; 3604 goto cutIf3;
3286 } 3605 }
3287 foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name))) 3606 foreach (bool l4 in YP.unify(NameCode, new Functor1("object", Name)))
3288 { 3607 {
3289 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) 3608 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3290 { 3609 {
3291 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3610 foreach (bool l6 in compileTerm(X1, State, Arg1))
3292 { 3611 {
3293 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) 3612 foreach (bool l7 in YP.unify(Result, new Functor2("new", Atom.a("Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3294 { 3613 {
3295 yield return true; 3614 yield return true;
3296 yield break; 3615 yield break;
@@ -3304,7 +3623,7 @@ namespace Temporary {
3304 { 3623 {
3305 foreach (bool l7 in compileTerm(X2, State, Arg2)) 3624 foreach (bool l7 in compileTerm(X2, State, Arg2))
3306 { 3625 {
3307 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3626 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3308 { 3627 {
3309 yield return true; 3628 yield return true;
3310 yield break; 3629 yield break;
@@ -3316,33 +3635,33 @@ namespace Temporary {
3316 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3635 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3317 { 3636 {
3318 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3637 foreach (bool l6 in compileTerm(X1, State, Arg1))
3319 {
3320 foreach (bool l7 in compileTerm(X2, State, Arg2))
3321 {
3322 foreach (bool l8 in compileTerm(X3, State, Arg3))
3323 { 3638 {
3324 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))))))) 3639 foreach (bool l7 in compileTerm(X2, State, Arg2))
3325 { 3640 {
3326 yield return true; 3641 foreach (bool l8 in compileTerm(X3, State, Arg3))
3327 yield break; 3642 {
3643 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)))))))
3644 {
3645 yield return true;
3646 yield break;
3647 }
3648 }
3328 } 3649 }
3329 } 3650 }
3330 } 3651 }
3331 }
3332 }
3333 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args)) 3652 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
3334 { 3653 {
3335 foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) 3654 foreach (bool l6 in YP.unify(Result, new Functor2("new", Atom.a("Functor"), new ListPair(NameCode, new ListPair(new Functor1("objectArray", Args), Atom.NIL)))))
3336 { 3655 {
3337 yield return true; 3656 yield return true;
3338 yield break; 3657 yield break;
3339 } 3658 }
3340 } 3659 }
3341 cutIf7: 3660 cutIf7:
3342 cutIf6: 3661 cutIf6:
3343 { } 3662 { }
3344 } 3663 }
3345 cutIf3: 3664 cutIf3:
3346 { } 3665 { }
3347 } 3666 }
3348 cutIf2: 3667 cutIf2:
@@ -3351,18 +3670,36 @@ namespace Temporary {
3351 } 3670 }
3352 } 3671 }
3353 3672
3354 public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode) 3673 public static IEnumerable<bool> compileAtomModule(object Name, object arg2, object arg3, object ModuleCode)
3355 { 3674 {
3356 { 3675 {
3357 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) 3676 object Arity = arg2;
3677 object State = arg3;
3678 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a("")))
3358 { 3679 {
3359 foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL)))) 3680 foreach (bool l3 in YP.unify(ModuleCode, new Functor2("call", Atom.a("Atom.a"), new ListPair(new Functor1("object", Atom.a("")), Atom.NIL))))
3360 { 3681 {
3361 yield return true; 3682 yield return true;
3362 yield break; 3683 yield break;
3363 } 3684 }
3364 } 3685 }
3365 } 3686 }
3687 {
3688 object _Arity = arg2;
3689 object _State = arg3;
3690 Variable Module = new Variable();
3691 foreach (bool l2 in Atom.module(Name, Module))
3692 {
3693 if (YP.termNotEqual(Module, Atom.NIL))
3694 {
3695 foreach (bool l4 in YP.unify(ModuleCode, new Functor2("call", Atom.a("Atom.a"), new ListPair(new Functor1("object", Module), Atom.NIL))))
3696 {
3697 yield return true;
3698 yield break;
3699 }
3700 }
3701 }
3702 }
3366 } 3703 }
3367 3704
3368 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3) 3705 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
@@ -3426,7 +3763,7 @@ namespace Temporary {
3426 { 3763 {
3427 foreach (bool l7 in compileExpression(X1, State, Arg1)) 3764 foreach (bool l7 in compileExpression(X1, State, Arg1))
3428 { 3765 {
3429 foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL)))) 3766 foreach (bool l8 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, Atom.NIL))))
3430 { 3767 {
3431 yield return true; 3768 yield return true;
3432 yield break; 3769 yield break;
@@ -3452,7 +3789,7 @@ namespace Temporary {
3452 { 3789 {
3453 foreach (bool l8 in compileExpression(X2, State, Arg2)) 3790 foreach (bool l8 in compileExpression(X2, State, Arg2))
3454 { 3791 {
3455 foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) 3792 foreach (bool l9 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3456 { 3793 {
3457 yield return true; 3794 yield return true;
3458 yield break; 3795 yield break;
@@ -3464,8 +3801,8 @@ namespace Temporary {
3464 } 3801 }
3465 foreach (bool l5 in YP.functor(Term, x12, Arity)) 3802 foreach (bool l5 in YP.functor(Term, x12, Arity))
3466 { 3803 {
3467 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Not an expression function"))); 3804 YP.throwException(new Functor2("error", new Functor2("type_error", Atom.a("evaluable"), new Functor2("/", Name, Arity)), Atom.a("Not an expression function")));
3468 yield return false; 3805 yield return false;
3469 } 3806 }
3470 cutIf3: 3807 cutIf3:
3471 cutIf2: 3808 cutIf2:
@@ -3487,9 +3824,9 @@ namespace Temporary {
3487 public static IEnumerable<bool> unaryFunction(object arg1, object arg2) 3824 public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
3488 { 3825 {
3489 { 3826 {
3490 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) 3827 foreach (bool l2 in YP.unify(arg1, Atom.a("-")))
3491 { 3828 {
3492 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate"))) 3829 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.negate")))
3493 { 3830 {
3494 yield return true; 3831 yield return true;
3495 yield break; 3832 yield break;
@@ -3497,9 +3834,9 @@ namespace Temporary {
3497 } 3834 }
3498 } 3835 }
3499 { 3836 {
3500 foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs"))) 3837 foreach (bool l2 in YP.unify(arg1, Atom.a("abs")))
3501 { 3838 {
3502 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs"))) 3839 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.abs")))
3503 { 3840 {
3504 yield return true; 3841 yield return true;
3505 yield break; 3842 yield break;
@@ -3507,9 +3844,9 @@ namespace Temporary {
3507 } 3844 }
3508 } 3845 }
3509 { 3846 {
3510 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign"))) 3847 foreach (bool l2 in YP.unify(arg1, Atom.a("sign")))
3511 { 3848 {
3512 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign"))) 3849 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.sign")))
3513 { 3850 {
3514 yield return true; 3851 yield return true;
3515 yield break; 3852 yield break;
@@ -3517,9 +3854,9 @@ namespace Temporary {
3517 } 3854 }
3518 } 3855 }
3519 { 3856 {
3520 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) 3857 foreach (bool l2 in YP.unify(arg1, Atom.a("float")))
3521 { 3858 {
3522 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor"))) 3859 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.toFloat")))
3523 { 3860 {
3524 yield return true; 3861 yield return true;
3525 yield break; 3862 yield break;
@@ -3527,9 +3864,9 @@ namespace Temporary {
3527 } 3864 }
3528 } 3865 }
3529 { 3866 {
3530 foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate"))) 3867 foreach (bool l2 in YP.unify(arg1, Atom.a("floor")))
3531 { 3868 {
3532 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate"))) 3869 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.floor")))
3533 { 3870 {
3534 yield return true; 3871 yield return true;
3535 yield break; 3872 yield break;
@@ -3537,9 +3874,9 @@ namespace Temporary {
3537 } 3874 }
3538 } 3875 }
3539 { 3876 {
3540 foreach (bool l2 in YP.unify(arg1, Atom.a(@"round"))) 3877 foreach (bool l2 in YP.unify(arg1, Atom.a("truncate")))
3541 { 3878 {
3542 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round"))) 3879 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.truncate")))
3543 { 3880 {
3544 yield return true; 3881 yield return true;
3545 yield break; 3882 yield break;
@@ -3547,9 +3884,9 @@ namespace Temporary {
3547 } 3884 }
3548 } 3885 }
3549 { 3886 {
3550 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) 3887 foreach (bool l2 in YP.unify(arg1, Atom.a("round")))
3551 { 3888 {
3552 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling"))) 3889 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.round")))
3553 { 3890 {
3554 yield return true; 3891 yield return true;
3555 yield break; 3892 yield break;
@@ -3557,9 +3894,9 @@ namespace Temporary {
3557 } 3894 }
3558 } 3895 }
3559 { 3896 {
3560 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin"))) 3897 foreach (bool l2 in YP.unify(arg1, Atom.a("ceiling")))
3561 { 3898 {
3562 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin"))) 3899 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.ceiling")))
3563 { 3900 {
3564 yield return true; 3901 yield return true;
3565 yield break; 3902 yield break;
@@ -3567,9 +3904,9 @@ namespace Temporary {
3567 } 3904 }
3568 } 3905 }
3569 { 3906 {
3570 foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos"))) 3907 foreach (bool l2 in YP.unify(arg1, Atom.a("sin")))
3571 { 3908 {
3572 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos"))) 3909 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.sin")))
3573 { 3910 {
3574 yield return true; 3911 yield return true;
3575 yield break; 3912 yield break;
@@ -3577,9 +3914,9 @@ namespace Temporary {
3577 } 3914 }
3578 } 3915 }
3579 { 3916 {
3580 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan"))) 3917 foreach (bool l2 in YP.unify(arg1, Atom.a("cos")))
3581 { 3918 {
3582 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan"))) 3919 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.cos")))
3583 { 3920 {
3584 yield return true; 3921 yield return true;
3585 yield break; 3922 yield break;
@@ -3587,9 +3924,9 @@ namespace Temporary {
3587 } 3924 }
3588 } 3925 }
3589 { 3926 {
3590 foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp"))) 3927 foreach (bool l2 in YP.unify(arg1, Atom.a("atan")))
3591 { 3928 {
3592 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp"))) 3929 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.atan")))
3593 { 3930 {
3594 yield return true; 3931 yield return true;
3595 yield break; 3932 yield break;
@@ -3597,9 +3934,9 @@ namespace Temporary {
3597 } 3934 }
3598 } 3935 }
3599 { 3936 {
3600 foreach (bool l2 in YP.unify(arg1, Atom.a(@"log"))) 3937 foreach (bool l2 in YP.unify(arg1, Atom.a("exp")))
3601 { 3938 {
3602 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log"))) 3939 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.exp")))
3603 { 3940 {
3604 yield return true; 3941 yield return true;
3605 yield break; 3942 yield break;
@@ -3607,9 +3944,9 @@ namespace Temporary {
3607 } 3944 }
3608 } 3945 }
3609 { 3946 {
3610 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt"))) 3947 foreach (bool l2 in YP.unify(arg1, Atom.a("log")))
3611 { 3948 {
3612 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt"))) 3949 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.log")))
3613 { 3950 {
3614 yield return true; 3951 yield return true;
3615 yield break; 3952 yield break;
@@ -3617,9 +3954,19 @@ namespace Temporary {
3617 } 3954 }
3618 } 3955 }
3619 { 3956 {
3620 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\"))) 3957 foreach (bool l2 in YP.unify(arg1, Atom.a("sqrt")))
3621 { 3958 {
3622 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement"))) 3959 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.sqrt")))
3960 {
3961 yield return true;
3962 yield break;
3963 }
3964 }
3965 }
3966 {
3967 foreach (bool l2 in YP.unify(arg1, Atom.a("\\")))
3968 {
3969 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseComplement")))
3623 { 3970 {
3624 yield return true; 3971 yield return true;
3625 yield break; 3972 yield break;
@@ -3631,9 +3978,9 @@ namespace Temporary {
3631 public static IEnumerable<bool> binaryFunction(object arg1, object arg2) 3978 public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
3632 { 3979 {
3633 { 3980 {
3634 foreach (bool l2 in YP.unify(arg1, Atom.a(@"+"))) 3981 foreach (bool l2 in YP.unify(arg1, Atom.a("+")))
3635 { 3982 {
3636 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add"))) 3983 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.add")))
3637 { 3984 {
3638 yield return true; 3985 yield return true;
3639 yield break; 3986 yield break;
@@ -3641,9 +3988,9 @@ namespace Temporary {
3641 } 3988 }
3642 } 3989 }
3643 { 3990 {
3644 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) 3991 foreach (bool l2 in YP.unify(arg1, Atom.a("-")))
3645 { 3992 {
3646 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract"))) 3993 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.subtract")))
3647 { 3994 {
3648 yield return true; 3995 yield return true;
3649 yield break; 3996 yield break;
@@ -3651,9 +3998,9 @@ namespace Temporary {
3651 } 3998 }
3652 } 3999 }
3653 { 4000 {
3654 foreach (bool l2 in YP.unify(arg1, Atom.a(@"*"))) 4001 foreach (bool l2 in YP.unify(arg1, Atom.a("*")))
3655 { 4002 {
3656 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply"))) 4003 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.multiply")))
3657 { 4004 {
3658 yield return true; 4005 yield return true;
3659 yield break; 4006 yield break;
@@ -3661,9 +4008,9 @@ namespace Temporary {
3661 } 4008 }
3662 } 4009 }
3663 { 4010 {
3664 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/"))) 4011 foreach (bool l2 in YP.unify(arg1, Atom.a("/")))
3665 { 4012 {
3666 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide"))) 4013 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.divide")))
3667 { 4014 {
3668 yield return true; 4015 yield return true;
3669 yield break; 4016 yield break;
@@ -3671,9 +4018,9 @@ namespace Temporary {
3671 } 4018 }
3672 } 4019 }
3673 { 4020 {
3674 foreach (bool l2 in YP.unify(arg1, Atom.a(@"//"))) 4021 foreach (bool l2 in YP.unify(arg1, Atom.a("//")))
3675 { 4022 {
3676 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide"))) 4023 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.intDivide")))
3677 { 4024 {
3678 yield return true; 4025 yield return true;
3679 yield break; 4026 yield break;
@@ -3681,9 +4028,9 @@ namespace Temporary {
3681 } 4028 }
3682 } 4029 }
3683 { 4030 {
3684 foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod"))) 4031 foreach (bool l2 in YP.unify(arg1, Atom.a("mod")))
3685 { 4032 {
3686 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod"))) 4033 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.mod")))
3687 { 4034 {
3688 yield return true; 4035 yield return true;
3689 yield break; 4036 yield break;
@@ -3691,9 +4038,9 @@ namespace Temporary {
3691 } 4038 }
3692 } 4039 }
3693 { 4040 {
3694 foreach (bool l2 in YP.unify(arg1, Atom.a(@"**"))) 4041 foreach (bool l2 in YP.unify(arg1, Atom.a("**")))
3695 { 4042 {
3696 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow"))) 4043 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.pow")))
3697 { 4044 {
3698 yield return true; 4045 yield return true;
3699 yield break; 4046 yield break;
@@ -3701,9 +4048,9 @@ namespace Temporary {
3701 } 4048 }
3702 } 4049 }
3703 { 4050 {
3704 foreach (bool l2 in YP.unify(arg1, Atom.a(@">>"))) 4051 foreach (bool l2 in YP.unify(arg1, Atom.a(">>")))
3705 { 4052 {
3706 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight"))) 4053 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseShiftRight")))
3707 { 4054 {
3708 yield return true; 4055 yield return true;
3709 yield break; 4056 yield break;
@@ -3711,9 +4058,9 @@ namespace Temporary {
3711 } 4058 }
3712 } 4059 }
3713 { 4060 {
3714 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<"))) 4061 foreach (bool l2 in YP.unify(arg1, Atom.a("<<")))
3715 { 4062 {
3716 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft"))) 4063 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseShiftLeft")))
3717 { 4064 {
3718 yield return true; 4065 yield return true;
3719 yield break; 4066 yield break;
@@ -3721,9 +4068,9 @@ namespace Temporary {
3721 } 4068 }
3722 } 4069 }
3723 { 4070 {
3724 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\"))) 4071 foreach (bool l2 in YP.unify(arg1, Atom.a("/\\")))
3725 { 4072 {
3726 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd"))) 4073 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseAnd")))
3727 { 4074 {
3728 yield return true; 4075 yield return true;
3729 yield break; 4076 yield break;
@@ -3731,9 +4078,9 @@ namespace Temporary {
3731 } 4078 }
3732 } 4079 }
3733 { 4080 {
3734 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/"))) 4081 foreach (bool l2 in YP.unify(arg1, Atom.a("\\/")))
3735 { 4082 {
3736 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr"))) 4083 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseOr")))
3737 { 4084 {
3738 yield return true; 4085 yield return true;
3739 yield break; 4086 yield break;
@@ -3741,9 +4088,9 @@ namespace Temporary {
3741 } 4088 }
3742 } 4089 }
3743 { 4090 {
3744 foreach (bool l2 in YP.unify(arg1, Atom.a(@"min"))) 4091 foreach (bool l2 in YP.unify(arg1, Atom.a("min")))
3745 { 4092 {
3746 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min"))) 4093 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.min")))
3747 { 4094 {
3748 yield return true; 4095 yield return true;
3749 yield break; 4096 yield break;
@@ -3751,9 +4098,9 @@ namespace Temporary {
3751 } 4098 }
3752 } 4099 }
3753 { 4100 {
3754 foreach (bool l2 in YP.unify(arg1, Atom.a(@"max"))) 4101 foreach (bool l2 in YP.unify(arg1, Atom.a("max")))
3755 { 4102 {
3756 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max"))) 4103 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.max")))
3757 { 4104 {
3758 yield return true; 4105 yield return true;
3759 yield break; 4106 yield break;
@@ -3765,11 +4112,11 @@ namespace Temporary {
3765 public static void convertFunctionCSharp(object arg1) 4112 public static void convertFunctionCSharp(object arg1)
3766 { 4113 {
3767 { 4114 {
3768 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 4115 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
3769 { 4116 {
3770 YP.write(Atom.a(@"public class YPInnerClass {}")); 4117 YP.write(Atom.a("public class YPInnerClass {}"));
3771 YP.nl(); 4118 YP.nl();
3772 YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }")); 4119 YP.write(Atom.a("public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
3773 YP.nl(); 4120 YP.nl();
3774 YP.nl(); 4121 YP.nl();
3775 return; 4122 return;
@@ -3781,20 +4128,20 @@ namespace Temporary {
3781 Variable ArgList = new Variable(); 4128 Variable ArgList = new Variable();
3782 Variable Body = new Variable(); 4129 Variable Body = new Variable();
3783 Variable Level = new Variable(); 4130 Variable Level = new Variable();
3784 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body }))) 4131 foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { ReturnType, Name, ArgList, Body })))
3785 { 4132 {
3786 YP.write(Atom.a(@"public static ")); 4133 YP.write(Atom.a("public static "));
3787 YP.write(ReturnType); 4134 YP.write(ReturnType);
3788 YP.write(Atom.a(@" ")); 4135 YP.write(Atom.a(" "));
3789 YP.write(Name); 4136 YP.write(Name);
3790 YP.write(Atom.a(@"(")); 4137 YP.write(Atom.a("("));
3791 convertArgListCSharp(ArgList); 4138 convertArgListCSharp(ArgList);
3792 YP.write(Atom.a(@") {")); 4139 YP.write(Atom.a(") {"));
3793 YP.nl(); 4140 YP.nl();
3794 foreach (bool l3 in YP.unify(Level, 1)) 4141 foreach (bool l3 in YP.unify(Level, 1))
3795 { 4142 {
3796 convertStatementListCSharp(Body, Level); 4143 convertStatementListCSharp(Body, Level);
3797 YP.write(Atom.a(@"}")); 4144 YP.write(Atom.a("}"));
3798 YP.nl(); 4145 YP.nl();
3799 YP.nl(); 4146 YP.nl();
3800 return; 4147 return;
@@ -3821,9 +4168,9 @@ namespace Temporary {
3821 Variable Body = new Variable(); 4168 Variable Body = new Variable();
3822 Variable RestStatements = new Variable(); 4169 Variable RestStatements = new Variable();
3823 Variable NewStatements = new Variable(); 4170 Variable NewStatements = new Variable();
3824 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) 4171 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
3825 { 4172 {
3826 foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements)) 4173 foreach (bool l3 in append(Body, new ListPair(new Functor1("label", Name), RestStatements), NewStatements))
3827 { 4174 {
3828 convertStatementListCSharp(NewStatements, Level); 4175 convertStatementListCSharp(NewStatements, Level);
3829 return; 4176 return;
@@ -3835,15 +4182,15 @@ namespace Temporary {
3835 Variable Name = new Variable(); 4182 Variable Name = new Variable();
3836 Variable Expression = new Variable(); 4183 Variable Expression = new Variable();
3837 Variable RestStatements = new Variable(); 4184 Variable RestStatements = new Variable();
3838 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements))) 4185 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", Type, Name, Expression), RestStatements)))
3839 { 4186 {
3840 convertIndentationCSharp(Level); 4187 convertIndentationCSharp(Level);
3841 YP.write(Type); 4188 YP.write(Type);
3842 YP.write(Atom.a(@" ")); 4189 YP.write(Atom.a(" "));
3843 YP.write(Name); 4190 YP.write(Name);
3844 YP.write(Atom.a(@" = ")); 4191 YP.write(Atom.a(" = "));
3845 convertExpressionCSharp(Expression); 4192 convertExpressionCSharp(Expression);
3846 YP.write(Atom.a(@";")); 4193 YP.write(Atom.a(";"));
3847 YP.nl(); 4194 YP.nl();
3848 convertStatementListCSharp(RestStatements, Level); 4195 convertStatementListCSharp(RestStatements, Level);
3849 return; 4196 return;
@@ -3853,13 +4200,13 @@ namespace Temporary {
3853 Variable Name = new Variable(); 4200 Variable Name = new Variable();
3854 Variable Expression = new Variable(); 4201 Variable Expression = new Variable();
3855 Variable RestStatements = new Variable(); 4202 Variable RestStatements = new Variable();
3856 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) 4203 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
3857 { 4204 {
3858 convertIndentationCSharp(Level); 4205 convertIndentationCSharp(Level);
3859 YP.write(Name); 4206 YP.write(Name);
3860 YP.write(Atom.a(@" = ")); 4207 YP.write(Atom.a(" = "));
3861 convertExpressionCSharp(Expression); 4208 convertExpressionCSharp(Expression);
3862 YP.write(Atom.a(@";")); 4209 YP.write(Atom.a(";"));
3863 YP.nl(); 4210 YP.nl();
3864 convertStatementListCSharp(RestStatements, Level); 4211 convertStatementListCSharp(RestStatements, Level);
3865 return; 4212 return;
@@ -3867,10 +4214,10 @@ namespace Temporary {
3867 } 4214 }
3868 { 4215 {
3869 Variable RestStatements = new Variable(); 4216 Variable RestStatements = new Variable();
3870 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) 4217 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
3871 { 4218 {
3872 convertIndentationCSharp(Level); 4219 convertIndentationCSharp(Level);
3873 YP.write(Atom.a(@"yield return true;")); 4220 YP.write(Atom.a("yield return true;"));
3874 YP.nl(); 4221 YP.nl();
3875 convertStatementListCSharp(RestStatements, Level); 4222 convertStatementListCSharp(RestStatements, Level);
3876 return; 4223 return;
@@ -3878,10 +4225,10 @@ namespace Temporary {
3878 } 4225 }
3879 { 4226 {
3880 Variable RestStatements = new Variable(); 4227 Variable RestStatements = new Variable();
3881 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) 4228 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
3882 { 4229 {
3883 convertIndentationCSharp(Level); 4230 convertIndentationCSharp(Level);
3884 YP.write(Atom.a(@"yield return false;")); 4231 YP.write(Atom.a("yield return false;"));
3885 YP.nl(); 4232 YP.nl();
3886 convertStatementListCSharp(RestStatements, Level); 4233 convertStatementListCSharp(RestStatements, Level);
3887 return; 4234 return;
@@ -3889,10 +4236,10 @@ namespace Temporary {
3889 } 4236 }
3890 { 4237 {
3891 Variable RestStatements = new Variable(); 4238 Variable RestStatements = new Variable();
3892 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) 4239 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
3893 { 4240 {
3894 convertIndentationCSharp(Level); 4241 convertIndentationCSharp(Level);
3895 YP.write(Atom.a(@"yield break;")); 4242 YP.write(Atom.a("yield break;"));
3896 YP.nl(); 4243 YP.nl();
3897 convertStatementListCSharp(RestStatements, Level); 4244 convertStatementListCSharp(RestStatements, Level);
3898 return; 4245 return;
@@ -3900,10 +4247,10 @@ namespace Temporary {
3900 } 4247 }
3901 { 4248 {
3902 Variable RestStatements = new Variable(); 4249 Variable RestStatements = new Variable();
3903 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) 4250 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
3904 { 4251 {
3905 convertIndentationCSharp(Level); 4252 convertIndentationCSharp(Level);
3906 YP.write(Atom.a(@"return;")); 4253 YP.write(Atom.a("return;"));
3907 YP.nl(); 4254 YP.nl();
3908 convertStatementListCSharp(RestStatements, Level); 4255 convertStatementListCSharp(RestStatements, Level);
3909 return; 4256 return;
@@ -3911,10 +4258,10 @@ namespace Temporary {
3911 } 4258 }
3912 { 4259 {
3913 Variable RestStatements = new Variable(); 4260 Variable RestStatements = new Variable();
3914 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) 4261 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
3915 { 4262 {
3916 convertIndentationCSharp(Level); 4263 convertIndentationCSharp(Level);
3917 YP.write(Atom.a(@"return true;")); 4264 YP.write(Atom.a("return true;"));
3918 YP.nl(); 4265 YP.nl();
3919 convertStatementListCSharp(RestStatements, Level); 4266 convertStatementListCSharp(RestStatements, Level);
3920 return; 4267 return;
@@ -3922,10 +4269,10 @@ namespace Temporary {
3922 } 4269 }
3923 { 4270 {
3924 Variable RestStatements = new Variable(); 4271 Variable RestStatements = new Variable();
3925 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) 4272 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
3926 { 4273 {
3927 convertIndentationCSharp(Level); 4274 convertIndentationCSharp(Level);
3928 YP.write(Atom.a(@"return false;")); 4275 YP.write(Atom.a("return false;"));
3929 YP.nl(); 4276 YP.nl();
3930 convertStatementListCSharp(RestStatements, Level); 4277 convertStatementListCSharp(RestStatements, Level);
3931 return; 4278 return;
@@ -3934,36 +4281,36 @@ namespace Temporary {
3934 { 4281 {
3935 Variable Name = new Variable(); 4282 Variable Name = new Variable();
3936 Variable RestStatements = new Variable(); 4283 Variable RestStatements = new Variable();
3937 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements))) 4284 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("label", Name), RestStatements)))
3938 { 4285 {
3939 convertIndentationCSharp(Level); 4286 convertIndentationCSharp(Level);
3940 YP.write(Name); 4287 YP.write(Name);
3941 YP.write(Atom.a(@":")); 4288 YP.write(Atom.a(":"));
3942 YP.nl(); 4289 YP.nl();
3943 if (YP.termEqual(RestStatements, Atom.NIL)) 4290 if (YP.termEqual(RestStatements, Atom.NIL))
3944 { 4291 {
3945 convertIndentationCSharp(Level); 4292 convertIndentationCSharp(Level);
3946 YP.write(Atom.a(@"{}")); 4293 YP.write(Atom.a("{}"));
3947 YP.nl(); 4294 YP.nl();
3948 convertStatementListCSharp(RestStatements, Level); 4295 convertStatementListCSharp(RestStatements, Level);
3949 return; 4296 return;
3950 // goto cutIf1; 4297 goto cutIf1;
3951 } 4298 }
3952 convertStatementListCSharp(RestStatements, Level); 4299 convertStatementListCSharp(RestStatements, Level);
3953 return; 4300 return;
3954 // cutIf1: 4301 cutIf1:
3955 // { } 4302 { }
3956 } 4303 }
3957 } 4304 }
3958 { 4305 {
3959 Variable Name = new Variable(); 4306 Variable Name = new Variable();
3960 Variable RestStatements = new Variable(); 4307 Variable RestStatements = new Variable();
3961 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) 4308 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
3962 { 4309 {
3963 convertIndentationCSharp(Level); 4310 convertIndentationCSharp(Level);
3964 YP.write(Atom.a(@"goto ")); 4311 YP.write(Atom.a("goto "));
3965 YP.write(Name); 4312 YP.write(Name);
3966 YP.write(Atom.a(@";")); 4313 YP.write(Atom.a(";"));
3967 YP.nl(); 4314 YP.nl();
3968 convertStatementListCSharp(RestStatements, Level); 4315 convertStatementListCSharp(RestStatements, Level);
3969 return; 4316 return;
@@ -3973,32 +4320,43 @@ namespace Temporary {
3973 Variable Name = new Variable(); 4320 Variable Name = new Variable();
3974 Variable ArgList = new Variable(); 4321 Variable ArgList = new Variable();
3975 Variable RestStatements = new Variable(); 4322 Variable RestStatements = new Variable();
3976 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) 4323 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
3977 { 4324 {
3978 convertIndentationCSharp(Level); 4325 convertIndentationCSharp(Level);
3979 YP.write(Name); 4326 YP.write(Name);
3980 YP.write(Atom.a(@"(")); 4327 YP.write(Atom.a("("));
3981 convertArgListCSharp(ArgList); 4328 convertArgListCSharp(ArgList);
3982 YP.write(Atom.a(@");")); 4329 YP.write(Atom.a(");"));
3983 YP.nl(); 4330 YP.nl();
3984 convertStatementListCSharp(RestStatements, Level); 4331 convertStatementListCSharp(RestStatements, Level);
3985 return; 4332 return;
3986 } 4333 }
3987 } 4334 }
3988 { 4335 {
4336 Variable Name = new Variable();
4337 Variable _FunctorArgs = new Variable();
4338 Variable ArgList = new Variable();
4339 Variable RestStatements = new Variable();
4340 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
4341 {
4342 convertStatementListCSharp(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level);
4343 return;
4344 }
4345 }
4346 {
3989 Variable Obj = new Variable(); 4347 Variable Obj = new Variable();
3990 Variable Name = new Variable(); 4348 Variable Name = new Variable();
3991 Variable ArgList = new Variable(); 4349 Variable ArgList = new Variable();
3992 Variable RestStatements = new Variable(); 4350 Variable RestStatements = new Variable();
3993 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) 4351 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
3994 { 4352 {
3995 convertIndentationCSharp(Level); 4353 convertIndentationCSharp(Level);
3996 YP.write(Obj); 4354 YP.write(Obj);
3997 YP.write(Atom.a(@".")); 4355 YP.write(Atom.a("."));
3998 YP.write(Name); 4356 YP.write(Name);
3999 YP.write(Atom.a(@"(")); 4357 YP.write(Atom.a("("));
4000 convertArgListCSharp(ArgList); 4358 convertArgListCSharp(ArgList);
4001 YP.write(Atom.a(@");")); 4359 YP.write(Atom.a(");"));
4002 YP.nl(); 4360 YP.nl();
4003 convertStatementListCSharp(RestStatements, Level); 4361 convertStatementListCSharp(RestStatements, Level);
4004 return; 4362 return;
@@ -4008,16 +4366,16 @@ namespace Temporary {
4008 Variable Body = new Variable(); 4366 Variable Body = new Variable();
4009 Variable RestStatements = new Variable(); 4367 Variable RestStatements = new Variable();
4010 Variable NextLevel = new Variable(); 4368 Variable NextLevel = new Variable();
4011 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) 4369 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
4012 { 4370 {
4013 convertIndentationCSharp(Level); 4371 convertIndentationCSharp(Level);
4014 YP.write(Atom.a(@"{")); 4372 YP.write(Atom.a("{"));
4015 YP.nl(); 4373 YP.nl();
4016 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4374 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4017 { 4375 {
4018 convertStatementListCSharp(Body, NextLevel); 4376 convertStatementListCSharp(Body, NextLevel);
4019 convertIndentationCSharp(Level); 4377 convertIndentationCSharp(Level);
4020 YP.write(Atom.a(@"}")); 4378 YP.write(Atom.a("}"));
4021 YP.nl(); 4379 YP.nl();
4022 convertStatementListCSharp(RestStatements, Level); 4380 convertStatementListCSharp(RestStatements, Level);
4023 return; 4381 return;
@@ -4029,18 +4387,18 @@ namespace Temporary {
4029 Variable Body = new Variable(); 4387 Variable Body = new Variable();
4030 Variable RestStatements = new Variable(); 4388 Variable RestStatements = new Variable();
4031 Variable NextLevel = new Variable(); 4389 Variable NextLevel = new Variable();
4032 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) 4390 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
4033 { 4391 {
4034 convertIndentationCSharp(Level); 4392 convertIndentationCSharp(Level);
4035 YP.write(Atom.a(@"if (")); 4393 YP.write(Atom.a("if ("));
4036 convertExpressionCSharp(Expression); 4394 convertExpressionCSharp(Expression);
4037 YP.write(Atom.a(@") {")); 4395 YP.write(Atom.a(") {"));
4038 YP.nl(); 4396 YP.nl();
4039 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4397 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4040 { 4398 {
4041 convertStatementListCSharp(Body, NextLevel); 4399 convertStatementListCSharp(Body, NextLevel);
4042 convertIndentationCSharp(Level); 4400 convertIndentationCSharp(Level);
4043 YP.write(Atom.a(@"}")); 4401 YP.write(Atom.a("}"));
4044 YP.nl(); 4402 YP.nl();
4045 convertStatementListCSharp(RestStatements, Level); 4403 convertStatementListCSharp(RestStatements, Level);
4046 return; 4404 return;
@@ -4052,20 +4410,20 @@ namespace Temporary {
4052 Variable Body = new Variable(); 4410 Variable Body = new Variable();
4053 Variable RestStatements = new Variable(); 4411 Variable RestStatements = new Variable();
4054 Variable NextLevel = new Variable(); 4412 Variable NextLevel = new Variable();
4055 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) 4413 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
4056 { 4414 {
4057 convertIndentationCSharp(Level); 4415 convertIndentationCSharp(Level);
4058 YP.write(Atom.a(@"foreach (bool l")); 4416 YP.write(Atom.a("foreach (bool l"));
4059 YP.write(Level); 4417 YP.write(Level);
4060 YP.write(Atom.a(@" in ")); 4418 YP.write(Atom.a(" in "));
4061 convertExpressionCSharp(Expression); 4419 convertExpressionCSharp(Expression);
4062 YP.write(Atom.a(@") {")); 4420 YP.write(Atom.a(") {"));
4063 YP.nl(); 4421 YP.nl();
4064 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4422 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4065 { 4423 {
4066 convertStatementListCSharp(Body, NextLevel); 4424 convertStatementListCSharp(Body, NextLevel);
4067 convertIndentationCSharp(Level); 4425 convertIndentationCSharp(Level);
4068 YP.write(Atom.a(@"}")); 4426 YP.write(Atom.a("}"));
4069 YP.nl(); 4427 YP.nl();
4070 convertStatementListCSharp(RestStatements, Level); 4428 convertStatementListCSharp(RestStatements, Level);
4071 return; 4429 return;
@@ -4075,12 +4433,12 @@ namespace Temporary {
4075 { 4433 {
4076 Variable Expression = new Variable(); 4434 Variable Expression = new Variable();
4077 Variable RestStatements = new Variable(); 4435 Variable RestStatements = new Variable();
4078 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) 4436 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
4079 { 4437 {
4080 convertIndentationCSharp(Level); 4438 convertIndentationCSharp(Level);
4081 YP.write(Atom.a(@"throw ")); 4439 YP.write(Atom.a("throw "));
4082 convertExpressionCSharp(Expression); 4440 convertExpressionCSharp(Expression);
4083 YP.write(Atom.a(@";")); 4441 YP.write(Atom.a(";"));
4084 YP.nl(); 4442 YP.nl();
4085 convertStatementListCSharp(RestStatements, Level); 4443 convertStatementListCSharp(RestStatements, Level);
4086 return; 4444 return;
@@ -4094,7 +4452,7 @@ namespace Temporary {
4094 Variable N = new Variable(); 4452 Variable N = new Variable();
4095 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 4453 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4096 { 4454 {
4097 repeatWrite(Atom.a(@" "), N); 4455 repeatWrite(Atom.a(" "), N);
4098 return; 4456 return;
4099 } 4457 }
4100 } 4458 }
@@ -4116,15 +4474,15 @@ namespace Temporary {
4116 convertExpressionCSharp(Head); 4474 convertExpressionCSharp(Head);
4117 if (YP.termNotEqual(Tail, Atom.NIL)) 4475 if (YP.termNotEqual(Tail, Atom.NIL))
4118 { 4476 {
4119 YP.write(Atom.a(@", ")); 4477 YP.write(Atom.a(", "));
4120 convertArgListCSharp(Tail); 4478 convertArgListCSharp(Tail);
4121 return; 4479 return;
4122 // goto cutIf1; 4480 goto cutIf1;
4123 } 4481 }
4124 convertArgListCSharp(Tail); 4482 convertArgListCSharp(Tail);
4125 return; 4483 return;
4126 // cutIf1: 4484 cutIf1:
4127 // { } 4485 { }
4128 } 4486 }
4129 } 4487 }
4130 } 4488 }
@@ -4133,9 +4491,9 @@ namespace Temporary {
4133 { 4491 {
4134 { 4492 {
4135 Variable X = new Variable(); 4493 Variable X = new Variable();
4136 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 4494 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
4137 { 4495 {
4138 YP.write(Atom.a(@"object ")); 4496 YP.write(Atom.a("object "));
4139 YP.write(X); 4497 YP.write(X);
4140 return; 4498 return;
4141 } 4499 }
@@ -4143,12 +4501,22 @@ namespace Temporary {
4143 { 4501 {
4144 Variable Name = new Variable(); 4502 Variable Name = new Variable();
4145 Variable ArgList = new Variable(); 4503 Variable ArgList = new Variable();
4146 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) 4504 foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
4147 { 4505 {
4148 YP.write(Name); 4506 YP.write(Name);
4149 YP.write(Atom.a(@"(")); 4507 YP.write(Atom.a("("));
4150 convertArgListCSharp(ArgList); 4508 convertArgListCSharp(ArgList);
4151 YP.write(Atom.a(@")")); 4509 YP.write(Atom.a(")"));
4510 return;
4511 }
4512 }
4513 {
4514 Variable Name = new Variable();
4515 Variable _FunctorArgs = new Variable();
4516 Variable ArgList = new Variable();
4517 foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
4518 {
4519 convertExpressionCSharp(new Functor2("call", Name, ArgList));
4152 return; 4520 return;
4153 } 4521 }
4154 } 4522 }
@@ -4156,90 +4524,90 @@ namespace Temporary {
4156 Variable Obj = new Variable(); 4524 Variable Obj = new Variable();
4157 Variable Name = new Variable(); 4525 Variable Name = new Variable();
4158 Variable ArgList = new Variable(); 4526 Variable ArgList = new Variable();
4159 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) 4527 foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
4160 { 4528 {
4161 YP.write(Obj); 4529 YP.write(Obj);
4162 YP.write(Atom.a(@".")); 4530 YP.write(Atom.a("."));
4163 YP.write(Name); 4531 YP.write(Name);
4164 YP.write(Atom.a(@"(")); 4532 YP.write(Atom.a("("));
4165 convertArgListCSharp(ArgList); 4533 convertArgListCSharp(ArgList);
4166 YP.write(Atom.a(@")")); 4534 YP.write(Atom.a(")"));
4167 return; 4535 return;
4168 } 4536 }
4169 } 4537 }
4170 { 4538 {
4171 Variable Name = new Variable(); 4539 Variable Name = new Variable();
4172 Variable ArgList = new Variable(); 4540 Variable ArgList = new Variable();
4173 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) 4541 foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
4174 { 4542 {
4175 YP.write(Atom.a(@"new ")); 4543 YP.write(Atom.a("new "));
4176 YP.write(Name); 4544 YP.write(Name);
4177 YP.write(Atom.a(@"(")); 4545 YP.write(Atom.a("("));
4178 convertArgListCSharp(ArgList); 4546 convertArgListCSharp(ArgList);
4179 YP.write(Atom.a(@")")); 4547 YP.write(Atom.a(")"));
4180 return; 4548 return;
4181 } 4549 }
4182 } 4550 }
4183 { 4551 {
4184 Variable Name = new Variable(); 4552 Variable Name = new Variable();
4185 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 4553 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
4186 { 4554 {
4187 YP.write(Name); 4555 YP.write(Name);
4188 return; 4556 return;
4189 } 4557 }
4190 } 4558 }
4191 { 4559 {
4192 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 4560 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
4193 { 4561 {
4194 YP.write(Atom.a(@"null")); 4562 YP.write(Atom.a("null"));
4195 return; 4563 return;
4196 } 4564 }
4197 } 4565 }
4198 { 4566 {
4199 Variable X = new Variable(); 4567 Variable X = new Variable();
4200 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 4568 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
4201 { 4569 {
4202 YP.write(Atom.a(@"!(")); 4570 YP.write(Atom.a("!("));
4203 convertExpressionCSharp(X); 4571 convertExpressionCSharp(X);
4204 YP.write(Atom.a(@")")); 4572 YP.write(Atom.a(")"));
4205 return; 4573 return;
4206 } 4574 }
4207 } 4575 }
4208 { 4576 {
4209 Variable X = new Variable(); 4577 Variable X = new Variable();
4210 Variable Y = new Variable(); 4578 Variable Y = new Variable();
4211 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) 4579 foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
4212 { 4580 {
4213 YP.write(Atom.a(@"(")); 4581 YP.write(Atom.a("("));
4214 convertExpressionCSharp(X); 4582 convertExpressionCSharp(X);
4215 YP.write(Atom.a(@") && (")); 4583 YP.write(Atom.a(") && ("));
4216 convertExpressionCSharp(Y); 4584 convertExpressionCSharp(Y);
4217 YP.write(Atom.a(@")")); 4585 YP.write(Atom.a(")"));
4218 return; 4586 return;
4219 } 4587 }
4220 } 4588 }
4221 { 4589 {
4222 Variable ArgList = new Variable(); 4590 Variable ArgList = new Variable();
4223 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 4591 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
4224 { 4592 {
4225 YP.write(Atom.a(@"new object[] {")); 4593 YP.write(Atom.a("new object[] {"));
4226 convertArgListCSharp(ArgList); 4594 convertArgListCSharp(ArgList);
4227 YP.write(Atom.a(@"}")); 4595 YP.write(Atom.a("}"));
4228 return; 4596 return;
4229 } 4597 }
4230 } 4598 }
4231 { 4599 {
4232 Variable X = new Variable(); 4600 Variable X = new Variable();
4233 Variable Codes = new Variable(); 4601 Variable Codes = new Variable();
4234 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 4602 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4235 { 4603 {
4236 if (YP.atom(X)) 4604 if (YP.atom(X))
4237 { 4605 {
4238 YP.write(Atom.a(@"@""")); 4606 YP.write(Atom.a("\""));
4239 foreach (bool l4 in YP.atom_codes(X, Codes)) 4607 foreach (bool l4 in YP.atom_codes(X, Codes))
4240 { 4608 {
4241 convertStringCodesCSharp(Codes); 4609 convertStringCodesCSharp(Codes);
4242 YP.write(Atom.a(@"""")); 4610 YP.write(Atom.a("\""));
4243 return; 4611 return;
4244 } 4612 }
4245 } 4613 }
@@ -4247,7 +4615,7 @@ namespace Temporary {
4247 } 4615 }
4248 { 4616 {
4249 Variable X = new Variable(); 4617 Variable X = new Variable();
4250 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 4618 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4251 { 4619 {
4252 YP.write(X); 4620 YP.write(X);
4253 return; 4621 return;
@@ -4268,19 +4636,11 @@ namespace Temporary {
4268 Variable RestCodes = new Variable(); 4636 Variable RestCodes = new Variable();
4269 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) 4637 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4270 { 4638 {
4271 if (YP.termEqual(Code, 34)) 4639 foreach (bool l3 in putCStringCode(Code))
4272 { 4640 {
4273 YP.put_code(34);
4274 YP.put_code(Code);
4275 convertStringCodesCSharp(RestCodes); 4641 convertStringCodesCSharp(RestCodes);
4276 return; 4642 return;
4277 // goto cutIf1;
4278 } 4643 }
4279 YP.put_code(Code);
4280 convertStringCodesCSharp(RestCodes);
4281 return;
4282 // cutIf1:
4283 // { }
4284 } 4644 }
4285 } 4645 }
4286 } 4646 }
@@ -4288,9 +4648,10 @@ namespace Temporary {
4288 public static void convertFunctionJavascript(object arg1) 4648 public static void convertFunctionJavascript(object arg1)
4289 { 4649 {
4290 { 4650 {
4291 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 4651 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
4292 { 4652 {
4293 YP.write(Atom.a(@"function getDeclaringClass() { return null; }")); 4653 YP.write(Atom.a("function getDeclaringClass() { return null; }"));
4654 YP.nl();
4294 YP.nl(); 4655 YP.nl();
4295 return; 4656 return;
4296 } 4657 }
@@ -4300,16 +4661,16 @@ namespace Temporary {
4300 Variable Name = new Variable(); 4661 Variable Name = new Variable();
4301 Variable ArgList = new Variable(); 4662 Variable ArgList = new Variable();
4302 Variable Body = new Variable(); 4663 Variable Body = new Variable();
4303 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) 4664 foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { x1, Name, ArgList, Body })))
4304 { 4665 {
4305 YP.write(Atom.a(@"function ")); 4666 YP.write(Atom.a("function "));
4306 YP.write(Name); 4667 YP.write(Name);
4307 YP.write(Atom.a(@"(")); 4668 YP.write(Atom.a("("));
4308 convertArgListJavascript(ArgList); 4669 convertArgListJavascript(ArgList);
4309 YP.write(Atom.a(@") {")); 4670 YP.write(Atom.a(") {"));
4310 YP.nl(); 4671 YP.nl();
4311 convertStatementListJavascript(Body, 1); 4672 convertStatementListJavascript(Body, 1);
4312 YP.write(Atom.a(@"}")); 4673 YP.write(Atom.a("}"));
4313 YP.nl(); 4674 YP.nl();
4314 YP.nl(); 4675 YP.nl();
4315 return; 4676 return;
@@ -4332,20 +4693,20 @@ namespace Temporary {
4332 Variable Body = new Variable(); 4693 Variable Body = new Variable();
4333 Variable RestStatements = new Variable(); 4694 Variable RestStatements = new Variable();
4334 Variable NextLevel = new Variable(); 4695 Variable NextLevel = new Variable();
4335 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) 4696 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
4336 { 4697 {
4337 convertIndentationJavascript(Level); 4698 convertIndentationJavascript(Level);
4338 YP.write(Name); 4699 YP.write(Name);
4339 YP.write(Atom.a(@":")); 4700 YP.write(Atom.a(":"));
4340 YP.nl(); 4701 YP.nl();
4341 convertIndentationJavascript(Level); 4702 convertIndentationJavascript(Level);
4342 YP.write(Atom.a(@"{")); 4703 YP.write(Atom.a("{"));
4343 YP.nl(); 4704 YP.nl();
4344 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4705 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4345 { 4706 {
4346 convertStatementListJavascript(Body, NextLevel); 4707 convertStatementListJavascript(Body, NextLevel);
4347 convertIndentationJavascript(Level); 4708 convertIndentationJavascript(Level);
4348 YP.write(Atom.a(@"}")); 4709 YP.write(Atom.a("}"));
4349 YP.nl(); 4710 YP.nl();
4350 convertStatementListJavascript(RestStatements, Level); 4711 convertStatementListJavascript(RestStatements, Level);
4351 return; 4712 return;
@@ -4358,14 +4719,14 @@ namespace Temporary {
4358 Variable Name = new Variable(); 4719 Variable Name = new Variable();
4359 Variable Expression = new Variable(); 4720 Variable Expression = new Variable();
4360 Variable RestStatements = new Variable(); 4721 Variable RestStatements = new Variable();
4361 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) 4722 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", _Type, Name, Expression), RestStatements)))
4362 { 4723 {
4363 convertIndentationJavascript(Level); 4724 convertIndentationJavascript(Level);
4364 YP.write(Atom.a(@"var ")); 4725 YP.write(Atom.a("var "));
4365 YP.write(Name); 4726 YP.write(Name);
4366 YP.write(Atom.a(@" = ")); 4727 YP.write(Atom.a(" = "));
4367 convertExpressionJavascript(Expression); 4728 convertExpressionJavascript(Expression);
4368 YP.write(Atom.a(@";")); 4729 YP.write(Atom.a(";"));
4369 YP.nl(); 4730 YP.nl();
4370 convertStatementListJavascript(RestStatements, Level); 4731 convertStatementListJavascript(RestStatements, Level);
4371 return; 4732 return;
@@ -4376,13 +4737,13 @@ namespace Temporary {
4376 Variable Name = new Variable(); 4737 Variable Name = new Variable();
4377 Variable Expression = new Variable(); 4738 Variable Expression = new Variable();
4378 Variable RestStatements = new Variable(); 4739 Variable RestStatements = new Variable();
4379 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) 4740 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
4380 { 4741 {
4381 convertIndentationJavascript(Level); 4742 convertIndentationJavascript(Level);
4382 YP.write(Name); 4743 YP.write(Name);
4383 YP.write(Atom.a(@" = ")); 4744 YP.write(Atom.a(" = "));
4384 convertExpressionJavascript(Expression); 4745 convertExpressionJavascript(Expression);
4385 YP.write(Atom.a(@";")); 4746 YP.write(Atom.a(";"));
4386 YP.nl(); 4747 YP.nl();
4387 convertStatementListJavascript(RestStatements, Level); 4748 convertStatementListJavascript(RestStatements, Level);
4388 return; 4749 return;
@@ -4391,10 +4752,10 @@ namespace Temporary {
4391 { 4752 {
4392 object Level = arg2; 4753 object Level = arg2;
4393 Variable RestStatements = new Variable(); 4754 Variable RestStatements = new Variable();
4394 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) 4755 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
4395 { 4756 {
4396 convertIndentationJavascript(Level); 4757 convertIndentationJavascript(Level);
4397 YP.write(Atom.a(@"yield true;")); 4758 YP.write(Atom.a("yield true;"));
4398 YP.nl(); 4759 YP.nl();
4399 convertStatementListJavascript(RestStatements, Level); 4760 convertStatementListJavascript(RestStatements, Level);
4400 return; 4761 return;
@@ -4403,10 +4764,10 @@ namespace Temporary {
4403 { 4764 {
4404 object Level = arg2; 4765 object Level = arg2;
4405 Variable RestStatements = new Variable(); 4766 Variable RestStatements = new Variable();
4406 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) 4767 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
4407 { 4768 {
4408 convertIndentationJavascript(Level); 4769 convertIndentationJavascript(Level);
4409 YP.write(Atom.a(@"yield false;")); 4770 YP.write(Atom.a("yield false;"));
4410 YP.nl(); 4771 YP.nl();
4411 convertStatementListJavascript(RestStatements, Level); 4772 convertStatementListJavascript(RestStatements, Level);
4412 return; 4773 return;
@@ -4415,10 +4776,10 @@ namespace Temporary {
4415 { 4776 {
4416 object Level = arg2; 4777 object Level = arg2;
4417 Variable RestStatements = new Variable(); 4778 Variable RestStatements = new Variable();
4418 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) 4779 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
4419 { 4780 {
4420 convertIndentationJavascript(Level); 4781 convertIndentationJavascript(Level);
4421 YP.write(Atom.a(@"return;")); 4782 YP.write(Atom.a("return;"));
4422 YP.nl(); 4783 YP.nl();
4423 convertStatementListJavascript(RestStatements, Level); 4784 convertStatementListJavascript(RestStatements, Level);
4424 return; 4785 return;
@@ -4427,10 +4788,10 @@ namespace Temporary {
4427 { 4788 {
4428 object Level = arg2; 4789 object Level = arg2;
4429 Variable RestStatements = new Variable(); 4790 Variable RestStatements = new Variable();
4430 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) 4791 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
4431 { 4792 {
4432 convertIndentationJavascript(Level); 4793 convertIndentationJavascript(Level);
4433 YP.write(Atom.a(@"return;")); 4794 YP.write(Atom.a("return;"));
4434 YP.nl(); 4795 YP.nl();
4435 convertStatementListJavascript(RestStatements, Level); 4796 convertStatementListJavascript(RestStatements, Level);
4436 return; 4797 return;
@@ -4439,10 +4800,10 @@ namespace Temporary {
4439 { 4800 {
4440 object Level = arg2; 4801 object Level = arg2;
4441 Variable RestStatements = new Variable(); 4802 Variable RestStatements = new Variable();
4442 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) 4803 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
4443 { 4804 {
4444 convertIndentationJavascript(Level); 4805 convertIndentationJavascript(Level);
4445 YP.write(Atom.a(@"return true;")); 4806 YP.write(Atom.a("return true;"));
4446 YP.nl(); 4807 YP.nl();
4447 convertStatementListJavascript(RestStatements, Level); 4808 convertStatementListJavascript(RestStatements, Level);
4448 return; 4809 return;
@@ -4451,10 +4812,10 @@ namespace Temporary {
4451 { 4812 {
4452 object Level = arg2; 4813 object Level = arg2;
4453 Variable RestStatements = new Variable(); 4814 Variable RestStatements = new Variable();
4454 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) 4815 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
4455 { 4816 {
4456 convertIndentationJavascript(Level); 4817 convertIndentationJavascript(Level);
4457 YP.write(Atom.a(@"return false;")); 4818 YP.write(Atom.a("return false;"));
4458 YP.nl(); 4819 YP.nl();
4459 convertStatementListJavascript(RestStatements, Level); 4820 convertStatementListJavascript(RestStatements, Level);
4460 return; 4821 return;
@@ -4464,12 +4825,12 @@ namespace Temporary {
4464 object Level = arg2; 4825 object Level = arg2;
4465 Variable Name = new Variable(); 4826 Variable Name = new Variable();
4466 Variable RestStatements = new Variable(); 4827 Variable RestStatements = new Variable();
4467 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) 4828 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
4468 { 4829 {
4469 convertIndentationJavascript(Level); 4830 convertIndentationJavascript(Level);
4470 YP.write(Atom.a(@"break ")); 4831 YP.write(Atom.a("break "));
4471 YP.write(Name); 4832 YP.write(Name);
4472 YP.write(Atom.a(@";")); 4833 YP.write(Atom.a(";"));
4473 YP.nl(); 4834 YP.nl();
4474 convertStatementListJavascript(RestStatements, Level); 4835 convertStatementListJavascript(RestStatements, Level);
4475 return; 4836 return;
@@ -4480,13 +4841,13 @@ namespace Temporary {
4480 Variable Name = new Variable(); 4841 Variable Name = new Variable();
4481 Variable ArgList = new Variable(); 4842 Variable ArgList = new Variable();
4482 Variable RestStatements = new Variable(); 4843 Variable RestStatements = new Variable();
4483 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) 4844 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
4484 { 4845 {
4485 convertIndentationJavascript(Level); 4846 convertIndentationJavascript(Level);
4486 YP.write(Name); 4847 YP.write(Name);
4487 YP.write(Atom.a(@"(")); 4848 YP.write(Atom.a("("));
4488 convertArgListJavascript(ArgList); 4849 convertArgListJavascript(ArgList);
4489 YP.write(Atom.a(@");")); 4850 YP.write(Atom.a(");"));
4490 YP.nl(); 4851 YP.nl();
4491 convertStatementListJavascript(RestStatements, Level); 4852 convertStatementListJavascript(RestStatements, Level);
4492 return; 4853 return;
@@ -4494,19 +4855,31 @@ namespace Temporary {
4494 } 4855 }
4495 { 4856 {
4496 object Level = arg2; 4857 object Level = arg2;
4858 Variable Name = new Variable();
4859 Variable _FunctorArgs = new Variable();
4860 Variable ArgList = new Variable();
4861 Variable RestStatements = new Variable();
4862 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
4863 {
4864 convertStatementListJavascript(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level);
4865 return;
4866 }
4867 }
4868 {
4869 object Level = arg2;
4497 Variable Obj = new Variable(); 4870 Variable Obj = new Variable();
4498 Variable Name = new Variable(); 4871 Variable Name = new Variable();
4499 Variable ArgList = new Variable(); 4872 Variable ArgList = new Variable();
4500 Variable RestStatements = new Variable(); 4873 Variable RestStatements = new Variable();
4501 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) 4874 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
4502 { 4875 {
4503 convertIndentationJavascript(Level); 4876 convertIndentationJavascript(Level);
4504 YP.write(Obj); 4877 YP.write(Obj);
4505 YP.write(Atom.a(@".")); 4878 YP.write(Atom.a("."));
4506 YP.write(Name); 4879 YP.write(Name);
4507 YP.write(Atom.a(@"(")); 4880 YP.write(Atom.a("("));
4508 convertArgListJavascript(ArgList); 4881 convertArgListJavascript(ArgList);
4509 YP.write(Atom.a(@");")); 4882 YP.write(Atom.a(");"));
4510 YP.nl(); 4883 YP.nl();
4511 convertStatementListJavascript(RestStatements, Level); 4884 convertStatementListJavascript(RestStatements, Level);
4512 return; 4885 return;
@@ -4517,16 +4890,16 @@ namespace Temporary {
4517 Variable Body = new Variable(); 4890 Variable Body = new Variable();
4518 Variable RestStatements = new Variable(); 4891 Variable RestStatements = new Variable();
4519 Variable NextLevel = new Variable(); 4892 Variable NextLevel = new Variable();
4520 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) 4893 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
4521 { 4894 {
4522 convertIndentationJavascript(Level); 4895 convertIndentationJavascript(Level);
4523 YP.write(Atom.a(@"{")); 4896 YP.write(Atom.a("{"));
4524 YP.nl(); 4897 YP.nl();
4525 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4898 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4526 { 4899 {
4527 convertStatementListJavascript(Body, NextLevel); 4900 convertStatementListJavascript(Body, NextLevel);
4528 convertIndentationJavascript(Level); 4901 convertIndentationJavascript(Level);
4529 YP.write(Atom.a(@"}")); 4902 YP.write(Atom.a("}"));
4530 YP.nl(); 4903 YP.nl();
4531 convertStatementListJavascript(RestStatements, Level); 4904 convertStatementListJavascript(RestStatements, Level);
4532 return; 4905 return;
@@ -4539,18 +4912,18 @@ namespace Temporary {
4539 Variable Body = new Variable(); 4912 Variable Body = new Variable();
4540 Variable RestStatements = new Variable(); 4913 Variable RestStatements = new Variable();
4541 Variable NextLevel = new Variable(); 4914 Variable NextLevel = new Variable();
4542 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) 4915 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
4543 { 4916 {
4544 convertIndentationJavascript(Level); 4917 convertIndentationJavascript(Level);
4545 YP.write(Atom.a(@"if (")); 4918 YP.write(Atom.a("if ("));
4546 convertExpressionJavascript(Expression); 4919 convertExpressionJavascript(Expression);
4547 YP.write(Atom.a(@") {")); 4920 YP.write(Atom.a(") {"));
4548 YP.nl(); 4921 YP.nl();
4549 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4922 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4550 { 4923 {
4551 convertStatementListJavascript(Body, NextLevel); 4924 convertStatementListJavascript(Body, NextLevel);
4552 convertIndentationJavascript(Level); 4925 convertIndentationJavascript(Level);
4553 YP.write(Atom.a(@"}")); 4926 YP.write(Atom.a("}"));
4554 YP.nl(); 4927 YP.nl();
4555 convertStatementListJavascript(RestStatements, Level); 4928 convertStatementListJavascript(RestStatements, Level);
4556 return; 4929 return;
@@ -4563,20 +4936,20 @@ namespace Temporary {
4563 Variable Body = new Variable(); 4936 Variable Body = new Variable();
4564 Variable RestStatements = new Variable(); 4937 Variable RestStatements = new Variable();
4565 Variable NextLevel = new Variable(); 4938 Variable NextLevel = new Variable();
4566 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) 4939 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
4567 { 4940 {
4568 convertIndentationJavascript(Level); 4941 convertIndentationJavascript(Level);
4569 YP.write(Atom.a(@"for each (var l")); 4942 YP.write(Atom.a("for each (var l"));
4570 YP.write(Level); 4943 YP.write(Level);
4571 YP.write(Atom.a(@" in ")); 4944 YP.write(Atom.a(" in "));
4572 convertExpressionJavascript(Expression); 4945 convertExpressionJavascript(Expression);
4573 YP.write(Atom.a(@") {")); 4946 YP.write(Atom.a(") {"));
4574 YP.nl(); 4947 YP.nl();
4575 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4948 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4576 { 4949 {
4577 convertStatementListJavascript(Body, NextLevel); 4950 convertStatementListJavascript(Body, NextLevel);
4578 convertIndentationJavascript(Level); 4951 convertIndentationJavascript(Level);
4579 YP.write(Atom.a(@"}")); 4952 YP.write(Atom.a("}"));
4580 YP.nl(); 4953 YP.nl();
4581 convertStatementListJavascript(RestStatements, Level); 4954 convertStatementListJavascript(RestStatements, Level);
4582 return; 4955 return;
@@ -4587,12 +4960,12 @@ namespace Temporary {
4587 object Level = arg2; 4960 object Level = arg2;
4588 Variable Expression = new Variable(); 4961 Variable Expression = new Variable();
4589 Variable RestStatements = new Variable(); 4962 Variable RestStatements = new Variable();
4590 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) 4963 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
4591 { 4964 {
4592 convertIndentationJavascript(Level); 4965 convertIndentationJavascript(Level);
4593 YP.write(Atom.a(@"throw ")); 4966 YP.write(Atom.a("throw "));
4594 convertExpressionJavascript(Expression); 4967 convertExpressionJavascript(Expression);
4595 YP.write(Atom.a(@";")); 4968 YP.write(Atom.a(";"));
4596 YP.nl(); 4969 YP.nl();
4597 convertStatementListJavascript(RestStatements, Level); 4970 convertStatementListJavascript(RestStatements, Level);
4598 return; 4971 return;
@@ -4606,7 +4979,7 @@ namespace Temporary {
4606 Variable N = new Variable(); 4979 Variable N = new Variable();
4607 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 4980 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4608 { 4981 {
4609 repeatWrite(Atom.a(@" "), N); 4982 repeatWrite(Atom.a(" "), N);
4610 return; 4983 return;
4611 } 4984 }
4612 } 4985 }
@@ -4628,15 +5001,15 @@ namespace Temporary {
4628 convertExpressionJavascript(Head); 5001 convertExpressionJavascript(Head);
4629 if (YP.termNotEqual(Tail, Atom.NIL)) 5002 if (YP.termNotEqual(Tail, Atom.NIL))
4630 { 5003 {
4631 YP.write(Atom.a(@", ")); 5004 YP.write(Atom.a(", "));
4632 convertArgListJavascript(Tail); 5005 convertArgListJavascript(Tail);
4633 return; 5006 return;
4634 // goto cutIf1; 5007 goto cutIf1;
4635 } 5008 }
4636 convertArgListJavascript(Tail); 5009 convertArgListJavascript(Tail);
4637 return; 5010 return;
4638 // cutIf1: 5011 cutIf1:
4639 // { } 5012 { }
4640 } 5013 }
4641 } 5014 }
4642 } 5015 }
@@ -4645,7 +5018,7 @@ namespace Temporary {
4645 { 5018 {
4646 { 5019 {
4647 Variable X = new Variable(); 5020 Variable X = new Variable();
4648 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 5021 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
4649 { 5022 {
4650 YP.write(X); 5023 YP.write(X);
4651 return; 5024 return;
@@ -4654,12 +5027,22 @@ namespace Temporary {
4654 { 5027 {
4655 Variable Name = new Variable(); 5028 Variable Name = new Variable();
4656 Variable ArgList = new Variable(); 5029 Variable ArgList = new Variable();
4657 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) 5030 foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
4658 { 5031 {
4659 YP.write(Name); 5032 YP.write(Name);
4660 YP.write(Atom.a(@"(")); 5033 YP.write(Atom.a("("));
4661 convertArgListJavascript(ArgList); 5034 convertArgListJavascript(ArgList);
4662 YP.write(Atom.a(@")")); 5035 YP.write(Atom.a(")"));
5036 return;
5037 }
5038 }
5039 {
5040 Variable Name = new Variable();
5041 Variable _FunctorArgs = new Variable();
5042 Variable ArgList = new Variable();
5043 foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
5044 {
5045 convertExpressionJavascript(new Functor2("call", Name, ArgList));
4663 return; 5046 return;
4664 } 5047 }
4665 } 5048 }
@@ -4667,90 +5050,90 @@ namespace Temporary {
4667 Variable Obj = new Variable(); 5050 Variable Obj = new Variable();
4668 Variable Name = new Variable(); 5051 Variable Name = new Variable();
4669 Variable ArgList = new Variable(); 5052 Variable ArgList = new Variable();
4670 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) 5053 foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
4671 { 5054 {
4672 YP.write(Obj); 5055 YP.write(Obj);
4673 YP.write(Atom.a(@".")); 5056 YP.write(Atom.a("."));
4674 YP.write(Name); 5057 YP.write(Name);
4675 YP.write(Atom.a(@"(")); 5058 YP.write(Atom.a("("));
4676 convertArgListJavascript(ArgList); 5059 convertArgListJavascript(ArgList);
4677 YP.write(Atom.a(@")")); 5060 YP.write(Atom.a(")"));
4678 return; 5061 return;
4679 } 5062 }
4680 } 5063 }
4681 { 5064 {
4682 Variable Name = new Variable(); 5065 Variable Name = new Variable();
4683 Variable ArgList = new Variable(); 5066 Variable ArgList = new Variable();
4684 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) 5067 foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
4685 { 5068 {
4686 YP.write(Atom.a(@"new ")); 5069 YP.write(Atom.a("new "));
4687 YP.write(Name); 5070 YP.write(Name);
4688 YP.write(Atom.a(@"(")); 5071 YP.write(Atom.a("("));
4689 convertArgListJavascript(ArgList); 5072 convertArgListJavascript(ArgList);
4690 YP.write(Atom.a(@")")); 5073 YP.write(Atom.a(")"));
4691 return; 5074 return;
4692 } 5075 }
4693 } 5076 }
4694 { 5077 {
4695 Variable Name = new Variable(); 5078 Variable Name = new Variable();
4696 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 5079 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
4697 { 5080 {
4698 YP.write(Name); 5081 YP.write(Name);
4699 return; 5082 return;
4700 } 5083 }
4701 } 5084 }
4702 { 5085 {
4703 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 5086 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
4704 { 5087 {
4705 YP.write(Atom.a(@"null")); 5088 YP.write(Atom.a("null"));
4706 return; 5089 return;
4707 } 5090 }
4708 } 5091 }
4709 { 5092 {
4710 Variable X = new Variable(); 5093 Variable X = new Variable();
4711 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 5094 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
4712 { 5095 {
4713 YP.write(Atom.a(@"!(")); 5096 YP.write(Atom.a("!("));
4714 convertExpressionJavascript(X); 5097 convertExpressionJavascript(X);
4715 YP.write(Atom.a(@")")); 5098 YP.write(Atom.a(")"));
4716 return; 5099 return;
4717 } 5100 }
4718 } 5101 }
4719 { 5102 {
4720 Variable X = new Variable(); 5103 Variable X = new Variable();
4721 Variable Y = new Variable(); 5104 Variable Y = new Variable();
4722 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) 5105 foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
4723 { 5106 {
4724 YP.write(Atom.a(@"(")); 5107 YP.write(Atom.a("("));
4725 convertExpressionJavascript(X); 5108 convertExpressionJavascript(X);
4726 YP.write(Atom.a(@") && (")); 5109 YP.write(Atom.a(") && ("));
4727 convertExpressionJavascript(Y); 5110 convertExpressionJavascript(Y);
4728 YP.write(Atom.a(@")")); 5111 YP.write(Atom.a(")"));
4729 return; 5112 return;
4730 } 5113 }
4731 } 5114 }
4732 { 5115 {
4733 Variable ArgList = new Variable(); 5116 Variable ArgList = new Variable();
4734 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 5117 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
4735 { 5118 {
4736 YP.write(Atom.a(@"[")); 5119 YP.write(Atom.a("["));
4737 convertArgListJavascript(ArgList); 5120 convertArgListJavascript(ArgList);
4738 YP.write(Atom.a(@"]")); 5121 YP.write(Atom.a("]"));
4739 return; 5122 return;
4740 } 5123 }
4741 } 5124 }
4742 { 5125 {
4743 Variable X = new Variable(); 5126 Variable X = new Variable();
4744 Variable Codes = new Variable(); 5127 Variable Codes = new Variable();
4745 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5128 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4746 { 5129 {
4747 if (YP.atom(X)) 5130 if (YP.atom(X))
4748 { 5131 {
4749 YP.write(Atom.a(@"""")); 5132 YP.write(Atom.a("\""));
4750 foreach (bool l4 in YP.atom_codes(X, Codes)) 5133 foreach (bool l4 in YP.atom_codes(X, Codes))
4751 { 5134 {
4752 convertStringCodesJavascript(Codes); 5135 convertStringCodesJavascript(Codes);
4753 YP.write(Atom.a(@"""")); 5136 YP.write(Atom.a("\""));
4754 return; 5137 return;
4755 } 5138 }
4756 } 5139 }
@@ -4758,7 +5141,7 @@ namespace Temporary {
4758 } 5141 }
4759 { 5142 {
4760 Variable X = new Variable(); 5143 Variable X = new Variable();
4761 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5144 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4762 { 5145 {
4763 YP.write(X); 5146 YP.write(X);
4764 return; 5147 return;
@@ -4779,27 +5162,11 @@ namespace Temporary {
4779 Variable RestCodes = new Variable(); 5162 Variable RestCodes = new Variable();
4780 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) 5163 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4781 { 5164 {
4782 if (YP.termEqual(Code, 34)) 5165 foreach (bool l3 in putCStringCode(Code))
4783 { 5166 {
4784 YP.put_code(92);
4785 YP.put_code(Code);
4786 convertStringCodesJavascript(RestCodes); 5167 convertStringCodesJavascript(RestCodes);
4787 return; 5168 return;
4788 // goto cutIf1;
4789 } 5169 }
4790 if (YP.termEqual(Code, 92))
4791 {
4792 YP.put_code(92);
4793 YP.put_code(Code);
4794 convertStringCodesJavascript(RestCodes);
4795 return;
4796 // goto cutIf1;
4797 }
4798 YP.put_code(Code);
4799 convertStringCodesJavascript(RestCodes);
4800 return;
4801 // cutIf1:
4802 // { }
4803 } 5170 }
4804 } 5171 }
4805 } 5172 }
@@ -4807,11 +5174,11 @@ namespace Temporary {
4807 public static void convertFunctionPython(object arg1) 5174 public static void convertFunctionPython(object arg1)
4808 { 5175 {
4809 { 5176 {
4810 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 5177 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
4811 { 5178 {
4812 YP.write(Atom.a(@"def getDeclaringClass():")); 5179 YP.write(Atom.a("def getDeclaringClass():"));
4813 YP.nl(); 5180 YP.nl();
4814 YP.write(Atom.a(@" return None")); 5181 YP.write(Atom.a(" return None"));
4815 YP.nl(); 5182 YP.nl();
4816 YP.nl(); 5183 YP.nl();
4817 return; 5184 return;
@@ -4824,13 +5191,13 @@ namespace Temporary {
4824 Variable Body = new Variable(); 5191 Variable Body = new Variable();
4825 Variable Level = new Variable(); 5192 Variable Level = new Variable();
4826 Variable HasBreakableBlock = new Variable(); 5193 Variable HasBreakableBlock = new Variable();
4827 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) 5194 foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { x1, Name, ArgList, Body })))
4828 { 5195 {
4829 YP.write(Atom.a(@"def ")); 5196 YP.write(Atom.a("def "));
4830 YP.write(Name); 5197 YP.write(Name);
4831 YP.write(Atom.a(@"(")); 5198 YP.write(Atom.a("("));
4832 convertArgListPython(ArgList); 5199 convertArgListPython(ArgList);
4833 YP.write(Atom.a(@"):")); 5200 YP.write(Atom.a("):"));
4834 YP.nl(); 5201 YP.nl();
4835 foreach (bool l3 in YP.unify(Level, 1)) 5202 foreach (bool l3 in YP.unify(Level, 1))
4836 { 5203 {
@@ -4841,7 +5208,7 @@ namespace Temporary {
4841 if (YP.termEqual(HasBreakableBlock, 1)) 5208 if (YP.termEqual(HasBreakableBlock, 1))
4842 { 5209 {
4843 convertIndentationPython(Level); 5210 convertIndentationPython(Level);
4844 YP.write(Atom.a(@"doBreak = False")); 5211 YP.write(Atom.a("doBreak = False"));
4845 YP.nl(); 5212 YP.nl();
4846 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock)) 5213 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
4847 { 5214 {
@@ -4865,7 +5232,7 @@ namespace Temporary {
4865 if (YP.termEqual(HasBreakableBlock, 1)) 5232 if (YP.termEqual(HasBreakableBlock, 1))
4866 { 5233 {
4867 convertIndentationPython(Level); 5234 convertIndentationPython(Level);
4868 YP.write(Atom.a(@"doBreak = False")); 5235 YP.write(Atom.a("doBreak = False"));
4869 YP.nl(); 5236 YP.nl();
4870 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) 5237 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4871 { 5238 {
@@ -4895,7 +5262,7 @@ namespace Temporary {
4895 Variable _Name = new Variable(); 5262 Variable _Name = new Variable();
4896 Variable _Body = new Variable(); 5263 Variable _Body = new Variable();
4897 Variable _RestStatements = new Variable(); 5264 Variable _RestStatements = new Variable();
4898 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements))) 5265 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", _Name, _Body), _RestStatements)))
4899 { 5266 {
4900 return true; 5267 return true;
4901 } 5268 }
@@ -4903,7 +5270,7 @@ namespace Temporary {
4903 { 5270 {
4904 Variable Body = new Variable(); 5271 Variable Body = new Variable();
4905 Variable _RestStatements = new Variable(); 5272 Variable _RestStatements = new Variable();
4906 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements))) 5273 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), _RestStatements)))
4907 { 5274 {
4908 if (hasBreakableBlockPython(Body)) 5275 if (hasBreakableBlockPython(Body))
4909 { 5276 {
@@ -4915,7 +5282,7 @@ namespace Temporary {
4915 Variable _Expression = new Variable(); 5282 Variable _Expression = new Variable();
4916 Variable Body = new Variable(); 5283 Variable Body = new Variable();
4917 Variable _RestStatements = new Variable(); 5284 Variable _RestStatements = new Variable();
4918 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements))) 5285 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", _Expression, Body), _RestStatements)))
4919 { 5286 {
4920 if (hasBreakableBlockPython(Body)) 5287 if (hasBreakableBlockPython(Body))
4921 { 5288 {
@@ -4927,7 +5294,7 @@ namespace Temporary {
4927 Variable _Expression = new Variable(); 5294 Variable _Expression = new Variable();
4928 Variable Body = new Variable(); 5295 Variable Body = new Variable();
4929 Variable _RestStatements = new Variable(); 5296 Variable _RestStatements = new Variable();
4930 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements))) 5297 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", _Expression, Body), _RestStatements)))
4931 { 5298 {
4932 if (hasBreakableBlockPython(Body)) 5299 if (hasBreakableBlockPython(Body))
4933 { 5300 {
@@ -4967,32 +5334,32 @@ namespace Temporary {
4967 Variable Body = new Variable(); 5334 Variable Body = new Variable();
4968 Variable RestStatements = new Variable(); 5335 Variable RestStatements = new Variable();
4969 Variable NextLevel = new Variable(); 5336 Variable NextLevel = new Variable();
4970 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) 5337 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
4971 { 5338 {
4972 convertIndentationPython(Level); 5339 convertIndentationPython(Level);
4973 YP.write(Name); 5340 YP.write(Name);
4974 YP.write(Atom.a(@" = False")); 5341 YP.write(Atom.a(" = False"));
4975 YP.nl(); 5342 YP.nl();
4976 convertIndentationPython(Level); 5343 convertIndentationPython(Level);
4977 YP.write(Atom.a(@"for _ in [1]:")); 5344 YP.write(Atom.a("for _ in [1]:"));
4978 YP.nl(); 5345 YP.nl();
4979 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5346 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4980 { 5347 {
4981 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) 5348 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
4982 { 5349 {
4983 convertIndentationPython(Level); 5350 convertIndentationPython(Level);
4984 YP.write(Atom.a(@"if ")); 5351 YP.write(Atom.a("if "));
4985 YP.write(Name); 5352 YP.write(Name);
4986 YP.write(Atom.a(@":")); 5353 YP.write(Atom.a(":"));
4987 YP.nl(); 5354 YP.nl();
4988 convertIndentationPython(NextLevel); 5355 convertIndentationPython(NextLevel);
4989 YP.write(Atom.a(@"doBreak = False")); 5356 YP.write(Atom.a("doBreak = False"));
4990 YP.nl(); 5357 YP.nl();
4991 convertIndentationPython(Level); 5358 convertIndentationPython(Level);
4992 YP.write(Atom.a(@"if doBreak:")); 5359 YP.write(Atom.a("if doBreak:"));
4993 YP.nl(); 5360 YP.nl();
4994 convertIndentationPython(NextLevel); 5361 convertIndentationPython(NextLevel);
4995 YP.write(Atom.a(@"break")); 5362 YP.write(Atom.a("break"));
4996 YP.nl(); 5363 YP.nl();
4997 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5364 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
4998 { 5365 {
@@ -5010,11 +5377,11 @@ namespace Temporary {
5010 Variable Name = new Variable(); 5377 Variable Name = new Variable();
5011 Variable Expression = new Variable(); 5378 Variable Expression = new Variable();
5012 Variable RestStatements = new Variable(); 5379 Variable RestStatements = new Variable();
5013 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) 5380 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", _Type, Name, Expression), RestStatements)))
5014 { 5381 {
5015 convertIndentationPython(Level); 5382 convertIndentationPython(Level);
5016 YP.write(Name); 5383 YP.write(Name);
5017 YP.write(Atom.a(@" = ")); 5384 YP.write(Atom.a(" = "));
5018 convertExpressionPython(Expression); 5385 convertExpressionPython(Expression);
5019 YP.nl(); 5386 YP.nl();
5020 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5387 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5030,11 +5397,11 @@ namespace Temporary {
5030 Variable Name = new Variable(); 5397 Variable Name = new Variable();
5031 Variable Expression = new Variable(); 5398 Variable Expression = new Variable();
5032 Variable RestStatements = new Variable(); 5399 Variable RestStatements = new Variable();
5033 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) 5400 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
5034 { 5401 {
5035 convertIndentationPython(Level); 5402 convertIndentationPython(Level);
5036 YP.write(Name); 5403 YP.write(Name);
5037 YP.write(Atom.a(@" = ")); 5404 YP.write(Atom.a(" = "));
5038 convertExpressionPython(Expression); 5405 convertExpressionPython(Expression);
5039 YP.nl(); 5406 YP.nl();
5040 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5407 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5048,10 +5415,10 @@ namespace Temporary {
5048 object Level = arg2; 5415 object Level = arg2;
5049 object HasBreakableBlock = arg3; 5416 object HasBreakableBlock = arg3;
5050 Variable RestStatements = new Variable(); 5417 Variable RestStatements = new Variable();
5051 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) 5418 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
5052 { 5419 {
5053 convertIndentationPython(Level); 5420 convertIndentationPython(Level);
5054 YP.write(Atom.a(@"yield True")); 5421 YP.write(Atom.a("yield True"));
5055 YP.nl(); 5422 YP.nl();
5056 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5423 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5057 { 5424 {
@@ -5064,10 +5431,10 @@ namespace Temporary {
5064 object Level = arg2; 5431 object Level = arg2;
5065 object HasBreakableBlock = arg3; 5432 object HasBreakableBlock = arg3;
5066 Variable RestStatements = new Variable(); 5433 Variable RestStatements = new Variable();
5067 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) 5434 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
5068 { 5435 {
5069 convertIndentationPython(Level); 5436 convertIndentationPython(Level);
5070 YP.write(Atom.a(@"yield False")); 5437 YP.write(Atom.a("yield False"));
5071 YP.nl(); 5438 YP.nl();
5072 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5439 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5073 { 5440 {
@@ -5080,10 +5447,10 @@ namespace Temporary {
5080 object Level = arg2; 5447 object Level = arg2;
5081 object HasBreakableBlock = arg3; 5448 object HasBreakableBlock = arg3;
5082 Variable RestStatements = new Variable(); 5449 Variable RestStatements = new Variable();
5083 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) 5450 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
5084 { 5451 {
5085 convertIndentationPython(Level); 5452 convertIndentationPython(Level);
5086 YP.write(Atom.a(@"return")); 5453 YP.write(Atom.a("return"));
5087 YP.nl(); 5454 YP.nl();
5088 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5455 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5089 { 5456 {
@@ -5096,10 +5463,10 @@ namespace Temporary {
5096 object Level = arg2; 5463 object Level = arg2;
5097 object HasBreakableBlock = arg3; 5464 object HasBreakableBlock = arg3;
5098 Variable RestStatements = new Variable(); 5465 Variable RestStatements = new Variable();
5099 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) 5466 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
5100 { 5467 {
5101 convertIndentationPython(Level); 5468 convertIndentationPython(Level);
5102 YP.write(Atom.a(@"return")); 5469 YP.write(Atom.a("return"));
5103 YP.nl(); 5470 YP.nl();
5104 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5471 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5105 { 5472 {
@@ -5112,10 +5479,10 @@ namespace Temporary {
5112 object Level = arg2; 5479 object Level = arg2;
5113 object HasBreakableBlock = arg3; 5480 object HasBreakableBlock = arg3;
5114 Variable RestStatements = new Variable(); 5481 Variable RestStatements = new Variable();
5115 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) 5482 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
5116 { 5483 {
5117 convertIndentationPython(Level); 5484 convertIndentationPython(Level);
5118 YP.write(Atom.a(@"return True")); 5485 YP.write(Atom.a("return True"));
5119 YP.nl(); 5486 YP.nl();
5120 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5487 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5121 { 5488 {
@@ -5128,10 +5495,10 @@ namespace Temporary {
5128 object Level = arg2; 5495 object Level = arg2;
5129 object HasBreakableBlock = arg3; 5496 object HasBreakableBlock = arg3;
5130 Variable RestStatements = new Variable(); 5497 Variable RestStatements = new Variable();
5131 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) 5498 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
5132 { 5499 {
5133 convertIndentationPython(Level); 5500 convertIndentationPython(Level);
5134 YP.write(Atom.a(@"return False")); 5501 YP.write(Atom.a("return False"));
5135 YP.nl(); 5502 YP.nl();
5136 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5503 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5137 { 5504 {
@@ -5145,17 +5512,17 @@ namespace Temporary {
5145 object HasBreakableBlock = arg3; 5512 object HasBreakableBlock = arg3;
5146 Variable Name = new Variable(); 5513 Variable Name = new Variable();
5147 Variable RestStatements = new Variable(); 5514 Variable RestStatements = new Variable();
5148 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) 5515 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
5149 { 5516 {
5150 convertIndentationPython(Level); 5517 convertIndentationPython(Level);
5151 YP.write(Name); 5518 YP.write(Name);
5152 YP.write(Atom.a(@" = True")); 5519 YP.write(Atom.a(" = True"));
5153 YP.nl(); 5520 YP.nl();
5154 convertIndentationPython(Level); 5521 convertIndentationPython(Level);
5155 YP.write(Atom.a(@"doBreak = True")); 5522 YP.write(Atom.a("doBreak = True"));
5156 YP.nl(); 5523 YP.nl();
5157 convertIndentationPython(Level); 5524 convertIndentationPython(Level);
5158 YP.write(Atom.a(@"break")); 5525 YP.write(Atom.a("break"));
5159 YP.nl(); 5526 YP.nl();
5160 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5527 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5161 { 5528 {
@@ -5170,13 +5537,13 @@ namespace Temporary {
5170 Variable Name = new Variable(); 5537 Variable Name = new Variable();
5171 Variable ArgList = new Variable(); 5538 Variable ArgList = new Variable();
5172 Variable RestStatements = new Variable(); 5539 Variable RestStatements = new Variable();
5173 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) 5540 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
5174 { 5541 {
5175 convertIndentationPython(Level); 5542 convertIndentationPython(Level);
5176 YP.write(Name); 5543 YP.write(Name);
5177 YP.write(Atom.a(@"(")); 5544 YP.write(Atom.a("("));
5178 convertArgListPython(ArgList); 5545 convertArgListPython(ArgList);
5179 YP.write(Atom.a(@")")); 5546 YP.write(Atom.a(")"));
5180 YP.nl(); 5547 YP.nl();
5181 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5548 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5182 { 5549 {
@@ -5188,19 +5555,35 @@ namespace Temporary {
5188 { 5555 {
5189 object Level = arg2; 5556 object Level = arg2;
5190 object HasBreakableBlock = arg3; 5557 object HasBreakableBlock = arg3;
5558 Variable Name = new Variable();
5559 Variable _FunctorArgs = new Variable();
5560 Variable ArgList = new Variable();
5561 Variable RestStatements = new Variable();
5562 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
5563 {
5564 foreach (bool l3 in convertStatementListPython(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level, HasBreakableBlock))
5565 {
5566 yield return true;
5567 yield break;
5568 }
5569 }
5570 }
5571 {
5572 object Level = arg2;
5573 object HasBreakableBlock = arg3;
5191 Variable Obj = new Variable(); 5574 Variable Obj = new Variable();
5192 Variable Name = new Variable(); 5575 Variable Name = new Variable();
5193 Variable ArgList = new Variable(); 5576 Variable ArgList = new Variable();
5194 Variable RestStatements = new Variable(); 5577 Variable RestStatements = new Variable();
5195 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) 5578 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
5196 { 5579 {
5197 convertIndentationPython(Level); 5580 convertIndentationPython(Level);
5198 YP.write(Obj); 5581 YP.write(Obj);
5199 YP.write(Atom.a(@".")); 5582 YP.write(Atom.a("."));
5200 YP.write(Name); 5583 YP.write(Name);
5201 YP.write(Atom.a(@"(")); 5584 YP.write(Atom.a("("));
5202 convertArgListPython(ArgList); 5585 convertArgListPython(ArgList);
5203 YP.write(Atom.a(@")")); 5586 YP.write(Atom.a(")"));
5204 YP.nl(); 5587 YP.nl();
5205 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5588 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5206 { 5589 {
@@ -5215,12 +5598,12 @@ namespace Temporary {
5215 Variable Body = new Variable(); 5598 Variable Body = new Variable();
5216 Variable RestStatements = new Variable(); 5599 Variable RestStatements = new Variable();
5217 Variable NextLevel = new Variable(); 5600 Variable NextLevel = new Variable();
5218 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) 5601 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
5219 { 5602 {
5220 if (YP.termEqual(HasBreakableBlock, 1)) 5603 if (YP.termEqual(HasBreakableBlock, 1))
5221 { 5604 {
5222 convertIndentationPython(Level); 5605 convertIndentationPython(Level);
5223 YP.write(Atom.a(@"for _ in [1]:")); 5606 YP.write(Atom.a("for _ in [1]:"));
5224 YP.nl(); 5607 YP.nl();
5225 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1))) 5608 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
5226 { 5609 {
@@ -5231,10 +5614,10 @@ namespace Temporary {
5231 if (YP.greaterThan(Level, 1)) 5614 if (YP.greaterThan(Level, 1))
5232 { 5615 {
5233 convertIndentationPython(Level); 5616 convertIndentationPython(Level);
5234 YP.write(Atom.a(@"if doBreak:")); 5617 YP.write(Atom.a("if doBreak:"));
5235 YP.nl(); 5618 YP.nl();
5236 convertIndentationPython(NextLevel); 5619 convertIndentationPython(NextLevel);
5237 YP.write(Atom.a(@"break")); 5620 YP.write(Atom.a("break"));
5238 YP.nl(); 5621 YP.nl();
5239 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5622 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5240 { 5623 {
@@ -5271,10 +5654,10 @@ namespace Temporary {
5271 if (YP.greaterThan(Level, 1)) 5654 if (YP.greaterThan(Level, 1))
5272 { 5655 {
5273 convertIndentationPython(Level); 5656 convertIndentationPython(Level);
5274 YP.write(Atom.a(@"if doBreak:")); 5657 YP.write(Atom.a("if doBreak:"));
5275 YP.nl(); 5658 YP.nl();
5276 convertIndentationPython(NextLevel); 5659 convertIndentationPython(NextLevel);
5277 YP.write(Atom.a(@"break")); 5660 YP.write(Atom.a("break"));
5278 YP.nl(); 5661 YP.nl();
5279 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5662 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5280 { 5663 {
@@ -5311,12 +5694,12 @@ namespace Temporary {
5311 Variable Body = new Variable(); 5694 Variable Body = new Variable();
5312 Variable RestStatements = new Variable(); 5695 Variable RestStatements = new Variable();
5313 Variable NextLevel = new Variable(); 5696 Variable NextLevel = new Variable();
5314 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) 5697 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
5315 { 5698 {
5316 convertIndentationPython(Level); 5699 convertIndentationPython(Level);
5317 YP.write(Atom.a(@"if ")); 5700 YP.write(Atom.a("if "));
5318 convertExpressionPython(Expression); 5701 convertExpressionPython(Expression);
5319 YP.write(Atom.a(@":")); 5702 YP.write(Atom.a(":"));
5320 YP.nl(); 5703 YP.nl();
5321 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5704 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5322 { 5705 {
@@ -5338,14 +5721,14 @@ namespace Temporary {
5338 Variable Body = new Variable(); 5721 Variable Body = new Variable();
5339 Variable RestStatements = new Variable(); 5722 Variable RestStatements = new Variable();
5340 Variable NextLevel = new Variable(); 5723 Variable NextLevel = new Variable();
5341 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) 5724 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
5342 { 5725 {
5343 convertIndentationPython(Level); 5726 convertIndentationPython(Level);
5344 YP.write(Atom.a(@"for l")); 5727 YP.write(Atom.a("for l"));
5345 YP.write(Level); 5728 YP.write(Level);
5346 YP.write(Atom.a(@" in ")); 5729 YP.write(Atom.a(" in "));
5347 convertExpressionPython(Expression); 5730 convertExpressionPython(Expression);
5348 YP.write(Atom.a(@":")); 5731 YP.write(Atom.a(":"));
5349 YP.nl(); 5732 YP.nl();
5350 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5733 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5351 { 5734 {
@@ -5354,10 +5737,10 @@ namespace Temporary {
5354 if (YP.termEqual(HasBreakableBlock, 1)) 5737 if (YP.termEqual(HasBreakableBlock, 1))
5355 { 5738 {
5356 convertIndentationPython(Level); 5739 convertIndentationPython(Level);
5357 YP.write(Atom.a(@"if doBreak:")); 5740 YP.write(Atom.a("if doBreak:"));
5358 YP.nl(); 5741 YP.nl();
5359 convertIndentationPython(NextLevel); 5742 convertIndentationPython(NextLevel);
5360 YP.write(Atom.a(@"break")); 5743 YP.write(Atom.a("break"));
5361 YP.nl(); 5744 YP.nl();
5362 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5745 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5363 { 5746 {
@@ -5382,10 +5765,10 @@ namespace Temporary {
5382 object HasBreakableBlock = arg3; 5765 object HasBreakableBlock = arg3;
5383 Variable Expression = new Variable(); 5766 Variable Expression = new Variable();
5384 Variable RestStatements = new Variable(); 5767 Variable RestStatements = new Variable();
5385 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) 5768 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
5386 { 5769 {
5387 convertIndentationPython(Level); 5770 convertIndentationPython(Level);
5388 YP.write(Atom.a(@"raise ")); 5771 YP.write(Atom.a("raise "));
5389 convertExpressionPython(Expression); 5772 convertExpressionPython(Expression);
5390 YP.nl(); 5773 YP.nl();
5391 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5774 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5403,7 +5786,7 @@ namespace Temporary {
5403 Variable N = new Variable(); 5786 Variable N = new Variable();
5404 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 5787 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
5405 { 5788 {
5406 repeatWrite(Atom.a(@" "), N); 5789 repeatWrite(Atom.a(" "), N);
5407 return; 5790 return;
5408 } 5791 }
5409 } 5792 }
@@ -5425,15 +5808,15 @@ namespace Temporary {
5425 convertExpressionPython(Head); 5808 convertExpressionPython(Head);
5426 if (YP.termNotEqual(Tail, Atom.NIL)) 5809 if (YP.termNotEqual(Tail, Atom.NIL))
5427 { 5810 {
5428 YP.write(Atom.a(@", ")); 5811 YP.write(Atom.a(", "));
5429 convertArgListPython(Tail); 5812 convertArgListPython(Tail);
5430 return; 5813 return;
5431 // goto cutIf1; 5814 goto cutIf1;
5432 } 5815 }
5433 convertArgListPython(Tail); 5816 convertArgListPython(Tail);
5434 return; 5817 return;
5435 // cutIf1: 5818 cutIf1:
5436 // { } 5819 { }
5437 } 5820 }
5438 } 5821 }
5439 } 5822 }
@@ -5442,7 +5825,7 @@ namespace Temporary {
5442 { 5825 {
5443 { 5826 {
5444 Variable X = new Variable(); 5827 Variable X = new Variable();
5445 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 5828 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
5446 { 5829 {
5447 YP.write(X); 5830 YP.write(X);
5448 return; 5831 return;
@@ -5451,12 +5834,22 @@ namespace Temporary {
5451 { 5834 {
5452 Variable Name = new Variable(); 5835 Variable Name = new Variable();
5453 Variable ArgList = new Variable(); 5836 Variable ArgList = new Variable();
5454 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) 5837 foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
5455 { 5838 {
5456 YP.write(Name); 5839 YP.write(Name);
5457 YP.write(Atom.a(@"(")); 5840 YP.write(Atom.a("("));
5458 convertArgListPython(ArgList); 5841 convertArgListPython(ArgList);
5459 YP.write(Atom.a(@")")); 5842 YP.write(Atom.a(")"));
5843 return;
5844 }
5845 }
5846 {
5847 Variable Name = new Variable();
5848 Variable _FunctorArgs = new Variable();
5849 Variable ArgList = new Variable();
5850 foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
5851 {
5852 convertExpressionPython(new Functor2("call", Name, ArgList));
5460 return; 5853 return;
5461 } 5854 }
5462 } 5855 }
@@ -5464,89 +5857,89 @@ namespace Temporary {
5464 Variable Obj = new Variable(); 5857 Variable Obj = new Variable();
5465 Variable Name = new Variable(); 5858 Variable Name = new Variable();
5466 Variable ArgList = new Variable(); 5859 Variable ArgList = new Variable();
5467 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) 5860 foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
5468 { 5861 {
5469 YP.write(Obj); 5862 YP.write(Obj);
5470 YP.write(Atom.a(@".")); 5863 YP.write(Atom.a("."));
5471 YP.write(Name); 5864 YP.write(Name);
5472 YP.write(Atom.a(@"(")); 5865 YP.write(Atom.a("("));
5473 convertArgListPython(ArgList); 5866 convertArgListPython(ArgList);
5474 YP.write(Atom.a(@")")); 5867 YP.write(Atom.a(")"));
5475 return; 5868 return;
5476 } 5869 }
5477 } 5870 }
5478 { 5871 {
5479 Variable Name = new Variable(); 5872 Variable Name = new Variable();
5480 Variable ArgList = new Variable(); 5873 Variable ArgList = new Variable();
5481 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) 5874 foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
5482 { 5875 {
5483 YP.write(Name); 5876 YP.write(Name);
5484 YP.write(Atom.a(@"(")); 5877 YP.write(Atom.a("("));
5485 convertArgListPython(ArgList); 5878 convertArgListPython(ArgList);
5486 YP.write(Atom.a(@")")); 5879 YP.write(Atom.a(")"));
5487 return; 5880 return;
5488 } 5881 }
5489 } 5882 }
5490 { 5883 {
5491 Variable Name = new Variable(); 5884 Variable Name = new Variable();
5492 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 5885 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
5493 { 5886 {
5494 YP.write(Name); 5887 YP.write(Name);
5495 return; 5888 return;
5496 } 5889 }
5497 } 5890 }
5498 { 5891 {
5499 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 5892 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
5500 { 5893 {
5501 YP.write(Atom.a(@"None")); 5894 YP.write(Atom.a("None"));
5502 return; 5895 return;
5503 } 5896 }
5504 } 5897 }
5505 { 5898 {
5506 Variable X = new Variable(); 5899 Variable X = new Variable();
5507 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 5900 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
5508 { 5901 {
5509 YP.write(Atom.a(@"not (")); 5902 YP.write(Atom.a("not ("));
5510 convertExpressionPython(X); 5903 convertExpressionPython(X);
5511 YP.write(Atom.a(@")")); 5904 YP.write(Atom.a(")"));
5512 return; 5905 return;
5513 } 5906 }
5514 } 5907 }
5515 { 5908 {
5516 Variable X = new Variable(); 5909 Variable X = new Variable();
5517 Variable Y = new Variable(); 5910 Variable Y = new Variable();
5518 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) 5911 foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
5519 { 5912 {
5520 YP.write(Atom.a(@"(")); 5913 YP.write(Atom.a("("));
5521 convertExpressionPython(X); 5914 convertExpressionPython(X);
5522 YP.write(Atom.a(@") and (")); 5915 YP.write(Atom.a(") and ("));
5523 convertExpressionPython(Y); 5916 convertExpressionPython(Y);
5524 YP.write(Atom.a(@")")); 5917 YP.write(Atom.a(")"));
5525 return; 5918 return;
5526 } 5919 }
5527 } 5920 }
5528 { 5921 {
5529 Variable ArgList = new Variable(); 5922 Variable ArgList = new Variable();
5530 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 5923 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
5531 { 5924 {
5532 YP.write(Atom.a(@"[")); 5925 YP.write(Atom.a("["));
5533 convertArgListPython(ArgList); 5926 convertArgListPython(ArgList);
5534 YP.write(Atom.a(@"]")); 5927 YP.write(Atom.a("]"));
5535 return; 5928 return;
5536 } 5929 }
5537 } 5930 }
5538 { 5931 {
5539 Variable X = new Variable(); 5932 Variable X = new Variable();
5540 Variable Codes = new Variable(); 5933 Variable Codes = new Variable();
5541 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5934 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
5542 { 5935 {
5543 if (YP.atom(X)) 5936 if (YP.atom(X))
5544 { 5937 {
5545 YP.write(Atom.a(@"""")); 5938 YP.write(Atom.a("\""));
5546 foreach (bool l4 in YP.atom_codes(X, Codes)) 5939 foreach (bool l4 in YP.atom_codes(X, Codes))
5547 { 5940 {
5548 convertStringCodesPython(Codes); 5941 convertStringCodesPython(Codes);
5549 YP.write(Atom.a(@"""")); 5942 YP.write(Atom.a("\""));
5550 return; 5943 return;
5551 } 5944 }
5552 } 5945 }
@@ -5554,7 +5947,7 @@ namespace Temporary {
5554 } 5947 }
5555 { 5948 {
5556 Variable X = new Variable(); 5949 Variable X = new Variable();
5557 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5950 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
5558 { 5951 {
5559 YP.write(X); 5952 YP.write(X);
5560 return; 5953 return;
@@ -5581,7 +5974,7 @@ namespace Temporary {
5581 YP.put_code(Code); 5974 YP.put_code(Code);
5582 convertStringCodesPython(RestCodes); 5975 convertStringCodesPython(RestCodes);
5583 return; 5976 return;
5584 // goto cutIf1; 5977 goto cutIf1;
5585 } 5978 }
5586 if (YP.termEqual(Code, 92)) 5979 if (YP.termEqual(Code, 92))
5587 { 5980 {
@@ -5589,15 +5982,99 @@ namespace Temporary {
5589 YP.put_code(Code); 5982 YP.put_code(Code);
5590 convertStringCodesPython(RestCodes); 5983 convertStringCodesPython(RestCodes);
5591 return; 5984 return;
5592 // goto cutIf1; 5985 goto cutIf1;
5593 } 5986 }
5594 YP.put_code(Code); 5987 YP.put_code(Code);
5595 convertStringCodesPython(RestCodes); 5988 convertStringCodesPython(RestCodes);
5596 return; 5989 return;
5597 // cutIf1: 5990 cutIf1:
5598 // { } 5991 { }
5992 }
5993 }
5994 }
5995
5996 public static IEnumerable<bool> putCStringCode(object Code)
5997 {
5998 {
5999 Variable HexDigit = new Variable();
6000 Variable HexChar = new Variable();
6001 if (YP.lessThanOrEqual(Code, 31))
6002 {
6003 if (YP.lessThanOrEqual(Code, 15))
6004 {
6005 YP.write(Atom.a("\\u000"));
6006 foreach (bool l4 in YP.unify(HexDigit, Code))
6007 {
6008 if (YP.lessThanOrEqual(HexDigit, 9))
6009 {
6010 foreach (bool l6 in YP.unify(HexChar, YP.add(HexDigit, 48)))
6011 {
6012 YP.put_code(HexChar);
6013 yield return true;
6014 yield break;
6015 }
6016 goto cutIf2;
6017 }
6018 foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 55)))
6019 {
6020 YP.put_code(HexChar);
6021 yield return true;
6022 yield break;
6023 }
6024 cutIf2:
6025 { }
6026 }
6027 goto cutIf1;
6028 }
6029 YP.write(Atom.a("\\u001"));
6030 foreach (bool l3 in YP.unify(HexDigit, YP.subtract(Code, 16)))
6031 {
6032 if (YP.lessThanOrEqual(HexDigit, 9))
6033 {
6034 foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 48)))
6035 {
6036 YP.put_code(HexChar);
6037 yield return true;
6038 yield break;
6039 }
6040 goto cutIf3;
6041 }
6042 foreach (bool l4 in YP.unify(HexChar, YP.add(HexDigit, 55)))
6043 {
6044 YP.put_code(HexChar);
6045 yield return true;
6046 yield break;
6047 }
6048 cutIf3:
6049 { }
6050 }
6051 cutIf1:
6052 { }
6053 }
6054 }
6055 {
6056 if (YP.termEqual(Code, 34))
6057 {
6058 YP.put_code(92);
6059 YP.put_code(34);
6060 yield return true;
6061 yield break;
5599 } 6062 }
5600 } 6063 }
6064 {
6065 if (YP.termEqual(Code, 92))
6066 {
6067 YP.put_code(92);
6068 YP.put_code(92);
6069 yield return true;
6070 yield break;
6071 }
6072 }
6073 {
6074 YP.put_code(Code);
6075 yield return true;
6076 yield break;
6077 }
5601 } 6078 }
5602 6079
5603 public static IEnumerable<bool> member(object X, object arg2) 6080 public static IEnumerable<bool> member(object X, object arg2)
@@ -5654,6 +6131,6 @@ namespace Temporary {
5654 } 6131 }
5655 } 6132 }
5656 } 6133 }
5657 #pragma warning restore 0168, 0219 6134 #pragma warning restore 0168, 0219, 0164,0162
5658 } 6135 }
5659} 6136}