aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs107
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs1221
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs2266
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs4
7 files changed, 2559 insertions, 1169 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
index 1be73f7..2bf9db7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
@@ -39,6 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.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.Shared.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.Shared.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.Shared.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.Shared.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.Shared.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/Shared/Api/Runtime/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
index 3d86905..3a15449 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
@@ -44,9 +44,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
44 yield return false; 44 yield return false;
45 } 45 }
46 46
47// disable warning: don't see how we can code this differently short 47 // disable warning on l1, don't see how we can
48// of rewriting the whole thing 48 // code this differently
49#pragma warning disable 0168, 0219 49 #pragma warning disable 0168, 0219
50 50
51 // Debug: Hand-modify this central predicate to do tail recursion. 51 // Debug: Hand-modify this central predicate to do tail recursion.
52 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3) 52 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
@@ -228,12 +228,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
228 if (YP.termEqual(Term, Atom.a(@"end_of_file"))) 228 if (YP.termEqual(Term, Atom.a(@"end_of_file")))
229 { 229 {
230 yield break; 230 yield break;
231 // unreachable code:
232 // goto cutIf1; 231 // goto cutIf1;
233 } 232 }
234 yield return false; 233 yield return false;
235 // cutIf1: 234 // cutIf1:
236 { } 235 // { }
237 } 236 }
238 } 237 }
239 } 238 }
@@ -4457,6 +4456,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
4457 { } 4456 { }
4458 } 4457 }
4459 } 4458 }
4460#pragma warning restore 0168 4459 #pragma warning restore 0168, 0219
4461 } 4460 }
4462} 4461}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
index f29c751..a2fe7ec 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/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.Shared.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.Shared.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/Shared/Api/Runtime/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
index c212fb8..3d19d3e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/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.Shared.YieldProlog 40namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
38{ 41{
@@ -48,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.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.Shared.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.Shared.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.Shared.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.Shared.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.Shared.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.Shared.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.
@@ -561,6 +598,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
561 return _repeat; 598 return _repeat;
562 } 599 }
563 600
601 // disable warning on l1, don't see how we can
602 // code this differently
603 #pragma warning disable 0168
564 public static IEnumerable<bool> univ(object Term, object List) 604 public static IEnumerable<bool> univ(object Term, object List)
565 { 605 {
566 Term = YP.getValue(Term); 606 Term = YP.getValue(Term);
@@ -572,23 +612,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
572 612
573 Variable Name = new Variable(); 613 Variable Name = new Variable();
574 Variable ArgList = new Variable(); 614 Variable ArgList = new Variable();
575// disable warning: don't see how we can code this differently short
576// of rewriting the whole thing
577#pragma warning disable 0168
578 foreach (bool l1 in new ListPair(Name, ArgList).unify(List)) 615 foreach (bool l1 in new ListPair(Name, ArgList).unify(List))
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 }
591#pragma warning restore 0168
592 632
593 return YP.fail(); 633 return YP.fail();
594 } 634 }
@@ -599,43 +639,81 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
599 FunctorName = YP.getValue(FunctorName); 639 FunctorName = YP.getValue(FunctorName);
600 Arity = YP.getValue(Arity); 640 Arity = YP.getValue(Arity);
601 641
602 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
603 { 681 {
604// disable warning: don't see how we can code this differently short
605// of rewriting the whole thing
606#pragma warning disable 0168
607 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term))) 682 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term)))
608 { 683 {
609 foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length)) 684 foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length))
610 yield return false; 685 yield return false;
611 } 686 }
612#pragma warning restore 0168
613 } 687 }
614 else
615 throw new NotImplementedException("Debug: must finish functor/3");
616 } 688 }
617 689
618 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value) 690 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value)
619 { 691 {
620 if (YP.var(ArgNumber)) 692 if (var(ArgNumber))
621 throw new NotImplementedException("Debug: must finish arg/3"); 693 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 ArgNumber is an unbound variable");
622 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)
623 { 713 {
624 int argNumberInt = convertInt(ArgNumber); 714 // The first ArgNumber is at 1, not 0.
625 if (argNumberInt < 0) 715 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
626 throw new Exception("ArgNumber must be non-negative"); 716 yield return false;
627 object[] termArgs = YP.getFunctorArgs(Term);
628 // Silently fail if argNumberInt is out of range.
629 if (argNumberInt >= 1 && argNumberInt <= termArgs.Length)
630 {
631 // The first ArgNumber is at 1, not 0.
632// disable warning: don't see how we can code this differently short
633// of rewriting the whole thing
634#pragma warning disable 0168
635 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
636 yield return false;
637#pragma warning restore 0168
638 }
639 } 717 }
640 } 718 }
641 719
@@ -665,8 +743,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
665 if (term1TypeCode == -2) 743 if (term1TypeCode == -2)
666 { 744 {
667 // Variable. 745 // Variable.
668 // 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
669 // that less than returns false if the terms are equal, in 747 // that less than returns false if the terms are equal, in
670 // 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.
671 if ((Variable)Term1 != (Variable)Term2) 749 if ((Variable)Term1 != (Variable)Term2)
672 // The hash code should be unique to a Variable object. 750 // The hash code should be unique to a Variable object.
@@ -709,8 +787,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
709 } 787 }
710 788
711 /// <summary> 789 /// <summary>
712 /// 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,
713 /// 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,
714 /// 4 if it is Functor. 792 /// 4 if it is Functor.
715 /// Otherwise, type code is -1. 793 /// Otherwise, type code is -1.
716 /// This does not call YP.getValue(term). 794 /// This does not call YP.getValue(term).
@@ -778,101 +856,303 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
778 if (_operatorTable == null) 856 if (_operatorTable == null)
779 { 857 {
780 // Initialize. 858 // Initialize.
781 _operatorTable = new List<object[]>(); 859 _operatorTable = new IndexedAnswers(3);
782 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") }); 860 _operatorTable.addAnswer(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") });
783 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") }); 861 _operatorTable.addAnswer(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") });
784 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") }); 862 _operatorTable.addAnswer(new object[] { 1200, Atom.a("fx"), Atom.a(":-") });
785 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") }); 863 _operatorTable.addAnswer(new object[] { 1200, Atom.a("fx"), Atom.a("?-") });
786 _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") }); 864 _operatorTable.addAnswer(new object[] { 1100, Atom.a("xfy"), Atom.a(";") });
787 _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") }); 865 _operatorTable.addAnswer(new object[] { 1050, Atom.a("xfy"), Atom.a("->") });
788 _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") }); 866 _operatorTable.addAnswer(new object[] { 1000, Atom.a("xfy"), Atom.a(",") });
789 _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") }); 867 _operatorTable.addAnswer(new object[] { 900, Atom.a("fy"), Atom.a("\\+") });
790 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") }); 868 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=") });
791 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") }); 869 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") });
792 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") }); 870 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("==") });
793 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") }); 871 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") });
794 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") }); 872 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@<") });
795 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") }); 873 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") });
796 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") }); 874 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@>") });
797 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") }); 875 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") });
798 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") }); 876 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=..") });
799 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") }); 877 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("is") });
800 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") }); 878 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") });
801 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") }); 879 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") });
802 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") }); 880 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("<") });
803 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") }); 881 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a("=<") });
804 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") }); 882 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a(">") });
805 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") }); 883 _operatorTable.addAnswer(new object[] { 700, Atom.a("xfx"), Atom.a(">=") });
806 _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") }); 884 _operatorTable.addAnswer(new object[] { 600, Atom.a("xfy"), Atom.a(":") });
807 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") }); 885 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("+") });
808 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") }); 886 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("-") });
809 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") }); 887 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") });
810 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") }); 888 _operatorTable.addAnswer(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") });
811 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") }); 889 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("*") });
812 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") }); 890 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("/") });
813 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") }); 891 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("//") });
814 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") }); 892 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("rem") });
815 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") }); 893 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("mod") });
816 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") }); 894 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a("<<") });
817 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") }); 895 _operatorTable.addAnswer(new object[] { 400, Atom.a("yfx"), Atom.a(">>") });
818 _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") }); 896 _operatorTable.addAnswer(new object[] { 200, Atom.a("xfx"), Atom.a("**") });
819 _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") }); 897 _operatorTable.addAnswer(new object[] { 200, Atom.a("xfy"), Atom.a("^") });
820 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") }); 898 _operatorTable.addAnswer(new object[] { 200, Atom.a("fy"), Atom.a("-") });
821 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") }); 899 _operatorTable.addAnswer(new object[] { 200, Atom.a("fy"), Atom.a("\\") });
822 // 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.
823 _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); 901 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
824 } 902 }
825 903
826 object[] args = new object[] { Priority, Specifier, Operator }; 904 foreach (bool l1 in _operatorTable.match(new object[] { Priority, Specifier, Operator }))
827 foreach (object[] answer in _operatorTable) 905 yield return false;
828 {
829// disable warning: don't see how we can code this differently short
830// of rewriting the whole thing
831#pragma warning disable 0168
832 foreach (bool l1 in YP.unifyArrays(args, answer))
833 yield return false;
834#pragma warning restore 0168
835 }
836 } 906 }
837 907
838 public static IEnumerable<bool> atom_length(object atom, object Length) 908 public static IEnumerable<bool> atom_length(object atom, object Length)
839 { 909 {
840 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);
841 } 929 }
842 930
843 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)
844 { 932 {
845 // Debug: Should implement for var(Start) which is a kind of search.
846 // Debug: Should we try to preserve the _declaringClass? 933 // Debug: Should we try to preserve the _declaringClass?
847 return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name + 934 Start = YP.getValue(Start);
848 ((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 }
849 } 999 }
850 1000
851 public static IEnumerable<bool> sub_atom 1001 public static IEnumerable<bool> sub_atom
852 (object atom, object Before, object Length, object After, object Sub_atom) 1002 (object atom, object Before, object Length, object After, object Sub_atom)
853 { 1003 {
854 // Debug: Should implement for var(atom) which is a kind of search.
855 // Debug: Should we try to preserve the _declaringClass? 1004 // Debug: Should we try to preserve the _declaringClass?
856 Atom atomAtom = (Atom)YP.getValue(atom); 1005 atom = YP.getValue(atom);
857 int beforeInt = YP.convertInt(Before); 1006 Before = YP.getValue(Before);
858 int lengthInt = YP.convertInt(Length); 1007 Length = YP.getValue(Length);
859 if (beforeInt < 0) 1008 After = YP.getValue(After);
860 throw new Exception("Before must be non-negative"); 1009 Sub_atom = YP.getValue(Sub_atom);
861 if (lengthInt < 0) 1010 if (atom is Variable)
862 throw new Exception("Length must be non-negative"); 1011 throw new PrologException(Atom.a("instantiation_error"),
863 int afterInt = atomAtom._name.Length - (beforeInt + lengthInt); 1012 "Expected atom(Arg1) but it is an unbound variable");
864 if (afterInt >= 0) 1013 if (!(atom is Atom))
865 { 1014 throw new PrologException
866// disable warning: don't see how we can code this differently short 1015 (new Functor2("type_error", Atom.a("atom"), atom), "Arg 1 Atom is not an atom");
867// of rewriting the whole thing 1016 if (!(Sub_atom is Variable))
868#pragma warning disable 0168 1017 {
869 foreach (bool l1 in YP.unify(After, afterInt)) 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)
870 { 1067 {
871 foreach (bool l2 in YP.unify 1068 foreach (bool l1 in YP.unify(After, xAfter))
872 (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt)))) 1069 {
873 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 }
874 } 1110 }
875#pragma warning restore 0168 1111 }
1112 }
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);
876 } 1156 }
877 } 1157 }
878 1158
@@ -881,38 +1161,141 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
881 atom = YP.getValue(atom); 1161 atom = YP.getValue(atom);
882 List = YP.getValue(List); 1162 List = YP.getValue(List);
883 1163
884 if (nonvar(atom)) 1164 if (atom is Variable)
885 { 1165 {
886 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;
887 object codeList = Atom.NIL; 1193 object codeList = Atom.NIL;
888 // Start from the back to make the list. 1194 // Start from the back to make the list.
889 for (int i = name.Length - 1; i >= 0; --i) 1195 for (int i = atomString.Length - 1; i >= 0; --i)
890 codeList = new ListPair((int)name[i], codeList); 1196 codeList = new ListPair((int)atomString[i], codeList);
891 return YP.unify(List, codeList); 1197 return YP.unify(List, codeList);
892 } 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)
893 { 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");
894 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
895 char[] charArray = new char[codeArray.Length]; 1216 char[] charArray = new char[codeArray.Length];
896 for (int i = 0; i < codeArray.Length; ++i) 1217 for (int i = 0; i < codeArray.Length; ++i)
897 charArray[i] = (char)YP.convertInt(codeArray[i]); 1218 {
898 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);
899 } 1253 }
900 } 1254 }
901 1255
902 public static IEnumerable<bool> number_codes(object number, object List) 1256 public static IEnumerable<bool> number_codes(object Number, object List)
903 { 1257 {
904 number = YP.getValue(number); 1258 Number = YP.getValue(Number);
905 List = YP.getValue(List); 1259 List = YP.getValue(List);
906 1260
907 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
908 { 1284 {
909 string numberString = null; 1285 string numberString = null;
910 // Try converting to an int first. 1286 // Try converting to an int first.
911 int intNumber; 1287 int intNumber;
912 if (YP.getInt(number, out intNumber)) 1288 if (YP.getInt(Number, out intNumber))
913 numberString = intNumber.ToString(); 1289 numberString = intNumber.ToString();
914 else 1290 else
915 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 }
916 1299
917 object codeList = Atom.NIL; 1300 object codeList = Atom.NIL;
918 // Start from the back to make the list. 1301 // Start from the back to make the list.
@@ -920,20 +1303,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
920 codeList = new ListPair((int)numberString[i], codeList); 1303 codeList = new ListPair((int)numberString[i], codeList);
921 return YP.unify(List, codeList); 1304 return YP.unify(List, codeList);
922 } 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"))
923 { 1321 {
924 object[] codeArray = ListPair.toArray(List);
925 char[] charArray = new char[codeArray.Length];
926 for (int i = 0; i < codeArray.Length; ++i)
927 charArray[i] = (char)YP.convertInt(codeArray[i]);
928 String numberString = new String(charArray);
929 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
930 try 1322 try
931 { 1323 {
932 // Try an int first. 1324 return Int32.Parse
933 return YP.unify(number, Convert.ToInt32(numberString)); 1325 (numberString.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier);
934 } 1326 }
935 catch (FormatException) { } 1327 catch (FormatException)
936 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]);
937 } 1392 }
938 } 1393 }
939 1394
@@ -1109,7 +1564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1109 } 1564 }
1110 1565
1111 /// <summary> 1566 /// <summary>
1112 /// 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
1113 /// use "1" which will parse as an int. 1568 /// use "1" which will parse as an int.
1114 /// </summary> 1569 /// </summary>
1115 /// <param name="x"></param> 1570 /// <param name="x"></param>
@@ -1134,7 +1589,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1134 1589
1135 public static void put_code(object x) 1590 public static void put_code(object x)
1136 { 1591 {
1137 _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);
1138 } 1599 }
1139 1600
1140 public static void nl() 1601 public static void nl()
@@ -1170,6 +1631,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1170 { 1631 {
1171 Head = YP.getValue(((Functor2)TermCopy)._arg1); 1632 Head = YP.getValue(((Functor2)TermCopy)._arg1);
1172 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");
1173 } 1638 }
1174 else 1639 else
1175 { 1640 {
@@ -1183,7 +1648,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1183 throw new PrologException 1648 throw new PrologException
1184 (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");
1185 object[] args = getFunctorArgs(Head); 1650 object[] args = getFunctorArgs(Head);
1186 if (!isDynamic(name, args.Length)) 1651 if (isSystemPredicate(name, args.Length))
1187 throw new PrologException 1652 throw new PrologException
1188 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"), 1653 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"),
1189 new Functor2(Atom.SLASH, name, args.Length)), 1654 new Functor2(Atom.SLASH, name, args.Length)),
@@ -1191,17 +1656,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1191 1656
1192 if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true")) 1657 if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true"))
1193 { 1658 {
1194 // Debug: Until IndexedAnswers supports prepend, compile the fact so we can prepend it below. 1659 // This is a fact with no unbound variables
1195 if (!prepend) 1660 // assertFact and prependFact use IndexedAnswers, so don't we don't need to compile.
1196 { 1661 if (prepend)
1197 // This is a fact with no unbound variables 1662 prependFact(name, args);
1198 // assertFact uses IndexedAnswers, so don't we don't need to compile. 1663 else
1199 assertFact(name, args); 1664 assertFact(name, args);
1200 return; 1665
1201 } 1666 return;
1202 } 1667 }
1203 1668
1204 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);
1205 1674
1206 // Add the clause to the entry in _predicatesStore. 1675 // Add the clause to the entry in _predicatesStore.
1207 NameArity nameArity = new NameArity(name, args.Length); 1676 NameArity nameArity = new NameArity(name, args.Length);
@@ -1216,19 +1685,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1216 clauses.Add(clause); 1685 clauses.Add(clause);
1217 } 1686 }
1218 1687
1219 private static bool isDynamic(Atom name, int arity) 1688 private static bool isSystemPredicate(Atom name, int arity)
1220 { 1689 {
1221 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))
1222 return false; 1691 return true;
1223 // 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.
1224// disable warning: don't see how we can code this differently short
1225// of rewriting the whole thing
1226#pragma warning disable 0168
1227 foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable())) 1693 foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable()))
1228 return false; 1694 return true;
1229 // Debug: Do we need to check if name._module is null? 1695 // Debug: Do we need to check if name._module is null?
1230#pragma warning restore 0168 1696 return false;
1231 return true;
1232 } 1697 }
1233 1698
1234 /// <summary> 1699 /// <summary>
@@ -1245,22 +1710,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1245 IndexedAnswers indexedAnswers; 1710 IndexedAnswers indexedAnswers;
1246 if (!_predicatesStore.TryGetValue(nameArity, out clauses)) 1711 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1247 { 1712 {
1248 // Create an IndexedAnswers as the first clause of the predicate. 1713 // Create an IndexedAnswers as the only clause of the predicate.
1249 _predicatesStore[nameArity] = (clauses = new List<IClause>()); 1714 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1250 clauses.Add(indexedAnswers = new IndexedAnswers()); 1715 clauses.Add(indexedAnswers = new IndexedAnswers(values.Length));
1251 } 1716 }
1252 else 1717 else
1253 { 1718 {
1254 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers; 1719 indexedAnswers = null;
1720 if (clauses.Count >= 1)
1721 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers;
1255 if (indexedAnswers == null) 1722 if (indexedAnswers == null)
1256 // The latest clause is not an IndexedAnswers, so add one. 1723 // The latest clause is not an IndexedAnswers, so add one.
1257 clauses.Add(indexedAnswers = new IndexedAnswers()); 1724 clauses.Add(indexedAnswers = new IndexedAnswers(values.Length));
1258 } 1725 }
1259 1726
1260 indexedAnswers.addAnswer(values); 1727 indexedAnswers.addAnswer(values);
1261 } 1728 }
1262 1729
1263 /// <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>
1264 /// 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
1265 /// arguments.Length. 1763 /// arguments.Length.
1266 /// It is an error if the predicate is not defined. 1764 /// It is an error if the predicate is not defined.
@@ -1272,9 +1770,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1272 { 1770 {
1273 List<IClause> clauses; 1771 List<IClause> clauses;
1274 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) 1772 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1275 throw new UndefinedPredicateException 1773 throw new PrologException
1276 ("Undefined fact: " + name + "/" + arguments.Length, name, 1774 (new Functor2
1277 arguments.Length); 1775 (Atom.a("existence_error"), Atom.a("procedure"),
1776 new Functor2(Atom.SLASH, name, arguments.Length)),
1777 "Undefined predicate: " + name + "/" + arguments.Length);
1278 1778
1279 if (clauses.Count == 1) 1779 if (clauses.Count == 1)
1280 // 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.
@@ -1292,7 +1792,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1292 /// <returns></returns> 1792 /// <returns></returns>
1293 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) 1793 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments)
1294 { 1794 {
1295 // 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
1296 // 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?
1297 foreach (IClause clause in clauses) 1797 foreach (IClause clause in clauses)
1298 { 1798 {
@@ -1318,16 +1818,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1318 return matchDynamic(name, arguments); 1818 return matchDynamic(name, arguments);
1319 } 1819 }
1320 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
1321 /// <summary> 1915 /// <summary>
1322 /// This actually searches all clauses, not just 1916 /// This is deprecated for backward compatibility. You should use retractall.
1323 /// the ones defined with assertFact, but we keep the name for
1324 /// backwards compatibility.
1325 /// </summary> 1917 /// </summary>
1326 /// <param name="name">must be an Atom</param> 1918 /// <param name="name">must be an Atom</param>
1327 /// <param name="arguments">an array of arity number of arguments</param> 1919 /// <param name="arguments">an array of arity number of arguments</param>
1328 public static void retractFact(Atom name, object[] arguments) 1920 public static void retractFact(Atom name, object[] arguments)
1329 { 1921 {
1330 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);
1331 List<IClause> clauses; 1937 List<IClause> clauses;
1332 if (!_predicatesStore.TryGetValue(nameArity, out clauses)) 1938 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1333 // Can't find, so ignore. 1939 // Can't find, so ignore.
@@ -1336,11 +1942,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1336 foreach (object arg in arguments) 1942 foreach (object arg in arguments)
1337 { 1943 {
1338 if (!YP.var(arg)) 1944 if (!YP.var(arg))
1339 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");
1340 } 1947 }
1341 // Set to a fresh empty IndexedAnswers. 1948 // Clear all clauses.
1342 _predicatesStore[nameArity] = (clauses = new List<IClause>()); 1949 _predicatesStore[nameArity] = new List<IClause>();
1343 clauses.Add(new IndexedAnswers());
1344 } 1950 }
1345 1951
1346 public static IEnumerable<bool> current_predicate(object NameSlashArity) 1952 public static IEnumerable<bool> current_predicate(object NameSlashArity)
@@ -1349,61 +1955,99 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1349 // 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.
1350 if (YP.ground(NameSlashArity)) 1956 if (YP.ground(NameSlashArity))
1351 { 1957 {
1352 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)
1353 { 1984 {
1354 Functor2 NameArityFunctor = (Functor2)NameSlashArity; 1985 foreach (bool l1 in YP.unify
1355 if (NameArityFunctor._name == Atom.SLASH) 1986 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity))
1356 { 1987 yield return false;
1357 if (_predicatesStore.ContainsKey(new NameArity
1358 ((Atom)YP.getValue(NameArityFunctor._arg1),
1359 (int)YP.getValue(NameArityFunctor._arg2))))
1360 // The predicate is defined.
1361 yield return false;
1362 }
1363 } 1988 }
1364 yield break;
1365 } 1989 }
1990 }
1366 1991
1367 foreach (NameArity key in _predicatesStore.Keys) 1992 public static void abolish(object NameSlashArity)
1368 { 1993 {
1369// disable warning: don't see how we can code this differently short 1994 NameSlashArity = YP.getValue(NameSlashArity);
1370// of rewriting the whole thing 1995 if (NameSlashArity is Variable)
1371#pragma warning disable 0168 1996 throw new PrologException
1372 foreach (bool l1 in YP.unify 1997 ("instantiation_error", "Predicate indicator is an unbound variable");
1373 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity)) 1998 Functor2 NameArityFunctor = NameSlashArity as Functor2;
1374 yield return false; 1999 if (!(NameArityFunctor != null && NameArityFunctor._name == Atom.SLASH))
1375#pragma warning restore 0168 2000 throw new PrologException
1376 } 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));
1377 } 2027 }
1378 2028
1379 /// <summary> 2029 /// <summary>
1380 /// 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
1381 /// declaringClass, using arguments from YP.getFunctorArgs(Goal). 2031 /// YP.getFunctorArgs(Goal). If not found, this throws a PrologException for existence_error.
1382 /// 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.
1383 /// If not found, this throws UndefinedPredicateException.
1384 /// </summary> 2033 /// </summary>
1385 /// <param name="Goal"></param> 2034 /// <param name="Goal"></param>
1386 /// <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>
1387 /// <returns></returns> 2037 /// <returns></returns>
1388 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) 2038 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass)
1389 { 2039 {
1390 Goal = YP.getValue(Goal);
1391 if (Goal is Variable)
1392 throw new PrologException("instantiation_error", "Goal to call is an unbound variable");
1393#if true
1394 List<Variable> variableSetList = new List<Variable>();
1395 addUniqueVariables(Goal, variableSetList);
1396 Variable[] variableSet = variableSetList.ToArray();
1397
1398 // Use Atom.F since it is ignored.
1399 return YPCompiler.compileAnonymousClause
1400 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1401#else
1402 Atom name; 2040 Atom name;
1403 object[] args; 2041 object[] args;
1404 while (true) 2042 while (true)
1405 { 2043 {
1406 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");
1407 args = YP.getFunctorArgs(Goal); 2051 args = YP.getFunctorArgs(Goal);
1408 if (name == Atom.HAT && args.Length == 2) 2052 if (name == Atom.HAT && args.Length == 2)
1409 // 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.
@@ -1411,22 +2055,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1411 else 2055 else
1412 break; 2056 break;
1413 } 2057 }
1414 try 2058
1415 { 2059 IEnumerable<bool> simpleIterator = YPCompiler.getSimpleIterator(name, args, declaringClass);
1416 return (IEnumerable<bool>)declaringClass.InvokeMember 2060 if (simpleIterator != null)
1417 (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.
1418 } 2062 return simpleIterator;
1419 catch (TargetInvocationException exception) 2063
1420 { 2064 // Compile the goal as a clause.
1421 throw exception.InnerException; 2065 List<Variable> variableSetList = new List<Variable>();
1422 } 2066 addUniqueVariables(Goal, variableSetList);
1423 catch (MissingMethodException) 2067 Variable[] variableSet = variableSetList.ToArray();
1424 { 2068
1425 throw new UndefinedPredicateException 2069 // Use Atom.F since it is ignored.
1426 ("Cannot find predicate function: " + name + "/" + args.Length + " in " + 2070 return YPCompiler.compileAnonymousClause
1427 declaringClass.FullName, name, args.Length); 2071 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1428 }
1429#endif
1430 } 2072 }
1431 2073
1432 public static void throwException(object Term) 2074 public static void throwException(object Term)
@@ -1440,12 +2082,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1440 /// <param name="script_event"></param> 2082 /// <param name="script_event"></param>
1441 /// <param name="script_params"></param> 2083 /// <param name="script_params"></param>
1442 /// <returns></returns> 2084 /// <returns></returns>
1443 public static void script_event(object script_event, object script_params) 2085 public static IEnumerable<bool> script_event(object script_event, object script_params)
1444 { 2086 {
1445 // string function = ((Atom)YP.getValue(script_event))._name; 2087 // string function = ((Atom)YP.getValue(script_event))._name;
1446 object[] array = ListPair.toArray(script_params); 2088 object[] array = ListPair.toArray(script_params);
1447 if (array == null) 2089 if (array == null)
1448 return; // YP.fail(); 2090 yield return false; // return; // YP.fail();
1449 if (array.Length > 1) 2091 if (array.Length > 1)
1450 { 2092 {
1451 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue 2093 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue
@@ -1453,8 +2095,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1453 // sortArray(array); 2095 // sortArray(array);
1454 } 2096 }
1455 //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;
1456 } 2113 }
1457 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 //}
1458 /// <summary> 2168 /// <summary>
1459 /// An enumerator that does zero loops. 2169 /// An enumerator that does zero loops.
1460 /// </summary> 2170 /// </summary>
@@ -1628,16 +2338,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1628 if (_exception != null) 2338 if (_exception != null)
1629 { 2339 {
1630 bool didUnify = false; 2340 bool didUnify = false;
1631// disable warning: don't see how we can code this differently short
1632// of rewriting the whole thing
1633#pragma warning disable 0168
1634 foreach (bool l1 in YP.unify(_exception._term, Catcher)) 2341 foreach (bool l1 in YP.unify(_exception._term, Catcher))
1635 { 2342 {
1636 didUnify = true; 2343 didUnify = true;
1637 yield return false; 2344 yield return false;
1638 } 2345 }
1639#pragma warning restore 0168
1640
1641 if (!didUnify) 2346 if (!didUnify)
1642 throw _exception; 2347 throw _exception;
1643 } 2348 }
@@ -1673,5 +2378,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1673 throw new NotImplementedException(); 2378 throw new NotImplementedException();
1674 } 2379 }
1675 } 2380 }
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 }
1676 } 2409 }
1677} 2410}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
index 96f2b89..1f1b41d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/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.Shared.YieldProlog 39namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
39{ 40{
@@ -41,7 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.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.Shared.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)
@@ -202,6 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
202 return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter)); 201 return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter));
203 } 202 }
204 203
204 // disable warning on l1, don't see how we can
205 // code this differently
206 #pragma warning disable 0168, 0164, 0162
205 public static bool isDetNoneOut(object State, object Term) 207 public static bool isDetNoneOut(object State, object Term)
206 { 208 {
207 State = YP.getValue(State); 209 State = YP.getValue(State);
@@ -209,18 +211,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
209 object[] functorArgs = YP.getFunctorArgs(Term); 211 object[] functorArgs = YP.getFunctorArgs(Term);
210 212
211 Variable pred = new Variable(); 213 Variable pred = new Variable();
212// disable warning: don't see how we can code this differently short
213// of rewriting the whole thing
214#pragma warning disable 0168
215 foreach (bool l1 in ((CompilerState)State)._pred.match 214 foreach (bool l1 in ((CompilerState)State)._pred.match
216 (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") })) 215 (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") }))
217 { 216 {
218 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) 217 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
219 { 218 {
220 return true; 219 return true;
221 } 220 }
222 } 221 }
223#pragma warning restore 0168
224 222
225 return false; 223 return false;
226 } 224 }
@@ -232,21 +230,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
232 object[] functorArgs = YP.getFunctorArgs(Term); 230 object[] functorArgs = YP.getFunctorArgs(Term);
233 231
234 Variable pred = new Variable(); 232 Variable pred = new Variable();
235// disable warning: don't see how we can code this differently short
236// of rewriting the whole thing
237#pragma warning disable 0168
238 foreach (bool l1 in ((CompilerState)State)._pred.match 233 foreach (bool l1 in ((CompilerState)State)._pred.match
239 (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") })) 234 (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") }))
240 { 235 {
241 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) 236 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
242 { 237 {
243 return true; 238 return true;
244 } 239 }
245 } 240 }
246#pragma warning restore 0168
247 241
248 return false; 242 return false;
249 } 243 }
244 #pragma warning restore 0168, 0164, 0162
250 245
251 /// <summary> 246 /// <summary>
252 /// Return false if any of args is out, otherwise true. 247 /// Return false if any of args is out, otherwise true.
@@ -283,9 +278,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
283 } 278 }
284 } 279 }
285 280
286 // disable warning unused variables, the following code is 281 // disable warning on l1, don't see how we can
287 // infested with it. 282 // code this differently
288#pragma warning disable 0168, 0219 283 #pragma warning disable 0168, 0219, 0164, 0162
289 284
290 /// <summary> 285 /// <summary>
291 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction 286 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
@@ -317,15 +312,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
317 try 312 try
318 { 313 {
319 YP.tell(functionCode); 314 YP.tell(functionCode);
320 Variable FunctionCode = new Variable(); 315 Variable PseudoCode = new Variable();
321 foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode)) 316 foreach (bool l2 in makeFunctionPseudoCode(RuleList, PseudoCode))
322 { 317 {
323 if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) 318 if (YP.termEqual(PseudoCode, Atom.a("getDeclaringClass")))
324 // Ignore getDeclaringClass since we have access to the one passed in. 319 // Ignore getDeclaringClass since we have access to the one passed in.
325 continue; 320 continue;
326 321
327 // Debug: should check if FunctionCode is a single call. 322 convertFunctionCSharp(PseudoCode);
328 convertFunctionCSharp(FunctionCode);
329 } 323 }
330 YP.told(); 324 YP.told();
331 } 325 }
@@ -340,7 +334,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
340 } 334 }
341 335
342 /// <summary> 336 /// <summary>
343 /// 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.
344 /// The function name must be "function" and have nArgs arguments. 339 /// The function name must be "function" and have nArgs arguments.
345 /// </summary> 340 /// </summary>
346 /// <param name="functionCode">the code for the iterator, such as 341 /// <param name="functionCode">the code for the iterator, such as
@@ -370,8 +365,16 @@ using System.Collections.Generic;
370using OpenSim.Region.ScriptEngine.Shared.YieldProlog; 365using OpenSim.Region.ScriptEngine.Shared.YieldProlog;
371 366
372namespace Temporary { 367namespace Temporary {
373 public class Temporary : YP.IClause { 368 public class Temporary : YP.ClauseHeadAndBody, YP.IClause {");
374 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 + @" {
375"); 378");
376 sourceCode.Append(functionCode); 379 sourceCode.Append(functionCode);
377 // Basically, match applies the args to function. 380 // Basically, match applies the args to function.
@@ -399,6 +402,102 @@ namespace Temporary {
399 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null); 402 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
400 } 403 }
401 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
402 // Compiler output follows. 501 // Compiler output follows.
403 502
404 public class YPInnerClass { } 503 public class YPInnerClass { }
@@ -448,26 +547,9 @@ namespace Temporary {
448 Variable State = new Variable(); 547 Variable State = new Variable();
449 foreach (bool l2 in CompilerState.make(State)) 548 foreach (bool l2 in CompilerState.make(State))
450 { 549 {
451 CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det")); 550 assertYPPred(State);
452 CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
453 CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
454 CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
455 CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
456 CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
457 CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
458 CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
459 CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
460 CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
461 CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
462 CompilerState.assertPred(State, new Functor1(@"compound", 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 CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
466 CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
467 CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
468 CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
469 processCompilerDirectives(RuleList, State); 551 processCompilerDirectives(RuleList, State);
470 foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass"))) 552 foreach (bool l3 in YP.unify(FunctionCode, Atom.a("getDeclaringClass")))
471 { 553 {
472 yield return false; 554 yield return false;
473 } 555 }
@@ -479,6 +561,33 @@ namespace Temporary {
479 } 561 }
480 } 562 }
481 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
482 public static void processCompilerDirectives(object arg1, object arg2) 591 public static void processCompilerDirectives(object arg1, object arg2)
483 { 592 {
484 { 593 {
@@ -494,7 +603,7 @@ namespace Temporary {
494 Variable Determinism = new Variable(); 603 Variable Determinism = new Variable();
495 Variable x3 = new Variable(); 604 Variable x3 = new Variable();
496 Variable RestRules = new Variable(); 605 Variable RestRules = new Variable();
497 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)))
498 { 607 {
499 CompilerState.assertPred(State, Pred, Determinism); 608 CompilerState.assertPred(State, Pred, Determinism);
500 processCompilerDirectives(RestRules, State); 609 processCompilerDirectives(RestRules, State);
@@ -507,7 +616,7 @@ namespace Temporary {
507 Variable PredicateList = new Variable(); 616 Variable PredicateList = new Variable();
508 Variable x3 = new Variable(); 617 Variable x3 = new Variable();
509 Variable RestRules = new Variable(); 618 Variable RestRules = new Variable();
510 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)))
511 { 620 {
512 foreach (bool l3 in importPredicateList(State, Module, PredicateList)) 621 foreach (bool l3 in importPredicateList(State, Module, PredicateList))
513 { 622 {
@@ -521,7 +630,7 @@ namespace Temporary {
521 Variable x1 = new Variable(); 630 Variable x1 = new Variable();
522 Variable x2 = new Variable(); 631 Variable x2 = new Variable();
523 Variable RestRules = new Variable(); 632 Variable RestRules = new Variable();
524 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)))
525 { 634 {
526 processCompilerDirectives(RestRules, State); 635 processCompilerDirectives(RestRules, State);
527 return; 636 return;
@@ -535,11 +644,11 @@ namespace Temporary {
535 Variable RestRules = new Variable(); 644 Variable RestRules = new Variable();
536 Variable Name = new Variable(); 645 Variable Name = new Variable();
537 Variable Arity = new Variable(); 646 Variable Arity = new Variable();
538 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)))
539 { 648 {
540 foreach (bool l3 in YP.functor(Head, Name, Arity)) 649 foreach (bool l3 in YP.functor(Head, Name, Arity))
541 { 650 {
542 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); 651 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
543 processCompilerDirectives(RestRules, State); 652 processCompilerDirectives(RestRules, State);
544 return; 653 return;
545 } 654 }
@@ -552,11 +661,11 @@ namespace Temporary {
552 Variable RestRules = new Variable(); 661 Variable RestRules = new Variable();
553 Variable Name = new Variable(); 662 Variable Name = new Variable();
554 Variable Arity = new Variable(); 663 Variable Arity = new Variable();
555 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)))
556 { 665 {
557 foreach (bool l3 in YP.functor(Fact, Name, Arity)) 666 foreach (bool l3 in YP.functor(Fact, Name, Arity))
558 { 667 {
559 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); 668 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
560 processCompilerDirectives(RestRules, State); 669 processCompilerDirectives(RestRules, State);
561 return; 670 return;
562 } 671 }
@@ -591,7 +700,7 @@ namespace Temporary {
591 Variable Name = new Variable(); 700 Variable Name = new Variable();
592 Variable Arity = new Variable(); 701 Variable Arity = new Variable();
593 Variable Rest = new Variable(); 702 Variable Rest = new Variable();
594 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)))
595 { 704 {
596 CompilerState.assertModuleForNameArity(State, Name, Arity, Module); 705 CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
597 foreach (bool l3 in importPredicateList(State, Module, Rest)) 706 foreach (bool l3 in importPredicateList(State, Module, Rest))
@@ -663,17 +772,17 @@ namespace Temporary {
663 Variable BodyCode = new Variable(); 772 Variable BodyCode = new Variable();
664 Variable ReturnType = new Variable(); 773 Variable ReturnType = new Variable();
665 Variable BodyWithReturn = new Variable(); 774 Variable BodyWithReturn = new Variable();
666 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))
667 { 776 {
668 foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7))) 777 foreach (bool l3 in YP.unify(FirstRule, new Functor1(":-", x7)))
669 { 778 {
670 goto cutIf1; 779 goto cutIf1;
671 } 780 }
672 foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule)) 781 foreach (bool l3 in YP.unify(new Functor2(":-", Head, x9), FirstRule))
673 { 782 {
674 CompilerState.startFunction(State, Head); 783 CompilerState.startFunction(State, Head);
675 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); 784 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
676 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) 785 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
677 { 786 {
678 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) 787 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
679 { 788 {
@@ -707,26 +816,26 @@ namespace Temporary {
707 { 816 {
708 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) 817 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
709 { 818 {
710 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 819 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
711 { 820 {
712 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) 821 foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
713 { 822 {
714 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 823 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
715 { 824 {
716 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))
717 { 826 {
718 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 })))
719 { 828 {
720 yield return false; 829 yield return false;
721 } 830 }
722 } 831 }
723 goto cutIf7; 832 goto cutIf7;
724 } 833 }
725 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 834 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
726 { 835 {
727 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 836 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
728 { 837 {
729 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 })))
730 { 839 {
731 yield return false; 840 yield return false;
732 } 841 }
@@ -737,16 +846,16 @@ namespace Temporary {
737 { 846 {
738 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 847 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
739 { 848 {
740 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 })))
741 { 850 {
742 yield return false; 851 yield return false;
743 } 852 }
744 } 853 }
745 goto cutIf9; 854 goto cutIf9;
746 } 855 }
747 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))
748 { 857 {
749 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 })))
750 { 859 {
751 yield return false; 860 yield return false;
752 } 861 }
@@ -758,26 +867,26 @@ namespace Temporary {
758 } 867 }
759 goto cutIf6; 868 goto cutIf6;
760 } 869 }
761 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 870 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
762 { 871 {
763 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) 872 foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
764 { 873 {
765 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 874 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
766 { 875 {
767 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))
768 { 877 {
769 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 })))
770 { 879 {
771 yield return false; 880 yield return false;
772 } 881 }
773 } 882 }
774 goto cutIf11; 883 goto cutIf11;
775 } 884 }
776 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 885 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
777 { 886 {
778 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 887 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
779 { 888 {
780 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 })))
781 { 890 {
782 yield return false; 891 yield return false;
783 } 892 }
@@ -788,16 +897,16 @@ namespace Temporary {
788 { 897 {
789 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 898 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
790 { 899 {
791 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 })))
792 { 901 {
793 yield return false; 902 yield return false;
794 } 903 }
795 } 904 }
796 goto cutIf13; 905 goto cutIf13;
797 } 906 }
798 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))
799 { 908 {
800 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 })))
801 { 910 {
802 yield return false; 911 yield return false;
803 } 912 }
@@ -809,24 +918,24 @@ namespace Temporary {
809 } 918 }
810 goto cutIf10; 919 goto cutIf10;
811 } 920 }
812 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) 921 foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
813 { 922 {
814 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 923 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
815 { 924 {
816 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))
817 { 926 {
818 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 })))
819 { 928 {
820 yield return false; 929 yield return false;
821 } 930 }
822 } 931 }
823 goto cutIf14; 932 goto cutIf14;
824 } 933 }
825 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 934 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
826 { 935 {
827 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 936 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
828 { 937 {
829 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 })))
830 { 939 {
831 yield return false; 940 yield return false;
832 } 941 }
@@ -837,16 +946,16 @@ namespace Temporary {
837 { 946 {
838 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 947 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
839 { 948 {
840 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 })))
841 { 950 {
842 yield return false; 951 yield return false;
843 } 952 }
844 } 953 }
845 goto cutIf16; 954 goto cutIf16;
846 } 955 }
847 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))
848 { 957 {
849 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 })))
850 { 959 {
851 yield return false; 960 yield return false;
852 } 961 }
@@ -870,8 +979,8 @@ namespace Temporary {
870 foreach (bool l3 in YP.unify(Head, FirstRule)) 979 foreach (bool l3 in YP.unify(Head, FirstRule))
871 { 980 {
872 CompilerState.startFunction(State, Head); 981 CompilerState.startFunction(State, Head);
873 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); 982 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
874 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) 983 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
875 { 984 {
876 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) 985 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
877 { 986 {
@@ -905,26 +1014,26 @@ namespace Temporary {
905 { 1014 {
906 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) 1015 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
907 { 1016 {
908 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1017 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
909 { 1018 {
910 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) 1019 foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
911 { 1020 {
912 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1021 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
913 { 1022 {
914 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))
915 { 1024 {
916 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 })))
917 { 1026 {
918 yield return false; 1027 yield return false;
919 } 1028 }
920 } 1029 }
921 goto cutIf21; 1030 goto cutIf21;
922 } 1031 }
923 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1032 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
924 { 1033 {
925 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1034 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
926 { 1035 {
927 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 })))
928 { 1037 {
929 yield return false; 1038 yield return false;
930 } 1039 }
@@ -935,16 +1044,16 @@ namespace Temporary {
935 { 1044 {
936 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1045 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
937 { 1046 {
938 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 })))
939 { 1048 {
940 yield return false; 1049 yield return false;
941 } 1050 }
942 } 1051 }
943 goto cutIf23; 1052 goto cutIf23;
944 } 1053 }
945 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))
946 { 1055 {
947 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 })))
948 { 1057 {
949 yield return false; 1058 yield return false;
950 } 1059 }
@@ -956,26 +1065,26 @@ namespace Temporary {
956 } 1065 }
957 goto cutIf20; 1066 goto cutIf20;
958 } 1067 }
959 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1068 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
960 { 1069 {
961 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) 1070 foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
962 { 1071 {
963 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1072 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
964 { 1073 {
965 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))
966 { 1075 {
967 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 })))
968 { 1077 {
969 yield return false; 1078 yield return false;
970 } 1079 }
971 } 1080 }
972 goto cutIf25; 1081 goto cutIf25;
973 } 1082 }
974 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1083 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
975 { 1084 {
976 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1085 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
977 { 1086 {
978 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 })))
979 { 1088 {
980 yield return false; 1089 yield return false;
981 } 1090 }
@@ -986,16 +1095,16 @@ namespace Temporary {
986 { 1095 {
987 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) 1096 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
988 { 1097 {
989 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 })))
990 { 1099 {
991 yield return false; 1100 yield return false;
992 } 1101 }
993 } 1102 }
994 goto cutIf27; 1103 goto cutIf27;
995 } 1104 }
996 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))
997 { 1106 {
998 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 })))
999 { 1108 {
1000 yield return false; 1109 yield return false;
1001 } 1110 }
@@ -1007,24 +1116,24 @@ namespace Temporary {
1007 } 1116 }
1008 goto cutIf24; 1117 goto cutIf24;
1009 } 1118 }
1010 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) 1119 foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
1011 { 1120 {
1012 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1121 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
1013 { 1122 {
1014 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))
1015 { 1124 {
1016 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 })))
1017 { 1126 {
1018 yield return false; 1127 yield return false;
1019 } 1128 }
1020 } 1129 }
1021 goto cutIf28; 1130 goto cutIf28;
1022 } 1131 }
1023 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1132 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
1024 { 1133 {
1025 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 1134 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1026 { 1135 {
1027 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 })))
1028 { 1137 {
1029 yield return false; 1138 yield return false;
1030 } 1139 }
@@ -1035,16 +1144,16 @@ namespace Temporary {
1035 { 1144 {
1036 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) 1145 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1037 { 1146 {
1038 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 })))
1039 { 1148 {
1040 yield return false; 1149 yield return false;
1041 } 1150 }
1042 } 1151 }
1043 goto cutIf30; 1152 goto cutIf30;
1044 } 1153 }
1045 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))
1046 { 1155 {
1047 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 })))
1048 { 1157 {
1049 yield return false; 1158 yield return false;
1050 } 1159 }
@@ -1119,13 +1228,13 @@ namespace Temporary {
1119 Variable RestSamePredicates = new Variable(); 1228 Variable RestSamePredicates = new Variable();
1120 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 1229 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1121 { 1230 {
1122 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))
1123 { 1232 {
1124 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))
1125 { 1234 {
1126 foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule)) 1235 foreach (bool l5 in YP.unify(new Functor2(":-", FirstHead, x11), FirstRule))
1127 { 1236 {
1128 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) 1237 foreach (bool l6 in YP.unify(new Functor2(":-", SecondHead, x13), SecondRule))
1129 { 1238 {
1130 foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) 1239 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1131 { 1240 {
@@ -1187,7 +1296,7 @@ namespace Temporary {
1187 } 1296 }
1188 foreach (bool l5 in YP.unify(FirstHead, FirstRule)) 1297 foreach (bool l5 in YP.unify(FirstHead, FirstRule))
1189 { 1298 {
1190 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) 1299 foreach (bool l6 in YP.unify(new Functor2(":-", SecondHead, x13), SecondRule))
1191 { 1300 {
1192 foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) 1301 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1193 { 1302 {
@@ -1275,9 +1384,9 @@ namespace Temporary {
1275 Variable Rest = new Variable(); 1384 Variable Rest = new Variable();
1276 Variable ClauseCode = new Variable(); 1385 Variable ClauseCode = new Variable();
1277 Variable RestResults = new Variable(); 1386 Variable RestResults = new Variable();
1278 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)))
1279 { 1388 {
1280 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)))
1281 { 1390 {
1282 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode)) 1391 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
1283 { 1392 {
@@ -1316,7 +1425,7 @@ namespace Temporary {
1316 Variable VariableName = new Variable(); 1425 Variable VariableName = new Variable();
1317 Variable ArgName = new Variable(); 1426 Variable ArgName = new Variable();
1318 Variable RestArgAssignments = new Variable(); 1427 Variable RestArgAssignments = new Variable();
1319 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)))
1320 { 1429 {
1321 foreach (bool l3 in member(VariableName, MergedArgNames)) 1430 foreach (bool l3 in member(VariableName, MergedArgNames))
1322 { 1431 {
@@ -1327,7 +1436,7 @@ namespace Temporary {
1327 } 1436 }
1328 goto cutIf1; 1437 goto cutIf1;
1329 } 1438 }
1330 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))
1331 { 1440 {
1332 yield return true; 1441 yield return true;
1333 yield break; 1442 yield break;
@@ -1356,9 +1465,9 @@ namespace Temporary {
1356 Variable ArgAssignments = new Variable(); 1465 Variable ArgAssignments = new Variable();
1357 Variable _Calls = new Variable(); 1466 Variable _Calls = new Variable();
1358 Variable RestClauseBag = new Variable(); 1467 Variable RestClauseBag = new Variable();
1359 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)))
1360 { 1469 {
1361 foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments)) 1470 foreach (bool l3 in member(new Functor2("f", VariableName, ArgName), ArgAssignments))
1362 { 1471 {
1363 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName)) 1472 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
1364 { 1473 {
@@ -1387,7 +1496,7 @@ namespace Temporary {
1387 Variable RestResults = new Variable(); 1496 Variable RestResults = new Variable();
1388 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 1497 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1389 { 1498 {
1390 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)))
1391 { 1500 {
1392 foreach (bool l4 in maplist_arg(Rest, RestResults)) 1501 foreach (bool l4 in maplist_arg(Rest, RestResults))
1393 { 1502 {
@@ -1429,7 +1538,7 @@ namespace Temporary {
1429 { 1538 {
1430 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) 1539 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1431 { 1540 {
1432 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))
1433 { 1542 {
1434 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1))) 1543 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
1435 { 1544 {
@@ -1458,7 +1567,7 @@ namespace Temporary {
1458 Variable BodyCode = new Variable(); 1567 Variable BodyCode = new Variable();
1459 Variable VariableNamesList = new Variable(); 1568 Variable VariableNamesList = new Variable();
1460 Variable ArgUnifications = new Variable(); 1569 Variable ArgUnifications = new Variable();
1461 foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule)) 1570 foreach (bool l2 in YP.unify(new Functor2(":-", Head, Body), Rule))
1462 { 1571 {
1463 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions); 1572 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
1464 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs))) 1573 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
@@ -1484,7 +1593,7 @@ namespace Temporary {
1484 } 1593 }
1485 } 1594 }
1486 { 1595 {
1487 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))
1488 { 1597 {
1489 yield return true; 1598 yield return true;
1490 yield break; 1599 yield break;
@@ -1557,13 +1666,13 @@ namespace Temporary {
1557 { 1666 {
1558 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs))) 1667 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
1559 { 1668 {
1560 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)))
1561 { 1670 {
1562 foreach (bool l5 in YP.number_codes(Index, NumberCodes)) 1671 foreach (bool l5 in YP.number_codes(Index, NumberCodes))
1563 { 1672 {
1564 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes)) 1673 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
1565 { 1674 {
1566 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))
1567 { 1676 {
1568 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1))) 1677 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
1569 { 1678 {
@@ -1619,7 +1728,7 @@ namespace Temporary {
1619 Variable NumberCodes = new Variable(); 1728 Variable NumberCodes = new Variable();
1620 Variable NumberAtom = new Variable(); 1729 Variable NumberAtom = new Variable();
1621 Variable ArgName = new Variable(); 1730 Variable ArgName = new Variable();
1622 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)))
1623 { 1732 {
1624 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1)) 1733 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
1625 { 1734 {
@@ -1627,9 +1736,9 @@ namespace Temporary {
1627 { 1736 {
1628 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) 1737 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1629 { 1738 {
1630 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))
1631 { 1740 {
1632 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))
1633 { 1742 {
1634 yield return true; 1743 yield return true;
1635 yield break; 1744 yield break;
@@ -1649,9 +1758,9 @@ namespace Temporary {
1649 Variable _Var = new Variable(); 1758 Variable _Var = new Variable();
1650 Variable RestVariableNames = new Variable(); 1759 Variable RestVariableNames = new Variable();
1651 Variable DeclarationsOut = new Variable(); 1760 Variable DeclarationsOut = new Variable();
1652 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)))
1653 { 1762 {
1654 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)))
1655 { 1764 {
1656 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) 1765 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1657 { 1766 {
@@ -1713,7 +1822,7 @@ namespace Temporary {
1713 object PseudoCode = arg3; 1822 object PseudoCode = arg3;
1714 if (YP.var(A)) 1823 if (YP.var(A))
1715 { 1824 {
1716 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))
1717 { 1826 {
1718 yield return true; 1827 yield return true;
1719 yield break; 1828 yield break;
@@ -1722,25 +1831,14 @@ namespace Temporary {
1722 } 1831 }
1723 { 1832 {
1724 object State = arg2; 1833 object State = arg2;
1725 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) 1834 object PseudoCode = arg3;
1726 { 1835 Variable A = new Variable();
1727 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) 1836 Variable B = new Variable();
1728 { 1837 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
1729 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1730 {
1731 yield return true;
1732 yield break;
1733 }
1734 }
1735 }
1736 }
1737 {
1738 object State = arg2;
1739 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1740 { 1838 {
1741 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) 1839 if (YP.var(A))
1742 { 1840 {
1743 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) 1841 foreach (bool l4 in compileRuleBody(new Functor2(",", new Functor1("call", A), B), State, PseudoCode))
1744 { 1842 {
1745 yield return true; 1843 yield return true;
1746 yield break; 1844 yield break;
@@ -1750,81 +1848,44 @@ namespace Temporary {
1750 } 1848 }
1751 { 1849 {
1752 object State = arg2; 1850 object State = arg2;
1753 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) 1851 object PseudoCode = arg3;
1754 { 1852 Variable A = new Variable();
1755 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) 1853 Variable B = new Variable();
1756 { 1854 Variable ACode = new Variable();
1757 CompilerState.setCodeUsesYield(State); 1855 Variable BCode = new Variable();
1758 yield return true; 1856 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
1759 yield break;
1760 }
1761 }
1762 }
1763 {
1764 object _State = arg2;
1765 Variable Name = new Variable();
1766 foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
1767 {
1768 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
1769 {
1770 yield return true;
1771 yield break;
1772 }
1773 }
1774 }
1775 {
1776 object State = arg2;
1777 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1778 { 1857 {
1779 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) 1858 foreach (bool l3 in compileFunctorCall(A, State, ACode))
1780 { 1859 {
1781 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) 1860 if (CompilerState.isDetNoneOut(State, A))
1782 { 1861 {
1783 yield return true; 1862 foreach (bool l5 in compileRuleBody(B, State, BCode))
1784 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 }
1785 } 1870 }
1786 } 1871 if (CompilerState.isSemidetNoneOut(State, A))
1787 }
1788 }
1789 {
1790 object State = arg2;
1791 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1792 {
1793 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1794 {
1795 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1796 { 1872 {
1797 yield return true; 1873 foreach (bool l5 in compileRuleBody(B, State, BCode))
1798 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 }
1799 } 1881 }
1800 } 1882 foreach (bool l4 in compileRuleBody(B, State, BCode))
1801 }
1802 }
1803 {
1804 object State = arg2;
1805 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1806 {
1807 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
1808 {
1809 CompilerState.setCodeUsesYield(State);
1810 yield return true;
1811 yield break;
1812 }
1813 }
1814 }
1815 {
1816 object State = arg2;
1817 object PseudoCode = arg3;
1818 Variable A = new Variable();
1819 Variable B = new Variable();
1820 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
1821 {
1822 if (YP.var(A))
1823 {
1824 foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
1825 { 1883 {
1826 yield return true; 1884 foreach (bool l5 in YP.unify(PseudoCode, new ListPair(new Functor2("foreach", ACode, BCode), Atom.NIL)))
1827 yield break; 1885 {
1886 yield return true;
1887 yield break;
1888 }
1828 } 1889 }
1829 } 1890 }
1830 } 1891 }
@@ -1836,9 +1897,9 @@ namespace Temporary {
1836 Variable T = new Variable(); 1897 Variable T = new Variable();
1837 Variable B = new Variable(); 1898 Variable B = new Variable();
1838 Variable C = new Variable(); 1899 Variable C = new Variable();
1839 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)))
1840 { 1901 {
1841 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))
1842 { 1903 {
1843 yield return true; 1904 yield return true;
1844 yield break; 1905 yield break;
@@ -1851,9 +1912,9 @@ namespace Temporary {
1851 Variable A = new Variable(); 1912 Variable A = new Variable();
1852 Variable B = new Variable(); 1913 Variable B = new Variable();
1853 Variable C = new Variable(); 1914 Variable C = new Variable();
1854 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)))
1855 { 1916 {
1856 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))
1857 { 1918 {
1858 yield return true; 1919 yield return true;
1859 yield break; 1920 yield break;
@@ -1866,9 +1927,9 @@ namespace Temporary {
1866 Variable B = new Variable(); 1927 Variable B = new Variable();
1867 Variable ACode = new Variable(); 1928 Variable ACode = new Variable();
1868 Variable BCode = new Variable(); 1929 Variable BCode = new Variable();
1869 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)))
1870 { 1931 {
1871 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)))
1872 { 1933 {
1873 if (CompilerState.isSemidetNoneOut(State, A)) 1934 if (CompilerState.isSemidetNoneOut(State, A))
1874 { 1935 {
@@ -1889,9 +1950,9 @@ namespace Temporary {
1889 object PseudoCode = arg3; 1950 object PseudoCode = arg3;
1890 Variable A = new Variable(); 1951 Variable A = new Variable();
1891 Variable B = new Variable(); 1952 Variable B = new Variable();
1892 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)))
1893 { 1954 {
1894 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))
1895 { 1956 {
1896 yield return true; 1957 yield return true;
1897 yield break; 1958 yield break;
@@ -1903,9 +1964,9 @@ namespace Temporary {
1903 object PseudoCode = arg3; 1964 object PseudoCode = arg3;
1904 Variable A = new Variable(); 1965 Variable A = new Variable();
1905 Variable B = new Variable(); 1966 Variable B = new Variable();
1906 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)))
1907 { 1968 {
1908 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))
1909 { 1970 {
1910 yield return true; 1971 yield return true;
1911 yield break; 1972 yield break;
@@ -1918,9 +1979,9 @@ namespace Temporary {
1918 Variable A = new Variable(); 1979 Variable A = new Variable();
1919 Variable T = new Variable(); 1980 Variable T = new Variable();
1920 Variable B = new Variable(); 1981 Variable B = new Variable();
1921 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)))
1922 { 1983 {
1923 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))
1924 { 1985 {
1925 yield return true; 1986 yield return true;
1926 yield break; 1987 yield break;
@@ -1933,9 +1994,9 @@ namespace Temporary {
1933 Variable A = new Variable(); 1994 Variable A = new Variable();
1934 Variable B = new Variable(); 1995 Variable B = new Variable();
1935 Variable C = new Variable(); 1996 Variable C = new Variable();
1936 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)))
1937 { 1998 {
1938 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))
1939 { 2000 {
1940 yield return true; 2001 yield return true;
1941 yield break; 2002 yield break;
@@ -1947,11 +2008,11 @@ namespace Temporary {
1947 object PseudoCode = arg3; 2008 object PseudoCode = arg3;
1948 Variable A = new Variable(); 2009 Variable A = new Variable();
1949 Variable ACode = new Variable(); 2010 Variable ACode = new Variable();
1950 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)))
1951 { 2012 {
1952 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2013 foreach (bool l3 in compileRuleBody(A, State, ACode))
1953 { 2014 {
1954 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))
1955 { 2016 {
1956 yield return true; 2017 yield return true;
1957 yield break; 2018 yield break;
@@ -1965,11 +2026,11 @@ namespace Temporary {
1965 Variable Name = new Variable(); 2026 Variable Name = new Variable();
1966 Variable A = new Variable(); 2027 Variable A = new Variable();
1967 Variable ACode = new Variable(); 2028 Variable ACode = new Variable();
1968 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)))
1969 { 2030 {
1970 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2031 foreach (bool l3 in compileRuleBody(A, State, ACode))
1971 { 2032 {
1972 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))
1973 { 2034 {
1974 yield return true; 2035 yield return true;
1975 yield break; 2036 yield break;
@@ -1980,7 +2041,7 @@ namespace Temporary {
1980 { 2041 {
1981 object _State = arg2; 2042 object _State = arg2;
1982 Variable x1 = new Variable(); 2043 Variable x1 = new Variable();
1983 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)))
1984 { 2045 {
1985 foreach (bool l3 in YP.unify(arg3, Atom.NIL)) 2046 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1986 { 2047 {
@@ -1993,7 +2054,7 @@ namespace Temporary {
1993 object State = arg2; 2054 object State = arg2;
1994 object PseudoCode = arg3; 2055 object PseudoCode = arg3;
1995 Variable A = new Variable(); 2056 Variable A = new Variable();
1996 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)))
1997 { 2058 {
1998 foreach (bool l3 in compileRuleBody(A, State, PseudoCode)) 2059 foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
1999 { 2060 {
@@ -2010,9 +2071,9 @@ namespace Temporary {
2010 Variable ACode = new Variable(); 2071 Variable ACode = new Variable();
2011 Variable TermCode = new Variable(); 2072 Variable TermCode = new Variable();
2012 Variable BCode = new Variable(); 2073 Variable BCode = new Variable();
2013 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)))
2014 { 2075 {
2015 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)))
2016 { 2077 {
2017 foreach (bool l4 in compileTerm(A, State, ACode)) 2078 foreach (bool l4 in compileTerm(A, State, ACode))
2018 { 2079 {
@@ -2030,58 +2091,10 @@ namespace Temporary {
2030 } 2091 }
2031 { 2092 {
2032 object State = arg2; 2093 object State = arg2;
2033 Variable A = new Variable();
2034 Variable B = new Variable();
2035 Variable ACode = new Variable(); 2094 Variable ACode = new Variable();
2036 Variable BCode = new Variable();
2037 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2038 {
2039 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2040 {
2041 if (CompilerState.isDetNoneOut(State, A))
2042 {
2043 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2044 {
2045 foreach (bool l6 in compileRuleBody(B, State, BCode))
2046 {
2047 yield return true;
2048 yield break;
2049 }
2050 }
2051 }
2052 }
2053 }
2054 }
2055 {
2056 object State = arg2;
2057 Variable A = new Variable();
2058 Variable B = new Variable(); 2095 Variable B = new Variable();
2059 Variable ACode = new Variable();
2060 Variable BCode = new Variable(); 2096 Variable BCode = new Variable();
2061 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)))
2062 {
2063 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
2064 {
2065 if (CompilerState.isSemidetNoneOut(State, A))
2066 {
2067 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2068 {
2069 foreach (bool l6 in compileRuleBody(B, State, BCode))
2070 {
2071 yield return true;
2072 yield break;
2073 }
2074 }
2075 }
2076 }
2077 }
2078 }
2079 {
2080 object State = arg2;
2081 Variable ACode = new Variable();
2082 Variable B = new Variable();
2083 Variable BCode = new Variable();
2084 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
2085 { 2098 {
2086 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) 2099 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2087 { 2100 {
@@ -2104,9 +2117,9 @@ namespace Temporary {
2104 Variable Name = new Variable(); 2117 Variable Name = new Variable();
2105 Variable X1 = new Variable(); 2118 Variable X1 = new Variable();
2106 Variable X2 = new Variable(); 2119 Variable X2 = new Variable();
2107 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) 2120 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
2108 { 2121 {
2109 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)))
2110 { 2123 {
2111 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)))))
2112 { 2125 {
@@ -2131,21 +2144,6 @@ namespace Temporary {
2131 { 2144 {
2132 object State = arg2; 2145 object State = arg2;
2133 object PseudoCode = arg3; 2146 object PseudoCode = arg3;
2134 Variable A = new Variable();
2135 Variable B = new Variable();
2136 Variable C = new Variable();
2137 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
2138 {
2139 foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
2140 {
2141 yield return true;
2142 yield break;
2143 }
2144 }
2145 }
2146 {
2147 object State = arg2;
2148 object PseudoCode = arg3;
2149 Variable Template = new Variable(); 2147 Variable Template = new Variable();
2150 Variable Goal = new Variable(); 2148 Variable Goal = new Variable();
2151 Variable Bag = new Variable(); 2149 Variable Bag = new Variable();
@@ -2155,19 +2153,19 @@ namespace Temporary {
2155 Variable GoalAndAddCode = new Variable(); 2153 Variable GoalAndAddCode = new Variable();
2156 Variable BagCode = new Variable(); 2154 Variable BagCode = new Variable();
2157 Variable BCode = new Variable(); 2155 Variable BCode = new Variable();
2158 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)))
2159 { 2157 {
2160 foreach (bool l3 in compileTerm(Template, State, TemplateCode)) 2158 foreach (bool l3 in compileTerm(Template, State, TemplateCode))
2161 { 2159 {
2162 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers)) 2160 foreach (bool l4 in CompilerState.gensym(State, Atom.a("findallAnswers"), FindallAnswers))
2163 { 2161 {
2164 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))
2165 { 2163 {
2166 foreach (bool l6 in compileTerm(Bag, State, BagCode)) 2164 foreach (bool l6 in compileTerm(Bag, State, BagCode))
2167 { 2165 {
2168 foreach (bool l7 in compileRuleBody(B, State, BCode)) 2166 foreach (bool l7 in compileRuleBody(B, State, BCode))
2169 { 2167 {
2170 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))
2171 { 2169 {
2172 yield return true; 2170 yield return true;
2173 yield break; 2171 yield break;
@@ -2186,9 +2184,9 @@ namespace Temporary {
2186 Variable Goal = new Variable(); 2184 Variable Goal = new Variable();
2187 Variable Bag = new Variable(); 2185 Variable Bag = new Variable();
2188 Variable B = new Variable(); 2186 Variable B = new Variable();
2189 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)))
2190 { 2188 {
2191 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))
2192 { 2190 {
2193 yield return true; 2191 yield return true;
2194 yield break; 2192 yield break;
@@ -2202,9 +2200,9 @@ namespace Temporary {
2202 Variable Goal = new Variable(); 2200 Variable Goal = new Variable();
2203 Variable Bag = new Variable(); 2201 Variable Bag = new Variable();
2204 Variable B = new Variable(); 2202 Variable B = new Variable();
2205 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)))
2206 { 2204 {
2207 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))
2208 { 2206 {
2209 yield return true; 2207 yield return true;
2210 yield break; 2208 yield break;
@@ -2217,9 +2215,9 @@ namespace Temporary {
2217 Variable B = new Variable(); 2215 Variable B = new Variable();
2218 Variable ATermCode = new Variable(); 2216 Variable ATermCode = new Variable();
2219 Variable BCode = new Variable(); 2217 Variable BCode = new Variable();
2220 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)))
2221 { 2219 {
2222 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)))
2223 { 2221 {
2224 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2222 foreach (bool l4 in compileTerm(A, State, ATermCode))
2225 { 2223 {
@@ -2238,9 +2236,9 @@ namespace Temporary {
2238 Variable B = new Variable(); 2236 Variable B = new Variable();
2239 Variable ATermCode = new Variable(); 2237 Variable ATermCode = new Variable();
2240 Variable BCode = new Variable(); 2238 Variable BCode = new Variable();
2241 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)))
2242 { 2240 {
2243 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)))
2244 { 2242 {
2245 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2243 foreach (bool l4 in compileTerm(A, State, ATermCode))
2246 { 2244 {
@@ -2259,9 +2257,9 @@ namespace Temporary {
2259 Variable B = new Variable(); 2257 Variable B = new Variable();
2260 Variable ATermCode = new Variable(); 2258 Variable ATermCode = new Variable();
2261 Variable BCode = new Variable(); 2259 Variable BCode = new Variable();
2262 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)))
2263 { 2261 {
2264 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)))
2265 { 2263 {
2266 foreach (bool l4 in compileTerm(A, State, ATermCode)) 2264 foreach (bool l4 in compileTerm(A, State, ATermCode))
2267 { 2265 {
@@ -2279,9 +2277,9 @@ namespace Temporary {
2279 object PseudoCode = arg3; 2277 object PseudoCode = arg3;
2280 Variable A = new Variable(); 2278 Variable A = new Variable();
2281 Variable B = new Variable(); 2279 Variable B = new Variable();
2282 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)))
2283 { 2281 {
2284 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))
2285 { 2283 {
2286 yield return true; 2284 yield return true;
2287 yield break; 2285 yield break;
@@ -2299,11 +2297,11 @@ namespace Temporary {
2299 Variable BCode = new Variable(); 2297 Variable BCode = new Variable();
2300 Variable CatcherTermCode = new Variable(); 2298 Variable CatcherTermCode = new Variable();
2301 Variable HandlerAndBCode = new Variable(); 2299 Variable HandlerAndBCode = new Variable();
2302 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)))
2303 { 2301 {
2304 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)))))
2305 { 2303 {
2306 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal)) 2304 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal))
2307 { 2305 {
2308 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode)) 2306 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode))
2309 { 2307 {
@@ -2311,7 +2309,7 @@ namespace Temporary {
2311 { 2309 {
2312 foreach (bool l7 in compileRuleBody(B, State, BCode)) 2310 foreach (bool l7 in compileRuleBody(B, State, BCode))
2313 { 2311 {
2314 foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode)) 2312 foreach (bool l8 in compileRuleBody(new Functor2(",", Handler, B), State, HandlerAndBCode))
2315 { 2313 {
2316 yield return true; 2314 yield return true;
2317 yield break; 2315 yield break;
@@ -2325,22 +2323,16 @@ namespace Temporary {
2325 } 2323 }
2326 { 2324 {
2327 object State = arg2; 2325 object State = arg2;
2326 object PseudoCode = arg3;
2328 Variable A = new Variable(); 2327 Variable A = new Variable();
2329 Variable B = new Variable(); 2328 Variable B = new Variable();
2330 Variable ACode = new Variable(); 2329 Variable C = new Variable();
2331 Variable BCode = new Variable(); 2330 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor2(",", A, B), C)))
2332 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2333 { 2331 {
2334 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))
2335 { 2333 {
2336 foreach (bool l4 in compileFunctorCall(A, State, ACode)) 2334 yield return true;
2337 { 2335 yield break;
2338 foreach (bool l5 in compileRuleBody(B, State, BCode))
2339 {
2340 yield return true;
2341 yield break;
2342 }
2343 }
2344 } 2336 }
2345 } 2337 }
2346 } 2338 }
@@ -2349,11 +2341,11 @@ namespace Temporary {
2349 object PseudoCode = arg3; 2341 object PseudoCode = arg3;
2350 Variable A = new Variable(); 2342 Variable A = new Variable();
2351 Variable B = new Variable(); 2343 Variable B = new Variable();
2352 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) 2344 foreach (bool l2 in YP.unify(arg1, new Functor2(";", A, B)))
2353 { 2345 {
2354 if (YP.var(A)) 2346 if (YP.var(A))
2355 { 2347 {
2356 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))
2357 { 2349 {
2358 yield return true; 2350 yield return true;
2359 yield break; 2351 yield break;
@@ -2368,13 +2360,13 @@ namespace Temporary {
2368 Variable B = new Variable(); 2360 Variable B = new Variable();
2369 Variable CutIfLabel = new Variable(); 2361 Variable CutIfLabel = new Variable();
2370 Variable Code = new Variable(); 2362 Variable Code = new Variable();
2371 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)))
2372 { 2364 {
2373 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)))
2374 { 2366 {
2375 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel)) 2367 foreach (bool l4 in CompilerState.gensym(State, Atom.a("cutIf"), CutIfLabel))
2376 { 2368 {
2377 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))
2378 { 2370 {
2379 yield return true; 2371 yield return true;
2380 yield break; 2372 yield break;
@@ -2386,11 +2378,24 @@ namespace Temporary {
2386 { 2378 {
2387 object State = arg2; 2379 object State = arg2;
2388 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;
2389 Variable A = new Variable(); 2394 Variable A = new Variable();
2390 Variable B = new Variable(); 2395 Variable B = new Variable();
2391 Variable ACode = new Variable(); 2396 Variable ACode = new Variable();
2392 Variable BCode = new Variable(); 2397 Variable BCode = new Variable();
2393 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) 2398 foreach (bool l2 in YP.unify(arg1, new Functor2(";", A, B)))
2394 { 2399 {
2395 foreach (bool l3 in compileRuleBody(A, State, ACode)) 2400 foreach (bool l3 in compileRuleBody(A, State, ACode))
2396 { 2401 {
@@ -2406,10 +2411,102 @@ namespace Temporary {
2406 } 2411 }
2407 } 2412 }
2408 { 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 {
2409 object A = arg1; 2506 object A = arg1;
2410 object State = arg2; 2507 object State = arg2;
2411 object PseudoCode = arg3; 2508 object PseudoCode = arg3;
2412 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))
2413 { 2510 {
2414 yield return true; 2511 yield return true;
2415 yield break; 2512 yield break;
@@ -2433,15 +2530,15 @@ namespace Temporary {
2433 { 2530 {
2434 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal)) 2531 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
2435 { 2532 {
2436 foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers)) 2533 foreach (bool l5 in CompilerState.gensym(State, Atom.a("bagofAnswers"), BagofAnswers))
2437 { 2534 {
2438 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))
2439 { 2536 {
2440 foreach (bool l7 in compileTerm(Bag, State, BagCode)) 2537 foreach (bool l7 in compileTerm(Bag, State, BagCode))
2441 { 2538 {
2442 foreach (bool l8 in compileRuleBody(B, State, BCode)) 2539 foreach (bool l8 in compileRuleBody(B, State, BCode))
2443 { 2540 {
2444 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))
2445 { 2542 {
2446 yield return true; 2543 yield return true;
2447 yield break; 2544 yield break;
@@ -2460,7 +2557,7 @@ namespace Temporary {
2460 { 2557 {
2461 { 2558 {
2462 object Goal = arg1; 2559 object Goal = arg1;
2463 foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal))) 2560 foreach (bool l2 in YP.unify(arg2, new Functor1("call", Goal)))
2464 { 2561 {
2465 if (YP.var(Goal)) 2562 if (YP.var(Goal))
2466 { 2563 {
@@ -2473,7 +2570,7 @@ namespace Temporary {
2473 object UnqualifiedGoal = arg2; 2570 object UnqualifiedGoal = arg2;
2474 Variable x1 = new Variable(); 2571 Variable x1 = new Variable();
2475 Variable Goal = new Variable(); 2572 Variable Goal = new Variable();
2476 foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal))) 2573 foreach (bool l2 in YP.unify(arg1, new Functor2("^", x1, Goal)))
2477 { 2574 {
2478 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal)) 2575 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
2479 { 2576 {
@@ -2498,9 +2595,9 @@ namespace Temporary {
2498 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2) 2595 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
2499 { 2596 {
2500 { 2597 {
2501 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:="))) 2598 foreach (bool l2 in YP.unify(arg1, Atom.a("=:=")))
2502 { 2599 {
2503 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal"))) 2600 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.equal")))
2504 { 2601 {
2505 yield return true; 2602 yield return true;
2506 yield break; 2603 yield break;
@@ -2508,9 +2605,9 @@ namespace Temporary {
2508 } 2605 }
2509 } 2606 }
2510 { 2607 {
2511 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\="))) 2608 foreach (bool l2 in YP.unify(arg1, Atom.a("=\\=")))
2512 { 2609 {
2513 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual"))) 2610 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.notEqual")))
2514 { 2611 {
2515 yield return true; 2612 yield return true;
2516 yield break; 2613 yield break;
@@ -2518,9 +2615,9 @@ namespace Temporary {
2518 } 2615 }
2519 } 2616 }
2520 { 2617 {
2521 foreach (bool l2 in YP.unify(arg1, Atom.a(@">"))) 2618 foreach (bool l2 in YP.unify(arg1, Atom.a(">")))
2522 { 2619 {
2523 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan"))) 2620 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.greaterThan")))
2524 { 2621 {
2525 yield return true; 2622 yield return true;
2526 yield break; 2623 yield break;
@@ -2528,9 +2625,9 @@ namespace Temporary {
2528 } 2625 }
2529 } 2626 }
2530 { 2627 {
2531 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<"))) 2628 foreach (bool l2 in YP.unify(arg1, Atom.a("<")))
2532 { 2629 {
2533 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan"))) 2630 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.lessThan")))
2534 { 2631 {
2535 yield return true; 2632 yield return true;
2536 yield break; 2633 yield break;
@@ -2538,9 +2635,9 @@ namespace Temporary {
2538 } 2635 }
2539 } 2636 }
2540 { 2637 {
2541 foreach (bool l2 in YP.unify(arg1, Atom.a(@">="))) 2638 foreach (bool l2 in YP.unify(arg1, Atom.a(">=")))
2542 { 2639 {
2543 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual"))) 2640 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.greaterThanOrEqual")))
2544 { 2641 {
2545 yield return true; 2642 yield return true;
2546 yield break; 2643 yield break;
@@ -2548,9 +2645,9 @@ namespace Temporary {
2548 } 2645 }
2549 } 2646 }
2550 { 2647 {
2551 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<"))) 2648 foreach (bool l2 in YP.unify(arg1, Atom.a("=<")))
2552 { 2649 {
2553 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual"))) 2650 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.lessThanOrEqual")))
2554 { 2651 {
2555 yield return true; 2652 yield return true;
2556 yield break; 2653 yield break;
@@ -2566,26 +2663,26 @@ namespace Temporary {
2566 Variable FunctorArgs = new Variable(); 2663 Variable FunctorArgs = new Variable();
2567 Variable x6 = new Variable(); 2664 Variable x6 = new Variable();
2568 Variable Arity = new Variable(); 2665 Variable Arity = new Variable();
2569 Variable CompiledArgs = new Variable();
2570 Variable FunctionName = new Variable(); 2666 Variable FunctionName = new Variable();
2667 Variable CompiledArgs = new Variable();
2571 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)))
2572 { 2669 {
2573 foreach (bool l3 in YP.functor(Functor_1, x6, Arity)) 2670 foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
2574 { 2671 {
2575 foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) 2672 foreach (bool l4 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
2576 { 2673 {
2577 foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) 2674 foreach (bool l5 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
2578 { 2675 {
2579 if (YP.termEqual(FunctionName, Atom.NIL)) 2676 if (YP.termEqual(FunctionName, Atom.NIL))
2580 { 2677 {
2581 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)))))
2582 { 2679 {
2583 yield return true; 2680 yield return true;
2584 yield break; 2681 yield break;
2585 } 2682 }
2586 goto cutIf1; 2683 goto cutIf1;
2587 } 2684 }
2588 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)))
2589 { 2686 {
2590 yield return true; 2687 yield return true;
2591 yield break; 2688 yield break;
@@ -2602,6 +2699,16 @@ namespace Temporary {
2602 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)
2603 { 2700 {
2604 { 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 {
2605 object x1 = arg1; 2712 object x1 = arg1;
2606 object Name = arg2; 2713 object Name = arg2;
2607 object Arity = arg3; 2714 object Arity = arg3;
@@ -2620,7 +2727,7 @@ namespace Temporary {
2620 { 2727 {
2621 foreach (bool l3 in YP.unify(arg4, Name)) 2728 foreach (bool l3 in YP.unify(arg4, Name))
2622 { 2729 {
2623 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) 2730 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a("")))
2624 { 2731 {
2625 yield return true; 2732 yield return true;
2626 yield break; 2733 yield break;
@@ -2636,7 +2743,7 @@ namespace Temporary {
2636 { 2743 {
2637 foreach (bool l3 in YP.unify(arg4, Name)) 2744 foreach (bool l3 in YP.unify(arg4, Name))
2638 { 2745 {
2639 foreach (bool l4 in Atom.module(Name, Atom.a(@""))) 2746 foreach (bool l4 in Atom.module(Name, Atom.a("")))
2640 { 2747 {
2641 yield return true; 2748 yield return true;
2642 yield break; 2749 yield break;
@@ -2647,7 +2754,7 @@ namespace Temporary {
2647 { 2754 {
2648 object _State = arg1; 2755 object _State = arg1;
2649 object Name = arg2; 2756 object Name = arg2;
2650 object Arity = arg3; 2757 object _Arity = arg3;
2651 foreach (bool l2 in YP.unify(arg4, Atom.NIL)) 2758 foreach (bool l2 in YP.unify(arg4, Atom.NIL))
2652 { 2759 {
2653 foreach (bool l3 in Atom.module(Name, Atom.NIL)) 2760 foreach (bool l3 in Atom.module(Name, Atom.NIL))
@@ -2666,33 +2773,137 @@ namespace Temporary {
2666 Variable Message = new Variable(); 2773 Variable Message = new Variable();
2667 foreach (bool l2 in Atom.module(Name, Module)) 2774 foreach (bool l2 in Atom.module(Name, Module))
2668 { 2775 {
2669 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))
2670 { 2777 {
2671 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));
2672 yield return true; 2779 yield return true;
2673 yield break; 2780 yield break;
2674 } 2781 }
2675 } 2782 }
2676 } 2783 }
2677 { 2784 {
2678 object _State = arg1; 2785 object _State = arg1;
2679 object Name = arg2; 2786 object Name = arg2;
2680 object _Arity = arg3; 2787 object _Arity = arg3;
2681 object x4 = arg4; 2788 object x4 = arg4;
2682 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")));
2683 yield return true; 2790 yield return true;
2684 yield break; 2791 yield break;
2685 } 2792 }
2686 } 2793 }
2687 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
2688 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3) 2899 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3)
2689 { 2900 {
2690 { 2901 {
2691 foreach (bool l2 in YP.unify(arg1, Atom.a(@"="))) 2902 foreach (bool l2 in YP.unify(arg1, Atom.a("=")))
2692 { 2903 {
2693 foreach (bool l3 in YP.unify(arg2, 2)) 2904 foreach (bool l3 in YP.unify(arg2, 2))
2694 { 2905 {
2695 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify"))) 2906 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.unify")))
2696 { 2907 {
2697 yield return true; 2908 yield return true;
2698 yield break; 2909 yield break;
@@ -2701,11 +2912,11 @@ namespace Temporary {
2701 } 2912 }
2702 } 2913 }
2703 { 2914 {
2704 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=.."))) 2915 foreach (bool l2 in YP.unify(arg1, Atom.a("=..")))
2705 { 2916 {
2706 foreach (bool l3 in YP.unify(arg2, 2)) 2917 foreach (bool l3 in YP.unify(arg2, 2))
2707 { 2918 {
2708 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ"))) 2919 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.univ")))
2709 { 2920 {
2710 yield return true; 2921 yield return true;
2711 yield break; 2922 yield break;
@@ -2714,11 +2925,11 @@ namespace Temporary {
2714 } 2925 }
2715 } 2926 }
2716 { 2927 {
2717 foreach (bool l2 in YP.unify(arg1, Atom.a(@"var"))) 2928 foreach (bool l2 in YP.unify(arg1, Atom.a("var")))
2718 { 2929 {
2719 foreach (bool l3 in YP.unify(arg2, 1)) 2930 foreach (bool l3 in YP.unify(arg2, 1))
2720 { 2931 {
2721 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var"))) 2932 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.var")))
2722 { 2933 {
2723 yield return true; 2934 yield return true;
2724 yield break; 2935 yield break;
@@ -2727,11 +2938,11 @@ namespace Temporary {
2727 } 2938 }
2728 } 2939 }
2729 { 2940 {
2730 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar"))) 2941 foreach (bool l2 in YP.unify(arg1, Atom.a("nonvar")))
2731 { 2942 {
2732 foreach (bool l3 in YP.unify(arg2, 1)) 2943 foreach (bool l3 in YP.unify(arg2, 1))
2733 { 2944 {
2734 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar"))) 2945 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.nonvar")))
2735 { 2946 {
2736 yield return true; 2947 yield return true;
2737 yield break; 2948 yield break;
@@ -2740,11 +2951,11 @@ namespace Temporary {
2740 } 2951 }
2741 } 2952 }
2742 { 2953 {
2743 foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg"))) 2954 foreach (bool l2 in YP.unify(arg1, Atom.a("arg")))
2744 { 2955 {
2745 foreach (bool l3 in YP.unify(arg2, 3)) 2956 foreach (bool l3 in YP.unify(arg2, 3))
2746 { 2957 {
2747 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg"))) 2958 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.arg")))
2748 { 2959 {
2749 yield return true; 2960 yield return true;
2750 yield break; 2961 yield break;
@@ -2753,11 +2964,11 @@ namespace Temporary {
2753 } 2964 }
2754 } 2965 }
2755 { 2966 {
2756 foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor"))) 2967 foreach (bool l2 in YP.unify(arg1, Atom.a("functor")))
2757 { 2968 {
2758 foreach (bool l3 in YP.unify(arg2, 3)) 2969 foreach (bool l3 in YP.unify(arg2, 3))
2759 { 2970 {
2760 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor"))) 2971 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.functor")))
2761 { 2972 {
2762 yield return true; 2973 yield return true;
2763 yield break; 2974 yield break;
@@ -2766,11 +2977,11 @@ namespace Temporary {
2766 } 2977 }
2767 } 2978 }
2768 { 2979 {
2769 foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat"))) 2980 foreach (bool l2 in YP.unify(arg1, Atom.a("repeat")))
2770 { 2981 {
2771 foreach (bool l3 in YP.unify(arg2, 0)) 2982 foreach (bool l3 in YP.unify(arg2, 0))
2772 { 2983 {
2773 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat"))) 2984 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.repeat")))
2774 { 2985 {
2775 yield return true; 2986 yield return true;
2776 yield break; 2987 yield break;
@@ -2779,11 +2990,11 @@ namespace Temporary {
2779 } 2990 }
2780 } 2991 }
2781 { 2992 {
2782 foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code"))) 2993 foreach (bool l2 in YP.unify(arg1, Atom.a("get_code")))
2783 { 2994 {
2784 foreach (bool l3 in YP.unify(arg2, 1)) 2995 foreach (bool l3 in YP.unify(arg2, 1))
2785 { 2996 {
2786 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")))
2787 { 2998 {
2788 yield return true; 2999 yield return true;
2789 yield break; 3000 yield break;
@@ -2792,11 +3003,11 @@ namespace Temporary {
2792 } 3003 }
2793 } 3004 }
2794 { 3005 {
2795 foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op"))) 3006 foreach (bool l2 in YP.unify(arg1, Atom.a("current_op")))
2796 { 3007 {
2797 foreach (bool l3 in YP.unify(arg2, 3)) 3008 foreach (bool l3 in YP.unify(arg2, 3))
2798 { 3009 {
2799 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")))
2800 { 3011 {
2801 yield return true; 3012 yield return true;
2802 yield break; 3013 yield break;
@@ -2805,11 +3016,24 @@ namespace Temporary {
2805 } 3016 }
2806 } 3017 }
2807 { 3018 {
2808 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")))
2809 { 3033 {
2810 foreach (bool l3 in YP.unify(arg2, 2)) 3034 foreach (bool l3 in YP.unify(arg2, 2))
2811 { 3035 {
2812 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")))
2813 { 3037 {
2814 yield return true; 3038 yield return true;
2815 yield break; 3039 yield break;
@@ -2818,11 +3042,11 @@ namespace Temporary {
2818 } 3042 }
2819 } 3043 }
2820 { 3044 {
2821 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat"))) 3045 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_concat")))
2822 { 3046 {
2823 foreach (bool l3 in YP.unify(arg2, 3)) 3047 foreach (bool l3 in YP.unify(arg2, 3))
2824 { 3048 {
2825 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")))
2826 { 3050 {
2827 yield return true; 3051 yield return true;
2828 yield break; 3052 yield break;
@@ -2831,11 +3055,11 @@ namespace Temporary {
2831 } 3055 }
2832 } 3056 }
2833 { 3057 {
2834 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom"))) 3058 foreach (bool l2 in YP.unify(arg1, Atom.a("sub_atom")))
2835 { 3059 {
2836 foreach (bool l3 in YP.unify(arg2, 5)) 3060 foreach (bool l3 in YP.unify(arg2, 5))
2837 { 3061 {
2838 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")))
2839 { 3063 {
2840 yield return true; 3064 yield return true;
2841 yield break; 3065 yield break;
@@ -2844,11 +3068,11 @@ namespace Temporary {
2844 } 3068 }
2845 } 3069 }
2846 { 3070 {
2847 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes"))) 3071 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_chars")))
2848 { 3072 {
2849 foreach (bool l3 in YP.unify(arg2, 2)) 3073 foreach (bool l3 in YP.unify(arg2, 2))
2850 { 3074 {
2851 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")))
2852 { 3076 {
2853 yield return true; 3077 yield return true;
2854 yield break; 3078 yield break;
@@ -2857,11 +3081,11 @@ namespace Temporary {
2857 } 3081 }
2858 } 3082 }
2859 { 3083 {
2860 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes"))) 3084 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_codes")))
2861 { 3085 {
2862 foreach (bool l3 in YP.unify(arg2, 2)) 3086 foreach (bool l3 in YP.unify(arg2, 2))
2863 { 3087 {
2864 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")))
2865 { 3089 {
2866 yield return true; 3090 yield return true;
2867 yield break; 3091 yield break;
@@ -2870,11 +3094,11 @@ namespace Temporary {
2870 } 3094 }
2871 } 3095 }
2872 { 3096 {
2873 foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term"))) 3097 foreach (bool l2 in YP.unify(arg1, Atom.a("char_code")))
2874 { 3098 {
2875 foreach (bool l3 in YP.unify(arg2, 2)) 3099 foreach (bool l3 in YP.unify(arg2, 2))
2876 { 3100 {
2877 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")))
2878 { 3102 {
2879 yield return true; 3103 yield return true;
2880 yield break; 3104 yield break;
@@ -2883,11 +3107,50 @@ namespace Temporary {
2883 } 3107 }
2884 } 3108 }
2885 { 3109 {
2886 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort"))) 3110 foreach (bool l2 in YP.unify(arg1, Atom.a("number_chars")))
2887 { 3111 {
2888 foreach (bool l3 in YP.unify(arg2, 2)) 3112 foreach (bool l3 in YP.unify(arg2, 2))
2889 { 3113 {
2890 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")))
2891 { 3154 {
2892 yield return true; 3155 yield return true;
2893 yield break; 3156 yield break;
@@ -2912,11 +3175,24 @@ namespace Temporary {
2912 } 3175 }
2913 } 3176 }
2914 { 3177 {
2915 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl"))) 3178 foreach (bool l2 in YP.unify(arg1, Atom.a("nl")))
2916 { 3179 {
2917 foreach (bool l3 in YP.unify(arg2, 0)) 3180 foreach (bool l3 in YP.unify(arg2, 0))
2918 { 3181 {
2919 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")))
2920 { 3196 {
2921 yield return true; 3197 yield return true;
2922 yield break; 3198 yield break;
@@ -2925,11 +3201,24 @@ namespace Temporary {
2925 } 3201 }
2926 } 3202 }
2927 { 3203 {
2928 foreach (bool l2 in YP.unify(arg1, Atom.a(@"write"))) 3204 foreach (bool l2 in YP.unify(arg1, Atom.a("put_code")))
2929 { 3205 {
2930 foreach (bool l3 in YP.unify(arg2, 1)) 3206 foreach (bool l3 in YP.unify(arg2, 1))
2931 { 3207 {
2932 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")))
2933 { 3222 {
2934 yield return true; 3223 yield return true;
2935 yield break; 3224 yield break;
@@ -2938,11 +3227,11 @@ namespace Temporary {
2938 } 3227 }
2939 } 3228 }
2940 { 3229 {
2941 foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code"))) 3230 foreach (bool l2 in YP.unify(arg1, Atom.a("retract")))
2942 { 3231 {
2943 foreach (bool l3 in YP.unify(arg2, 1)) 3232 foreach (bool l3 in YP.unify(arg2, 1))
2944 { 3233 {
2945 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code"))) 3234 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.retract")))
2946 { 3235 {
2947 yield return true; 3236 yield return true;
2948 yield break; 3237 yield break;
@@ -2951,11 +3240,11 @@ namespace Temporary {
2951 } 3240 }
2952 } 3241 }
2953 { 3242 {
2954 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom"))) 3243 foreach (bool l2 in YP.unify(arg1, Atom.a("abolish")))
2955 { 3244 {
2956 foreach (bool l3 in YP.unify(arg2, 1)) 3245 foreach (bool l3 in YP.unify(arg2, 1))
2957 { 3246 {
2958 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom"))) 3247 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.abolish")))
2959 { 3248 {
2960 yield return true; 3249 yield return true;
2961 yield break; 3250 yield break;
@@ -2964,11 +3253,11 @@ namespace Temporary {
2964 } 3253 }
2965 } 3254 }
2966 { 3255 {
2967 foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer"))) 3256 foreach (bool l2 in YP.unify(arg1, Atom.a("retractall")))
2968 { 3257 {
2969 foreach (bool l3 in YP.unify(arg2, 1)) 3258 foreach (bool l3 in YP.unify(arg2, 1))
2970 { 3259 {
2971 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer"))) 3260 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.retractall")))
2972 { 3261 {
2973 yield return true; 3262 yield return true;
2974 yield break; 3263 yield break;
@@ -2977,12 +3266,25 @@ namespace Temporary {
2977 } 3266 }
2978 } 3267 }
2979 { 3268 {
2980 foreach (bool l2 in YP.unify(arg1, Atom.a(@"float"))) 3269 foreach (bool l2 in YP.unify(arg1, Atom.a("atom")))
2981 { 3270 {
2982 foreach (bool l3 in YP.unify(arg2, 1)) 3271 foreach (bool l3 in YP.unify(arg2, 1))
2983 { 3272 {
2984 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")))
2985 { 3283 {
3284 foreach (bool l3 in YP.unify(arg2, 1))
3285 {
3286 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.integer")))
3287 {
2986 yield return true; 3288 yield return true;
2987 yield break; 3289 yield break;
2988 } 3290 }
@@ -2990,11 +3292,11 @@ namespace Temporary {
2990 } 3292 }
2991 } 3293 }
2992 { 3294 {
2993 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number"))) 3295 foreach (bool l2 in YP.unify(arg1, Atom.a("float")))
2994 { 3296 {
2995 foreach (bool l3 in YP.unify(arg2, 1)) 3297 foreach (bool l3 in YP.unify(arg2, 1))
2996 { 3298 {
2997 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number"))) 3299 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.isFloat")))
2998 { 3300 {
2999 yield return true; 3301 yield return true;
3000 yield break; 3302 yield break;
@@ -3003,11 +3305,11 @@ namespace Temporary {
3003 } 3305 }
3004 } 3306 }
3005 { 3307 {
3006 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic"))) 3308 foreach (bool l2 in YP.unify(arg1, Atom.a("number")))
3007 { 3309 {
3008 foreach (bool l3 in YP.unify(arg2, 1)) 3310 foreach (bool l3 in YP.unify(arg2, 1))
3009 { 3311 {
3010 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic"))) 3312 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.number")))
3011 { 3313 {
3012 yield return true; 3314 yield return true;
3013 yield break; 3315 yield break;
@@ -3016,11 +3318,11 @@ namespace Temporary {
3016 } 3318 }
3017 } 3319 }
3018 { 3320 {
3019 foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound"))) 3321 foreach (bool l2 in YP.unify(arg1, Atom.a("atomic")))
3020 { 3322 {
3021 foreach (bool l3 in YP.unify(arg2, 1)) 3323 foreach (bool l3 in YP.unify(arg2, 1))
3022 { 3324 {
3023 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound"))) 3325 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.atomic")))
3024 { 3326 {
3025 yield return true; 3327 yield return true;
3026 yield break; 3328 yield break;
@@ -3029,11 +3331,11 @@ namespace Temporary {
3029 } 3331 }
3030 } 3332 }
3031 { 3333 {
3032 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=="))) 3334 foreach (bool l2 in YP.unify(arg1, Atom.a("compound")))
3033 { 3335 {
3034 foreach (bool l3 in YP.unify(arg2, 2)) 3336 foreach (bool l3 in YP.unify(arg2, 1))
3035 { 3337 {
3036 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual"))) 3338 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.compound")))
3037 { 3339 {
3038 yield return true; 3340 yield return true;
3039 yield break; 3341 yield break;
@@ -3042,11 +3344,11 @@ namespace Temporary {
3042 } 3344 }
3043 } 3345 }
3044 { 3346 {
3045 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\=="))) 3347 foreach (bool l2 in YP.unify(arg1, Atom.a("==")))
3046 { 3348 {
3047 foreach (bool l3 in YP.unify(arg2, 2)) 3349 foreach (bool l3 in YP.unify(arg2, 2))
3048 { 3350 {
3049 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual"))) 3351 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termEqual")))
3050 { 3352 {
3051 yield return true; 3353 yield return true;
3052 yield break; 3354 yield break;
@@ -3055,11 +3357,11 @@ namespace Temporary {
3055 } 3357 }
3056 } 3358 }
3057 { 3359 {
3058 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<"))) 3360 foreach (bool l2 in YP.unify(arg1, Atom.a("\\==")))
3059 { 3361 {
3060 foreach (bool l3 in YP.unify(arg2, 2)) 3362 foreach (bool l3 in YP.unify(arg2, 2))
3061 { 3363 {
3062 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan"))) 3364 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termNotEqual")))
3063 { 3365 {
3064 yield return true; 3366 yield return true;
3065 yield break; 3367 yield break;
@@ -3068,11 +3370,11 @@ namespace Temporary {
3068 } 3370 }
3069 } 3371 }
3070 { 3372 {
3071 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<"))) 3373 foreach (bool l2 in YP.unify(arg1, Atom.a("@<")))
3072 { 3374 {
3073 foreach (bool l3 in YP.unify(arg2, 2)) 3375 foreach (bool l3 in YP.unify(arg2, 2))
3074 { 3376 {
3075 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual"))) 3377 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termLessThan")))
3076 { 3378 {
3077 yield return true; 3379 yield return true;
3078 yield break; 3380 yield break;
@@ -3081,11 +3383,11 @@ namespace Temporary {
3081 } 3383 }
3082 } 3384 }
3083 { 3385 {
3084 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>"))) 3386 foreach (bool l2 in YP.unify(arg1, Atom.a("@=<")))
3085 { 3387 {
3086 foreach (bool l3 in YP.unify(arg2, 2)) 3388 foreach (bool l3 in YP.unify(arg2, 2))
3087 { 3389 {
3088 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan"))) 3390 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termLessThanOrEqual")))
3089 { 3391 {
3090 yield return true; 3392 yield return true;
3091 yield break; 3393 yield break;
@@ -3094,32 +3396,45 @@ namespace Temporary {
3094 } 3396 }
3095 } 3397 }
3096 { 3398 {
3097 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>="))) 3399 foreach (bool l2 in YP.unify(arg1, Atom.a("@>")))
3098 { 3400 {
3099 foreach (bool l3 in YP.unify(arg2, 2)) 3401 foreach (bool l3 in YP.unify(arg2, 2))
3100 { 3402 {
3101 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual"))) 3403 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.termGreaterThan")))
3102 { 3404 {
3103 yield return true; 3405 yield return true;
3104 yield break; 3406 yield break;
3407 }
3408 }
3105 } 3409 }
3106 } 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 }
3107 } 3422 }
3108 } 3423 }
3109 { 3424 {
3110 foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw"))) 3425 foreach (bool l2 in YP.unify(arg1, Atom.a("throw")))
3111 { 3426 {
3112 foreach (bool l3 in YP.unify(arg2, 1)) 3427 foreach (bool l3 in YP.unify(arg2, 1))
3113 {
3114 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
3115 { 3428 {
3116 yield return true; 3429 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.throwException")))
3117 yield break; 3430 {
3431 yield return true;
3432 yield break;
3433 }
3118 } 3434 }
3119 } 3435 }
3120 } 3436 }
3121 } 3437 }
3122 }
3123 3438
3124 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) 3439 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
3125 { 3440 {
@@ -3127,7 +3442,7 @@ namespace Temporary {
3127 object Term = arg1; 3442 object Term = arg1;
3128 object State = arg2; 3443 object State = arg2;
3129 Variable VariableName = new Variable(); 3444 Variable VariableName = new Variable();
3130 foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName))) 3445 foreach (bool l2 in YP.unify(arg3, new Functor1("var", VariableName)))
3131 { 3446 {
3132 if (YP.var(Term)) 3447 if (YP.var(Term))
3133 { 3448 {
@@ -3143,7 +3458,7 @@ namespace Temporary {
3143 object _State = arg2; 3458 object _State = arg2;
3144 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 3459 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3145 { 3460 {
3146 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"))))
3147 { 3462 {
3148 yield return true; 3463 yield return true;
3149 yield break; 3464 yield break;
@@ -3159,14 +3474,14 @@ namespace Temporary {
3159 { 3474 {
3160 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode)) 3475 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
3161 { 3476 {
3162 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)))))
3163 { 3478 {
3164 yield return true; 3479 yield return true;
3165 yield break; 3480 yield break;
3166 } 3481 }
3167 goto cutIf1; 3482 goto cutIf1;
3168 } 3483 }
3169 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))))
3170 { 3485 {
3171 yield return true; 3486 yield return true;
3172 yield break; 3487 yield break;
@@ -3183,7 +3498,7 @@ namespace Temporary {
3183 Variable Arg2 = new Variable(); 3498 Variable Arg2 = new Variable();
3184 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 3499 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3185 { 3500 {
3186 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)))))
3187 { 3502 {
3188 foreach (bool l4 in compileTerm(First, State, Arg1)) 3503 foreach (bool l4 in compileTerm(First, State, Arg1))
3189 { 3504 {
@@ -3217,7 +3532,7 @@ namespace Temporary {
3217 { 3532 {
3218 if (YP.termEqual(TermArgs, Atom.NIL)) 3533 if (YP.termEqual(TermArgs, Atom.NIL))
3219 { 3534 {
3220 foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name))) 3535 foreach (bool l4 in YP.unify(Result, new Functor1("object", Name)))
3221 { 3536 {
3222 yield return true; 3537 yield return true;
3223 yield break; 3538 yield break;
@@ -3228,55 +3543,55 @@ namespace Temporary {
3228 { 3543 {
3229 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode)) 3544 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
3230 { 3545 {
3231 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)))))
3232 { 3547 {
3233 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)))
3234 { 3549 {
3235 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3550 foreach (bool l7 in compileTerm(X1, State, Arg1))
3236 { 3551 {
3237 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)))))
3238 { 3553 {
3239 yield return true; 3554 yield return true;
3240 yield break; 3555 yield break;
3241 } 3556 }
3242 } 3557 }
3243 goto cutIf4; 3558 goto cutIf4;
3244 } 3559 }
3245 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))))
3246 { 3561 {
3247 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3562 foreach (bool l7 in compileTerm(X1, State, Arg1))
3248 { 3563 {
3249 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3564 foreach (bool l8 in compileTerm(X2, State, Arg2))
3250 { 3565 {
3251 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))))))
3252 { 3567 {
3253 yield return true; 3568 yield return true;
3254 yield break; 3569 yield break;
3255 } 3570 }
3256 } 3571 }
3257 } 3572 }
3258 goto cutIf5; 3573 goto cutIf5;
3259 } 3574 }
3260 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)))))
3261 { 3576 {
3262 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3577 foreach (bool l7 in compileTerm(X1, State, Arg1))
3263 { 3578 {
3264 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3579 foreach (bool l8 in compileTerm(X2, State, Arg2))
3265 { 3580 {
3266 foreach (bool l9 in compileTerm(X3, State, Arg3)) 3581 foreach (bool l9 in compileTerm(X3, State, Arg3))
3267 { 3582 {
3268 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)))))))
3269 { 3584 {
3270 yield return true; 3585 yield return true;
3271 yield break; 3586 yield break;
3272 } 3587 }
3273 } 3588 }
3274 } 3589 }
3275 } 3590 }
3276 } 3591 }
3277 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args)) 3592 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
3278 { 3593 {
3279 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)))))
3280 { 3595 {
3281 yield return true; 3596 yield return true;
3282 yield break; 3597 yield break;
@@ -3286,15 +3601,15 @@ namespace Temporary {
3286 cutIf4: 3601 cutIf4:
3287 { } 3602 { }
3288 } 3603 }
3289 goto cutIf3; 3604 goto cutIf3;
3290 } 3605 }
3291 foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name))) 3606 foreach (bool l4 in YP.unify(NameCode, new Functor1("object", Name)))
3292 { 3607 {
3293 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)))
3294 { 3609 {
3295 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3610 foreach (bool l6 in compileTerm(X1, State, Arg1))
3296 { 3611 {
3297 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)))))
3298 { 3613 {
3299 yield return true; 3614 yield return true;
3300 yield break; 3615 yield break;
@@ -3308,7 +3623,7 @@ namespace Temporary {
3308 { 3623 {
3309 foreach (bool l7 in compileTerm(X2, State, Arg2)) 3624 foreach (bool l7 in compileTerm(X2, State, Arg2))
3310 { 3625 {
3311 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))))))
3312 { 3627 {
3313 yield return true; 3628 yield return true;
3314 yield break; 3629 yield break;
@@ -3320,33 +3635,33 @@ namespace Temporary {
3320 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)))))
3321 { 3636 {
3322 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3637 foreach (bool l6 in compileTerm(X1, State, Arg1))
3323 {
3324 foreach (bool l7 in compileTerm(X2, State, Arg2))
3325 {
3326 foreach (bool l8 in compileTerm(X3, State, Arg3))
3327 { 3638 {
3328 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))
3329 { 3640 {
3330 yield return true; 3641 foreach (bool l8 in compileTerm(X3, State, Arg3))
3331 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 }
3332 } 3649 }
3333 } 3650 }
3334 } 3651 }
3335 }
3336 }
3337 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args)) 3652 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
3338 { 3653 {
3339 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)))))
3340 { 3655 {
3341 yield return true; 3656 yield return true;
3342 yield break; 3657 yield break;
3343 } 3658 }
3344 } 3659 }
3345 cutIf7: 3660 cutIf7:
3346 cutIf6: 3661 cutIf6:
3347 { } 3662 { }
3348 } 3663 }
3349 cutIf3: 3664 cutIf3:
3350 { } 3665 { }
3351 } 3666 }
3352 cutIf2: 3667 cutIf2:
@@ -3355,18 +3670,36 @@ namespace Temporary {
3355 } 3670 }
3356 } 3671 }
3357 3672
3358 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)
3359 { 3674 {
3360 { 3675 {
3361 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("")))
3362 { 3679 {
3363 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))))
3364 { 3681 {
3365 yield return true; 3682 yield return true;
3366 yield break; 3683 yield break;
3367 } 3684 }
3368 } 3685 }
3369 } 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 }
3370 } 3703 }
3371 3704
3372 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)
@@ -3430,7 +3763,7 @@ namespace Temporary {
3430 { 3763 {
3431 foreach (bool l7 in compileExpression(X1, State, Arg1)) 3764 foreach (bool l7 in compileExpression(X1, State, Arg1))
3432 { 3765 {
3433 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))))
3434 { 3767 {
3435 yield return true; 3768 yield return true;
3436 yield break; 3769 yield break;
@@ -3456,7 +3789,7 @@ namespace Temporary {
3456 { 3789 {
3457 foreach (bool l8 in compileExpression(X2, State, Arg2)) 3790 foreach (bool l8 in compileExpression(X2, State, Arg2))
3458 { 3791 {
3459 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)))))
3460 { 3793 {
3461 yield return true; 3794 yield return true;
3462 yield break; 3795 yield break;
@@ -3468,8 +3801,8 @@ namespace Temporary {
3468 } 3801 }
3469 foreach (bool l5 in YP.functor(Term, x12, Arity)) 3802 foreach (bool l5 in YP.functor(Term, x12, Arity))
3470 { 3803 {
3471 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")));
3472 yield return false; 3805 yield return false;
3473 } 3806 }
3474 cutIf3: 3807 cutIf3:
3475 cutIf2: 3808 cutIf2:
@@ -3491,9 +3824,9 @@ namespace Temporary {
3491 public static IEnumerable<bool> unaryFunction(object arg1, object arg2) 3824 public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
3492 { 3825 {
3493 { 3826 {
3494 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) 3827 foreach (bool l2 in YP.unify(arg1, Atom.a("-")))
3495 { 3828 {
3496 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate"))) 3829 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.negate")))
3497 { 3830 {
3498 yield return true; 3831 yield return true;
3499 yield break; 3832 yield break;
@@ -3501,9 +3834,9 @@ namespace Temporary {
3501 } 3834 }
3502 } 3835 }
3503 { 3836 {
3504 foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs"))) 3837 foreach (bool l2 in YP.unify(arg1, Atom.a("abs")))
3505 { 3838 {
3506 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs"))) 3839 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.abs")))
3507 { 3840 {
3508 yield return true; 3841 yield return true;
3509 yield break; 3842 yield break;
@@ -3511,9 +3844,9 @@ namespace Temporary {
3511 } 3844 }
3512 } 3845 }
3513 { 3846 {
3514 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign"))) 3847 foreach (bool l2 in YP.unify(arg1, Atom.a("sign")))
3515 { 3848 {
3516 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign"))) 3849 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.sign")))
3517 { 3850 {
3518 yield return true; 3851 yield return true;
3519 yield break; 3852 yield break;
@@ -3521,9 +3854,9 @@ namespace Temporary {
3521 } 3854 }
3522 } 3855 }
3523 { 3856 {
3524 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) 3857 foreach (bool l2 in YP.unify(arg1, Atom.a("float")))
3525 { 3858 {
3526 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor"))) 3859 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.toFloat")))
3527 { 3860 {
3528 yield return true; 3861 yield return true;
3529 yield break; 3862 yield break;
@@ -3531,9 +3864,9 @@ namespace Temporary {
3531 } 3864 }
3532 } 3865 }
3533 { 3866 {
3534 foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate"))) 3867 foreach (bool l2 in YP.unify(arg1, Atom.a("floor")))
3535 { 3868 {
3536 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate"))) 3869 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.floor")))
3537 { 3870 {
3538 yield return true; 3871 yield return true;
3539 yield break; 3872 yield break;
@@ -3541,9 +3874,9 @@ namespace Temporary {
3541 } 3874 }
3542 } 3875 }
3543 { 3876 {
3544 foreach (bool l2 in YP.unify(arg1, Atom.a(@"round"))) 3877 foreach (bool l2 in YP.unify(arg1, Atom.a("truncate")))
3545 { 3878 {
3546 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round"))) 3879 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.truncate")))
3547 { 3880 {
3548 yield return true; 3881 yield return true;
3549 yield break; 3882 yield break;
@@ -3551,9 +3884,9 @@ namespace Temporary {
3551 } 3884 }
3552 } 3885 }
3553 { 3886 {
3554 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) 3887 foreach (bool l2 in YP.unify(arg1, Atom.a("round")))
3555 { 3888 {
3556 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling"))) 3889 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.round")))
3557 { 3890 {
3558 yield return true; 3891 yield return true;
3559 yield break; 3892 yield break;
@@ -3561,9 +3894,9 @@ namespace Temporary {
3561 } 3894 }
3562 } 3895 }
3563 { 3896 {
3564 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin"))) 3897 foreach (bool l2 in YP.unify(arg1, Atom.a("ceiling")))
3565 { 3898 {
3566 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin"))) 3899 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.ceiling")))
3567 { 3900 {
3568 yield return true; 3901 yield return true;
3569 yield break; 3902 yield break;
@@ -3571,9 +3904,9 @@ namespace Temporary {
3571 } 3904 }
3572 } 3905 }
3573 { 3906 {
3574 foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos"))) 3907 foreach (bool l2 in YP.unify(arg1, Atom.a("sin")))
3575 { 3908 {
3576 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos"))) 3909 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.sin")))
3577 { 3910 {
3578 yield return true; 3911 yield return true;
3579 yield break; 3912 yield break;
@@ -3581,9 +3914,9 @@ namespace Temporary {
3581 } 3914 }
3582 } 3915 }
3583 { 3916 {
3584 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan"))) 3917 foreach (bool l2 in YP.unify(arg1, Atom.a("cos")))
3585 { 3918 {
3586 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan"))) 3919 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.cos")))
3587 { 3920 {
3588 yield return true; 3921 yield return true;
3589 yield break; 3922 yield break;
@@ -3591,9 +3924,9 @@ namespace Temporary {
3591 } 3924 }
3592 } 3925 }
3593 { 3926 {
3594 foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp"))) 3927 foreach (bool l2 in YP.unify(arg1, Atom.a("atan")))
3595 { 3928 {
3596 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp"))) 3929 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.atan")))
3597 { 3930 {
3598 yield return true; 3931 yield return true;
3599 yield break; 3932 yield break;
@@ -3601,9 +3934,9 @@ namespace Temporary {
3601 } 3934 }
3602 } 3935 }
3603 { 3936 {
3604 foreach (bool l2 in YP.unify(arg1, Atom.a(@"log"))) 3937 foreach (bool l2 in YP.unify(arg1, Atom.a("exp")))
3605 { 3938 {
3606 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log"))) 3939 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.exp")))
3607 { 3940 {
3608 yield return true; 3941 yield return true;
3609 yield break; 3942 yield break;
@@ -3611,9 +3944,9 @@ namespace Temporary {
3611 } 3944 }
3612 } 3945 }
3613 { 3946 {
3614 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt"))) 3947 foreach (bool l2 in YP.unify(arg1, Atom.a("log")))
3615 { 3948 {
3616 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt"))) 3949 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.log")))
3617 { 3950 {
3618 yield return true; 3951 yield return true;
3619 yield break; 3952 yield break;
@@ -3621,9 +3954,19 @@ namespace Temporary {
3621 } 3954 }
3622 } 3955 }
3623 { 3956 {
3624 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\"))) 3957 foreach (bool l2 in YP.unify(arg1, Atom.a("sqrt")))
3625 { 3958 {
3626 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")))
3627 { 3970 {
3628 yield return true; 3971 yield return true;
3629 yield break; 3972 yield break;
@@ -3635,9 +3978,9 @@ namespace Temporary {
3635 public static IEnumerable<bool> binaryFunction(object arg1, object arg2) 3978 public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
3636 { 3979 {
3637 { 3980 {
3638 foreach (bool l2 in YP.unify(arg1, Atom.a(@"+"))) 3981 foreach (bool l2 in YP.unify(arg1, Atom.a("+")))
3639 { 3982 {
3640 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add"))) 3983 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.add")))
3641 { 3984 {
3642 yield return true; 3985 yield return true;
3643 yield break; 3986 yield break;
@@ -3645,9 +3988,9 @@ namespace Temporary {
3645 } 3988 }
3646 } 3989 }
3647 { 3990 {
3648 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) 3991 foreach (bool l2 in YP.unify(arg1, Atom.a("-")))
3649 { 3992 {
3650 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract"))) 3993 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.subtract")))
3651 { 3994 {
3652 yield return true; 3995 yield return true;
3653 yield break; 3996 yield break;
@@ -3655,9 +3998,9 @@ namespace Temporary {
3655 } 3998 }
3656 } 3999 }
3657 { 4000 {
3658 foreach (bool l2 in YP.unify(arg1, Atom.a(@"*"))) 4001 foreach (bool l2 in YP.unify(arg1, Atom.a("*")))
3659 { 4002 {
3660 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply"))) 4003 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.multiply")))
3661 { 4004 {
3662 yield return true; 4005 yield return true;
3663 yield break; 4006 yield break;
@@ -3665,9 +4008,9 @@ namespace Temporary {
3665 } 4008 }
3666 } 4009 }
3667 { 4010 {
3668 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/"))) 4011 foreach (bool l2 in YP.unify(arg1, Atom.a("/")))
3669 { 4012 {
3670 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide"))) 4013 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.divide")))
3671 { 4014 {
3672 yield return true; 4015 yield return true;
3673 yield break; 4016 yield break;
@@ -3675,9 +4018,9 @@ namespace Temporary {
3675 } 4018 }
3676 } 4019 }
3677 { 4020 {
3678 foreach (bool l2 in YP.unify(arg1, Atom.a(@"//"))) 4021 foreach (bool l2 in YP.unify(arg1, Atom.a("//")))
3679 { 4022 {
3680 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide"))) 4023 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.intDivide")))
3681 { 4024 {
3682 yield return true; 4025 yield return true;
3683 yield break; 4026 yield break;
@@ -3685,9 +4028,9 @@ namespace Temporary {
3685 } 4028 }
3686 } 4029 }
3687 { 4030 {
3688 foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod"))) 4031 foreach (bool l2 in YP.unify(arg1, Atom.a("mod")))
3689 { 4032 {
3690 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod"))) 4033 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.mod")))
3691 { 4034 {
3692 yield return true; 4035 yield return true;
3693 yield break; 4036 yield break;
@@ -3695,9 +4038,9 @@ namespace Temporary {
3695 } 4038 }
3696 } 4039 }
3697 { 4040 {
3698 foreach (bool l2 in YP.unify(arg1, Atom.a(@"**"))) 4041 foreach (bool l2 in YP.unify(arg1, Atom.a("**")))
3699 { 4042 {
3700 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow"))) 4043 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.pow")))
3701 { 4044 {
3702 yield return true; 4045 yield return true;
3703 yield break; 4046 yield break;
@@ -3705,9 +4048,9 @@ namespace Temporary {
3705 } 4048 }
3706 } 4049 }
3707 { 4050 {
3708 foreach (bool l2 in YP.unify(arg1, Atom.a(@">>"))) 4051 foreach (bool l2 in YP.unify(arg1, Atom.a(">>")))
3709 { 4052 {
3710 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight"))) 4053 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseShiftRight")))
3711 { 4054 {
3712 yield return true; 4055 yield return true;
3713 yield break; 4056 yield break;
@@ -3715,9 +4058,9 @@ namespace Temporary {
3715 } 4058 }
3716 } 4059 }
3717 { 4060 {
3718 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<"))) 4061 foreach (bool l2 in YP.unify(arg1, Atom.a("<<")))
3719 { 4062 {
3720 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft"))) 4063 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseShiftLeft")))
3721 { 4064 {
3722 yield return true; 4065 yield return true;
3723 yield break; 4066 yield break;
@@ -3725,9 +4068,9 @@ namespace Temporary {
3725 } 4068 }
3726 } 4069 }
3727 { 4070 {
3728 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\"))) 4071 foreach (bool l2 in YP.unify(arg1, Atom.a("/\\")))
3729 { 4072 {
3730 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd"))) 4073 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseAnd")))
3731 { 4074 {
3732 yield return true; 4075 yield return true;
3733 yield break; 4076 yield break;
@@ -3735,9 +4078,9 @@ namespace Temporary {
3735 } 4078 }
3736 } 4079 }
3737 { 4080 {
3738 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/"))) 4081 foreach (bool l2 in YP.unify(arg1, Atom.a("\\/")))
3739 { 4082 {
3740 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr"))) 4083 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.bitwiseOr")))
3741 { 4084 {
3742 yield return true; 4085 yield return true;
3743 yield break; 4086 yield break;
@@ -3745,9 +4088,9 @@ namespace Temporary {
3745 } 4088 }
3746 } 4089 }
3747 { 4090 {
3748 foreach (bool l2 in YP.unify(arg1, Atom.a(@"min"))) 4091 foreach (bool l2 in YP.unify(arg1, Atom.a("min")))
3749 { 4092 {
3750 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min"))) 4093 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.min")))
3751 { 4094 {
3752 yield return true; 4095 yield return true;
3753 yield break; 4096 yield break;
@@ -3755,9 +4098,9 @@ namespace Temporary {
3755 } 4098 }
3756 } 4099 }
3757 { 4100 {
3758 foreach (bool l2 in YP.unify(arg1, Atom.a(@"max"))) 4101 foreach (bool l2 in YP.unify(arg1, Atom.a("max")))
3759 { 4102 {
3760 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max"))) 4103 foreach (bool l3 in YP.unify(arg2, Atom.a("YP.max")))
3761 { 4104 {
3762 yield return true; 4105 yield return true;
3763 yield break; 4106 yield break;
@@ -3769,11 +4112,11 @@ namespace Temporary {
3769 public static void convertFunctionCSharp(object arg1) 4112 public static void convertFunctionCSharp(object arg1)
3770 { 4113 {
3771 { 4114 {
3772 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 4115 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
3773 { 4116 {
3774 YP.write(Atom.a(@"public class YPInnerClass {}")); 4117 YP.write(Atom.a("public class YPInnerClass {}"));
3775 YP.nl(); 4118 YP.nl();
3776 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; }"));
3777 YP.nl(); 4120 YP.nl();
3778 YP.nl(); 4121 YP.nl();
3779 return; 4122 return;
@@ -3785,20 +4128,20 @@ namespace Temporary {
3785 Variable ArgList = new Variable(); 4128 Variable ArgList = new Variable();
3786 Variable Body = new Variable(); 4129 Variable Body = new Variable();
3787 Variable Level = new Variable(); 4130 Variable Level = new Variable();
3788 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 })))
3789 { 4132 {
3790 YP.write(Atom.a(@"public static ")); 4133 YP.write(Atom.a("public static "));
3791 YP.write(ReturnType); 4134 YP.write(ReturnType);
3792 YP.write(Atom.a(@" ")); 4135 YP.write(Atom.a(" "));
3793 YP.write(Name); 4136 YP.write(Name);
3794 YP.write(Atom.a(@"(")); 4137 YP.write(Atom.a("("));
3795 convertArgListCSharp(ArgList); 4138 convertArgListCSharp(ArgList);
3796 YP.write(Atom.a(@") {")); 4139 YP.write(Atom.a(") {"));
3797 YP.nl(); 4140 YP.nl();
3798 foreach (bool l3 in YP.unify(Level, 1)) 4141 foreach (bool l3 in YP.unify(Level, 1))
3799 { 4142 {
3800 convertStatementListCSharp(Body, Level); 4143 convertStatementListCSharp(Body, Level);
3801 YP.write(Atom.a(@"}")); 4144 YP.write(Atom.a("}"));
3802 YP.nl(); 4145 YP.nl();
3803 YP.nl(); 4146 YP.nl();
3804 return; 4147 return;
@@ -3825,9 +4168,9 @@ namespace Temporary {
3825 Variable Body = new Variable(); 4168 Variable Body = new Variable();
3826 Variable RestStatements = new Variable(); 4169 Variable RestStatements = new Variable();
3827 Variable NewStatements = new Variable(); 4170 Variable NewStatements = new Variable();
3828 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)))
3829 { 4172 {
3830 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))
3831 { 4174 {
3832 convertStatementListCSharp(NewStatements, Level); 4175 convertStatementListCSharp(NewStatements, Level);
3833 return; 4176 return;
@@ -3839,15 +4182,15 @@ namespace Temporary {
3839 Variable Name = new Variable(); 4182 Variable Name = new Variable();
3840 Variable Expression = new Variable(); 4183 Variable Expression = new Variable();
3841 Variable RestStatements = new Variable(); 4184 Variable RestStatements = new Variable();
3842 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)))
3843 { 4186 {
3844 convertIndentationCSharp(Level); 4187 convertIndentationCSharp(Level);
3845 YP.write(Type); 4188 YP.write(Type);
3846 YP.write(Atom.a(@" ")); 4189 YP.write(Atom.a(" "));
3847 YP.write(Name); 4190 YP.write(Name);
3848 YP.write(Atom.a(@" = ")); 4191 YP.write(Atom.a(" = "));
3849 convertExpressionCSharp(Expression); 4192 convertExpressionCSharp(Expression);
3850 YP.write(Atom.a(@";")); 4193 YP.write(Atom.a(";"));
3851 YP.nl(); 4194 YP.nl();
3852 convertStatementListCSharp(RestStatements, Level); 4195 convertStatementListCSharp(RestStatements, Level);
3853 return; 4196 return;
@@ -3857,13 +4200,13 @@ namespace Temporary {
3857 Variable Name = new Variable(); 4200 Variable Name = new Variable();
3858 Variable Expression = new Variable(); 4201 Variable Expression = new Variable();
3859 Variable RestStatements = new Variable(); 4202 Variable RestStatements = new Variable();
3860 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)))
3861 { 4204 {
3862 convertIndentationCSharp(Level); 4205 convertIndentationCSharp(Level);
3863 YP.write(Name); 4206 YP.write(Name);
3864 YP.write(Atom.a(@" = ")); 4207 YP.write(Atom.a(" = "));
3865 convertExpressionCSharp(Expression); 4208 convertExpressionCSharp(Expression);
3866 YP.write(Atom.a(@";")); 4209 YP.write(Atom.a(";"));
3867 YP.nl(); 4210 YP.nl();
3868 convertStatementListCSharp(RestStatements, Level); 4211 convertStatementListCSharp(RestStatements, Level);
3869 return; 4212 return;
@@ -3871,10 +4214,10 @@ namespace Temporary {
3871 } 4214 }
3872 { 4215 {
3873 Variable RestStatements = new Variable(); 4216 Variable RestStatements = new Variable();
3874 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)))
3875 { 4218 {
3876 convertIndentationCSharp(Level); 4219 convertIndentationCSharp(Level);
3877 YP.write(Atom.a(@"yield return true;")); 4220 YP.write(Atom.a("yield return true;"));
3878 YP.nl(); 4221 YP.nl();
3879 convertStatementListCSharp(RestStatements, Level); 4222 convertStatementListCSharp(RestStatements, Level);
3880 return; 4223 return;
@@ -3882,10 +4225,10 @@ namespace Temporary {
3882 } 4225 }
3883 { 4226 {
3884 Variable RestStatements = new Variable(); 4227 Variable RestStatements = new Variable();
3885 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)))
3886 { 4229 {
3887 convertIndentationCSharp(Level); 4230 convertIndentationCSharp(Level);
3888 YP.write(Atom.a(@"yield return false;")); 4231 YP.write(Atom.a("yield return false;"));
3889 YP.nl(); 4232 YP.nl();
3890 convertStatementListCSharp(RestStatements, Level); 4233 convertStatementListCSharp(RestStatements, Level);
3891 return; 4234 return;
@@ -3893,10 +4236,10 @@ namespace Temporary {
3893 } 4236 }
3894 { 4237 {
3895 Variable RestStatements = new Variable(); 4238 Variable RestStatements = new Variable();
3896 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)))
3897 { 4240 {
3898 convertIndentationCSharp(Level); 4241 convertIndentationCSharp(Level);
3899 YP.write(Atom.a(@"yield break;")); 4242 YP.write(Atom.a("yield break;"));
3900 YP.nl(); 4243 YP.nl();
3901 convertStatementListCSharp(RestStatements, Level); 4244 convertStatementListCSharp(RestStatements, Level);
3902 return; 4245 return;
@@ -3904,10 +4247,10 @@ namespace Temporary {
3904 } 4247 }
3905 { 4248 {
3906 Variable RestStatements = new Variable(); 4249 Variable RestStatements = new Variable();
3907 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)))
3908 { 4251 {
3909 convertIndentationCSharp(Level); 4252 convertIndentationCSharp(Level);
3910 YP.write(Atom.a(@"return;")); 4253 YP.write(Atom.a("return;"));
3911 YP.nl(); 4254 YP.nl();
3912 convertStatementListCSharp(RestStatements, Level); 4255 convertStatementListCSharp(RestStatements, Level);
3913 return; 4256 return;
@@ -3915,10 +4258,10 @@ namespace Temporary {
3915 } 4258 }
3916 { 4259 {
3917 Variable RestStatements = new Variable(); 4260 Variable RestStatements = new Variable();
3918 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)))
3919 { 4262 {
3920 convertIndentationCSharp(Level); 4263 convertIndentationCSharp(Level);
3921 YP.write(Atom.a(@"return true;")); 4264 YP.write(Atom.a("return true;"));
3922 YP.nl(); 4265 YP.nl();
3923 convertStatementListCSharp(RestStatements, Level); 4266 convertStatementListCSharp(RestStatements, Level);
3924 return; 4267 return;
@@ -3926,10 +4269,10 @@ namespace Temporary {
3926 } 4269 }
3927 { 4270 {
3928 Variable RestStatements = new Variable(); 4271 Variable RestStatements = new Variable();
3929 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)))
3930 { 4273 {
3931 convertIndentationCSharp(Level); 4274 convertIndentationCSharp(Level);
3932 YP.write(Atom.a(@"return false;")); 4275 YP.write(Atom.a("return false;"));
3933 YP.nl(); 4276 YP.nl();
3934 convertStatementListCSharp(RestStatements, Level); 4277 convertStatementListCSharp(RestStatements, Level);
3935 return; 4278 return;
@@ -3938,36 +4281,36 @@ namespace Temporary {
3938 { 4281 {
3939 Variable Name = new Variable(); 4282 Variable Name = new Variable();
3940 Variable RestStatements = new Variable(); 4283 Variable RestStatements = new Variable();
3941 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)))
3942 { 4285 {
3943 convertIndentationCSharp(Level); 4286 convertIndentationCSharp(Level);
3944 YP.write(Name); 4287 YP.write(Name);
3945 YP.write(Atom.a(@":")); 4288 YP.write(Atom.a(":"));
3946 YP.nl(); 4289 YP.nl();
3947 if (YP.termEqual(RestStatements, Atom.NIL)) 4290 if (YP.termEqual(RestStatements, Atom.NIL))
3948 { 4291 {
3949 convertIndentationCSharp(Level); 4292 convertIndentationCSharp(Level);
3950 YP.write(Atom.a(@"{}")); 4293 YP.write(Atom.a("{}"));
3951 YP.nl(); 4294 YP.nl();
3952 convertStatementListCSharp(RestStatements, Level); 4295 convertStatementListCSharp(RestStatements, Level);
3953 return; 4296 return;
3954 // goto cutIf1; 4297 goto cutIf1;
3955 } 4298 }
3956 convertStatementListCSharp(RestStatements, Level); 4299 convertStatementListCSharp(RestStatements, Level);
3957 return; 4300 return;
3958 // cutIf1: 4301 cutIf1:
3959 // { } 4302 { }
3960 } 4303 }
3961 } 4304 }
3962 { 4305 {
3963 Variable Name = new Variable(); 4306 Variable Name = new Variable();
3964 Variable RestStatements = new Variable(); 4307 Variable RestStatements = new Variable();
3965 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)))
3966 { 4309 {
3967 convertIndentationCSharp(Level); 4310 convertIndentationCSharp(Level);
3968 YP.write(Atom.a(@"goto ")); 4311 YP.write(Atom.a("goto "));
3969 YP.write(Name); 4312 YP.write(Name);
3970 YP.write(Atom.a(@";")); 4313 YP.write(Atom.a(";"));
3971 YP.nl(); 4314 YP.nl();
3972 convertStatementListCSharp(RestStatements, Level); 4315 convertStatementListCSharp(RestStatements, Level);
3973 return; 4316 return;
@@ -3977,32 +4320,43 @@ namespace Temporary {
3977 Variable Name = new Variable(); 4320 Variable Name = new Variable();
3978 Variable ArgList = new Variable(); 4321 Variable ArgList = new Variable();
3979 Variable RestStatements = new Variable(); 4322 Variable RestStatements = new Variable();
3980 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)))
3981 { 4324 {
3982 convertIndentationCSharp(Level); 4325 convertIndentationCSharp(Level);
3983 YP.write(Name); 4326 YP.write(Name);
3984 YP.write(Atom.a(@"(")); 4327 YP.write(Atom.a("("));
3985 convertArgListCSharp(ArgList); 4328 convertArgListCSharp(ArgList);
3986 YP.write(Atom.a(@");")); 4329 YP.write(Atom.a(");"));
3987 YP.nl(); 4330 YP.nl();
3988 convertStatementListCSharp(RestStatements, Level); 4331 convertStatementListCSharp(RestStatements, Level);
3989 return; 4332 return;
3990 } 4333 }
3991 } 4334 }
3992 { 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 {
3993 Variable Obj = new Variable(); 4347 Variable Obj = new Variable();
3994 Variable Name = new Variable(); 4348 Variable Name = new Variable();
3995 Variable ArgList = new Variable(); 4349 Variable ArgList = new Variable();
3996 Variable RestStatements = new Variable(); 4350 Variable RestStatements = new Variable();
3997 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)))
3998 { 4352 {
3999 convertIndentationCSharp(Level); 4353 convertIndentationCSharp(Level);
4000 YP.write(Obj); 4354 YP.write(Obj);
4001 YP.write(Atom.a(@".")); 4355 YP.write(Atom.a("."));
4002 YP.write(Name); 4356 YP.write(Name);
4003 YP.write(Atom.a(@"(")); 4357 YP.write(Atom.a("("));
4004 convertArgListCSharp(ArgList); 4358 convertArgListCSharp(ArgList);
4005 YP.write(Atom.a(@");")); 4359 YP.write(Atom.a(");"));
4006 YP.nl(); 4360 YP.nl();
4007 convertStatementListCSharp(RestStatements, Level); 4361 convertStatementListCSharp(RestStatements, Level);
4008 return; 4362 return;
@@ -4012,16 +4366,16 @@ namespace Temporary {
4012 Variable Body = new Variable(); 4366 Variable Body = new Variable();
4013 Variable RestStatements = new Variable(); 4367 Variable RestStatements = new Variable();
4014 Variable NextLevel = new Variable(); 4368 Variable NextLevel = new Variable();
4015 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)))
4016 { 4370 {
4017 convertIndentationCSharp(Level); 4371 convertIndentationCSharp(Level);
4018 YP.write(Atom.a(@"{")); 4372 YP.write(Atom.a("{"));
4019 YP.nl(); 4373 YP.nl();
4020 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4374 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4021 { 4375 {
4022 convertStatementListCSharp(Body, NextLevel); 4376 convertStatementListCSharp(Body, NextLevel);
4023 convertIndentationCSharp(Level); 4377 convertIndentationCSharp(Level);
4024 YP.write(Atom.a(@"}")); 4378 YP.write(Atom.a("}"));
4025 YP.nl(); 4379 YP.nl();
4026 convertStatementListCSharp(RestStatements, Level); 4380 convertStatementListCSharp(RestStatements, Level);
4027 return; 4381 return;
@@ -4033,18 +4387,18 @@ namespace Temporary {
4033 Variable Body = new Variable(); 4387 Variable Body = new Variable();
4034 Variable RestStatements = new Variable(); 4388 Variable RestStatements = new Variable();
4035 Variable NextLevel = new Variable(); 4389 Variable NextLevel = new Variable();
4036 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)))
4037 { 4391 {
4038 convertIndentationCSharp(Level); 4392 convertIndentationCSharp(Level);
4039 YP.write(Atom.a(@"if (")); 4393 YP.write(Atom.a("if ("));
4040 convertExpressionCSharp(Expression); 4394 convertExpressionCSharp(Expression);
4041 YP.write(Atom.a(@") {")); 4395 YP.write(Atom.a(") {"));
4042 YP.nl(); 4396 YP.nl();
4043 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4397 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4044 { 4398 {
4045 convertStatementListCSharp(Body, NextLevel); 4399 convertStatementListCSharp(Body, NextLevel);
4046 convertIndentationCSharp(Level); 4400 convertIndentationCSharp(Level);
4047 YP.write(Atom.a(@"}")); 4401 YP.write(Atom.a("}"));
4048 YP.nl(); 4402 YP.nl();
4049 convertStatementListCSharp(RestStatements, Level); 4403 convertStatementListCSharp(RestStatements, Level);
4050 return; 4404 return;
@@ -4056,20 +4410,20 @@ namespace Temporary {
4056 Variable Body = new Variable(); 4410 Variable Body = new Variable();
4057 Variable RestStatements = new Variable(); 4411 Variable RestStatements = new Variable();
4058 Variable NextLevel = new Variable(); 4412 Variable NextLevel = new Variable();
4059 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)))
4060 { 4414 {
4061 convertIndentationCSharp(Level); 4415 convertIndentationCSharp(Level);
4062 YP.write(Atom.a(@"foreach (bool l")); 4416 YP.write(Atom.a("foreach (bool l"));
4063 YP.write(Level); 4417 YP.write(Level);
4064 YP.write(Atom.a(@" in ")); 4418 YP.write(Atom.a(" in "));
4065 convertExpressionCSharp(Expression); 4419 convertExpressionCSharp(Expression);
4066 YP.write(Atom.a(@") {")); 4420 YP.write(Atom.a(") {"));
4067 YP.nl(); 4421 YP.nl();
4068 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4422 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4069 { 4423 {
4070 convertStatementListCSharp(Body, NextLevel); 4424 convertStatementListCSharp(Body, NextLevel);
4071 convertIndentationCSharp(Level); 4425 convertIndentationCSharp(Level);
4072 YP.write(Atom.a(@"}")); 4426 YP.write(Atom.a("}"));
4073 YP.nl(); 4427 YP.nl();
4074 convertStatementListCSharp(RestStatements, Level); 4428 convertStatementListCSharp(RestStatements, Level);
4075 return; 4429 return;
@@ -4079,12 +4433,12 @@ namespace Temporary {
4079 { 4433 {
4080 Variable Expression = new Variable(); 4434 Variable Expression = new Variable();
4081 Variable RestStatements = new Variable(); 4435 Variable RestStatements = new Variable();
4082 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)))
4083 { 4437 {
4084 convertIndentationCSharp(Level); 4438 convertIndentationCSharp(Level);
4085 YP.write(Atom.a(@"throw ")); 4439 YP.write(Atom.a("throw "));
4086 convertExpressionCSharp(Expression); 4440 convertExpressionCSharp(Expression);
4087 YP.write(Atom.a(@";")); 4441 YP.write(Atom.a(";"));
4088 YP.nl(); 4442 YP.nl();
4089 convertStatementListCSharp(RestStatements, Level); 4443 convertStatementListCSharp(RestStatements, Level);
4090 return; 4444 return;
@@ -4098,7 +4452,7 @@ namespace Temporary {
4098 Variable N = new Variable(); 4452 Variable N = new Variable();
4099 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 4453 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4100 { 4454 {
4101 repeatWrite(Atom.a(@" "), N); 4455 repeatWrite(Atom.a(" "), N);
4102 return; 4456 return;
4103 } 4457 }
4104 } 4458 }
@@ -4120,15 +4474,15 @@ namespace Temporary {
4120 convertExpressionCSharp(Head); 4474 convertExpressionCSharp(Head);
4121 if (YP.termNotEqual(Tail, Atom.NIL)) 4475 if (YP.termNotEqual(Tail, Atom.NIL))
4122 { 4476 {
4123 YP.write(Atom.a(@", ")); 4477 YP.write(Atom.a(", "));
4124 convertArgListCSharp(Tail); 4478 convertArgListCSharp(Tail);
4125 return; 4479 return;
4126 // goto cutIf1; 4480 goto cutIf1;
4127 } 4481 }
4128 convertArgListCSharp(Tail); 4482 convertArgListCSharp(Tail);
4129 return; 4483 return;
4130 // cutIf1: 4484 cutIf1:
4131 // { } 4485 { }
4132 } 4486 }
4133 } 4487 }
4134 } 4488 }
@@ -4137,9 +4491,9 @@ namespace Temporary {
4137 { 4491 {
4138 { 4492 {
4139 Variable X = new Variable(); 4493 Variable X = new Variable();
4140 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 4494 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
4141 { 4495 {
4142 YP.write(Atom.a(@"object ")); 4496 YP.write(Atom.a("object "));
4143 YP.write(X); 4497 YP.write(X);
4144 return; 4498 return;
4145 } 4499 }
@@ -4147,12 +4501,22 @@ namespace Temporary {
4147 { 4501 {
4148 Variable Name = new Variable(); 4502 Variable Name = new Variable();
4149 Variable ArgList = new Variable(); 4503 Variable ArgList = new Variable();
4150 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)))
4151 { 4505 {
4152 YP.write(Name); 4506 YP.write(Name);
4153 YP.write(Atom.a(@"(")); 4507 YP.write(Atom.a("("));
4154 convertArgListCSharp(ArgList); 4508 convertArgListCSharp(ArgList);
4155 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));
4156 return; 4520 return;
4157 } 4521 }
4158 } 4522 }
@@ -4160,90 +4524,90 @@ namespace Temporary {
4160 Variable Obj = new Variable(); 4524 Variable Obj = new Variable();
4161 Variable Name = new Variable(); 4525 Variable Name = new Variable();
4162 Variable ArgList = new Variable(); 4526 Variable ArgList = new Variable();
4163 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)))
4164 { 4528 {
4165 YP.write(Obj); 4529 YP.write(Obj);
4166 YP.write(Atom.a(@".")); 4530 YP.write(Atom.a("."));
4167 YP.write(Name); 4531 YP.write(Name);
4168 YP.write(Atom.a(@"(")); 4532 YP.write(Atom.a("("));
4169 convertArgListCSharp(ArgList); 4533 convertArgListCSharp(ArgList);
4170 YP.write(Atom.a(@")")); 4534 YP.write(Atom.a(")"));
4171 return; 4535 return;
4172 } 4536 }
4173 } 4537 }
4174 { 4538 {
4175 Variable Name = new Variable(); 4539 Variable Name = new Variable();
4176 Variable ArgList = new Variable(); 4540 Variable ArgList = new Variable();
4177 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)))
4178 { 4542 {
4179 YP.write(Atom.a(@"new ")); 4543 YP.write(Atom.a("new "));
4180 YP.write(Name); 4544 YP.write(Name);
4181 YP.write(Atom.a(@"(")); 4545 YP.write(Atom.a("("));
4182 convertArgListCSharp(ArgList); 4546 convertArgListCSharp(ArgList);
4183 YP.write(Atom.a(@")")); 4547 YP.write(Atom.a(")"));
4184 return; 4548 return;
4185 } 4549 }
4186 } 4550 }
4187 { 4551 {
4188 Variable Name = new Variable(); 4552 Variable Name = new Variable();
4189 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 4553 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
4190 { 4554 {
4191 YP.write(Name); 4555 YP.write(Name);
4192 return; 4556 return;
4193 } 4557 }
4194 } 4558 }
4195 { 4559 {
4196 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 4560 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
4197 { 4561 {
4198 YP.write(Atom.a(@"null")); 4562 YP.write(Atom.a("null"));
4199 return; 4563 return;
4200 } 4564 }
4201 } 4565 }
4202 { 4566 {
4203 Variable X = new Variable(); 4567 Variable X = new Variable();
4204 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 4568 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
4205 { 4569 {
4206 YP.write(Atom.a(@"!(")); 4570 YP.write(Atom.a("!("));
4207 convertExpressionCSharp(X); 4571 convertExpressionCSharp(X);
4208 YP.write(Atom.a(@")")); 4572 YP.write(Atom.a(")"));
4209 return; 4573 return;
4210 } 4574 }
4211 } 4575 }
4212 { 4576 {
4213 Variable X = new Variable(); 4577 Variable X = new Variable();
4214 Variable Y = new Variable(); 4578 Variable Y = new Variable();
4215 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)))
4216 { 4580 {
4217 YP.write(Atom.a(@"(")); 4581 YP.write(Atom.a("("));
4218 convertExpressionCSharp(X); 4582 convertExpressionCSharp(X);
4219 YP.write(Atom.a(@") && (")); 4583 YP.write(Atom.a(") && ("));
4220 convertExpressionCSharp(Y); 4584 convertExpressionCSharp(Y);
4221 YP.write(Atom.a(@")")); 4585 YP.write(Atom.a(")"));
4222 return; 4586 return;
4223 } 4587 }
4224 } 4588 }
4225 { 4589 {
4226 Variable ArgList = new Variable(); 4590 Variable ArgList = new Variable();
4227 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 4591 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
4228 { 4592 {
4229 YP.write(Atom.a(@"new object[] {")); 4593 YP.write(Atom.a("new object[] {"));
4230 convertArgListCSharp(ArgList); 4594 convertArgListCSharp(ArgList);
4231 YP.write(Atom.a(@"}")); 4595 YP.write(Atom.a("}"));
4232 return; 4596 return;
4233 } 4597 }
4234 } 4598 }
4235 { 4599 {
4236 Variable X = new Variable(); 4600 Variable X = new Variable();
4237 Variable Codes = new Variable(); 4601 Variable Codes = new Variable();
4238 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 4602 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4239 { 4603 {
4240 if (YP.atom(X)) 4604 if (YP.atom(X))
4241 { 4605 {
4242 YP.write(Atom.a(@"@""")); 4606 YP.write(Atom.a("\""));
4243 foreach (bool l4 in YP.atom_codes(X, Codes)) 4607 foreach (bool l4 in YP.atom_codes(X, Codes))
4244 { 4608 {
4245 convertStringCodesCSharp(Codes); 4609 convertStringCodesCSharp(Codes);
4246 YP.write(Atom.a(@"""")); 4610 YP.write(Atom.a("\""));
4247 return; 4611 return;
4248 } 4612 }
4249 } 4613 }
@@ -4251,7 +4615,7 @@ namespace Temporary {
4251 } 4615 }
4252 { 4616 {
4253 Variable X = new Variable(); 4617 Variable X = new Variable();
4254 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 4618 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4255 { 4619 {
4256 YP.write(X); 4620 YP.write(X);
4257 return; 4621 return;
@@ -4272,19 +4636,11 @@ namespace Temporary {
4272 Variable RestCodes = new Variable(); 4636 Variable RestCodes = new Variable();
4273 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) 4637 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4274 { 4638 {
4275 if (YP.termEqual(Code, 34)) 4639 foreach (bool l3 in putCStringCode(Code))
4276 { 4640 {
4277 YP.put_code(34);
4278 YP.put_code(Code);
4279 convertStringCodesCSharp(RestCodes); 4641 convertStringCodesCSharp(RestCodes);
4280 return; 4642 return;
4281 // goto cutIf1;
4282 } 4643 }
4283 YP.put_code(Code);
4284 convertStringCodesCSharp(RestCodes);
4285 return;
4286 // cutIf1:
4287 // { }
4288 } 4644 }
4289 } 4645 }
4290 } 4646 }
@@ -4292,9 +4648,10 @@ namespace Temporary {
4292 public static void convertFunctionJavascript(object arg1) 4648 public static void convertFunctionJavascript(object arg1)
4293 { 4649 {
4294 { 4650 {
4295 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 4651 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
4296 { 4652 {
4297 YP.write(Atom.a(@"function getDeclaringClass() { return null; }")); 4653 YP.write(Atom.a("function getDeclaringClass() { return null; }"));
4654 YP.nl();
4298 YP.nl(); 4655 YP.nl();
4299 return; 4656 return;
4300 } 4657 }
@@ -4304,16 +4661,16 @@ namespace Temporary {
4304 Variable Name = new Variable(); 4661 Variable Name = new Variable();
4305 Variable ArgList = new Variable(); 4662 Variable ArgList = new Variable();
4306 Variable Body = new Variable(); 4663 Variable Body = new Variable();
4307 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 })))
4308 { 4665 {
4309 YP.write(Atom.a(@"function ")); 4666 YP.write(Atom.a("function "));
4310 YP.write(Name); 4667 YP.write(Name);
4311 YP.write(Atom.a(@"(")); 4668 YP.write(Atom.a("("));
4312 convertArgListJavascript(ArgList); 4669 convertArgListJavascript(ArgList);
4313 YP.write(Atom.a(@") {")); 4670 YP.write(Atom.a(") {"));
4314 YP.nl(); 4671 YP.nl();
4315 convertStatementListJavascript(Body, 1); 4672 convertStatementListJavascript(Body, 1);
4316 YP.write(Atom.a(@"}")); 4673 YP.write(Atom.a("}"));
4317 YP.nl(); 4674 YP.nl();
4318 YP.nl(); 4675 YP.nl();
4319 return; 4676 return;
@@ -4336,20 +4693,20 @@ namespace Temporary {
4336 Variable Body = new Variable(); 4693 Variable Body = new Variable();
4337 Variable RestStatements = new Variable(); 4694 Variable RestStatements = new Variable();
4338 Variable NextLevel = new Variable(); 4695 Variable NextLevel = new Variable();
4339 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)))
4340 { 4697 {
4341 convertIndentationJavascript(Level); 4698 convertIndentationJavascript(Level);
4342 YP.write(Name); 4699 YP.write(Name);
4343 YP.write(Atom.a(@":")); 4700 YP.write(Atom.a(":"));
4344 YP.nl(); 4701 YP.nl();
4345 convertIndentationJavascript(Level); 4702 convertIndentationJavascript(Level);
4346 YP.write(Atom.a(@"{")); 4703 YP.write(Atom.a("{"));
4347 YP.nl(); 4704 YP.nl();
4348 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4705 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4349 { 4706 {
4350 convertStatementListJavascript(Body, NextLevel); 4707 convertStatementListJavascript(Body, NextLevel);
4351 convertIndentationJavascript(Level); 4708 convertIndentationJavascript(Level);
4352 YP.write(Atom.a(@"}")); 4709 YP.write(Atom.a("}"));
4353 YP.nl(); 4710 YP.nl();
4354 convertStatementListJavascript(RestStatements, Level); 4711 convertStatementListJavascript(RestStatements, Level);
4355 return; 4712 return;
@@ -4362,14 +4719,14 @@ namespace Temporary {
4362 Variable Name = new Variable(); 4719 Variable Name = new Variable();
4363 Variable Expression = new Variable(); 4720 Variable Expression = new Variable();
4364 Variable RestStatements = new Variable(); 4721 Variable RestStatements = new Variable();
4365 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)))
4366 { 4723 {
4367 convertIndentationJavascript(Level); 4724 convertIndentationJavascript(Level);
4368 YP.write(Atom.a(@"var ")); 4725 YP.write(Atom.a("var "));
4369 YP.write(Name); 4726 YP.write(Name);
4370 YP.write(Atom.a(@" = ")); 4727 YP.write(Atom.a(" = "));
4371 convertExpressionJavascript(Expression); 4728 convertExpressionJavascript(Expression);
4372 YP.write(Atom.a(@";")); 4729 YP.write(Atom.a(";"));
4373 YP.nl(); 4730 YP.nl();
4374 convertStatementListJavascript(RestStatements, Level); 4731 convertStatementListJavascript(RestStatements, Level);
4375 return; 4732 return;
@@ -4380,13 +4737,13 @@ namespace Temporary {
4380 Variable Name = new Variable(); 4737 Variable Name = new Variable();
4381 Variable Expression = new Variable(); 4738 Variable Expression = new Variable();
4382 Variable RestStatements = new Variable(); 4739 Variable RestStatements = new Variable();
4383 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)))
4384 { 4741 {
4385 convertIndentationJavascript(Level); 4742 convertIndentationJavascript(Level);
4386 YP.write(Name); 4743 YP.write(Name);
4387 YP.write(Atom.a(@" = ")); 4744 YP.write(Atom.a(" = "));
4388 convertExpressionJavascript(Expression); 4745 convertExpressionJavascript(Expression);
4389 YP.write(Atom.a(@";")); 4746 YP.write(Atom.a(";"));
4390 YP.nl(); 4747 YP.nl();
4391 convertStatementListJavascript(RestStatements, Level); 4748 convertStatementListJavascript(RestStatements, Level);
4392 return; 4749 return;
@@ -4395,10 +4752,10 @@ namespace Temporary {
4395 { 4752 {
4396 object Level = arg2; 4753 object Level = arg2;
4397 Variable RestStatements = new Variable(); 4754 Variable RestStatements = new Variable();
4398 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)))
4399 { 4756 {
4400 convertIndentationJavascript(Level); 4757 convertIndentationJavascript(Level);
4401 YP.write(Atom.a(@"yield true;")); 4758 YP.write(Atom.a("yield true;"));
4402 YP.nl(); 4759 YP.nl();
4403 convertStatementListJavascript(RestStatements, Level); 4760 convertStatementListJavascript(RestStatements, Level);
4404 return; 4761 return;
@@ -4407,10 +4764,10 @@ namespace Temporary {
4407 { 4764 {
4408 object Level = arg2; 4765 object Level = arg2;
4409 Variable RestStatements = new Variable(); 4766 Variable RestStatements = new Variable();
4410 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)))
4411 { 4768 {
4412 convertIndentationJavascript(Level); 4769 convertIndentationJavascript(Level);
4413 YP.write(Atom.a(@"yield false;")); 4770 YP.write(Atom.a("yield false;"));
4414 YP.nl(); 4771 YP.nl();
4415 convertStatementListJavascript(RestStatements, Level); 4772 convertStatementListJavascript(RestStatements, Level);
4416 return; 4773 return;
@@ -4419,10 +4776,10 @@ namespace Temporary {
4419 { 4776 {
4420 object Level = arg2; 4777 object Level = arg2;
4421 Variable RestStatements = new Variable(); 4778 Variable RestStatements = new Variable();
4422 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)))
4423 { 4780 {
4424 convertIndentationJavascript(Level); 4781 convertIndentationJavascript(Level);
4425 YP.write(Atom.a(@"return;")); 4782 YP.write(Atom.a("return;"));
4426 YP.nl(); 4783 YP.nl();
4427 convertStatementListJavascript(RestStatements, Level); 4784 convertStatementListJavascript(RestStatements, Level);
4428 return; 4785 return;
@@ -4431,10 +4788,10 @@ namespace Temporary {
4431 { 4788 {
4432 object Level = arg2; 4789 object Level = arg2;
4433 Variable RestStatements = new Variable(); 4790 Variable RestStatements = new Variable();
4434 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)))
4435 { 4792 {
4436 convertIndentationJavascript(Level); 4793 convertIndentationJavascript(Level);
4437 YP.write(Atom.a(@"return;")); 4794 YP.write(Atom.a("return;"));
4438 YP.nl(); 4795 YP.nl();
4439 convertStatementListJavascript(RestStatements, Level); 4796 convertStatementListJavascript(RestStatements, Level);
4440 return; 4797 return;
@@ -4443,10 +4800,10 @@ namespace Temporary {
4443 { 4800 {
4444 object Level = arg2; 4801 object Level = arg2;
4445 Variable RestStatements = new Variable(); 4802 Variable RestStatements = new Variable();
4446 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)))
4447 { 4804 {
4448 convertIndentationJavascript(Level); 4805 convertIndentationJavascript(Level);
4449 YP.write(Atom.a(@"return true;")); 4806 YP.write(Atom.a("return true;"));
4450 YP.nl(); 4807 YP.nl();
4451 convertStatementListJavascript(RestStatements, Level); 4808 convertStatementListJavascript(RestStatements, Level);
4452 return; 4809 return;
@@ -4455,10 +4812,10 @@ namespace Temporary {
4455 { 4812 {
4456 object Level = arg2; 4813 object Level = arg2;
4457 Variable RestStatements = new Variable(); 4814 Variable RestStatements = new Variable();
4458 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)))
4459 { 4816 {
4460 convertIndentationJavascript(Level); 4817 convertIndentationJavascript(Level);
4461 YP.write(Atom.a(@"return false;")); 4818 YP.write(Atom.a("return false;"));
4462 YP.nl(); 4819 YP.nl();
4463 convertStatementListJavascript(RestStatements, Level); 4820 convertStatementListJavascript(RestStatements, Level);
4464 return; 4821 return;
@@ -4468,12 +4825,12 @@ namespace Temporary {
4468 object Level = arg2; 4825 object Level = arg2;
4469 Variable Name = new Variable(); 4826 Variable Name = new Variable();
4470 Variable RestStatements = new Variable(); 4827 Variable RestStatements = new Variable();
4471 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)))
4472 { 4829 {
4473 convertIndentationJavascript(Level); 4830 convertIndentationJavascript(Level);
4474 YP.write(Atom.a(@"break ")); 4831 YP.write(Atom.a("break "));
4475 YP.write(Name); 4832 YP.write(Name);
4476 YP.write(Atom.a(@";")); 4833 YP.write(Atom.a(";"));
4477 YP.nl(); 4834 YP.nl();
4478 convertStatementListJavascript(RestStatements, Level); 4835 convertStatementListJavascript(RestStatements, Level);
4479 return; 4836 return;
@@ -4484,13 +4841,13 @@ namespace Temporary {
4484 Variable Name = new Variable(); 4841 Variable Name = new Variable();
4485 Variable ArgList = new Variable(); 4842 Variable ArgList = new Variable();
4486 Variable RestStatements = new Variable(); 4843 Variable RestStatements = new Variable();
4487 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)))
4488 { 4845 {
4489 convertIndentationJavascript(Level); 4846 convertIndentationJavascript(Level);
4490 YP.write(Name); 4847 YP.write(Name);
4491 YP.write(Atom.a(@"(")); 4848 YP.write(Atom.a("("));
4492 convertArgListJavascript(ArgList); 4849 convertArgListJavascript(ArgList);
4493 YP.write(Atom.a(@");")); 4850 YP.write(Atom.a(");"));
4494 YP.nl(); 4851 YP.nl();
4495 convertStatementListJavascript(RestStatements, Level); 4852 convertStatementListJavascript(RestStatements, Level);
4496 return; 4853 return;
@@ -4498,19 +4855,31 @@ namespace Temporary {
4498 } 4855 }
4499 { 4856 {
4500 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;
4501 Variable Obj = new Variable(); 4870 Variable Obj = new Variable();
4502 Variable Name = new Variable(); 4871 Variable Name = new Variable();
4503 Variable ArgList = new Variable(); 4872 Variable ArgList = new Variable();
4504 Variable RestStatements = new Variable(); 4873 Variable RestStatements = new Variable();
4505 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)))
4506 { 4875 {
4507 convertIndentationJavascript(Level); 4876 convertIndentationJavascript(Level);
4508 YP.write(Obj); 4877 YP.write(Obj);
4509 YP.write(Atom.a(@".")); 4878 YP.write(Atom.a("."));
4510 YP.write(Name); 4879 YP.write(Name);
4511 YP.write(Atom.a(@"(")); 4880 YP.write(Atom.a("("));
4512 convertArgListJavascript(ArgList); 4881 convertArgListJavascript(ArgList);
4513 YP.write(Atom.a(@");")); 4882 YP.write(Atom.a(");"));
4514 YP.nl(); 4883 YP.nl();
4515 convertStatementListJavascript(RestStatements, Level); 4884 convertStatementListJavascript(RestStatements, Level);
4516 return; 4885 return;
@@ -4521,16 +4890,16 @@ namespace Temporary {
4521 Variable Body = new Variable(); 4890 Variable Body = new Variable();
4522 Variable RestStatements = new Variable(); 4891 Variable RestStatements = new Variable();
4523 Variable NextLevel = new Variable(); 4892 Variable NextLevel = new Variable();
4524 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)))
4525 { 4894 {
4526 convertIndentationJavascript(Level); 4895 convertIndentationJavascript(Level);
4527 YP.write(Atom.a(@"{")); 4896 YP.write(Atom.a("{"));
4528 YP.nl(); 4897 YP.nl();
4529 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4898 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4530 { 4899 {
4531 convertStatementListJavascript(Body, NextLevel); 4900 convertStatementListJavascript(Body, NextLevel);
4532 convertIndentationJavascript(Level); 4901 convertIndentationJavascript(Level);
4533 YP.write(Atom.a(@"}")); 4902 YP.write(Atom.a("}"));
4534 YP.nl(); 4903 YP.nl();
4535 convertStatementListJavascript(RestStatements, Level); 4904 convertStatementListJavascript(RestStatements, Level);
4536 return; 4905 return;
@@ -4543,18 +4912,18 @@ namespace Temporary {
4543 Variable Body = new Variable(); 4912 Variable Body = new Variable();
4544 Variable RestStatements = new Variable(); 4913 Variable RestStatements = new Variable();
4545 Variable NextLevel = new Variable(); 4914 Variable NextLevel = new Variable();
4546 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)))
4547 { 4916 {
4548 convertIndentationJavascript(Level); 4917 convertIndentationJavascript(Level);
4549 YP.write(Atom.a(@"if (")); 4918 YP.write(Atom.a("if ("));
4550 convertExpressionJavascript(Expression); 4919 convertExpressionJavascript(Expression);
4551 YP.write(Atom.a(@") {")); 4920 YP.write(Atom.a(") {"));
4552 YP.nl(); 4921 YP.nl();
4553 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4922 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4554 { 4923 {
4555 convertStatementListJavascript(Body, NextLevel); 4924 convertStatementListJavascript(Body, NextLevel);
4556 convertIndentationJavascript(Level); 4925 convertIndentationJavascript(Level);
4557 YP.write(Atom.a(@"}")); 4926 YP.write(Atom.a("}"));
4558 YP.nl(); 4927 YP.nl();
4559 convertStatementListJavascript(RestStatements, Level); 4928 convertStatementListJavascript(RestStatements, Level);
4560 return; 4929 return;
@@ -4567,20 +4936,20 @@ namespace Temporary {
4567 Variable Body = new Variable(); 4936 Variable Body = new Variable();
4568 Variable RestStatements = new Variable(); 4937 Variable RestStatements = new Variable();
4569 Variable NextLevel = new Variable(); 4938 Variable NextLevel = new Variable();
4570 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)))
4571 { 4940 {
4572 convertIndentationJavascript(Level); 4941 convertIndentationJavascript(Level);
4573 YP.write(Atom.a(@"for each (var l")); 4942 YP.write(Atom.a("for each (var l"));
4574 YP.write(Level); 4943 YP.write(Level);
4575 YP.write(Atom.a(@" in ")); 4944 YP.write(Atom.a(" in "));
4576 convertExpressionJavascript(Expression); 4945 convertExpressionJavascript(Expression);
4577 YP.write(Atom.a(@") {")); 4946 YP.write(Atom.a(") {"));
4578 YP.nl(); 4947 YP.nl();
4579 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 4948 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4580 { 4949 {
4581 convertStatementListJavascript(Body, NextLevel); 4950 convertStatementListJavascript(Body, NextLevel);
4582 convertIndentationJavascript(Level); 4951 convertIndentationJavascript(Level);
4583 YP.write(Atom.a(@"}")); 4952 YP.write(Atom.a("}"));
4584 YP.nl(); 4953 YP.nl();
4585 convertStatementListJavascript(RestStatements, Level); 4954 convertStatementListJavascript(RestStatements, Level);
4586 return; 4955 return;
@@ -4591,12 +4960,12 @@ namespace Temporary {
4591 object Level = arg2; 4960 object Level = arg2;
4592 Variable Expression = new Variable(); 4961 Variable Expression = new Variable();
4593 Variable RestStatements = new Variable(); 4962 Variable RestStatements = new Variable();
4594 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)))
4595 { 4964 {
4596 convertIndentationJavascript(Level); 4965 convertIndentationJavascript(Level);
4597 YP.write(Atom.a(@"throw ")); 4966 YP.write(Atom.a("throw "));
4598 convertExpressionJavascript(Expression); 4967 convertExpressionJavascript(Expression);
4599 YP.write(Atom.a(@";")); 4968 YP.write(Atom.a(";"));
4600 YP.nl(); 4969 YP.nl();
4601 convertStatementListJavascript(RestStatements, Level); 4970 convertStatementListJavascript(RestStatements, Level);
4602 return; 4971 return;
@@ -4610,7 +4979,7 @@ namespace Temporary {
4610 Variable N = new Variable(); 4979 Variable N = new Variable();
4611 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 4980 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4612 { 4981 {
4613 repeatWrite(Atom.a(@" "), N); 4982 repeatWrite(Atom.a(" "), N);
4614 return; 4983 return;
4615 } 4984 }
4616 } 4985 }
@@ -4632,15 +5001,15 @@ namespace Temporary {
4632 convertExpressionJavascript(Head); 5001 convertExpressionJavascript(Head);
4633 if (YP.termNotEqual(Tail, Atom.NIL)) 5002 if (YP.termNotEqual(Tail, Atom.NIL))
4634 { 5003 {
4635 YP.write(Atom.a(@", ")); 5004 YP.write(Atom.a(", "));
4636 convertArgListJavascript(Tail); 5005 convertArgListJavascript(Tail);
4637 return; 5006 return;
4638 // goto cutIf1; 5007 goto cutIf1;
4639 } 5008 }
4640 convertArgListJavascript(Tail); 5009 convertArgListJavascript(Tail);
4641 return; 5010 return;
4642 // cutIf1: 5011 cutIf1:
4643 // { } 5012 { }
4644 } 5013 }
4645 } 5014 }
4646 } 5015 }
@@ -4649,7 +5018,7 @@ namespace Temporary {
4649 { 5018 {
4650 { 5019 {
4651 Variable X = new Variable(); 5020 Variable X = new Variable();
4652 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 5021 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
4653 { 5022 {
4654 YP.write(X); 5023 YP.write(X);
4655 return; 5024 return;
@@ -4658,12 +5027,22 @@ namespace Temporary {
4658 { 5027 {
4659 Variable Name = new Variable(); 5028 Variable Name = new Variable();
4660 Variable ArgList = new Variable(); 5029 Variable ArgList = new Variable();
4661 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)))
4662 { 5031 {
4663 YP.write(Name); 5032 YP.write(Name);
4664 YP.write(Atom.a(@"(")); 5033 YP.write(Atom.a("("));
4665 convertArgListJavascript(ArgList); 5034 convertArgListJavascript(ArgList);
4666 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));
4667 return; 5046 return;
4668 } 5047 }
4669 } 5048 }
@@ -4671,90 +5050,90 @@ namespace Temporary {
4671 Variable Obj = new Variable(); 5050 Variable Obj = new Variable();
4672 Variable Name = new Variable(); 5051 Variable Name = new Variable();
4673 Variable ArgList = new Variable(); 5052 Variable ArgList = new Variable();
4674 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)))
4675 { 5054 {
4676 YP.write(Obj); 5055 YP.write(Obj);
4677 YP.write(Atom.a(@".")); 5056 YP.write(Atom.a("."));
4678 YP.write(Name); 5057 YP.write(Name);
4679 YP.write(Atom.a(@"(")); 5058 YP.write(Atom.a("("));
4680 convertArgListJavascript(ArgList); 5059 convertArgListJavascript(ArgList);
4681 YP.write(Atom.a(@")")); 5060 YP.write(Atom.a(")"));
4682 return; 5061 return;
4683 } 5062 }
4684 } 5063 }
4685 { 5064 {
4686 Variable Name = new Variable(); 5065 Variable Name = new Variable();
4687 Variable ArgList = new Variable(); 5066 Variable ArgList = new Variable();
4688 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)))
4689 { 5068 {
4690 YP.write(Atom.a(@"new ")); 5069 YP.write(Atom.a("new "));
4691 YP.write(Name); 5070 YP.write(Name);
4692 YP.write(Atom.a(@"(")); 5071 YP.write(Atom.a("("));
4693 convertArgListJavascript(ArgList); 5072 convertArgListJavascript(ArgList);
4694 YP.write(Atom.a(@")")); 5073 YP.write(Atom.a(")"));
4695 return; 5074 return;
4696 } 5075 }
4697 } 5076 }
4698 { 5077 {
4699 Variable Name = new Variable(); 5078 Variable Name = new Variable();
4700 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 5079 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
4701 { 5080 {
4702 YP.write(Name); 5081 YP.write(Name);
4703 return; 5082 return;
4704 } 5083 }
4705 } 5084 }
4706 { 5085 {
4707 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 5086 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
4708 { 5087 {
4709 YP.write(Atom.a(@"null")); 5088 YP.write(Atom.a("null"));
4710 return; 5089 return;
4711 } 5090 }
4712 } 5091 }
4713 { 5092 {
4714 Variable X = new Variable(); 5093 Variable X = new Variable();
4715 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 5094 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
4716 { 5095 {
4717 YP.write(Atom.a(@"!(")); 5096 YP.write(Atom.a("!("));
4718 convertExpressionJavascript(X); 5097 convertExpressionJavascript(X);
4719 YP.write(Atom.a(@")")); 5098 YP.write(Atom.a(")"));
4720 return; 5099 return;
4721 } 5100 }
4722 } 5101 }
4723 { 5102 {
4724 Variable X = new Variable(); 5103 Variable X = new Variable();
4725 Variable Y = new Variable(); 5104 Variable Y = new Variable();
4726 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)))
4727 { 5106 {
4728 YP.write(Atom.a(@"(")); 5107 YP.write(Atom.a("("));
4729 convertExpressionJavascript(X); 5108 convertExpressionJavascript(X);
4730 YP.write(Atom.a(@") && (")); 5109 YP.write(Atom.a(") && ("));
4731 convertExpressionJavascript(Y); 5110 convertExpressionJavascript(Y);
4732 YP.write(Atom.a(@")")); 5111 YP.write(Atom.a(")"));
4733 return; 5112 return;
4734 } 5113 }
4735 } 5114 }
4736 { 5115 {
4737 Variable ArgList = new Variable(); 5116 Variable ArgList = new Variable();
4738 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 5117 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
4739 { 5118 {
4740 YP.write(Atom.a(@"[")); 5119 YP.write(Atom.a("["));
4741 convertArgListJavascript(ArgList); 5120 convertArgListJavascript(ArgList);
4742 YP.write(Atom.a(@"]")); 5121 YP.write(Atom.a("]"));
4743 return; 5122 return;
4744 } 5123 }
4745 } 5124 }
4746 { 5125 {
4747 Variable X = new Variable(); 5126 Variable X = new Variable();
4748 Variable Codes = new Variable(); 5127 Variable Codes = new Variable();
4749 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5128 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4750 { 5129 {
4751 if (YP.atom(X)) 5130 if (YP.atom(X))
4752 { 5131 {
4753 YP.write(Atom.a(@"""")); 5132 YP.write(Atom.a("\""));
4754 foreach (bool l4 in YP.atom_codes(X, Codes)) 5133 foreach (bool l4 in YP.atom_codes(X, Codes))
4755 { 5134 {
4756 convertStringCodesJavascript(Codes); 5135 convertStringCodesJavascript(Codes);
4757 YP.write(Atom.a(@"""")); 5136 YP.write(Atom.a("\""));
4758 return; 5137 return;
4759 } 5138 }
4760 } 5139 }
@@ -4762,7 +5141,7 @@ namespace Temporary {
4762 } 5141 }
4763 { 5142 {
4764 Variable X = new Variable(); 5143 Variable X = new Variable();
4765 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5144 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
4766 { 5145 {
4767 YP.write(X); 5146 YP.write(X);
4768 return; 5147 return;
@@ -4783,27 +5162,11 @@ namespace Temporary {
4783 Variable RestCodes = new Variable(); 5162 Variable RestCodes = new Variable();
4784 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) 5163 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4785 { 5164 {
4786 if (YP.termEqual(Code, 34)) 5165 foreach (bool l3 in putCStringCode(Code))
4787 { 5166 {
4788 YP.put_code(92);
4789 YP.put_code(Code);
4790 convertStringCodesJavascript(RestCodes); 5167 convertStringCodesJavascript(RestCodes);
4791 return; 5168 return;
4792 // goto cutIf1;
4793 } 5169 }
4794 if (YP.termEqual(Code, 92))
4795 {
4796 YP.put_code(92);
4797 YP.put_code(Code);
4798 convertStringCodesJavascript(RestCodes);
4799 return;
4800 // goto cutIf1;
4801 }
4802 YP.put_code(Code);
4803 convertStringCodesJavascript(RestCodes);
4804 return;
4805 // cutIf1:
4806 // { }
4807 } 5170 }
4808 } 5171 }
4809 } 5172 }
@@ -4811,11 +5174,11 @@ namespace Temporary {
4811 public static void convertFunctionPython(object arg1) 5174 public static void convertFunctionPython(object arg1)
4812 { 5175 {
4813 { 5176 {
4814 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) 5177 foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
4815 { 5178 {
4816 YP.write(Atom.a(@"def getDeclaringClass():")); 5179 YP.write(Atom.a("def getDeclaringClass():"));
4817 YP.nl(); 5180 YP.nl();
4818 YP.write(Atom.a(@" return None")); 5181 YP.write(Atom.a(" return None"));
4819 YP.nl(); 5182 YP.nl();
4820 YP.nl(); 5183 YP.nl();
4821 return; 5184 return;
@@ -4828,13 +5191,13 @@ namespace Temporary {
4828 Variable Body = new Variable(); 5191 Variable Body = new Variable();
4829 Variable Level = new Variable(); 5192 Variable Level = new Variable();
4830 Variable HasBreakableBlock = new Variable(); 5193 Variable HasBreakableBlock = new Variable();
4831 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 })))
4832 { 5195 {
4833 YP.write(Atom.a(@"def ")); 5196 YP.write(Atom.a("def "));
4834 YP.write(Name); 5197 YP.write(Name);
4835 YP.write(Atom.a(@"(")); 5198 YP.write(Atom.a("("));
4836 convertArgListPython(ArgList); 5199 convertArgListPython(ArgList);
4837 YP.write(Atom.a(@"):")); 5200 YP.write(Atom.a("):"));
4838 YP.nl(); 5201 YP.nl();
4839 foreach (bool l3 in YP.unify(Level, 1)) 5202 foreach (bool l3 in YP.unify(Level, 1))
4840 { 5203 {
@@ -4845,7 +5208,7 @@ namespace Temporary {
4845 if (YP.termEqual(HasBreakableBlock, 1)) 5208 if (YP.termEqual(HasBreakableBlock, 1))
4846 { 5209 {
4847 convertIndentationPython(Level); 5210 convertIndentationPython(Level);
4848 YP.write(Atom.a(@"doBreak = False")); 5211 YP.write(Atom.a("doBreak = False"));
4849 YP.nl(); 5212 YP.nl();
4850 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock)) 5213 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
4851 { 5214 {
@@ -4869,7 +5232,7 @@ namespace Temporary {
4869 if (YP.termEqual(HasBreakableBlock, 1)) 5232 if (YP.termEqual(HasBreakableBlock, 1))
4870 { 5233 {
4871 convertIndentationPython(Level); 5234 convertIndentationPython(Level);
4872 YP.write(Atom.a(@"doBreak = False")); 5235 YP.write(Atom.a("doBreak = False"));
4873 YP.nl(); 5236 YP.nl();
4874 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) 5237 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4875 { 5238 {
@@ -4899,7 +5262,7 @@ namespace Temporary {
4899 Variable _Name = new Variable(); 5262 Variable _Name = new Variable();
4900 Variable _Body = new Variable(); 5263 Variable _Body = new Variable();
4901 Variable _RestStatements = new Variable(); 5264 Variable _RestStatements = new Variable();
4902 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)))
4903 { 5266 {
4904 return true; 5267 return true;
4905 } 5268 }
@@ -4907,7 +5270,7 @@ namespace Temporary {
4907 { 5270 {
4908 Variable Body = new Variable(); 5271 Variable Body = new Variable();
4909 Variable _RestStatements = new Variable(); 5272 Variable _RestStatements = new Variable();
4910 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)))
4911 { 5274 {
4912 if (hasBreakableBlockPython(Body)) 5275 if (hasBreakableBlockPython(Body))
4913 { 5276 {
@@ -4919,7 +5282,7 @@ namespace Temporary {
4919 Variable _Expression = new Variable(); 5282 Variable _Expression = new Variable();
4920 Variable Body = new Variable(); 5283 Variable Body = new Variable();
4921 Variable _RestStatements = new Variable(); 5284 Variable _RestStatements = new Variable();
4922 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)))
4923 { 5286 {
4924 if (hasBreakableBlockPython(Body)) 5287 if (hasBreakableBlockPython(Body))
4925 { 5288 {
@@ -4931,7 +5294,7 @@ namespace Temporary {
4931 Variable _Expression = new Variable(); 5294 Variable _Expression = new Variable();
4932 Variable Body = new Variable(); 5295 Variable Body = new Variable();
4933 Variable _RestStatements = new Variable(); 5296 Variable _RestStatements = new Variable();
4934 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)))
4935 { 5298 {
4936 if (hasBreakableBlockPython(Body)) 5299 if (hasBreakableBlockPython(Body))
4937 { 5300 {
@@ -4971,32 +5334,32 @@ namespace Temporary {
4971 Variable Body = new Variable(); 5334 Variable Body = new Variable();
4972 Variable RestStatements = new Variable(); 5335 Variable RestStatements = new Variable();
4973 Variable NextLevel = new Variable(); 5336 Variable NextLevel = new Variable();
4974 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)))
4975 { 5338 {
4976 convertIndentationPython(Level); 5339 convertIndentationPython(Level);
4977 YP.write(Name); 5340 YP.write(Name);
4978 YP.write(Atom.a(@" = False")); 5341 YP.write(Atom.a(" = False"));
4979 YP.nl(); 5342 YP.nl();
4980 convertIndentationPython(Level); 5343 convertIndentationPython(Level);
4981 YP.write(Atom.a(@"for _ in [1]:")); 5344 YP.write(Atom.a("for _ in [1]:"));
4982 YP.nl(); 5345 YP.nl();
4983 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5346 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4984 { 5347 {
4985 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) 5348 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
4986 { 5349 {
4987 convertIndentationPython(Level); 5350 convertIndentationPython(Level);
4988 YP.write(Atom.a(@"if ")); 5351 YP.write(Atom.a("if "));
4989 YP.write(Name); 5352 YP.write(Name);
4990 YP.write(Atom.a(@":")); 5353 YP.write(Atom.a(":"));
4991 YP.nl(); 5354 YP.nl();
4992 convertIndentationPython(NextLevel); 5355 convertIndentationPython(NextLevel);
4993 YP.write(Atom.a(@"doBreak = False")); 5356 YP.write(Atom.a("doBreak = False"));
4994 YP.nl(); 5357 YP.nl();
4995 convertIndentationPython(Level); 5358 convertIndentationPython(Level);
4996 YP.write(Atom.a(@"if doBreak:")); 5359 YP.write(Atom.a("if doBreak:"));
4997 YP.nl(); 5360 YP.nl();
4998 convertIndentationPython(NextLevel); 5361 convertIndentationPython(NextLevel);
4999 YP.write(Atom.a(@"break")); 5362 YP.write(Atom.a("break"));
5000 YP.nl(); 5363 YP.nl();
5001 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5364 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5002 { 5365 {
@@ -5014,11 +5377,11 @@ namespace Temporary {
5014 Variable Name = new Variable(); 5377 Variable Name = new Variable();
5015 Variable Expression = new Variable(); 5378 Variable Expression = new Variable();
5016 Variable RestStatements = new Variable(); 5379 Variable RestStatements = new Variable();
5017 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)))
5018 { 5381 {
5019 convertIndentationPython(Level); 5382 convertIndentationPython(Level);
5020 YP.write(Name); 5383 YP.write(Name);
5021 YP.write(Atom.a(@" = ")); 5384 YP.write(Atom.a(" = "));
5022 convertExpressionPython(Expression); 5385 convertExpressionPython(Expression);
5023 YP.nl(); 5386 YP.nl();
5024 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5387 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5034,11 +5397,11 @@ namespace Temporary {
5034 Variable Name = new Variable(); 5397 Variable Name = new Variable();
5035 Variable Expression = new Variable(); 5398 Variable Expression = new Variable();
5036 Variable RestStatements = new Variable(); 5399 Variable RestStatements = new Variable();
5037 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)))
5038 { 5401 {
5039 convertIndentationPython(Level); 5402 convertIndentationPython(Level);
5040 YP.write(Name); 5403 YP.write(Name);
5041 YP.write(Atom.a(@" = ")); 5404 YP.write(Atom.a(" = "));
5042 convertExpressionPython(Expression); 5405 convertExpressionPython(Expression);
5043 YP.nl(); 5406 YP.nl();
5044 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5407 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5052,10 +5415,10 @@ namespace Temporary {
5052 object Level = arg2; 5415 object Level = arg2;
5053 object HasBreakableBlock = arg3; 5416 object HasBreakableBlock = arg3;
5054 Variable RestStatements = new Variable(); 5417 Variable RestStatements = new Variable();
5055 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)))
5056 { 5419 {
5057 convertIndentationPython(Level); 5420 convertIndentationPython(Level);
5058 YP.write(Atom.a(@"yield True")); 5421 YP.write(Atom.a("yield True"));
5059 YP.nl(); 5422 YP.nl();
5060 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5423 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5061 { 5424 {
@@ -5068,10 +5431,10 @@ namespace Temporary {
5068 object Level = arg2; 5431 object Level = arg2;
5069 object HasBreakableBlock = arg3; 5432 object HasBreakableBlock = arg3;
5070 Variable RestStatements = new Variable(); 5433 Variable RestStatements = new Variable();
5071 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)))
5072 { 5435 {
5073 convertIndentationPython(Level); 5436 convertIndentationPython(Level);
5074 YP.write(Atom.a(@"yield False")); 5437 YP.write(Atom.a("yield False"));
5075 YP.nl(); 5438 YP.nl();
5076 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5439 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5077 { 5440 {
@@ -5084,10 +5447,10 @@ namespace Temporary {
5084 object Level = arg2; 5447 object Level = arg2;
5085 object HasBreakableBlock = arg3; 5448 object HasBreakableBlock = arg3;
5086 Variable RestStatements = new Variable(); 5449 Variable RestStatements = new Variable();
5087 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)))
5088 { 5451 {
5089 convertIndentationPython(Level); 5452 convertIndentationPython(Level);
5090 YP.write(Atom.a(@"return")); 5453 YP.write(Atom.a("return"));
5091 YP.nl(); 5454 YP.nl();
5092 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5455 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5093 { 5456 {
@@ -5100,10 +5463,10 @@ namespace Temporary {
5100 object Level = arg2; 5463 object Level = arg2;
5101 object HasBreakableBlock = arg3; 5464 object HasBreakableBlock = arg3;
5102 Variable RestStatements = new Variable(); 5465 Variable RestStatements = new Variable();
5103 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)))
5104 { 5467 {
5105 convertIndentationPython(Level); 5468 convertIndentationPython(Level);
5106 YP.write(Atom.a(@"return")); 5469 YP.write(Atom.a("return"));
5107 YP.nl(); 5470 YP.nl();
5108 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5471 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5109 { 5472 {
@@ -5116,10 +5479,10 @@ namespace Temporary {
5116 object Level = arg2; 5479 object Level = arg2;
5117 object HasBreakableBlock = arg3; 5480 object HasBreakableBlock = arg3;
5118 Variable RestStatements = new Variable(); 5481 Variable RestStatements = new Variable();
5119 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)))
5120 { 5483 {
5121 convertIndentationPython(Level); 5484 convertIndentationPython(Level);
5122 YP.write(Atom.a(@"return True")); 5485 YP.write(Atom.a("return True"));
5123 YP.nl(); 5486 YP.nl();
5124 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5487 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5125 { 5488 {
@@ -5132,10 +5495,10 @@ namespace Temporary {
5132 object Level = arg2; 5495 object Level = arg2;
5133 object HasBreakableBlock = arg3; 5496 object HasBreakableBlock = arg3;
5134 Variable RestStatements = new Variable(); 5497 Variable RestStatements = new Variable();
5135 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)))
5136 { 5499 {
5137 convertIndentationPython(Level); 5500 convertIndentationPython(Level);
5138 YP.write(Atom.a(@"return False")); 5501 YP.write(Atom.a("return False"));
5139 YP.nl(); 5502 YP.nl();
5140 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5503 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5141 { 5504 {
@@ -5149,17 +5512,17 @@ namespace Temporary {
5149 object HasBreakableBlock = arg3; 5512 object HasBreakableBlock = arg3;
5150 Variable Name = new Variable(); 5513 Variable Name = new Variable();
5151 Variable RestStatements = new Variable(); 5514 Variable RestStatements = new Variable();
5152 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)))
5153 { 5516 {
5154 convertIndentationPython(Level); 5517 convertIndentationPython(Level);
5155 YP.write(Name); 5518 YP.write(Name);
5156 YP.write(Atom.a(@" = True")); 5519 YP.write(Atom.a(" = True"));
5157 YP.nl(); 5520 YP.nl();
5158 convertIndentationPython(Level); 5521 convertIndentationPython(Level);
5159 YP.write(Atom.a(@"doBreak = True")); 5522 YP.write(Atom.a("doBreak = True"));
5160 YP.nl(); 5523 YP.nl();
5161 convertIndentationPython(Level); 5524 convertIndentationPython(Level);
5162 YP.write(Atom.a(@"break")); 5525 YP.write(Atom.a("break"));
5163 YP.nl(); 5526 YP.nl();
5164 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5527 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5165 { 5528 {
@@ -5174,13 +5537,13 @@ namespace Temporary {
5174 Variable Name = new Variable(); 5537 Variable Name = new Variable();
5175 Variable ArgList = new Variable(); 5538 Variable ArgList = new Variable();
5176 Variable RestStatements = new Variable(); 5539 Variable RestStatements = new Variable();
5177 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)))
5178 { 5541 {
5179 convertIndentationPython(Level); 5542 convertIndentationPython(Level);
5180 YP.write(Name); 5543 YP.write(Name);
5181 YP.write(Atom.a(@"(")); 5544 YP.write(Atom.a("("));
5182 convertArgListPython(ArgList); 5545 convertArgListPython(ArgList);
5183 YP.write(Atom.a(@")")); 5546 YP.write(Atom.a(")"));
5184 YP.nl(); 5547 YP.nl();
5185 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5548 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5186 { 5549 {
@@ -5192,19 +5555,35 @@ namespace Temporary {
5192 { 5555 {
5193 object Level = arg2; 5556 object Level = arg2;
5194 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;
5195 Variable Obj = new Variable(); 5574 Variable Obj = new Variable();
5196 Variable Name = new Variable(); 5575 Variable Name = new Variable();
5197 Variable ArgList = new Variable(); 5576 Variable ArgList = new Variable();
5198 Variable RestStatements = new Variable(); 5577 Variable RestStatements = new Variable();
5199 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)))
5200 { 5579 {
5201 convertIndentationPython(Level); 5580 convertIndentationPython(Level);
5202 YP.write(Obj); 5581 YP.write(Obj);
5203 YP.write(Atom.a(@".")); 5582 YP.write(Atom.a("."));
5204 YP.write(Name); 5583 YP.write(Name);
5205 YP.write(Atom.a(@"(")); 5584 YP.write(Atom.a("("));
5206 convertArgListPython(ArgList); 5585 convertArgListPython(ArgList);
5207 YP.write(Atom.a(@")")); 5586 YP.write(Atom.a(")"));
5208 YP.nl(); 5587 YP.nl();
5209 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5588 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5210 { 5589 {
@@ -5219,12 +5598,12 @@ namespace Temporary {
5219 Variable Body = new Variable(); 5598 Variable Body = new Variable();
5220 Variable RestStatements = new Variable(); 5599 Variable RestStatements = new Variable();
5221 Variable NextLevel = new Variable(); 5600 Variable NextLevel = new Variable();
5222 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)))
5223 { 5602 {
5224 if (YP.termEqual(HasBreakableBlock, 1)) 5603 if (YP.termEqual(HasBreakableBlock, 1))
5225 { 5604 {
5226 convertIndentationPython(Level); 5605 convertIndentationPython(Level);
5227 YP.write(Atom.a(@"for _ in [1]:")); 5606 YP.write(Atom.a("for _ in [1]:"));
5228 YP.nl(); 5607 YP.nl();
5229 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1))) 5608 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
5230 { 5609 {
@@ -5235,10 +5614,10 @@ namespace Temporary {
5235 if (YP.greaterThan(Level, 1)) 5614 if (YP.greaterThan(Level, 1))
5236 { 5615 {
5237 convertIndentationPython(Level); 5616 convertIndentationPython(Level);
5238 YP.write(Atom.a(@"if doBreak:")); 5617 YP.write(Atom.a("if doBreak:"));
5239 YP.nl(); 5618 YP.nl();
5240 convertIndentationPython(NextLevel); 5619 convertIndentationPython(NextLevel);
5241 YP.write(Atom.a(@"break")); 5620 YP.write(Atom.a("break"));
5242 YP.nl(); 5621 YP.nl();
5243 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5622 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5244 { 5623 {
@@ -5275,10 +5654,10 @@ namespace Temporary {
5275 if (YP.greaterThan(Level, 1)) 5654 if (YP.greaterThan(Level, 1))
5276 { 5655 {
5277 convertIndentationPython(Level); 5656 convertIndentationPython(Level);
5278 YP.write(Atom.a(@"if doBreak:")); 5657 YP.write(Atom.a("if doBreak:"));
5279 YP.nl(); 5658 YP.nl();
5280 convertIndentationPython(NextLevel); 5659 convertIndentationPython(NextLevel);
5281 YP.write(Atom.a(@"break")); 5660 YP.write(Atom.a("break"));
5282 YP.nl(); 5661 YP.nl();
5283 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5662 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5284 { 5663 {
@@ -5315,12 +5694,12 @@ namespace Temporary {
5315 Variable Body = new Variable(); 5694 Variable Body = new Variable();
5316 Variable RestStatements = new Variable(); 5695 Variable RestStatements = new Variable();
5317 Variable NextLevel = new Variable(); 5696 Variable NextLevel = new Variable();
5318 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)))
5319 { 5698 {
5320 convertIndentationPython(Level); 5699 convertIndentationPython(Level);
5321 YP.write(Atom.a(@"if ")); 5700 YP.write(Atom.a("if "));
5322 convertExpressionPython(Expression); 5701 convertExpressionPython(Expression);
5323 YP.write(Atom.a(@":")); 5702 YP.write(Atom.a(":"));
5324 YP.nl(); 5703 YP.nl();
5325 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5704 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5326 { 5705 {
@@ -5342,14 +5721,14 @@ namespace Temporary {
5342 Variable Body = new Variable(); 5721 Variable Body = new Variable();
5343 Variable RestStatements = new Variable(); 5722 Variable RestStatements = new Variable();
5344 Variable NextLevel = new Variable(); 5723 Variable NextLevel = new Variable();
5345 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)))
5346 { 5725 {
5347 convertIndentationPython(Level); 5726 convertIndentationPython(Level);
5348 YP.write(Atom.a(@"for l")); 5727 YP.write(Atom.a("for l"));
5349 YP.write(Level); 5728 YP.write(Level);
5350 YP.write(Atom.a(@" in ")); 5729 YP.write(Atom.a(" in "));
5351 convertExpressionPython(Expression); 5730 convertExpressionPython(Expression);
5352 YP.write(Atom.a(@":")); 5731 YP.write(Atom.a(":"));
5353 YP.nl(); 5732 YP.nl();
5354 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) 5733 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5355 { 5734 {
@@ -5358,10 +5737,10 @@ namespace Temporary {
5358 if (YP.termEqual(HasBreakableBlock, 1)) 5737 if (YP.termEqual(HasBreakableBlock, 1))
5359 { 5738 {
5360 convertIndentationPython(Level); 5739 convertIndentationPython(Level);
5361 YP.write(Atom.a(@"if doBreak:")); 5740 YP.write(Atom.a("if doBreak:"));
5362 YP.nl(); 5741 YP.nl();
5363 convertIndentationPython(NextLevel); 5742 convertIndentationPython(NextLevel);
5364 YP.write(Atom.a(@"break")); 5743 YP.write(Atom.a("break"));
5365 YP.nl(); 5744 YP.nl();
5366 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5745 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5367 { 5746 {
@@ -5386,10 +5765,10 @@ namespace Temporary {
5386 object HasBreakableBlock = arg3; 5765 object HasBreakableBlock = arg3;
5387 Variable Expression = new Variable(); 5766 Variable Expression = new Variable();
5388 Variable RestStatements = new Variable(); 5767 Variable RestStatements = new Variable();
5389 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)))
5390 { 5769 {
5391 convertIndentationPython(Level); 5770 convertIndentationPython(Level);
5392 YP.write(Atom.a(@"raise ")); 5771 YP.write(Atom.a("raise "));
5393 convertExpressionPython(Expression); 5772 convertExpressionPython(Expression);
5394 YP.nl(); 5773 YP.nl();
5395 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) 5774 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
@@ -5407,7 +5786,7 @@ namespace Temporary {
5407 Variable N = new Variable(); 5786 Variable N = new Variable();
5408 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) 5787 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
5409 { 5788 {
5410 repeatWrite(Atom.a(@" "), N); 5789 repeatWrite(Atom.a(" "), N);
5411 return; 5790 return;
5412 } 5791 }
5413 } 5792 }
@@ -5429,15 +5808,15 @@ namespace Temporary {
5429 convertExpressionPython(Head); 5808 convertExpressionPython(Head);
5430 if (YP.termNotEqual(Tail, Atom.NIL)) 5809 if (YP.termNotEqual(Tail, Atom.NIL))
5431 { 5810 {
5432 YP.write(Atom.a(@", ")); 5811 YP.write(Atom.a(", "));
5433 convertArgListPython(Tail); 5812 convertArgListPython(Tail);
5434 return; 5813 return;
5435 // goto cutIf1; 5814 goto cutIf1;
5436 } 5815 }
5437 convertArgListPython(Tail); 5816 convertArgListPython(Tail);
5438 return; 5817 return;
5439 // cutIf1: 5818 cutIf1:
5440 // { } 5819 { }
5441 } 5820 }
5442 } 5821 }
5443 } 5822 }
@@ -5446,7 +5825,7 @@ namespace Temporary {
5446 { 5825 {
5447 { 5826 {
5448 Variable X = new Variable(); 5827 Variable X = new Variable();
5449 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) 5828 foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
5450 { 5829 {
5451 YP.write(X); 5830 YP.write(X);
5452 return; 5831 return;
@@ -5455,12 +5834,22 @@ namespace Temporary {
5455 { 5834 {
5456 Variable Name = new Variable(); 5835 Variable Name = new Variable();
5457 Variable ArgList = new Variable(); 5836 Variable ArgList = new Variable();
5458 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)))
5459 { 5838 {
5460 YP.write(Name); 5839 YP.write(Name);
5461 YP.write(Atom.a(@"(")); 5840 YP.write(Atom.a("("));
5462 convertArgListPython(ArgList); 5841 convertArgListPython(ArgList);
5463 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));
5464 return; 5853 return;
5465 } 5854 }
5466 } 5855 }
@@ -5468,89 +5857,89 @@ namespace Temporary {
5468 Variable Obj = new Variable(); 5857 Variable Obj = new Variable();
5469 Variable Name = new Variable(); 5858 Variable Name = new Variable();
5470 Variable ArgList = new Variable(); 5859 Variable ArgList = new Variable();
5471 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)))
5472 { 5861 {
5473 YP.write(Obj); 5862 YP.write(Obj);
5474 YP.write(Atom.a(@".")); 5863 YP.write(Atom.a("."));
5475 YP.write(Name); 5864 YP.write(Name);
5476 YP.write(Atom.a(@"(")); 5865 YP.write(Atom.a("("));
5477 convertArgListPython(ArgList); 5866 convertArgListPython(ArgList);
5478 YP.write(Atom.a(@")")); 5867 YP.write(Atom.a(")"));
5479 return; 5868 return;
5480 } 5869 }
5481 } 5870 }
5482 { 5871 {
5483 Variable Name = new Variable(); 5872 Variable Name = new Variable();
5484 Variable ArgList = new Variable(); 5873 Variable ArgList = new Variable();
5485 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)))
5486 { 5875 {
5487 YP.write(Name); 5876 YP.write(Name);
5488 YP.write(Atom.a(@"(")); 5877 YP.write(Atom.a("("));
5489 convertArgListPython(ArgList); 5878 convertArgListPython(ArgList);
5490 YP.write(Atom.a(@")")); 5879 YP.write(Atom.a(")"));
5491 return; 5880 return;
5492 } 5881 }
5493 } 5882 }
5494 { 5883 {
5495 Variable Name = new Variable(); 5884 Variable Name = new Variable();
5496 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) 5885 foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
5497 { 5886 {
5498 YP.write(Name); 5887 YP.write(Name);
5499 return; 5888 return;
5500 } 5889 }
5501 } 5890 }
5502 { 5891 {
5503 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) 5892 foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
5504 { 5893 {
5505 YP.write(Atom.a(@"None")); 5894 YP.write(Atom.a("None"));
5506 return; 5895 return;
5507 } 5896 }
5508 } 5897 }
5509 { 5898 {
5510 Variable X = new Variable(); 5899 Variable X = new Variable();
5511 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) 5900 foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
5512 { 5901 {
5513 YP.write(Atom.a(@"not (")); 5902 YP.write(Atom.a("not ("));
5514 convertExpressionPython(X); 5903 convertExpressionPython(X);
5515 YP.write(Atom.a(@")")); 5904 YP.write(Atom.a(")"));
5516 return; 5905 return;
5517 } 5906 }
5518 } 5907 }
5519 { 5908 {
5520 Variable X = new Variable(); 5909 Variable X = new Variable();
5521 Variable Y = new Variable(); 5910 Variable Y = new Variable();
5522 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)))
5523 { 5912 {
5524 YP.write(Atom.a(@"(")); 5913 YP.write(Atom.a("("));
5525 convertExpressionPython(X); 5914 convertExpressionPython(X);
5526 YP.write(Atom.a(@") and (")); 5915 YP.write(Atom.a(") and ("));
5527 convertExpressionPython(Y); 5916 convertExpressionPython(Y);
5528 YP.write(Atom.a(@")")); 5917 YP.write(Atom.a(")"));
5529 return; 5918 return;
5530 } 5919 }
5531 } 5920 }
5532 { 5921 {
5533 Variable ArgList = new Variable(); 5922 Variable ArgList = new Variable();
5534 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) 5923 foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
5535 { 5924 {
5536 YP.write(Atom.a(@"[")); 5925 YP.write(Atom.a("["));
5537 convertArgListPython(ArgList); 5926 convertArgListPython(ArgList);
5538 YP.write(Atom.a(@"]")); 5927 YP.write(Atom.a("]"));
5539 return; 5928 return;
5540 } 5929 }
5541 } 5930 }
5542 { 5931 {
5543 Variable X = new Variable(); 5932 Variable X = new Variable();
5544 Variable Codes = new Variable(); 5933 Variable Codes = new Variable();
5545 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5934 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
5546 { 5935 {
5547 if (YP.atom(X)) 5936 if (YP.atom(X))
5548 { 5937 {
5549 YP.write(Atom.a(@"""")); 5938 YP.write(Atom.a("\""));
5550 foreach (bool l4 in YP.atom_codes(X, Codes)) 5939 foreach (bool l4 in YP.atom_codes(X, Codes))
5551 { 5940 {
5552 convertStringCodesPython(Codes); 5941 convertStringCodesPython(Codes);
5553 YP.write(Atom.a(@"""")); 5942 YP.write(Atom.a("\""));
5554 return; 5943 return;
5555 } 5944 }
5556 } 5945 }
@@ -5558,7 +5947,7 @@ namespace Temporary {
5558 } 5947 }
5559 { 5948 {
5560 Variable X = new Variable(); 5949 Variable X = new Variable();
5561 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) 5950 foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
5562 { 5951 {
5563 YP.write(X); 5952 YP.write(X);
5564 return; 5953 return;
@@ -5585,7 +5974,7 @@ namespace Temporary {
5585 YP.put_code(Code); 5974 YP.put_code(Code);
5586 convertStringCodesPython(RestCodes); 5975 convertStringCodesPython(RestCodes);
5587 return; 5976 return;
5588 // goto cutIf1; 5977 goto cutIf1;
5589 } 5978 }
5590 if (YP.termEqual(Code, 92)) 5979 if (YP.termEqual(Code, 92))
5591 { 5980 {
@@ -5593,15 +5982,99 @@ namespace Temporary {
5593 YP.put_code(Code); 5982 YP.put_code(Code);
5594 convertStringCodesPython(RestCodes); 5983 convertStringCodesPython(RestCodes);
5595 return; 5984 return;
5596 // goto cutIf1; 5985 goto cutIf1;
5597 } 5986 }
5598 YP.put_code(Code); 5987 YP.put_code(Code);
5599 convertStringCodesPython(RestCodes); 5988 convertStringCodesPython(RestCodes);
5600 return; 5989 return;
5601 // cutIf1: 5990 cutIf1:
5602 // { } 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;
5603 } 6062 }
5604 } 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 }
5605 } 6078 }
5606 6079
5607 public static IEnumerable<bool> member(object X, object arg2) 6080 public static IEnumerable<bool> member(object X, object arg2)
@@ -5658,7 +6131,6 @@ namespace Temporary {
5658 } 6131 }
5659 } 6132 }
5660 } 6133 }
5661 #pragma warning restore 0168 6134 #pragma warning restore 0168, 0219, 0164, 0162
5662
5663 } 6135 }
5664} 6136}
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 09d816f..a8c61ed 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -544,6 +544,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
544 ", Error Number: " + CompErr.ErrorNumber + 544 ", Error Number: " + CompErr.ErrorNumber +
545 ", '" + CompErr.ErrorText + "'\r\n"; 545 ", '" + CompErr.ErrorText + "'\r\n";
546 } 546 }
547 Console.WriteLine("[COMPILER ERROR]:" + errtext);
547 if (!File.Exists(OutFile)) 548 if (!File.Exists(OutFile))
548 { 549 {
549 throw new Exception(errtext); 550 throw new Exception(errtext);
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
index 52c8251..831b918 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
@@ -98,6 +98,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
98 @"this.$1(", 98 @"this.$1(",
99 RegexOptions.Compiled | RegexOptions.Singleline); 99 RegexOptions.Compiled | RegexOptions.Singleline);
100 finalcode = Regex.Replace(finalcode, 100 finalcode = Regex.Replace(finalcode,
101 @"YP.script_event\(Atom.a\(\""(.*?)""\)\,",
102 @"this.$1(",
103 RegexOptions.Compiled | RegexOptions.Singleline);
104 finalcode = Regex.Replace(finalcode,
101 @" static ", 105 @" static ",
102 @" ", 106 @" ",
103 RegexOptions.Compiled | RegexOptions.Singleline); 107 RegexOptions.Compiled | RegexOptions.Singleline);