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