diff options
author | Charles Krinke | 2008-06-07 15:43:16 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-07 15:43:16 +0000 |
commit | 80079e14e3f92accb309c25778fe87e3916e0143 (patch) | |
tree | 829b5cfd7a69799c35a05ed61d77161d0cdcfdd3 /OpenSim/Region/ScriptEngine/DotNetEngine | |
parent | *Fixing another object counting bug (diff) | |
download | opensim-SC-80079e14e3f92accb309c25778fe87e3916e0143.zip opensim-SC-80079e14e3f92accb309c25778fe87e3916e0143.tar.gz opensim-SC-80079e14e3f92accb309c25778fe87e3916e0143.tar.bz2 opensim-SC-80079e14e3f92accb309c25778fe87e3916e0143.tar.xz |
Mantis#1475. Thank you kindly, Kinoc for a patch that:
This patch brings the Yield Prolog in sync with the YP r669.
Biggest item is support for functions asserta and assertz ,
providing dynamic databases.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs | 270 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs | 782 |
2 files changed, 830 insertions, 222 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs index a03cd30..68cfd3e 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs | |||
@@ -149,6 +149,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
149 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) | 149 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) |
150 | // Assume it is a char type like "a". | 150 | // Assume it is a char type like "a". |
151 | term = YP.getValue(((Functor2)term)._arg1); | 151 | term = YP.getValue(((Functor2)term)._arg1); |
152 | if (term is Variable) | ||
153 | throw new PrologException(Atom.a("instantiation_error"), | ||
154 | "Expected a number but the argument is an unbound variable"); | ||
152 | 155 | ||
153 | return Convert.ToDouble(term); | 156 | return Convert.ToDouble(term); |
154 | } | 157 | } |
@@ -982,11 +985,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
982 | return YP.getValue(Term) is Atom; | 985 | return YP.getValue(Term) is Atom; |
983 | } | 986 | } |
984 | 987 | ||
988 | public static bool integer(object Term) | ||
989 | { | ||
990 | // Debug: Should exhaustively check for all integer types. | ||
991 | return getValue(Term) is int; | ||
992 | } | ||
993 | |||
994 | // Use isFloat instead of float because it is a reserved keyword. | ||
995 | public static bool isFloat(object Term) | ||
996 | { | ||
997 | // Debug: Should exhaustively check for all float types. | ||
998 | return getValue(Term) is double; | ||
999 | } | ||
1000 | |||
985 | public static bool number(object Term) | 1001 | public static bool number(object Term) |
986 | { | 1002 | { |
987 | Term = getValue(Term); | 1003 | return YP.integer(Term) || YP.isFloat(Term); |
988 | // Debug: Should exhaustively check for all number types. | ||
989 | return Term is int || Term is double; | ||
990 | } | 1004 | } |
991 | 1005 | ||
992 | public static bool atomic(object Term) | 1006 | public static bool atomic(object Term) |
@@ -1060,6 +1074,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1060 | _outputStream = Console.Out; | 1074 | _outputStream = Console.Out; |
1061 | } | 1075 | } |
1062 | 1076 | ||
1077 | public static IEnumerable<bool> current_output(object Stream) | ||
1078 | { | ||
1079 | return YP.unify(Stream, _outputStream); | ||
1080 | } | ||
1081 | |||
1063 | public static void write(object x) | 1082 | public static void write(object x) |
1064 | { | 1083 | { |
1065 | x = YP.getValue(x); | 1084 | x = YP.getValue(x); |
@@ -1108,6 +1127,93 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1108 | return YP.unify(code, _inputStream.Read()); | 1127 | return YP.unify(code, _inputStream.Read()); |
1109 | } | 1128 | } |
1110 | 1129 | ||
1130 | public static void asserta(object Term, Type declaringClass) | ||
1131 | { | ||
1132 | assertDynamic(Term, declaringClass, true); | ||
1133 | } | ||
1134 | |||
1135 | public static void assertz(object Term, Type declaringClass) | ||
1136 | { | ||
1137 | assertDynamic(Term, declaringClass, false); | ||
1138 | } | ||
1139 | |||
1140 | public static void assertDynamic(object Term, Type declaringClass, bool prepend) | ||
1141 | { | ||
1142 | Term = getValue(Term); | ||
1143 | if (Term is Variable) | ||
1144 | throw new PrologException("instantiation_error", "Term to assert is an unbound variable"); | ||
1145 | |||
1146 | Variable.CopyStore copyStore = new Variable.CopyStore(); | ||
1147 | object TermCopy = makeCopy(Term, copyStore); | ||
1148 | object Head, Body; | ||
1149 | if (TermCopy is Functor2 && ((Functor2)TermCopy)._name == Atom.RULE) | ||
1150 | { | ||
1151 | Head = YP.getValue(((Functor2)TermCopy)._arg1); | ||
1152 | Body = YP.getValue(((Functor2)TermCopy)._arg2); | ||
1153 | } | ||
1154 | else | ||
1155 | { | ||
1156 | Head = TermCopy; | ||
1157 | Body = Atom.a("true"); | ||
1158 | } | ||
1159 | |||
1160 | Atom name = getFunctorName(Head) as Atom; | ||
1161 | if (name == null) | ||
1162 | // name is a non-Atom, such as a number. | ||
1163 | throw new PrologException | ||
1164 | (new Functor2("type_error", Atom.a("callable"), Head), "Term to assert is not callable"); | ||
1165 | object[] args = getFunctorArgs(Head); | ||
1166 | if (!isDynamic(name, args.Length)) | ||
1167 | throw new PrologException | ||
1168 | (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"), | ||
1169 | new Functor2(Atom.SLASH, name, args.Length)), | ||
1170 | "Assert cannot modify static predicate " + name + "/" + args.Length); | ||
1171 | |||
1172 | if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true")) | ||
1173 | { | ||
1174 | // Debug: Until IndexedAnswers supports prepend, compile the fact so we can prepend it below. | ||
1175 | if (!prepend) | ||
1176 | { | ||
1177 | // This is a fact with no unbound variables | ||
1178 | // assertFact uses IndexedAnswers, so don't we don't need to compile. | ||
1179 | assertFact(name, args); | ||
1180 | return; | ||
1181 | } | ||
1182 | } | ||
1183 | |||
1184 | IClause clause = YPCompiler.compileAnonymousClause(Head, Body, declaringClass); | ||
1185 | |||
1186 | // Add the clause to the entry in _predicatesStore. | ||
1187 | NameArity nameArity = new NameArity(name, args.Length); | ||
1188 | List<IClause> clauses; | ||
1189 | if (!_predicatesStore.TryGetValue(nameArity, out clauses)) | ||
1190 | // Create an entry for the nameArity. | ||
1191 | _predicatesStore[nameArity] = (clauses = new List<IClause>()); | ||
1192 | |||
1193 | if (prepend) | ||
1194 | clauses.Insert(0, clause); | ||
1195 | else | ||
1196 | clauses.Add(clause); | ||
1197 | } | ||
1198 | |||
1199 | private static bool isDynamic(Atom name, int arity) | ||
1200 | { | ||
1201 | if (arity == 2 && (name == Atom.a(",") || name == Atom.a(";") || name == Atom.DOT)) | ||
1202 | return false; | ||
1203 | // Use the same mapping to static predicates in YP as the compiler. | ||
1204 | foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable())) | ||
1205 | return false; | ||
1206 | // Debug: Do we need to check if name._module is null? | ||
1207 | return true; | ||
1208 | } | ||
1209 | |||
1210 | /// <summary> | ||
1211 | /// Assert values at the end of the set of facts for the predicate with the | ||
1212 | /// name and with arity values.Length. | ||
1213 | /// </summary> | ||
1214 | /// <param name="name">must be an Atom</param> | ||
1215 | /// <param name="values">the array of arguments to the fact predicate. | ||
1216 | /// It is an error if an value has an unbound variable.</param> | ||
1111 | public static void assertFact(Atom name, object[] values) | 1217 | public static void assertFact(Atom name, object[] values) |
1112 | { | 1218 | { |
1113 | NameArity nameArity = new NameArity(name, values.Length); | 1219 | NameArity nameArity = new NameArity(name, values.Length); |
@@ -1130,7 +1236,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1130 | indexedAnswers.addAnswer(values); | 1236 | indexedAnswers.addAnswer(values); |
1131 | } | 1237 | } |
1132 | 1238 | ||
1133 | public static IEnumerable<bool> matchFact(Atom name, object[] arguments) | 1239 | /// <summary> |
1240 | /// Match all clauses of the dynamic predicate with the name and with arity | ||
1241 | /// arguments.Length. | ||
1242 | /// It is an error if the predicate is not defined. | ||
1243 | /// </summary> | ||
1244 | /// <param name="name">must be an Atom</param> | ||
1245 | /// <param name="arguments">an array of arity number of arguments</param> | ||
1246 | /// <returns>an iterator which you can use in foreach</returns> | ||
1247 | public static IEnumerable<bool> matchDynamic(Atom name, object[] arguments) | ||
1134 | { | 1248 | { |
1135 | List<IClause> clauses; | 1249 | List<IClause> clauses; |
1136 | if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) | 1250 | if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) |
@@ -1147,20 +1261,46 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1147 | 1261 | ||
1148 | /// <summary> | 1262 | /// <summary> |
1149 | /// Call match(arguments) for each IClause in clauses. We make this a separate | 1263 | /// Call match(arguments) for each IClause in clauses. We make this a separate |
1150 | /// function so that matchFact itself does not need to be an iterator object. | 1264 | /// function so that matchDynamic itself does not need to be an iterator object. |
1151 | /// </summary> | 1265 | /// </summary> |
1152 | /// <param name="clauses"></param> | 1266 | /// <param name="clauses"></param> |
1153 | /// <param name="arguments"></param> | 1267 | /// <param name="arguments"></param> |
1154 | /// <returns></returns> | 1268 | /// <returns></returns> |
1155 | private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) | 1269 | private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) |
1156 | { | 1270 | { |
1271 | // Debug: If the clause asserts another clause into this same predicate, the iterator | ||
1272 | // over clauses will be corrupted. Should we take the time to copy clauses? | ||
1157 | foreach (IClause clause in clauses) | 1273 | foreach (IClause clause in clauses) |
1158 | { | 1274 | { |
1159 | foreach (bool lastCall in clause.match(arguments)) | 1275 | foreach (bool lastCall in clause.match(arguments)) |
1276 | { | ||
1160 | yield return false; | 1277 | yield return false; |
1278 | if (lastCall) | ||
1279 | // This happens after a cut in a clause. | ||
1280 | yield break; | ||
1281 | } | ||
1161 | } | 1282 | } |
1162 | } | 1283 | } |
1163 | 1284 | ||
1285 | /// <summary> | ||
1286 | /// This is deprecated and just calls matchDynamic. This matches all clauses, | ||
1287 | /// not just the ones defined with assertFact. | ||
1288 | /// </summary> | ||
1289 | /// <param name="name"></param> | ||
1290 | /// <param name="arguments"></param> | ||
1291 | /// <returns></returns> | ||
1292 | public static IEnumerable<bool> matchFact(Atom name, object[] arguments) | ||
1293 | { | ||
1294 | return matchDynamic(name, arguments); | ||
1295 | } | ||
1296 | |||
1297 | /// <summary> | ||
1298 | /// This actually searches all clauses, not just | ||
1299 | /// the ones defined with assertFact, but we keep the name for | ||
1300 | /// backwards compatibility. | ||
1301 | /// </summary> | ||
1302 | /// <param name="name">must be an Atom</param> | ||
1303 | /// <param name="arguments">an array of arity number of arguments</param> | ||
1164 | public static void retractFact(Atom name, object[] arguments) | 1304 | public static void retractFact(Atom name, object[] arguments) |
1165 | { | 1305 | { |
1166 | NameArity nameArity = new NameArity(name, arguments.Length); | 1306 | NameArity nameArity = new NameArity(name, arguments.Length); |
@@ -1219,40 +1359,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1219 | /// <returns></returns> | 1359 | /// <returns></returns> |
1220 | public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) | 1360 | public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) |
1221 | { | 1361 | { |
1362 | Goal = YP.getValue(Goal); | ||
1363 | if (Goal is Variable) | ||
1364 | throw new PrologException("instantiation_error", "Goal to call is an unbound variable"); | ||
1222 | #if true | 1365 | #if true |
1223 | List<Variable> variableSetList = new List<Variable>(); | 1366 | List<Variable> variableSetList = new List<Variable>(); |
1224 | addUniqueVariables(Goal, variableSetList); | 1367 | addUniqueVariables(Goal, variableSetList); |
1225 | Variable[] variableSet = variableSetList.ToArray(); | 1368 | Variable[] variableSet = variableSetList.ToArray(); |
1226 | object Head = Functor.make("function", variableSet); | ||
1227 | 1369 | ||
1228 | object Rule = new Functor2(Atom.RULE, Head, Goal); | 1370 | // Use Atom.F since it is ignored. |
1229 | object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL)); | 1371 | return YPCompiler.compileAnonymousClause |
1230 | StringWriter functionCode = new StringWriter(); | 1372 | (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet); |
1231 | TextWriter saveOutputStream = _outputStream; | ||
1232 | try | ||
1233 | { | ||
1234 | tell(functionCode); | ||
1235 | Variable FunctionCode = new Variable(); | ||
1236 | foreach (bool l1 in YPCompiler.makeFunctionPseudoCode(RuleList, FunctionCode)) | ||
1237 | { | ||
1238 | if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) | ||
1239 | // Ignore getDeclaringClass since we have access to the one passed in. | ||
1240 | continue; | ||
1241 | |||
1242 | // Debug: should check if FunctionCode is a single call. | ||
1243 | YPCompiler.convertFunctionCSharp(FunctionCode); | ||
1244 | } | ||
1245 | told(); | ||
1246 | } | ||
1247 | finally | ||
1248 | { | ||
1249 | // Restore after calling tell. | ||
1250 | _outputStream = saveOutputStream; | ||
1251 | } | ||
1252 | return YPCompiler.compileAnonymousFunction | ||
1253 | (functionCode.ToString(), variableSet.Length, declaringClass).match(variableSet); | ||
1254 | #else | 1373 | #else |
1255 | Goal = YP.getValue(Goal); | ||
1256 | Atom name; | 1374 | Atom name; |
1257 | object[] args; | 1375 | object[] args; |
1258 | while (true) | 1376 | while (true) |
@@ -1436,5 +1554,91 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
1436 | throw new NotImplementedException(); | 1554 | throw new NotImplementedException(); |
1437 | } | 1555 | } |
1438 | } | 1556 | } |
1557 | |||
1558 | /// <summary> | ||
1559 | /// An enumerator that wraps another enumerator in order to catch a PrologException. | ||
1560 | /// </summary> | ||
1561 | public class Catch : IEnumerator<bool>, IEnumerable<bool> | ||
1562 | { | ||
1563 | private IEnumerator<bool> _enumerator; | ||
1564 | private PrologException _exception = null; | ||
1565 | |||
1566 | public Catch(IEnumerable<bool> iterator) | ||
1567 | { | ||
1568 | _enumerator = iterator.GetEnumerator(); | ||
1569 | } | ||
1570 | |||
1571 | /// <summary> | ||
1572 | /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception | ||
1573 | /// and return false. After this returns false, call unifyExceptionOrThrow. | ||
1574 | /// Assume that, after this returns false, it will not be called again. | ||
1575 | /// </summary> | ||
1576 | /// <returns></returns> | ||
1577 | public bool MoveNext() | ||
1578 | { | ||
1579 | try | ||
1580 | { | ||
1581 | return _enumerator.MoveNext(); | ||
1582 | } | ||
1583 | catch (PrologException exception) | ||
1584 | { | ||
1585 | _exception = exception; | ||
1586 | return false; | ||
1587 | } | ||
1588 | } | ||
1589 | |||
1590 | /// <summary> | ||
1591 | /// Call this after MoveNext() returns false to check for an exception. If | ||
1592 | /// MoveNext did not get a PrologException, don't yield. | ||
1593 | /// Otherwise, unify the exception with Catcher and yield so the caller can | ||
1594 | /// do the handler code. However, if can't unify with Catcher then throw the exception. | ||
1595 | /// </summary> | ||
1596 | /// <param name="Catcher"></param> | ||
1597 | /// <returns></returns> | ||
1598 | public IEnumerable<bool> unifyExceptionOrThrow(object Catcher) | ||
1599 | { | ||
1600 | if (_exception != null) | ||
1601 | { | ||
1602 | bool didUnify = false; | ||
1603 | foreach (bool l1 in YP.unify(_exception._term, Catcher)) | ||
1604 | { | ||
1605 | didUnify = true; | ||
1606 | yield return false; | ||
1607 | } | ||
1608 | if (!didUnify) | ||
1609 | throw _exception; | ||
1610 | } | ||
1611 | } | ||
1612 | |||
1613 | public IEnumerator<bool> GetEnumerator() | ||
1614 | { | ||
1615 | return (IEnumerator<bool>)this; | ||
1616 | } | ||
1617 | |||
1618 | IEnumerator IEnumerable.GetEnumerator() | ||
1619 | { | ||
1620 | return GetEnumerator(); | ||
1621 | } | ||
1622 | |||
1623 | public bool Current | ||
1624 | { | ||
1625 | get { return _enumerator.Current; } | ||
1626 | } | ||
1627 | |||
1628 | object IEnumerator.Current | ||
1629 | { | ||
1630 | get { return _enumerator.Current; } | ||
1631 | } | ||
1632 | |||
1633 | public void Dispose() | ||
1634 | { | ||
1635 | _enumerator.Dispose(); | ||
1636 | } | ||
1637 | |||
1638 | public void Reset() | ||
1639 | { | ||
1640 | throw new NotImplementedException(); | ||
1641 | } | ||
1642 | } | ||
1439 | } | 1643 | } |
1440 | } | 1644 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs index d998bac..572583b 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs | |||
@@ -276,6 +276,58 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
276 | } | 276 | } |
277 | 277 | ||
278 | /// <summary> | 278 | /// <summary> |
279 | /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction | ||
280 | /// to return an anonymous YP.IClause for the Head and Body of a rule clause. | ||
281 | /// </summary> | ||
282 | /// <param name="Head">a prolog term such as new Functor2("test1", X, Y). | ||
283 | /// Note that the name of the head is ignored. | ||
284 | /// </param> | ||
285 | /// <param name="Body">a prolog term such as | ||
286 | /// new Functor2(",", new Functor1(Atom.a("test2", Atom.a("")), X), | ||
287 | /// new Functor2("=", Y, X)). | ||
288 | /// This may not be null. (For a head-only clause, set the Body to Atom.a("true"). | ||
289 | /// </param> | ||
290 | /// <param name="declaringClass">if not null, the code is compiled as a subclass of this class | ||
291 | /// to resolve references to the default module Atom.a("")</param> | ||
292 | /// <returns>a new YP.IClause object on which you can call match(object[] args) where | ||
293 | /// args length is the arity of the Head</returns> | ||
294 | public static YP.IClause compileAnonymousClause(object Head, object Body, Type declaringClass) | ||
295 | { | ||
296 | object[] args = YP.getFunctorArgs(Head); | ||
297 | // compileAnonymousFunction wants "function". | ||
298 | object Rule = new Functor2(Atom.RULE, Functor.make("function", args), Body); | ||
299 | object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL)); | ||
300 | |||
301 | StringWriter functionCode = new StringWriter(); | ||
302 | Variable SaveOutputStream = new Variable(); | ||
303 | foreach (bool l1 in YP.current_output(SaveOutputStream)) | ||
304 | { | ||
305 | try | ||
306 | { | ||
307 | YP.tell(functionCode); | ||
308 | Variable FunctionCode = new Variable(); | ||
309 | foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode)) | ||
310 | { | ||
311 | if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) | ||
312 | // Ignore getDeclaringClass since we have access to the one passed in. | ||
313 | continue; | ||
314 | |||
315 | // Debug: should check if FunctionCode is a single call. | ||
316 | convertFunctionCSharp(FunctionCode); | ||
317 | } | ||
318 | YP.told(); | ||
319 | } | ||
320 | finally | ||
321 | { | ||
322 | // Restore after calling tell. | ||
323 | YP.tell(SaveOutputStream.getValue()); | ||
324 | } | ||
325 | } | ||
326 | return YPCompiler.compileAnonymousFunction | ||
327 | (functionCode.ToString(), args.Length, declaringClass); | ||
328 | } | ||
329 | |||
330 | /// <summary> | ||
279 | /// Use CodeDomProvider to compile the functionCode and return a YP.IClause. | 331 | /// Use CodeDomProvider to compile the functionCode and return a YP.IClause. |
280 | /// The function name must be "function" and have nArgs arguments. | 332 | /// The function name must be "function" and have nArgs arguments. |
281 | /// </summary> | 333 | /// </summary> |
@@ -337,8 +389,8 @@ namespace Temporary { | |||
337 | 389 | ||
338 | // Compiler output follows. | 390 | // Compiler output follows. |
339 | 391 | ||
340 | class YPInnerClass { } | 392 | public class YPInnerClass { } |
341 | static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } | 393 | public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } |
342 | 394 | ||
343 | public static void repeatWrite(object arg1, object N) | 395 | public static void repeatWrite(object arg1, object N) |
344 | { | 396 | { |
@@ -391,7 +443,11 @@ namespace Temporary { | |||
391 | CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 443 | CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
392 | CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 444 | CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
393 | CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 445 | CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
446 | CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | ||
447 | CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | ||
394 | CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 448 | CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
449 | CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | ||
450 | CompilerState.assertPred(State, new Functor1(@"compound", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | ||
395 | CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 451 | CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
396 | CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 452 | CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
397 | CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 453 | CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
@@ -654,13 +710,37 @@ namespace Temporary { | |||
654 | } | 710 | } |
655 | goto cutIf7; | 711 | goto cutIf7; |
656 | } | 712 | } |
657 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 713 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
714 | { | ||
715 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
716 | { | ||
717 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
718 | { | ||
719 | yield return false; | ||
720 | } | ||
721 | } | ||
722 | goto cutIf8; | ||
723 | } | ||
724 | if (CompilerState.codeUsesYield(State)) | ||
725 | { | ||
726 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
727 | { | ||
728 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
729 | { | ||
730 | yield return false; | ||
731 | } | ||
732 | } | ||
733 | goto cutIf9; | ||
734 | } | ||
735 | foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
658 | { | 736 | { |
659 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 737 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
660 | { | 738 | { |
661 | yield return false; | 739 | yield return false; |
662 | } | 740 | } |
663 | } | 741 | } |
742 | cutIf9: | ||
743 | cutIf8: | ||
664 | cutIf7: | 744 | cutIf7: |
665 | { } | 745 | { } |
666 | } | 746 | } |
@@ -679,19 +759,43 @@ namespace Temporary { | |||
679 | yield return false; | 759 | yield return false; |
680 | } | 760 | } |
681 | } | 761 | } |
682 | goto cutIf9; | 762 | goto cutIf11; |
683 | } | 763 | } |
684 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 764 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
765 | { | ||
766 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
767 | { | ||
768 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
769 | { | ||
770 | yield return false; | ||
771 | } | ||
772 | } | ||
773 | goto cutIf12; | ||
774 | } | ||
775 | if (CompilerState.codeUsesYield(State)) | ||
776 | { | ||
777 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
778 | { | ||
779 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
780 | { | ||
781 | yield return false; | ||
782 | } | ||
783 | } | ||
784 | goto cutIf13; | ||
785 | } | ||
786 | foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
685 | { | 787 | { |
686 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 788 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
687 | { | 789 | { |
688 | yield return false; | 790 | yield return false; |
689 | } | 791 | } |
690 | } | 792 | } |
691 | cutIf9: | 793 | cutIf13: |
794 | cutIf12: | ||
795 | cutIf11: | ||
692 | { } | 796 | { } |
693 | } | 797 | } |
694 | goto cutIf8; | 798 | goto cutIf10; |
695 | } | 799 | } |
696 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) | 800 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) |
697 | { | 801 | { |
@@ -704,19 +808,43 @@ namespace Temporary { | |||
704 | yield return false; | 808 | yield return false; |
705 | } | 809 | } |
706 | } | 810 | } |
707 | goto cutIf10; | 811 | goto cutIf14; |
708 | } | 812 | } |
709 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) | 813 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
814 | { | ||
815 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | ||
816 | { | ||
817 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
818 | { | ||
819 | yield return false; | ||
820 | } | ||
821 | } | ||
822 | goto cutIf15; | ||
823 | } | ||
824 | if (CompilerState.codeUsesYield(State)) | ||
825 | { | ||
826 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | ||
827 | { | ||
828 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
829 | { | ||
830 | yield return false; | ||
831 | } | ||
832 | } | ||
833 | goto cutIf16; | ||
834 | } | ||
835 | foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
710 | { | 836 | { |
711 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 837 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
712 | { | 838 | { |
713 | yield return false; | 839 | yield return false; |
714 | } | 840 | } |
715 | } | 841 | } |
716 | cutIf10: | 842 | cutIf16: |
843 | cutIf15: | ||
844 | cutIf14: | ||
717 | { } | 845 | { } |
718 | } | 846 | } |
719 | cutIf8: | 847 | cutIf10: |
720 | cutIf6: | 848 | cutIf6: |
721 | { } | 849 | { } |
722 | } | 850 | } |
@@ -730,36 +858,36 @@ namespace Temporary { | |||
730 | foreach (bool l3 in YP.unify(Head, FirstRule)) | 858 | foreach (bool l3 in YP.unify(Head, FirstRule)) |
731 | { | 859 | { |
732 | CompilerState.startFunction(State, Head); | 860 | CompilerState.startFunction(State, Head); |
733 | FindallAnswers findallAnswers11 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); | 861 | FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); |
734 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) | 862 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) |
735 | { | 863 | { |
736 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) | 864 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) |
737 | { | 865 | { |
738 | findallAnswers11.add(); | 866 | findallAnswers17.add(); |
739 | } | 867 | } |
740 | } | 868 | } |
741 | foreach (bool l4 in findallAnswers11.result(ClauseBag)) | 869 | foreach (bool l4 in findallAnswers17.result(ClauseBag)) |
742 | { | 870 | { |
743 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) | 871 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) |
744 | { | 872 | { |
745 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) | 873 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) |
746 | { | 874 | { |
747 | FindallAnswers findallAnswers12 = new FindallAnswers(MergedArgName); | 875 | FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName); |
748 | foreach (bool l7 in member(ArgName, FunctionArgNames)) | 876 | foreach (bool l7 in member(ArgName, FunctionArgNames)) |
749 | { | 877 | { |
750 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) | 878 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) |
751 | { | 879 | { |
752 | findallAnswers12.add(); | 880 | findallAnswers18.add(); |
753 | goto cutIf13; | 881 | goto cutIf19; |
754 | } | 882 | } |
755 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) | 883 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) |
756 | { | 884 | { |
757 | findallAnswers12.add(); | 885 | findallAnswers18.add(); |
758 | } | 886 | } |
759 | cutIf13: | 887 | cutIf19: |
760 | { } | 888 | { } |
761 | } | 889 | } |
762 | foreach (bool l7 in findallAnswers12.result(MergedArgNames)) | 890 | foreach (bool l7 in findallAnswers18.result(MergedArgNames)) |
763 | { | 891 | { |
764 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) | 892 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) |
765 | { | 893 | { |
@@ -778,19 +906,43 @@ namespace Temporary { | |||
778 | yield return false; | 906 | yield return false; |
779 | } | 907 | } |
780 | } | 908 | } |
781 | goto cutIf15; | 909 | goto cutIf21; |
782 | } | 910 | } |
783 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 911 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
912 | { | ||
913 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
914 | { | ||
915 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
916 | { | ||
917 | yield return false; | ||
918 | } | ||
919 | } | ||
920 | goto cutIf22; | ||
921 | } | ||
922 | if (CompilerState.codeUsesYield(State)) | ||
923 | { | ||
924 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
925 | { | ||
926 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
927 | { | ||
928 | yield return false; | ||
929 | } | ||
930 | } | ||
931 | goto cutIf23; | ||
932 | } | ||
933 | foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
784 | { | 934 | { |
785 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 935 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
786 | { | 936 | { |
787 | yield return false; | 937 | yield return false; |
788 | } | 938 | } |
789 | } | 939 | } |
790 | cutIf15: | 940 | cutIf23: |
941 | cutIf22: | ||
942 | cutIf21: | ||
791 | { } | 943 | { } |
792 | } | 944 | } |
793 | goto cutIf14; | 945 | goto cutIf20; |
794 | } | 946 | } |
795 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 947 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
796 | { | 948 | { |
@@ -805,19 +957,43 @@ namespace Temporary { | |||
805 | yield return false; | 957 | yield return false; |
806 | } | 958 | } |
807 | } | 959 | } |
808 | goto cutIf17; | 960 | goto cutIf25; |
809 | } | 961 | } |
810 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 962 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
963 | { | ||
964 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
965 | { | ||
966 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
967 | { | ||
968 | yield return false; | ||
969 | } | ||
970 | } | ||
971 | goto cutIf26; | ||
972 | } | ||
973 | if (CompilerState.codeUsesYield(State)) | ||
974 | { | ||
975 | foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode)) | ||
976 | { | ||
977 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
978 | { | ||
979 | yield return false; | ||
980 | } | ||
981 | } | ||
982 | goto cutIf27; | ||
983 | } | ||
984 | foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
811 | { | 985 | { |
812 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 986 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
813 | { | 987 | { |
814 | yield return false; | 988 | yield return false; |
815 | } | 989 | } |
816 | } | 990 | } |
817 | cutIf17: | 991 | cutIf27: |
992 | cutIf26: | ||
993 | cutIf25: | ||
818 | { } | 994 | { } |
819 | } | 995 | } |
820 | goto cutIf16; | 996 | goto cutIf24; |
821 | } | 997 | } |
822 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) | 998 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) |
823 | { | 999 | { |
@@ -830,20 +1006,44 @@ namespace Temporary { | |||
830 | yield return false; | 1006 | yield return false; |
831 | } | 1007 | } |
832 | } | 1008 | } |
833 | goto cutIf18; | 1009 | goto cutIf28; |
1010 | } | ||
1011 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) | ||
1012 | { | ||
1013 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | ||
1014 | { | ||
1015 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
1016 | { | ||
1017 | yield return false; | ||
1018 | } | ||
1019 | } | ||
1020 | goto cutIf29; | ||
834 | } | 1021 | } |
835 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) | 1022 | if (CompilerState.codeUsesYield(State)) |
1023 | { | ||
1024 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | ||
1025 | { | ||
1026 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | ||
1027 | { | ||
1028 | yield return false; | ||
1029 | } | ||
1030 | } | ||
1031 | goto cutIf30; | ||
1032 | } | ||
1033 | foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn)) | ||
836 | { | 1034 | { |
837 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 1035 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
838 | { | 1036 | { |
839 | yield return false; | 1037 | yield return false; |
840 | } | 1038 | } |
841 | } | 1039 | } |
842 | cutIf18: | 1040 | cutIf30: |
1041 | cutIf29: | ||
1042 | cutIf28: | ||
843 | { } | 1043 | { } |
844 | } | 1044 | } |
845 | cutIf16: | 1045 | cutIf24: |
846 | cutIf14: | 1046 | cutIf20: |
847 | { } | 1047 | { } |
848 | } | 1048 | } |
849 | } | 1049 | } |
@@ -1537,11 +1737,12 @@ namespace Temporary { | |||
1537 | } | 1737 | } |
1538 | } | 1738 | } |
1539 | { | 1739 | { |
1540 | object _State = arg2; | 1740 | object State = arg2; |
1541 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) | 1741 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) |
1542 | { | 1742 | { |
1543 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) | 1743 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) |
1544 | { | 1744 | { |
1745 | CompilerState.setCodeUsesYield(State); | ||
1545 | yield return true; | 1746 | yield return true; |
1546 | yield break; | 1747 | yield break; |
1547 | } | 1748 | } |
@@ -1588,11 +1789,12 @@ namespace Temporary { | |||
1588 | } | 1789 | } |
1589 | } | 1790 | } |
1590 | { | 1791 | { |
1591 | object _State = arg2; | 1792 | object State = arg2; |
1592 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) | 1793 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) |
1593 | { | 1794 | { |
1594 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL))) | 1795 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL))) |
1595 | { | 1796 | { |
1797 | CompilerState.setCodeUsesYield(State); | ||
1596 | yield return true; | 1798 | yield return true; |
1597 | yield break; | 1799 | yield break; |
1598 | } | 1800 | } |
@@ -2022,6 +2224,97 @@ namespace Temporary { | |||
2022 | object State = arg2; | 2224 | object State = arg2; |
2023 | Variable A = new Variable(); | 2225 | Variable A = new Variable(); |
2024 | Variable B = new Variable(); | 2226 | Variable B = new Variable(); |
2227 | Variable ATermCode = new Variable(); | ||
2228 | Variable BCode = new Variable(); | ||
2229 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"asserta", A), B))) | ||
2230 | { | ||
2231 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) | ||
2232 | { | ||
2233 | foreach (bool l4 in compileTerm(A, State, ATermCode)) | ||
2234 | { | ||
2235 | foreach (bool l5 in compileRuleBody(B, State, BCode)) | ||
2236 | { | ||
2237 | yield return true; | ||
2238 | yield break; | ||
2239 | } | ||
2240 | } | ||
2241 | } | ||
2242 | } | ||
2243 | } | ||
2244 | { | ||
2245 | object State = arg2; | ||
2246 | Variable A = new Variable(); | ||
2247 | Variable B = new Variable(); | ||
2248 | Variable ATermCode = new Variable(); | ||
2249 | Variable BCode = new Variable(); | ||
2250 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assertz", A), B))) | ||
2251 | { | ||
2252 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) | ||
2253 | { | ||
2254 | foreach (bool l4 in compileTerm(A, State, ATermCode)) | ||
2255 | { | ||
2256 | foreach (bool l5 in compileRuleBody(B, State, BCode)) | ||
2257 | { | ||
2258 | yield return true; | ||
2259 | yield break; | ||
2260 | } | ||
2261 | } | ||
2262 | } | ||
2263 | } | ||
2264 | } | ||
2265 | { | ||
2266 | object State = arg2; | ||
2267 | object PseudoCode = arg3; | ||
2268 | Variable A = new Variable(); | ||
2269 | Variable B = new Variable(); | ||
2270 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assert", A), B))) | ||
2271 | { | ||
2272 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"assertz", A), B), State, PseudoCode)) | ||
2273 | { | ||
2274 | yield return true; | ||
2275 | yield break; | ||
2276 | } | ||
2277 | } | ||
2278 | } | ||
2279 | { | ||
2280 | object State = arg2; | ||
2281 | Variable Goal = new Variable(); | ||
2282 | Variable Catcher = new Variable(); | ||
2283 | Variable Handler = new Variable(); | ||
2284 | Variable B = new Variable(); | ||
2285 | Variable CatchGoal = new Variable(); | ||
2286 | Variable GoalTermCode = new Variable(); | ||
2287 | Variable BCode = new Variable(); | ||
2288 | Variable CatcherTermCode = new Variable(); | ||
2289 | Variable HandlerAndBCode = new Variable(); | ||
2290 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"catch", Goal, Catcher, Handler), B))) | ||
2291 | { | ||
2292 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3(@"declare", Atom.a(@"YP.Catch"), CatchGoal, new Functor2(@"new", Atom.a(@"YP.Catch"), new ListPair(new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2(@"foreach", new Functor1(@"var", CatchGoal), BCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", CatchGoal), Atom.a(@"unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL))))) | ||
2293 | { | ||
2294 | foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal)) | ||
2295 | { | ||
2296 | foreach (bool l5 in compileTerm(Goal, State, GoalTermCode)) | ||
2297 | { | ||
2298 | foreach (bool l6 in compileTerm(Catcher, State, CatcherTermCode)) | ||
2299 | { | ||
2300 | foreach (bool l7 in compileRuleBody(B, State, BCode)) | ||
2301 | { | ||
2302 | foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode)) | ||
2303 | { | ||
2304 | yield return true; | ||
2305 | yield break; | ||
2306 | } | ||
2307 | } | ||
2308 | } | ||
2309 | } | ||
2310 | } | ||
2311 | } | ||
2312 | } | ||
2313 | } | ||
2314 | { | ||
2315 | object State = arg2; | ||
2316 | Variable A = new Variable(); | ||
2317 | Variable B = new Variable(); | ||
2025 | Variable ACode = new Variable(); | 2318 | Variable ACode = new Variable(); |
2026 | Variable BCode = new Variable(); | 2319 | Variable BCode = new Variable(); |
2027 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 2320 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
@@ -2254,28 +2547,39 @@ namespace Temporary { | |||
2254 | } | 2547 | } |
2255 | } | 2548 | } |
2256 | 2549 | ||
2257 | public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object arg3) | 2550 | public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object PseudoCode) |
2258 | { | 2551 | { |
2259 | { | 2552 | { |
2260 | Variable FunctionName = new Variable(); | ||
2261 | Variable CompiledArgs = new Variable(); | ||
2262 | Variable FunctorName = new Variable(); | 2553 | Variable FunctorName = new Variable(); |
2263 | Variable FunctorArgs = new Variable(); | 2554 | Variable FunctorArgs = new Variable(); |
2264 | Variable x7 = new Variable(); | 2555 | Variable x6 = new Variable(); |
2265 | Variable Arity = new Variable(); | 2556 | Variable Arity = new Variable(); |
2266 | foreach (bool l2 in YP.unify(arg3, new Functor2(@"call", FunctionName, CompiledArgs))) | 2557 | Variable CompiledArgs = new Variable(); |
2558 | Variable FunctionName = new Variable(); | ||
2559 | foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs))) | ||
2267 | { | 2560 | { |
2268 | foreach (bool l3 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs))) | 2561 | foreach (bool l3 in YP.functor(Functor_1, x6, Arity)) |
2269 | { | 2562 | { |
2270 | foreach (bool l4 in YP.functor(Functor_1, x7, Arity)) | 2563 | foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) |
2271 | { | 2564 | { |
2272 | foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) | 2565 | foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) |
2273 | { | 2566 | { |
2274 | foreach (bool l6 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) | 2567 | if (YP.termEqual(FunctionName, Atom.NIL)) |
2568 | { | ||
2569 | foreach (bool l7 in YP.unify(PseudoCode, new Functor2(@"call", Atom.a(@"YP.matchDynamic"), new ListPair(new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", FunctorName), Atom.NIL)), new ListPair(new Functor1(@"objectArray", CompiledArgs), Atom.NIL))))) | ||
2570 | { | ||
2571 | yield return true; | ||
2572 | yield break; | ||
2573 | } | ||
2574 | goto cutIf1; | ||
2575 | } | ||
2576 | foreach (bool l6 in YP.unify(PseudoCode, new Functor2(@"call", FunctionName, CompiledArgs))) | ||
2275 | { | 2577 | { |
2276 | yield return true; | 2578 | yield return true; |
2277 | yield break; | 2579 | yield break; |
2278 | } | 2580 | } |
2581 | cutIf1: | ||
2582 | { } | ||
2279 | } | 2583 | } |
2280 | } | 2584 | } |
2281 | } | 2585 | } |
@@ -2287,11 +2591,24 @@ namespace Temporary { | |||
2287 | { | 2591 | { |
2288 | { | 2592 | { |
2289 | object x1 = arg1; | 2593 | object x1 = arg1; |
2290 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"="))) | 2594 | object Name = arg2; |
2595 | object Arity = arg3; | ||
2596 | object FunctionName = arg4; | ||
2597 | foreach (bool l2 in functorCallYPFunctionName(Name, Arity, FunctionName)) | ||
2291 | { | 2598 | { |
2292 | foreach (bool l3 in YP.unify(arg3, 2)) | 2599 | yield return true; |
2600 | yield break; | ||
2601 | } | ||
2602 | } | ||
2603 | { | ||
2604 | object State = arg1; | ||
2605 | object Arity = arg3; | ||
2606 | Variable Name = new Variable(); | ||
2607 | foreach (bool l2 in YP.unify(arg2, Name)) | ||
2608 | { | ||
2609 | foreach (bool l3 in YP.unify(arg4, Name)) | ||
2293 | { | 2610 | { |
2294 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.unify"))) | 2611 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) |
2295 | { | 2612 | { |
2296 | yield return true; | 2613 | yield return true; |
2297 | yield break; | 2614 | yield break; |
@@ -2300,12 +2617,14 @@ namespace Temporary { | |||
2300 | } | 2617 | } |
2301 | } | 2618 | } |
2302 | { | 2619 | { |
2303 | object x1 = arg1; | 2620 | object _State = arg1; |
2304 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=.."))) | 2621 | object _Arity = arg3; |
2622 | Variable Name = new Variable(); | ||
2623 | foreach (bool l2 in YP.unify(arg2, Name)) | ||
2305 | { | 2624 | { |
2306 | foreach (bool l3 in YP.unify(arg3, 2)) | 2625 | foreach (bool l3 in YP.unify(arg4, Name)) |
2307 | { | 2626 | { |
2308 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.univ"))) | 2627 | foreach (bool l4 in Atom.module(Name, Atom.a(@""))) |
2309 | { | 2628 | { |
2310 | yield return true; | 2629 | yield return true; |
2311 | yield break; | 2630 | yield break; |
@@ -2314,12 +2633,54 @@ namespace Temporary { | |||
2314 | } | 2633 | } |
2315 | } | 2634 | } |
2316 | { | 2635 | { |
2317 | object x1 = arg1; | 2636 | object _State = arg1; |
2318 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"var"))) | 2637 | object Name = arg2; |
2638 | object Arity = arg3; | ||
2639 | foreach (bool l2 in YP.unify(arg4, Atom.NIL)) | ||
2319 | { | 2640 | { |
2320 | foreach (bool l3 in YP.unify(arg3, 1)) | 2641 | foreach (bool l3 in Atom.module(Name, Atom.NIL)) |
2321 | { | 2642 | { |
2322 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.var"))) | 2643 | yield return true; |
2644 | yield break; | ||
2645 | } | ||
2646 | } | ||
2647 | } | ||
2648 | { | ||
2649 | object _State = arg1; | ||
2650 | object Name = arg2; | ||
2651 | object Arity = arg3; | ||
2652 | object x4 = arg4; | ||
2653 | Variable Module = new Variable(); | ||
2654 | Variable Message = new Variable(); | ||
2655 | foreach (bool l2 in Atom.module(Name, Module)) | ||
2656 | { | ||
2657 | foreach (bool l3 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message)) | ||
2658 | { | ||
2659 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message)); | ||
2660 | yield return true; | ||
2661 | yield break; | ||
2662 | } | ||
2663 | } | ||
2664 | } | ||
2665 | { | ||
2666 | object _State = arg1; | ||
2667 | object Name = arg2; | ||
2668 | object _Arity = arg3; | ||
2669 | object x4 = arg4; | ||
2670 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), Name), Atom.a(@"Term is not callable"))); | ||
2671 | yield return true; | ||
2672 | yield break; | ||
2673 | } | ||
2674 | } | ||
2675 | |||
2676 | public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3) | ||
2677 | { | ||
2678 | { | ||
2679 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"="))) | ||
2680 | { | ||
2681 | foreach (bool l3 in YP.unify(arg2, 2)) | ||
2682 | { | ||
2683 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify"))) | ||
2323 | { | 2684 | { |
2324 | yield return true; | 2685 | yield return true; |
2325 | yield break; | 2686 | yield break; |
@@ -2328,12 +2689,11 @@ namespace Temporary { | |||
2328 | } | 2689 | } |
2329 | } | 2690 | } |
2330 | { | 2691 | { |
2331 | object x1 = arg1; | 2692 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=.."))) |
2332 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nonvar"))) | ||
2333 | { | 2693 | { |
2334 | foreach (bool l3 in YP.unify(arg3, 1)) | 2694 | foreach (bool l3 in YP.unify(arg2, 2)) |
2335 | { | 2695 | { |
2336 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nonvar"))) | 2696 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ"))) |
2337 | { | 2697 | { |
2338 | yield return true; | 2698 | yield return true; |
2339 | yield break; | 2699 | yield break; |
@@ -2342,12 +2702,11 @@ namespace Temporary { | |||
2342 | } | 2702 | } |
2343 | } | 2703 | } |
2344 | { | 2704 | { |
2345 | object x1 = arg1; | 2705 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"var"))) |
2346 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"arg"))) | ||
2347 | { | 2706 | { |
2348 | foreach (bool l3 in YP.unify(arg3, 3)) | 2707 | foreach (bool l3 in YP.unify(arg2, 1)) |
2349 | { | 2708 | { |
2350 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.arg"))) | 2709 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var"))) |
2351 | { | 2710 | { |
2352 | yield return true; | 2711 | yield return true; |
2353 | yield break; | 2712 | yield break; |
@@ -2356,12 +2715,11 @@ namespace Temporary { | |||
2356 | } | 2715 | } |
2357 | } | 2716 | } |
2358 | { | 2717 | { |
2359 | object x1 = arg1; | 2718 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar"))) |
2360 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"functor"))) | ||
2361 | { | 2719 | { |
2362 | foreach (bool l3 in YP.unify(arg3, 3)) | 2720 | foreach (bool l3 in YP.unify(arg2, 1)) |
2363 | { | 2721 | { |
2364 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.functor"))) | 2722 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar"))) |
2365 | { | 2723 | { |
2366 | yield return true; | 2724 | yield return true; |
2367 | yield break; | 2725 | yield break; |
@@ -2370,12 +2728,11 @@ namespace Temporary { | |||
2370 | } | 2728 | } |
2371 | } | 2729 | } |
2372 | { | 2730 | { |
2373 | object x1 = arg1; | 2731 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg"))) |
2374 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"repeat"))) | ||
2375 | { | 2732 | { |
2376 | foreach (bool l3 in YP.unify(arg3, 0)) | 2733 | foreach (bool l3 in YP.unify(arg2, 3)) |
2377 | { | 2734 | { |
2378 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.repeat"))) | 2735 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg"))) |
2379 | { | 2736 | { |
2380 | yield return true; | 2737 | yield return true; |
2381 | yield break; | 2738 | yield break; |
@@ -2384,12 +2741,11 @@ namespace Temporary { | |||
2384 | } | 2741 | } |
2385 | } | 2742 | } |
2386 | { | 2743 | { |
2387 | object x1 = arg1; | 2744 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor"))) |
2388 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"get_code"))) | ||
2389 | { | 2745 | { |
2390 | foreach (bool l3 in YP.unify(arg3, 1)) | 2746 | foreach (bool l3 in YP.unify(arg2, 3)) |
2391 | { | 2747 | { |
2392 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.get_code"))) | 2748 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor"))) |
2393 | { | 2749 | { |
2394 | yield return true; | 2750 | yield return true; |
2395 | yield break; | 2751 | yield break; |
@@ -2398,12 +2754,11 @@ namespace Temporary { | |||
2398 | } | 2754 | } |
2399 | } | 2755 | } |
2400 | { | 2756 | { |
2401 | object x1 = arg1; | 2757 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat"))) |
2402 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"current_op"))) | ||
2403 | { | 2758 | { |
2404 | foreach (bool l3 in YP.unify(arg3, 3)) | 2759 | foreach (bool l3 in YP.unify(arg2, 0)) |
2405 | { | 2760 | { |
2406 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.current_op"))) | 2761 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat"))) |
2407 | { | 2762 | { |
2408 | yield return true; | 2763 | yield return true; |
2409 | yield break; | 2764 | yield break; |
@@ -2412,12 +2767,11 @@ namespace Temporary { | |||
2412 | } | 2767 | } |
2413 | } | 2768 | } |
2414 | { | 2769 | { |
2415 | object x1 = arg1; | 2770 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code"))) |
2416 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_length"))) | ||
2417 | { | 2771 | { |
2418 | foreach (bool l3 in YP.unify(arg3, 2)) | 2772 | foreach (bool l3 in YP.unify(arg2, 1)) |
2419 | { | 2773 | { |
2420 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_length"))) | 2774 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code"))) |
2421 | { | 2775 | { |
2422 | yield return true; | 2776 | yield return true; |
2423 | yield break; | 2777 | yield break; |
@@ -2426,12 +2780,11 @@ namespace Temporary { | |||
2426 | } | 2780 | } |
2427 | } | 2781 | } |
2428 | { | 2782 | { |
2429 | object x1 = arg1; | 2783 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op"))) |
2430 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_concat"))) | ||
2431 | { | 2784 | { |
2432 | foreach (bool l3 in YP.unify(arg3, 3)) | 2785 | foreach (bool l3 in YP.unify(arg2, 3)) |
2433 | { | 2786 | { |
2434 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_concat"))) | 2787 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op"))) |
2435 | { | 2788 | { |
2436 | yield return true; | 2789 | yield return true; |
2437 | yield break; | 2790 | yield break; |
@@ -2440,12 +2793,11 @@ namespace Temporary { | |||
2440 | } | 2793 | } |
2441 | } | 2794 | } |
2442 | { | 2795 | { |
2443 | object x1 = arg1; | 2796 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length"))) |
2444 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sub_atom"))) | ||
2445 | { | 2797 | { |
2446 | foreach (bool l3 in YP.unify(arg3, 5)) | 2798 | foreach (bool l3 in YP.unify(arg2, 2)) |
2447 | { | 2799 | { |
2448 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sub_atom"))) | 2800 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length"))) |
2449 | { | 2801 | { |
2450 | yield return true; | 2802 | yield return true; |
2451 | yield break; | 2803 | yield break; |
@@ -2454,12 +2806,11 @@ namespace Temporary { | |||
2454 | } | 2806 | } |
2455 | } | 2807 | } |
2456 | { | 2808 | { |
2457 | object x1 = arg1; | 2809 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat"))) |
2458 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_codes"))) | ||
2459 | { | 2810 | { |
2460 | foreach (bool l3 in YP.unify(arg3, 2)) | 2811 | foreach (bool l3 in YP.unify(arg2, 3)) |
2461 | { | 2812 | { |
2462 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_codes"))) | 2813 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat"))) |
2463 | { | 2814 | { |
2464 | yield return true; | 2815 | yield return true; |
2465 | yield break; | 2816 | yield break; |
@@ -2468,12 +2819,11 @@ namespace Temporary { | |||
2468 | } | 2819 | } |
2469 | } | 2820 | } |
2470 | { | 2821 | { |
2471 | object x1 = arg1; | 2822 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom"))) |
2472 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number_codes"))) | ||
2473 | { | 2823 | { |
2474 | foreach (bool l3 in YP.unify(arg3, 2)) | 2824 | foreach (bool l3 in YP.unify(arg2, 5)) |
2475 | { | 2825 | { |
2476 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number_codes"))) | 2826 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom"))) |
2477 | { | 2827 | { |
2478 | yield return true; | 2828 | yield return true; |
2479 | yield break; | 2829 | yield break; |
@@ -2482,12 +2832,11 @@ namespace Temporary { | |||
2482 | } | 2832 | } |
2483 | } | 2833 | } |
2484 | { | 2834 | { |
2485 | object x1 = arg1; | 2835 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes"))) |
2486 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"copy_term"))) | ||
2487 | { | 2836 | { |
2488 | foreach (bool l3 in YP.unify(arg3, 2)) | 2837 | foreach (bool l3 in YP.unify(arg2, 2)) |
2489 | { | 2838 | { |
2490 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.copy_term"))) | 2839 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes"))) |
2491 | { | 2840 | { |
2492 | yield return true; | 2841 | yield return true; |
2493 | yield break; | 2842 | yield break; |
@@ -2496,12 +2845,11 @@ namespace Temporary { | |||
2496 | } | 2845 | } |
2497 | } | 2846 | } |
2498 | { | 2847 | { |
2499 | object x1 = arg1; | 2848 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes"))) |
2500 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sort"))) | ||
2501 | { | 2849 | { |
2502 | foreach (bool l3 in YP.unify(arg3, 2)) | 2850 | foreach (bool l3 in YP.unify(arg2, 2)) |
2503 | { | 2851 | { |
2504 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sort"))) | 2852 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes"))) |
2505 | { | 2853 | { |
2506 | yield return true; | 2854 | yield return true; |
2507 | yield break; | 2855 | yield break; |
@@ -2510,12 +2858,11 @@ namespace Temporary { | |||
2510 | } | 2858 | } |
2511 | } | 2859 | } |
2512 | { | 2860 | { |
2513 | object x1 = arg1; | 2861 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term"))) |
2514 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"script_event"))) | ||
2515 | { | 2862 | { |
2516 | foreach (bool l3 in YP.unify(arg3, 2)) | 2863 | foreach (bool l3 in YP.unify(arg2, 2)) |
2517 | { | 2864 | { |
2518 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.script_event"))) | 2865 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term"))) |
2519 | { | 2866 | { |
2520 | yield return true; | 2867 | yield return true; |
2521 | yield break; | 2868 | yield break; |
@@ -2524,12 +2871,11 @@ namespace Temporary { | |||
2524 | } | 2871 | } |
2525 | } | 2872 | } |
2526 | { | 2873 | { |
2527 | object x1 = arg1; | 2874 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort"))) |
2528 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nl"))) | ||
2529 | { | 2875 | { |
2530 | foreach (bool l3 in YP.unify(arg3, 0)) | 2876 | foreach (bool l3 in YP.unify(arg2, 2)) |
2531 | { | 2877 | { |
2532 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nl"))) | 2878 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort"))) |
2533 | { | 2879 | { |
2534 | yield return true; | 2880 | yield return true; |
2535 | yield break; | 2881 | yield break; |
@@ -2538,12 +2884,14 @@ namespace Temporary { | |||
2538 | } | 2884 | } |
2539 | } | 2885 | } |
2540 | { | 2886 | { |
2541 | object x1 = arg1; | 2887 | // Manually included : script_event for callback to LSL/C# |
2542 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"write"))) | 2888 | |
2889 | //object x1 = arg1; | ||
2890 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"script_event"))) | ||
2543 | { | 2891 | { |
2544 | foreach (bool l3 in YP.unify(arg3, 1)) | 2892 | foreach (bool l3 in YP.unify(arg2, 2)) |
2545 | { | 2893 | { |
2546 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.write"))) | 2894 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.script_event"))) |
2547 | { | 2895 | { |
2548 | yield return true; | 2896 | yield return true; |
2549 | yield break; | 2897 | yield break; |
@@ -2552,12 +2900,11 @@ namespace Temporary { | |||
2552 | } | 2900 | } |
2553 | } | 2901 | } |
2554 | { | 2902 | { |
2555 | object x1 = arg1; | 2903 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl"))) |
2556 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"put_code"))) | ||
2557 | { | 2904 | { |
2558 | foreach (bool l3 in YP.unify(arg3, 1)) | 2905 | foreach (bool l3 in YP.unify(arg2, 0)) |
2559 | { | 2906 | { |
2560 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.put_code"))) | 2907 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl"))) |
2561 | { | 2908 | { |
2562 | yield return true; | 2909 | yield return true; |
2563 | yield break; | 2910 | yield break; |
@@ -2566,12 +2913,11 @@ namespace Temporary { | |||
2566 | } | 2913 | } |
2567 | } | 2914 | } |
2568 | { | 2915 | { |
2569 | object x1 = arg1; | 2916 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"write"))) |
2570 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom"))) | ||
2571 | { | 2917 | { |
2572 | foreach (bool l3 in YP.unify(arg3, 1)) | 2918 | foreach (bool l3 in YP.unify(arg2, 1)) |
2573 | { | 2919 | { |
2574 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom"))) | 2920 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write"))) |
2575 | { | 2921 | { |
2576 | yield return true; | 2922 | yield return true; |
2577 | yield break; | 2923 | yield break; |
@@ -2580,12 +2926,11 @@ namespace Temporary { | |||
2580 | } | 2926 | } |
2581 | } | 2927 | } |
2582 | { | 2928 | { |
2583 | object x1 = arg1; | 2929 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code"))) |
2584 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number"))) | ||
2585 | { | 2930 | { |
2586 | foreach (bool l3 in YP.unify(arg3, 1)) | 2931 | foreach (bool l3 in YP.unify(arg2, 1)) |
2587 | { | 2932 | { |
2588 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number"))) | 2933 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code"))) |
2589 | { | 2934 | { |
2590 | yield return true; | 2935 | yield return true; |
2591 | yield break; | 2936 | yield break; |
@@ -2594,13 +2939,25 @@ namespace Temporary { | |||
2594 | } | 2939 | } |
2595 | } | 2940 | } |
2596 | { | 2941 | { |
2597 | object x1 = arg1; | 2942 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom"))) |
2598 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=="))) | ||
2599 | { | 2943 | { |
2600 | foreach (bool l3 in YP.unify(arg3, 2)) | 2944 | foreach (bool l3 in YP.unify(arg2, 1)) |
2601 | { | 2945 | { |
2602 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termEqual"))) | 2946 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom"))) |
2947 | { | ||
2948 | yield return true; | ||
2949 | yield break; | ||
2950 | } | ||
2951 | } | ||
2952 | } | ||
2953 | } | ||
2954 | { | ||
2955 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer"))) | ||
2603 | { | 2956 | { |
2957 | foreach (bool l3 in YP.unify(arg2, 1)) | ||
2958 | { | ||
2959 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer"))) | ||
2960 | { | ||
2604 | yield return true; | 2961 | yield return true; |
2605 | yield break; | 2962 | yield break; |
2606 | } | 2963 | } |
@@ -2608,12 +2965,24 @@ namespace Temporary { | |||
2608 | } | 2965 | } |
2609 | } | 2966 | } |
2610 | { | 2967 | { |
2611 | object x1 = arg1; | 2968 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"float"))) |
2612 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"\=="))) | ||
2613 | { | 2969 | { |
2614 | foreach (bool l3 in YP.unify(arg3, 2)) | 2970 | foreach (bool l3 in YP.unify(arg2, 1)) |
2615 | { | 2971 | { |
2616 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termNotEqual"))) | 2972 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.isFloat"))) |
2973 | { | ||
2974 | yield return true; | ||
2975 | yield break; | ||
2976 | } | ||
2977 | } | ||
2978 | } | ||
2979 | } | ||
2980 | { | ||
2981 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"number"))) | ||
2982 | { | ||
2983 | foreach (bool l3 in YP.unify(arg2, 1)) | ||
2984 | { | ||
2985 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number"))) | ||
2617 | { | 2986 | { |
2618 | yield return true; | 2987 | yield return true; |
2619 | yield break; | 2988 | yield break; |
@@ -2622,12 +2991,11 @@ namespace Temporary { | |||
2622 | } | 2991 | } |
2623 | } | 2992 | } |
2624 | { | 2993 | { |
2625 | object x1 = arg1; | 2994 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic"))) |
2626 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@<"))) | ||
2627 | { | 2995 | { |
2628 | foreach (bool l3 in YP.unify(arg3, 2)) | 2996 | foreach (bool l3 in YP.unify(arg2, 1)) |
2629 | { | 2997 | { |
2630 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThan"))) | 2998 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic"))) |
2631 | { | 2999 | { |
2632 | yield return true; | 3000 | yield return true; |
2633 | yield break; | 3001 | yield break; |
@@ -2636,12 +3004,11 @@ namespace Temporary { | |||
2636 | } | 3004 | } |
2637 | } | 3005 | } |
2638 | { | 3006 | { |
2639 | object x1 = arg1; | 3007 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound"))) |
2640 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@=<"))) | ||
2641 | { | 3008 | { |
2642 | foreach (bool l3 in YP.unify(arg3, 2)) | 3009 | foreach (bool l3 in YP.unify(arg2, 1)) |
2643 | { | 3010 | { |
2644 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThanOrEqual"))) | 3011 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound"))) |
2645 | { | 3012 | { |
2646 | yield return true; | 3013 | yield return true; |
2647 | yield break; | 3014 | yield break; |
@@ -2650,12 +3017,11 @@ namespace Temporary { | |||
2650 | } | 3017 | } |
2651 | } | 3018 | } |
2652 | { | 3019 | { |
2653 | object x1 = arg1; | 3020 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=="))) |
2654 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>"))) | ||
2655 | { | 3021 | { |
2656 | foreach (bool l3 in YP.unify(arg3, 2)) | 3022 | foreach (bool l3 in YP.unify(arg2, 2)) |
2657 | { | 3023 | { |
2658 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThan"))) | 3024 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual"))) |
2659 | { | 3025 | { |
2660 | yield return true; | 3026 | yield return true; |
2661 | yield break; | 3027 | yield break; |
@@ -2664,12 +3030,11 @@ namespace Temporary { | |||
2664 | } | 3030 | } |
2665 | } | 3031 | } |
2666 | { | 3032 | { |
2667 | object x1 = arg1; | 3033 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"\=="))) |
2668 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>="))) | ||
2669 | { | 3034 | { |
2670 | foreach (bool l3 in YP.unify(arg3, 2)) | 3035 | foreach (bool l3 in YP.unify(arg2, 2)) |
2671 | { | 3036 | { |
2672 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThanOrEqual"))) | 3037 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual"))) |
2673 | { | 3038 | { |
2674 | yield return true; | 3039 | yield return true; |
2675 | yield break; | 3040 | yield break; |
@@ -2678,12 +3043,11 @@ namespace Temporary { | |||
2678 | } | 3043 | } |
2679 | } | 3044 | } |
2680 | { | 3045 | { |
2681 | object x1 = arg1; | 3046 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<"))) |
2682 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"throw"))) | ||
2683 | { | 3047 | { |
2684 | foreach (bool l3 in YP.unify(arg3, 1)) | 3048 | foreach (bool l3 in YP.unify(arg2, 2)) |
2685 | { | 3049 | { |
2686 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.throwException"))) | 3050 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan"))) |
2687 | { | 3051 | { |
2688 | yield return true; | 3052 | yield return true; |
2689 | yield break; | 3053 | yield break; |
@@ -2692,14 +3056,11 @@ namespace Temporary { | |||
2692 | } | 3056 | } |
2693 | } | 3057 | } |
2694 | { | 3058 | { |
2695 | object State = arg1; | 3059 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<"))) |
2696 | object Arity = arg3; | ||
2697 | Variable Name = new Variable(); | ||
2698 | foreach (bool l2 in YP.unify(arg2, Name)) | ||
2699 | { | 3060 | { |
2700 | foreach (bool l3 in YP.unify(arg4, Name)) | 3061 | foreach (bool l3 in YP.unify(arg2, 2)) |
2701 | { | 3062 | { |
2702 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) | 3063 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual"))) |
2703 | { | 3064 | { |
2704 | yield return true; | 3065 | yield return true; |
2705 | yield break; | 3066 | yield break; |
@@ -2708,14 +3069,11 @@ namespace Temporary { | |||
2708 | } | 3069 | } |
2709 | } | 3070 | } |
2710 | { | 3071 | { |
2711 | object _State = arg1; | 3072 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>"))) |
2712 | object _Arity = arg3; | ||
2713 | Variable Name = new Variable(); | ||
2714 | foreach (bool l2 in YP.unify(arg2, Name)) | ||
2715 | { | 3073 | { |
2716 | foreach (bool l3 in YP.unify(arg4, Name)) | 3074 | foreach (bool l3 in YP.unify(arg2, 2)) |
2717 | { | 3075 | { |
2718 | foreach (bool l4 in Atom.module(Name, Atom.a(@""))) | 3076 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan"))) |
2719 | { | 3077 | { |
2720 | yield return true; | 3078 | yield return true; |
2721 | yield break; | 3079 | yield break; |
@@ -2724,31 +3082,25 @@ namespace Temporary { | |||
2724 | } | 3082 | } |
2725 | } | 3083 | } |
2726 | { | 3084 | { |
2727 | object _State = arg1; | 3085 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>="))) |
2728 | object Name = arg2; | 3086 | { |
2729 | object Arity = arg3; | 3087 | foreach (bool l3 in YP.unify(arg2, 2)) |
2730 | object x4 = arg4; | 3088 | { |
2731 | foreach (bool l2 in Atom.module(Name, Atom.NIL)) | 3089 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual"))) |
2732 | { | 3090 | { |
2733 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Calls to dynamic predicates not supported"))); | ||
2734 | yield return true; | 3091 | yield return true; |
2735 | yield break; | 3092 | yield break; |
2736 | } | 3093 | } |
2737 | } | 3094 | } |
3095 | } | ||
3096 | } | ||
2738 | { | 3097 | { |
2739 | object _State = arg1; | 3098 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw"))) |
2740 | object Name = arg2; | ||
2741 | object Arity = arg3; | ||
2742 | object x4 = arg4; | ||
2743 | Variable Module = new Variable(); | ||
2744 | Variable Message = new Variable(); | ||
2745 | foreach (bool l2 in Atom.module(Name, Module)) | ||
2746 | { | 3099 | { |
2747 | foreach (bool l3 in Atom.module(Name, Atom.NIL)) | 3100 | foreach (bool l3 in YP.unify(arg2, 1)) |
2748 | { | 3101 | { |
2749 | foreach (bool l4 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message)) | 3102 | foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException"))) |
2750 | { | 3103 | { |
2751 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message)); | ||
2752 | yield return true; | 3104 | yield return true; |
2753 | yield break; | 3105 | yield break; |
2754 | } | 3106 | } |
@@ -3052,6 +3404,8 @@ namespace Temporary { | |||
3052 | Variable x9 = new Variable(); | 3404 | Variable x9 = new Variable(); |
3053 | Variable X2 = new Variable(); | 3405 | Variable X2 = new Variable(); |
3054 | Variable Arg2 = new Variable(); | 3406 | Variable Arg2 = new Variable(); |
3407 | Variable x12 = new Variable(); | ||
3408 | Variable Arity = new Variable(); | ||
3055 | if (YP.nonvar(Term)) | 3409 | if (YP.nonvar(Term)) |
3056 | { | 3410 | { |
3057 | foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs))) | 3411 | foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs))) |
@@ -3100,8 +3454,11 @@ namespace Temporary { | |||
3100 | goto cutIf3; | 3454 | goto cutIf3; |
3101 | } | 3455 | } |
3102 | } | 3456 | } |
3103 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), Name), Atom.a(@"Not an expression function"))); | 3457 | foreach (bool l5 in YP.functor(Term, x12, Arity)) |
3458 | { | ||
3459 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Not an expression function"))); | ||
3104 | yield return false; | 3460 | yield return false; |
3461 | } | ||
3105 | cutIf3: | 3462 | cutIf3: |
3106 | cutIf2: | 3463 | cutIf2: |
3107 | cutIf1: | 3464 | cutIf1: |
@@ -3402,9 +3759,9 @@ namespace Temporary { | |||
3402 | { | 3759 | { |
3403 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) | 3760 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) |
3404 | { | 3761 | { |
3405 | YP.write(Atom.a(@"class YPInnerClass {}")); | 3762 | YP.write(Atom.a(@"public class YPInnerClass {}")); |
3406 | YP.nl(); | 3763 | YP.nl(); |
3407 | YP.write(Atom.a(@"static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }")); | 3764 | YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }")); |
3408 | YP.nl(); | 3765 | YP.nl(); |
3409 | YP.nl(); | 3766 | YP.nl(); |
3410 | return; | 3767 | return; |
@@ -3707,6 +4064,20 @@ namespace Temporary { | |||
3707 | } | 4064 | } |
3708 | } | 4065 | } |
3709 | } | 4066 | } |
4067 | { | ||
4068 | Variable Expression = new Variable(); | ||
4069 | Variable RestStatements = new Variable(); | ||
4070 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) | ||
4071 | { | ||
4072 | convertIndentationCSharp(Level); | ||
4073 | YP.write(Atom.a(@"throw ")); | ||
4074 | convertExpressionCSharp(Expression); | ||
4075 | YP.write(Atom.a(@";")); | ||
4076 | YP.nl(); | ||
4077 | convertStatementListCSharp(RestStatements, Level); | ||
4078 | return; | ||
4079 | } | ||
4080 | } | ||
3710 | } | 4081 | } |
3711 | 4082 | ||
3712 | public static void convertIndentationCSharp(object Level) | 4083 | public static void convertIndentationCSharp(object Level) |
@@ -4204,6 +4575,21 @@ namespace Temporary { | |||
4204 | } | 4575 | } |
4205 | } | 4576 | } |
4206 | } | 4577 | } |
4578 | { | ||
4579 | object Level = arg2; | ||
4580 | Variable Expression = new Variable(); | ||
4581 | Variable RestStatements = new Variable(); | ||
4582 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) | ||
4583 | { | ||
4584 | convertIndentationJavascript(Level); | ||
4585 | YP.write(Atom.a(@"throw ")); | ||
4586 | convertExpressionJavascript(Expression); | ||
4587 | YP.write(Atom.a(@";")); | ||
4588 | YP.nl(); | ||
4589 | convertStatementListJavascript(RestStatements, Level); | ||
4590 | return; | ||
4591 | } | ||
4592 | } | ||
4207 | } | 4593 | } |
4208 | 4594 | ||
4209 | public static void convertIndentationJavascript(object Level) | 4595 | public static void convertIndentationJavascript(object Level) |
@@ -4983,6 +5369,24 @@ namespace Temporary { | |||
4983 | } | 5369 | } |
4984 | } | 5370 | } |
4985 | } | 5371 | } |
5372 | { | ||
5373 | object Level = arg2; | ||
5374 | object HasBreakableBlock = arg3; | ||
5375 | Variable Expression = new Variable(); | ||
5376 | Variable RestStatements = new Variable(); | ||
5377 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements))) | ||
5378 | { | ||
5379 | convertIndentationPython(Level); | ||
5380 | YP.write(Atom.a(@"raise ")); | ||
5381 | convertExpressionPython(Expression); | ||
5382 | YP.nl(); | ||
5383 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | ||
5384 | { | ||
5385 | yield return true; | ||
5386 | yield break; | ||
5387 | } | ||
5388 | } | ||
5389 | } | ||
4986 | } | 5390 | } |
4987 | 5391 | ||
4988 | public static void convertIndentationPython(object Level) | 5392 | public static void convertIndentationPython(object Level) |