aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712008-06-24 21:09:49 +0000
committerlbsa712008-06-24 21:09:49 +0000
commit6b7930104bdb845d3b9c085dc04f52b6446f23b1 (patch)
tree05ee45781a455817fa400bb99f30f4d19d4eb1f8 /OpenSim
parentbased on positive feedback on performance of making keys fixed length (diff)
downloadopensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.zip
opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.gz
opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.bz2
opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.xz
* Applied patch from Melanie, mantis issue #1581 - "Refactor LSL language, api and compiler out of XEngine"
"First stage in a major Script Engine refactor, that will result in the LSL implementaions ebing reconverged. Not there yet, but one major part is done." Thank you, Melanie!
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs)17
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScript.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs43
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs)66
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs79
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs)72
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs)342
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs)76
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs)9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs)14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs)9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs)30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs)7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs)22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs)16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs)4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs421
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs)697
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs199
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj161
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build62
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp43
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs124
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs218
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs234
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs103
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs188
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs111
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs154
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs133
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs288
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs156
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs4457
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs71
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs62
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs196
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs1644
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs5651
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs)2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Compiler.cs)70
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs)6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs108
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs121
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs)21
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs99
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Executor.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs234
49 files changed, 15616 insertions, 1288 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs
index e5d0b33..efb05d3 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs
@@ -25,22 +25,15 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Reflection;
29using System; 28using System;
30using System.Collections;
31using System.Collections.Generic; 29using System.Collections.Generic;
32using OpenSim.Region.Environment.Interfaces; 30using Nini.Config;
33 31
34namespace OpenSim.Region.ScriptEngine.XEngine.Script 32namespace OpenSim.Region.ScriptEngine.Interfaces
35{ 33{
36 public interface IScript 34 public interface ICompiler
37 { 35 {
38 Type Start(ILSL_ScriptCommands lsl, IOSSL_ScriptCommands ossl); 36 void Configure(IConfig configSource);
39 37 void Compile(string text, string outFile, List<IScriptApi> apiList);
40 Dictionary<string, object> GetVars();
41 void SetVars(Dictionary<string, object> vars);
42 void ResetVars();
43
44 string State { get; set; }
45 } 38 }
46} 39}
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs
new file mode 100644
index 0000000..553d56d
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScript.cs
@@ -0,0 +1,17 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using OpenSim.Region.ScriptEngine.Interfaces;
5
6namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
7{
8 public interface IScript
9 {
10 string[] GetApis();
11 void InitApi(string name, IScriptApi data);
12
13 Dictionary<string,Object> GetVars();
14 void SetVars(Dictionary<string,Object> vars);
15 void ResetVars();
16 }
17}
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs
new file mode 100644
index 0000000..2df41d0
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs
@@ -0,0 +1,43 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using libsecondlife;
30using OpenSim.Region.Environment.Scenes;
31
32
33namespace OpenSim.Region.ScriptEngine.Interfaces
34{
35 public interface IScriptApi
36 {
37 //
38 // Each API has an identifier, which is used to load the
39 // proper runtime assembly at load time.
40 //
41 void Initialize(IScriptEngine engine, SceneObjectPart part, uint localID, LLUUID item);
42 }
43}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index dab7a0a..2fa67a4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -25,51 +25,35 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net;
28using System; 29using System;
29using System.Collections; 30using OpenSim.Region.ScriptEngine.Shared;
30using System.Collections.Generic;
31using libsecondlife;
32using OpenSim.Region.Environment.Scenes; 31using OpenSim.Region.Environment.Scenes;
32using libsecondlife;
33using Nini.Config;
34using OpenSim.Region.ScriptEngine.Interfaces;
33 35
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 36namespace OpenSim.Region.ScriptEngine.Interfaces
35{ 37{
36 public class Eventstream 38 public interface IScriptEngine
37 { 39 {
38 public AsyncCommandManager m_CmdManager; 40 //
39 41 // An interface for a script API module to communicate with
40 private class Event 42 // the engine it's running under
41 { 43 //
42 public uint LocalID; 44
43 public string EventName; 45 Scene World { get; }
44 public Dictionary<LLUUID, XDetectParams> DetectParams; 46 IConfig Config { get; }
45 } 47 Object AsyncCommands { get; }
46 48 ILog Log { get; }
47 private Dictionary<uint, Dictionary<string, Event> > m_Events = 49
48 new Dictionary<uint, Dictionary<string, Event> >(); 50 bool PostScriptEvent(LLUUID itemID, EventParams parms);
49 51 bool PostObjectEvent(uint localID, EventParams parms);
50 public Eventstream(AsyncCommandManager CmdManager) 52 void ResetScript(LLUUID itemID);
51 { 53 void SetScriptState(LLUUID itemID, bool state);
52 m_CmdManager = CmdManager; 54 bool GetScriptState(LLUUID itemID);
53 } 55 void SetState(LLUUID itemID, string newState);
54 56
55 public void AddObjectEvent(uint localID, string eventName, XDetectParams det) 57 DetectParams GetDetectParams(LLUUID item, int number);
56 {
57 SceneObjectPart part = m_CmdManager.m_ScriptEngine.World.
58 GetSceneObjectPart(localID);
59
60 if (part == null) // Can't register events for non-prims
61 return;
62
63 if (!part.ContainsScripts())
64 return;
65 }
66
67 public void RemoveObjectEvent(uint localID, string eventName, LLUUID id)
68 {
69 }
70
71 public void RemoveObjects(uint localID)
72 {
73 }
74 } 58 }
75} 59}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
new file mode 100644
index 0000000..f7f2676
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
@@ -0,0 +1,79 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using OpenSim.Region.ScriptEngine.Interfaces;
33
34namespace OpenSim.Region.ScriptEngine.Shared.Api
35{
36 public class ApiManager
37 {
38 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
39
40 public string[] GetApis()
41 {
42 if(m_Apis.Count > 0)
43 {
44 List<string> l = new List<string>(m_Apis.Keys);
45 return l.ToArray();
46 }
47
48 Assembly a = Assembly.GetExecutingAssembly();
49
50 Type[] types = a.GetExportedTypes();
51
52 foreach (Type t in types)
53 {
54 string name = t.ToString();
55 int idx = name.LastIndexOf('.');
56 if(idx != -1)
57 name = name.Substring(idx+1);
58
59 if(name.EndsWith("_Api"))
60 {
61 name = name.Substring(0, name.Length - 4);
62 m_Apis[name] = t;
63 }
64 }
65
66 List<string> ret = new List<string>(m_Apis.Keys);
67 return ret.ToArray();
68 }
69
70 public IScriptApi CreateApi(string api)
71 {
72 if(!m_Apis.ContainsKey(api))
73 return null;
74
75 IScriptApi ret = (IScriptApi)(Activator.CreateInstance(m_Apis[api]));
76 return ret;
77 }
78 }
79}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index fdad5b0..8c967a2 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -32,11 +32,12 @@ using System.Threading;
32using libsecondlife; 32using libsecondlife;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins; 35using OpenSim.Region.ScriptEngine.Interfaces;
36using Timer=OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins.Timer; 36using OpenSim.Region.ScriptEngine.Shared;
37using Dataserver=OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins.Dataserver; 37using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
38using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
38 39
39namespace OpenSim.Region.ScriptEngine.XEngine 40namespace OpenSim.Region.ScriptEngine.Shared.Api
40{ 41{
41 /// <summary> 42 /// <summary>
42 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. 43 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
@@ -46,18 +47,57 @@ namespace OpenSim.Region.ScriptEngine.XEngine
46 private static Thread cmdHandlerThread; 47 private static Thread cmdHandlerThread;
47 private static int cmdHandlerThreadCycleSleepms; 48 private static int cmdHandlerThreadCycleSleepms;
48 49
49 public XEngine m_ScriptEngine; 50 private static List<AsyncCommandManager> m_Managers = new List<AsyncCommandManager>();
51 public IScriptEngine m_ScriptEngine;
50 52
51 public Dataserver m_Dataserver; 53 private Dataserver m_Dataserver;
52 public Timer m_Timer; 54 private Timer m_Timer;
53 public HttpRequest m_HttpRequest; 55 private HttpRequest m_HttpRequest;
54 public Listener m_Listener; 56 private Listener m_Listener;
55 public SensorRepeat m_SensorRepeat; 57 private SensorRepeat m_SensorRepeat;
56 public XmlRequest m_XmlRequest; 58 private XmlRequest m_XmlRequest;
57 59
58 public AsyncCommandManager(XEngine _ScriptEngine) 60 public Dataserver DataserverPlugin
61 {
62 get { return m_Dataserver; }
63 }
64
65 public Timer TimerPlugin
66 {
67 get { return m_Timer; }
68 }
69
70 public HttpRequest HttpRequestPlugin
71 {
72 get { return m_HttpRequest; }
73 }
74
75 public Listener ListenerPlugin
76 {
77 get { return m_Listener; }
78 }
79
80 public SensorRepeat SensorRepeatPlugin
81 {
82 get { return m_SensorRepeat; }
83 }
84
85 public XmlRequest XmlRequestPlugin
86 {
87 get { return m_XmlRequest; }
88 }
89
90 public AsyncCommandManager[] Managers
91 {
92 get { return m_Managers.ToArray(); }
93 }
94
95 public AsyncCommandManager(IScriptEngine _ScriptEngine)
59 { 96 {
60 m_ScriptEngine = _ScriptEngine; 97 m_ScriptEngine = _ScriptEngine;
98 if(!m_Managers.Contains(this))
99 m_Managers.Add(this);
100
61 ReadConfig(); 101 ReadConfig();
62 102
63 // Create instances of all plugins 103 // Create instances of all plugins
@@ -87,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
87 127
88 public void ReadConfig() 128 public void ReadConfig()
89 { 129 {
90 cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100); 130 cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100);
91 } 131 }
92 132
93 ~AsyncCommandManager() 133 ~AsyncCommandManager()
@@ -119,9 +159,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
119 { 159 {
120 Thread.Sleep(cmdHandlerThreadCycleSleepms); 160 Thread.Sleep(cmdHandlerThreadCycleSleepms);
121 161
122 foreach (XEngine xe in XEngine.ScriptEngines) 162 foreach (AsyncCommandManager m in m_Managers)
123 { 163 {
124 xe.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass(); 164 m.DoOneCmdHandlerPass();
125 } 165 }
126 } 166 }
127 } 167 }
@@ -131,7 +171,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
131 } 171 }
132 } 172 }
133 173
134 internal void DoOneCmdHandlerPass() 174 public void DoOneCmdHandlerPass()
135 { 175 {
136 // Check timers 176 // Check timers
137 m_Timer.CheckTimerEvents(); 177 m_Timer.CheckTimerEvents();
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9c660c1..7832633 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -41,65 +41,50 @@ using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; 41using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
42using OpenSim.Region.Environment.Modules.World.Land; 42using OpenSim.Region.Environment.Modules.World.Land;
43using OpenSim.Region.Environment.Scenes; 43using OpenSim.Region.Environment.Scenes;
44using OpenSim.Region.ScriptEngine.XEngine; 44using OpenSim.Region.ScriptEngine.Shared;
45using OpenSim.Region.ScriptEngine.XEngine.Script; 45using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
46using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
47using OpenSim.Region.ScriptEngine.Interfaces;
48using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
46 49
47 50namespace OpenSim.Region.ScriptEngine.Shared.Api
48namespace OpenSim.Region.ScriptEngine.XEngine
49{ 51{
50 /// <summary> 52 /// <summary>
51 /// Contains all LSL ll-functions. This class will be in Default AppDomain. 53 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
52 /// </summary> 54 /// </summary>
53 public class LSL_ScriptCommands : MarshalByRefObject, ILSL_ScriptCommands 55 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
54 { 56 {
55 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 57 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
56 58
57 internal XEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
58 internal XScriptInstance m_Instance;
59 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
60 internal uint m_localID; 61 internal uint m_localID;
61 internal LLUUID m_itemID; 62 internal LLUUID m_itemID;
62 internal bool throwErrorOnNotImplemented = true; 63 internal bool throwErrorOnNotImplemented = true;
64 internal static AsyncCommandManager AsyncCommands = null;
63 65
64 public LSL_ScriptCommands(XEngine ScriptEngine, XScriptInstance instance, SceneObjectPart host, uint localID, LLUUID itemID) 66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
65 { 67 {
66 m_ScriptEngine = ScriptEngine; 68 m_ScriptEngine = ScriptEngine;
67 m_Instance = instance;
68 m_host = host; 69 m_host = host;
69 m_localID = localID; 70 m_localID = localID;
70 m_itemID = itemID; 71 m_itemID = itemID;
71 72
72 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); 73 AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands;
73 } 74 }
74 75
75 private DateTime m_timer = DateTime.Now; 76 private DateTime m_timer = DateTime.Now;
76 private string m_state = "default";
77 private bool m_waitingForScriptAnswer=false; 77 private bool m_waitingForScriptAnswer=false;
78 78
79 79
80 public string State
81 {
82 get { return m_Instance.State; }
83 set { m_Instance.State = value; }
84 }
85
86 public void state(string newState)
87 {
88 m_Instance.SetState(newState);
89 }
90
91 // Object never expires 80 // Object never expires
92 public override Object InitializeLifetimeService() 81 public override Object InitializeLifetimeService()
93 { 82 {
94 //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()");
95 // return null;
96 ILease lease = (ILease)base.InitializeLifetimeService(); 83 ILease lease = (ILease)base.InitializeLifetimeService();
97 84
98 if (lease.CurrentState == LeaseState.Initial) 85 if (lease.CurrentState == LeaseState.Initial)
99 { 86 {
100 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); 87 lease.InitialLeaseTime = TimeSpan.Zero;
101 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
102 // lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
103 } 88 }
104 return lease; 89 return lease;
105 } 90 }
@@ -109,6 +94,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
109 get { return m_ScriptEngine.World; } 94 get { return m_ScriptEngine.World; }
110 } 95 }
111 96
97 public void state(string newState)
98 {
99 m_ScriptEngine.SetState(m_itemID, newState);
100 }
101
112 public void llSay(int channelID, string text) 102 public void llSay(int channelID, string text)
113 { 103 {
114 m_host.AddScriptLPS(1); 104 m_host.AddScriptLPS(1);
@@ -501,7 +491,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
501 LLUUID keyID = LLUUID.Zero; 491 LLUUID keyID = LLUUID.Zero;
502 LLUUID.TryParse(id, out keyID); 492 LLUUID.TryParse(id, out keyID);
503 493
504 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 494 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host);
505 } 495 }
506 496
507 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 497 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -510,13 +500,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
510 LLUUID keyID = LLUUID.Zero; 500 LLUUID keyID = LLUUID.Zero;
511 LLUUID.TryParse(id, out keyID); 501 LLUUID.TryParse(id, out keyID);
512 502
513 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 503 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host);
514 } 504 }
515 505
516 public void llSensorRemove() 506 public void llSensorRemove()
517 { 507 {
518 m_host.AddScriptLPS(1); 508 m_host.AddScriptLPS(1);
519 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.UnSetSenseRepeaterEvents(m_localID, m_itemID); 509 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID);
520 } 510 }
521 511
522 public string resolveName(LLUUID objecUUID) 512 public string resolveName(LLUUID objecUUID)
@@ -550,7 +540,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
550 public string llDetectedName(int number) 540 public string llDetectedName(int number)
551 { 541 {
552 m_host.AddScriptLPS(1); 542 m_host.AddScriptLPS(1);
553 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 543 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
554 if (d == null) 544 if (d == null)
555 return String.Empty; 545 return String.Empty;
556 return d.Name; 546 return d.Name;
@@ -559,7 +549,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
559 public string llDetectedKey(int number) 549 public string llDetectedKey(int number)
560 { 550 {
561 m_host.AddScriptLPS(1); 551 m_host.AddScriptLPS(1);
562 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 552 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
563 if (d == null) 553 if (d == null)
564 return String.Empty; 554 return String.Empty;
565 return d.Key.ToString(); 555 return d.Key.ToString();
@@ -568,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
568 public string llDetectedOwner(int number) 558 public string llDetectedOwner(int number)
569 { 559 {
570 m_host.AddScriptLPS(1); 560 m_host.AddScriptLPS(1);
571 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 561 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
572 if (d == null) 562 if (d == null)
573 return String.Empty; 563 return String.Empty;
574 return d.Owner.ToString(); 564 return d.Owner.ToString();
@@ -577,7 +567,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
577 public LSL_Types.LSLInteger llDetectedType(int number) 567 public LSL_Types.LSLInteger llDetectedType(int number)
578 { 568 {
579 m_host.AddScriptLPS(1); 569 m_host.AddScriptLPS(1);
580 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 570 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
581 if (d == null) 571 if (d == null)
582 return 0; 572 return 0;
583 return new LSL_Types.LSLInteger(d.Type); 573 return new LSL_Types.LSLInteger(d.Type);
@@ -586,7 +576,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
586 public LSL_Types.Vector3 llDetectedPos(int number) 576 public LSL_Types.Vector3 llDetectedPos(int number)
587 { 577 {
588 m_host.AddScriptLPS(1); 578 m_host.AddScriptLPS(1);
589 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 579 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
590 if (d == null) 580 if (d == null)
591 return new LSL_Types.Vector3(); 581 return new LSL_Types.Vector3();
592 return d.Position; 582 return d.Position;
@@ -595,7 +585,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
595 public LSL_Types.Vector3 llDetectedVel(int number) 585 public LSL_Types.Vector3 llDetectedVel(int number)
596 { 586 {
597 m_host.AddScriptLPS(1); 587 m_host.AddScriptLPS(1);
598 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 588 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
599 if (d == null) 589 if (d == null)
600 return new LSL_Types.Vector3(); 590 return new LSL_Types.Vector3();
601 return d.Velocity; 591 return d.Velocity;
@@ -604,7 +594,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
604 public LSL_Types.Vector3 llDetectedGrab(int number) 594 public LSL_Types.Vector3 llDetectedGrab(int number)
605 { 595 {
606 m_host.AddScriptLPS(1); 596 m_host.AddScriptLPS(1);
607 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 597 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
608 if (parms == null) 598 if (parms == null)
609 return new LSL_Types.Vector3(0, 0, 0); 599 return new LSL_Types.Vector3(0, 0, 0);
610 600
@@ -614,7 +604,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
614 public LSL_Types.Quaternion llDetectedRot(int number) 604 public LSL_Types.Quaternion llDetectedRot(int number)
615 { 605 {
616 m_host.AddScriptLPS(1); 606 m_host.AddScriptLPS(1);
617 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 607 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
618 if (d == null) 608 if (d == null)
619 return new LSL_Types.Quaternion(); 609 return new LSL_Types.Quaternion();
620 return d.Rotation; 610 return d.Rotation;
@@ -623,7 +613,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
623 public LSL_Types.LSLInteger llDetectedGroup(int number) 613 public LSL_Types.LSLInteger llDetectedGroup(int number)
624 { 614 {
625 m_host.AddScriptLPS(1); 615 m_host.AddScriptLPS(1);
626 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); 616 DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
627 if (d == null) 617 if (d == null)
628 return new LSL_Types.LSLInteger(0); 618 return new LSL_Types.LSLInteger(0);
629 if (m_host.GroupID == d.Group) 619 if (m_host.GroupID == d.Group)
@@ -634,7 +624,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
634 public LSL_Types.LSLInteger llDetectedLinkNumber(int number) 624 public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
635 { 625 {
636 m_host.AddScriptLPS(1); 626 m_host.AddScriptLPS(1);
637 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 627 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
638 if (parms == null) 628 if (parms == null)
639 return new LSL_Types.LSLInteger(0); 629 return new LSL_Types.LSLInteger(0);
640 630
@@ -675,7 +665,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
675 665
676 int statusrotationaxis = 0; 666 int statusrotationaxis = 0;
677 667
678 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS) 668 if ((status & ScriptBaseClass.STATUS_PHYSICS) == ScriptBaseClass.STATUS_PHYSICS)
679 { 669 {
680 if (value == 1) 670 if (value == 1)
681 m_host.ScriptSetPhysicsStatus(true); 671 m_host.ScriptSetPhysicsStatus(true);
@@ -683,7 +673,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
683 m_host.ScriptSetPhysicsStatus(false); 673 m_host.ScriptSetPhysicsStatus(false);
684 } 674 }
685 675
686 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM) 676 if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM)
687 { 677 {
688 if (value == 1) 678 if (value == 1)
689 m_host.ScriptSetPhantomStatus(true); 679 m_host.ScriptSetPhantomStatus(true);
@@ -691,32 +681,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine
691 m_host.ScriptSetPhantomStatus(false); 681 m_host.ScriptSetPhantomStatus(false);
692 } 682 }
693 683
694 if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) 684 if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS)
695 { 685 {
696 m_host.AddFlag(LLObject.ObjectFlags.CastShadows); 686 m_host.AddFlag(LLObject.ObjectFlags.CastShadows);
697 } 687 }
698 688
699 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) 689 if ((status & ScriptBaseClass.STATUS_ROTATE_X) == ScriptBaseClass.STATUS_ROTATE_X)
700 { 690 {
701 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_X; 691 statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_X;
702 } 692 }
703 693
704 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) 694 if ((status & ScriptBaseClass.STATUS_ROTATE_Y) == ScriptBaseClass.STATUS_ROTATE_Y)
705 { 695 {
706 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y; 696 statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_Y;
707 } 697 }
708 698
709 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) 699 if ((status & ScriptBaseClass.STATUS_ROTATE_Z) == ScriptBaseClass.STATUS_ROTATE_Z)
710 { 700 {
711 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z; 701 statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_Z;
712 } 702 }
713 703
714 if ((status & BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) == BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) 704 if ((status & ScriptBaseClass.STATUS_BLOCK_GRAB) == ScriptBaseClass.STATUS_BLOCK_GRAB)
715 { 705 {
716 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB"); 706 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB");
717 } 707 }
718 708
719 if ((status & BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) 709 if ((status & ScriptBaseClass.STATUS_DIE_AT_EDGE) == ScriptBaseClass.STATUS_DIE_AT_EDGE)
720 { 710 {
721 if (value == 1) 711 if (value == 1)
722 m_host.SetDieAtEdge(true); 712 m_host.SetDieAtEdge(true);
@@ -724,12 +714,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
724 m_host.SetDieAtEdge(false); 714 m_host.SetDieAtEdge(false);
725 } 715 }
726 716
727 if ((status & BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) 717 if ((status & ScriptBaseClass.STATUS_RETURN_AT_EDGE) == ScriptBaseClass.STATUS_RETURN_AT_EDGE)
728 { 718 {
729 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE"); 719 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE");
730 } 720 }
731 721
732 if ((status & BuiltIn_Commands_BaseClass.STATUS_SANDBOX) == BuiltIn_Commands_BaseClass.STATUS_SANDBOX) 722 if ((status & ScriptBaseClass.STATUS_SANDBOX) == ScriptBaseClass.STATUS_SANDBOX)
733 { 723 {
734 NotImplemented("llSetStatus - STATUS_SANDBOX"); 724 NotImplemented("llSetStatus - STATUS_SANDBOX");
735 } 725 }
@@ -746,54 +736,54 @@ namespace OpenSim.Region.ScriptEngine.XEngine
746 // Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString()); 736 // Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString());
747 switch (status) 737 switch (status)
748 { 738 {
749 case BuiltIn_Commands_BaseClass.STATUS_PHYSICS: 739 case ScriptBaseClass.STATUS_PHYSICS:
750 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics) 740 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics)
751 { 741 {
752 return 1; 742 return 1;
753 } 743 }
754 return 0; 744 return 0;
755 745
756 case BuiltIn_Commands_BaseClass.STATUS_PHANTOM: 746 case ScriptBaseClass.STATUS_PHANTOM:
757 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom) 747 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
758 { 748 {
759 return 1; 749 return 1;
760 } 750 }
761 return 0; 751 return 0;
762 752
763 case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS: 753 case ScriptBaseClass.STATUS_CAST_SHADOWS:
764 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows) 754 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
765 { 755 {
766 return 1; 756 return 1;
767 } 757 }
768 return 0; 758 return 0;
769 759
770 case BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB: 760 case ScriptBaseClass.STATUS_BLOCK_GRAB:
771 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB"); 761 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB");
772 return 0; 762 return 0;
773 763
774 case BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE: 764 case ScriptBaseClass.STATUS_DIE_AT_EDGE:
775 if (m_host.GetDieAtEdge()) 765 if (m_host.GetDieAtEdge())
776 return 1; 766 return 1;
777 else 767 else
778 return 0; 768 return 0;
779 769
780 case BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE: 770 case ScriptBaseClass.STATUS_RETURN_AT_EDGE:
781 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE"); 771 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE");
782 return 0; 772 return 0;
783 773
784 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_X: 774 case ScriptBaseClass.STATUS_ROTATE_X:
785 NotImplemented("llGetStatus - STATUS_ROTATE_X"); 775 NotImplemented("llGetStatus - STATUS_ROTATE_X");
786 return 0; 776 return 0;
787 777
788 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y: 778 case ScriptBaseClass.STATUS_ROTATE_Y:
789 NotImplemented("llGetStatus - STATUS_ROTATE_Y"); 779 NotImplemented("llGetStatus - STATUS_ROTATE_Y");
790 return 0; 780 return 0;
791 781
792 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z: 782 case ScriptBaseClass.STATUS_ROTATE_Z:
793 NotImplemented("llGetStatus - STATUS_ROTATE_Z"); 783 NotImplemented("llGetStatus - STATUS_ROTATE_Z");
794 return 0; 784 return 0;
795 785
796 case BuiltIn_Commands_BaseClass.STATUS_SANDBOX: 786 case ScriptBaseClass.STATUS_SANDBOX:
797 NotImplemented("llGetStatus - STATUS_SANDBOX"); 787 NotImplemented("llGetStatus - STATUS_SANDBOX");
798 return 0; 788 return 0;
799 } 789 }
@@ -1743,7 +1733,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1743 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) 1733 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
1744 return 0; 1734 return 0;
1745 1735
1746 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) == 0) 1736 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
1747 { 1737 {
1748 LSLError("No permissions to give money"); 1738 LSLError("No permissions to give money");
1749 return 0; 1739 return 0;
@@ -1840,11 +1830,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1840 // objects rezzed with this method are die_at_edge by default. 1830 // objects rezzed with this method are die_at_edge by default.
1841 new_group.RootPart.SetDieAtEdge(true); 1831 new_group.RootPart.SetDieAtEdge(true);
1842 1832
1843 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 1833 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
1844 "object_rez", new Object[] { 1834 "object_rez", new Object[] {
1845 new LSL_Types.LSLString( 1835 new LSL_Types.LSLString(
1846 new_group.RootPart.UUID.ToString()) }, 1836 new_group.RootPart.UUID.ToString()) },
1847 new XDetectParams[0])); 1837 new DetectParams[0]));
1848 1838
1849 float groupmass = new_group.GetMass(); 1839 float groupmass = new_group.GetMass();
1850 1840
@@ -1876,7 +1866,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1876 { 1866 {
1877 m_host.AddScriptLPS(1); 1867 m_host.AddScriptLPS(1);
1878 // Setting timer repeat 1868 // Setting timer repeat
1879 m_ScriptEngine.m_ASYNCLSLCommandManager.m_Timer.SetTimerEvent(m_localID, m_itemID, sec); 1869 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec);
1880 } 1870 }
1881 1871
1882 public void llSleep(double sec) 1872 public void llSleep(double sec)
@@ -1910,7 +1900,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1910 1900
1911 if (presence != null) 1901 if (presence != null)
1912 { 1902 {
1913 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0) 1903 if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1914 { 1904 {
1915 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 1905 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
1916 1906
@@ -1937,12 +1927,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1937 1927
1938 if (presence != null) 1928 if (presence != null)
1939 { 1929 {
1940 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0) 1930 if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1941 { 1931 {
1942 // Unregister controls from Presence 1932 // Unregister controls from Presence
1943 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 1933 presence.UnRegisterControlEventsToScript(m_localID, m_itemID);
1944 // Remove Take Control permission. 1934 // Remove Take Control permission.
1945 m_host.TaskInventory[InventorySelf()].PermsMask &= ~BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS; 1935 m_host.TaskInventory[InventorySelf()].PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
1946 } 1936 }
1947 } 1937 }
1948 } 1938 }
@@ -2110,7 +2100,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2110 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) 2100 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
2111 return; 2101 return;
2112 2102
2113 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 2103 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
2114 { 2104 {
2115 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter); 2105 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
2116 2106
@@ -2137,7 +2127,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2137 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) 2127 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
2138 return; 2128 return;
2139 2129
2140 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 2130 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
2141 { 2131 {
2142 LLUUID animID = new LLUUID(); 2132 LLUUID animID = new LLUUID();
2143 2133
@@ -2212,10 +2202,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2212 m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero; 2202 m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero;
2213 m_host.TaskInventory[invItemID].PermsMask=0; 2203 m_host.TaskInventory[invItemID].PermsMask=0;
2214 2204
2215 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 2205 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2216 "run_time_permissions", new Object[] { 2206 "run_time_permissions", new Object[] {
2217 new LSL_Types.LSLInteger(0) }, 2207 new LSL_Types.LSLInteger(0) },
2218 new XDetectParams[0])); 2208 new DetectParams[0]));
2219 2209
2220 return; 2210 return;
2221 } 2211 }
@@ -2225,19 +2215,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2225 if (m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar) 2215 if (m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar)
2226 { 2216 {
2227 // When attached, certain permissions are implicit if requested from owner 2217 // When attached, certain permissions are implicit if requested from owner
2228 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS | 2218 int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS |
2229 BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION | 2219 ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
2230 BuiltIn_Commands_BaseClass.PERMISSION_ATTACH; 2220 ScriptBaseClass.PERMISSION_ATTACH;
2231 2221
2232 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 2222 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
2233 { 2223 {
2234 m_host.TaskInventory[invItemID].PermsGranter=agentID; 2224 m_host.TaskInventory[invItemID].PermsGranter=agentID;
2235 m_host.TaskInventory[invItemID].PermsMask=perm; 2225 m_host.TaskInventory[invItemID].PermsMask=perm;
2236 2226
2237 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 2227 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2238 "run_time_permissions", new Object[] { 2228 "run_time_permissions", new Object[] {
2239 new LSL_Types.LSLInteger(perm) }, 2229 new LSL_Types.LSLInteger(perm) },
2240 new XDetectParams[0])); 2230 new DetectParams[0]));
2241 2231
2242 return; 2232 return;
2243 } 2233 }
@@ -2245,18 +2235,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2245 else if (m_host.m_sitTargetAvatar == agentID) // Sitting avatar 2235 else if (m_host.m_sitTargetAvatar == agentID) // Sitting avatar
2246 { 2236 {
2247 // When agent is sitting, certain permissions are implicit if requested from sitting agent 2237 // When agent is sitting, certain permissions are implicit if requested from sitting agent
2248 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION | 2238 int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
2249 BuiltIn_Commands_BaseClass.PERMISSION_TRACK_CAMERA; 2239 ScriptBaseClass.PERMISSION_TRACK_CAMERA;
2250 2240
2251 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 2241 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
2252 { 2242 {
2253 m_host.TaskInventory[invItemID].PermsGranter=agentID; 2243 m_host.TaskInventory[invItemID].PermsGranter=agentID;
2254 m_host.TaskInventory[invItemID].PermsMask=perm; 2244 m_host.TaskInventory[invItemID].PermsMask=perm;
2255 2245
2256 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 2246 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2257 "run_time_permissions", new Object[] { 2247 "run_time_permissions", new Object[] {
2258 new LSL_Types.LSLInteger(perm) }, 2248 new LSL_Types.LSLInteger(perm) },
2259 new XDetectParams[0])); 2249 new DetectParams[0]));
2260 2250
2261 return; 2251 return;
2262 } 2252 }
@@ -2283,10 +2273,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2283 } 2273 }
2284 2274
2285 // Requested agent is not in range, refuse perms 2275 // Requested agent is not in range, refuse perms
2286 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 2276 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2287 "run_time_permissions", new Object[] { 2277 "run_time_permissions", new Object[] {
2288 new LSL_Types.LSLInteger(0) }, 2278 new LSL_Types.LSLInteger(0) },
2289 new XDetectParams[0])); 2279 new DetectParams[0]));
2290 } 2280 }
2291 2281
2292 void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer) 2282 void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer)
@@ -2303,10 +2293,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2303 m_waitingForScriptAnswer=false; 2293 m_waitingForScriptAnswer=false;
2304 2294
2305 m_host.TaskInventory[invItemID].PermsMask=answer; 2295 m_host.TaskInventory[invItemID].PermsMask=answer;
2306 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 2296 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2307 "run_time_permissions", new Object[] { 2297 "run_time_permissions", new Object[] {
2308 new LSL_Types.LSLInteger(answer) }, 2298 new LSL_Types.LSLInteger(answer) },
2309 new XDetectParams[0])); 2299 new DetectParams[0]));
2310 } 2300 }
2311 2301
2312 public string llGetPermissionsKey() 2302 public string llGetPermissionsKey()
@@ -2631,12 +2621,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2631 2621
2632 LLUUID rq = LLUUID.Random(); 2622 LLUUID rq = LLUUID.Random();
2633 2623
2634 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 2624 LLUUID tid = AsyncCommands.
2635 m_Dataserver.RegisterRequest(m_localID, 2625 DataserverPlugin.RegisterRequest(m_localID,
2636 m_itemID, rq.ToString()); 2626 m_itemID, rq.ToString());
2637 2627
2638 m_ScriptEngine.m_ASYNCLSLCommandManager. 2628 AsyncCommands.
2639 m_Dataserver.DataserverReply(rq.ToString(), reply); 2629 DataserverPlugin.DataserverReply(rq.ToString(), reply);
2640 2630
2641 return tid.ToString(); 2631 return tid.ToString();
2642 } 2632 }
@@ -2649,8 +2639,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2649 { 2639 {
2650 if (item.Type == 3 && item.Name == name) 2640 if (item.Type == 3 && item.Name == name)
2651 { 2641 {
2652 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 2642 LLUUID tid = AsyncCommands.
2653 m_Dataserver.RegisterRequest(m_localID, 2643 DataserverPlugin.RegisterRequest(m_localID,
2654 m_itemID, item.AssetID.ToString()); 2644 m_itemID, item.AssetID.ToString());
2655 2645
2656 LLVector3 region = new LLVector3( 2646 LLVector3 region = new LLVector3(
@@ -2667,8 +2657,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2667 2657
2668 string reply = region.ToString(); 2658 string reply = region.ToString();
2669 2659
2670 m_ScriptEngine.m_ASYNCLSLCommandManager. 2660 AsyncCommands.
2671 m_Dataserver.DataserverReply(i.ToString(), 2661 DataserverPlugin.DataserverReply(i.ToString(),
2672 reply); 2662 reply);
2673 }, false); 2663 }, false);
2674 2664
@@ -2733,7 +2723,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2733 switch ((int)linknum) 2723 switch ((int)linknum)
2734 { 2724 {
2735 2725
2736 case (int)BuiltIn_Commands_BaseClass.LINK_ROOT: 2726 case (int)ScriptBaseClass.LINK_ROOT:
2737 2727
2738 SceneObjectPart part = m_host.ParentGroup.RootPart; 2728 SceneObjectPart part = m_host.ParentGroup.RootPart;
2739 2729
@@ -2750,14 +2740,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2750 }; 2740 };
2751 2741
2752 m_ScriptEngine.PostScriptEvent(partItemID, 2742 m_ScriptEngine.PostScriptEvent(partItemID,
2753 new XEventParams("link_message", 2743 new EventParams("link_message",
2754 resobj, new XDetectParams[0])); 2744 resobj, new DetectParams[0]));
2755 } 2745 }
2756 } 2746 }
2757 2747
2758 break; 2748 break;
2759 2749
2760 case (int)BuiltIn_Commands_BaseClass.LINK_SET: 2750 case (int)ScriptBaseClass.LINK_SET:
2761 2751
2762 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) 2752 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2763 { 2753 {
@@ -2774,15 +2764,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2774 }; 2764 };
2775 2765
2776 m_ScriptEngine.PostScriptEvent(partItemID, 2766 m_ScriptEngine.PostScriptEvent(partItemID,
2777 new XEventParams("link_message", 2767 new EventParams("link_message",
2778 resobj, new XDetectParams[0])); 2768 resobj, new DetectParams[0]));
2779 } 2769 }
2780 } 2770 }
2781 } 2771 }
2782 2772
2783 break; 2773 break;
2784 2774
2785 case (int)BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS: 2775 case (int)ScriptBaseClass.LINK_ALL_OTHERS:
2786 2776
2787 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) 2777 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2788 { 2778 {
@@ -2802,8 +2792,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2802 }; 2792 };
2803 2793
2804 m_ScriptEngine.PostScriptEvent(partItemID, 2794 m_ScriptEngine.PostScriptEvent(partItemID,
2805 new XEventParams("link_message", 2795 new EventParams("link_message",
2806 resobj, new XDetectParams[0])); 2796 resobj, new DetectParams[0]));
2807 } 2797 }
2808 } 2798 }
2809 2799
@@ -2812,7 +2802,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2812 2802
2813 break; 2803 break;
2814 2804
2815 case (int)BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN: 2805 case (int)ScriptBaseClass.LINK_ALL_CHILDREN:
2816 2806
2817 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) 2807 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2818 { 2808 {
@@ -2832,8 +2822,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2832 }; 2822 };
2833 2823
2834 m_ScriptEngine.PostScriptEvent(partItemID, 2824 m_ScriptEngine.PostScriptEvent(partItemID,
2835 new XEventParams("link_message", 2825 new EventParams("link_message",
2836 resobj, new XDetectParams[0])); 2826 resobj, new DetectParams[0]));
2837 } 2827 }
2838 } 2828 }
2839 2829
@@ -2842,7 +2832,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2842 2832
2843 break; 2833 break;
2844 2834
2845 case (int)BuiltIn_Commands_BaseClass.LINK_THIS: 2835 case (int)ScriptBaseClass.LINK_THIS:
2846 2836
2847 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 2837 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2848 { 2838 {
@@ -2856,8 +2846,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2856 }; 2846 };
2857 2847
2858 m_ScriptEngine.PostScriptEvent(partItemID, 2848 m_ScriptEngine.PostScriptEvent(partItemID,
2859 new XEventParams("link_message", 2849 new EventParams("link_message",
2860 resobj, new XDetectParams[0])); 2850 resobj, new DetectParams[0]));
2861 } 2851 }
2862 } 2852 }
2863 2853
@@ -2883,8 +2873,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2883 }; 2873 };
2884 2874
2885 m_ScriptEngine.PostScriptEvent(partItemID, 2875 m_ScriptEngine.PostScriptEvent(partItemID,
2886 new XEventParams("link_message", 2876 new EventParams("link_message",
2887 resObjDef, new XDetectParams[0])); 2877 resObjDef, new DetectParams[0]));
2888 } 2878 }
2889 } 2879 }
2890 2880
@@ -4061,23 +4051,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4061 { 4051 {
4062 switch ((int)rules.Data[i]) 4052 switch ((int)rules.Data[i])
4063 { 4053 {
4064 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_FLAGS: 4054 case (int)ScriptBaseClass.PSYS_PART_FLAGS:
4065 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); 4055 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString()));
4066 break; 4056 break;
4067 4057
4068 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_COLOR: 4058 case (int)ScriptBaseClass.PSYS_PART_START_COLOR:
4069 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4059 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4070 prules.PartStartColor.R = (float)tempv.x; 4060 prules.PartStartColor.R = (float)tempv.x;
4071 prules.PartStartColor.G = (float)tempv.y; 4061 prules.PartStartColor.G = (float)tempv.y;
4072 prules.PartStartColor.B = (float)tempv.z; 4062 prules.PartStartColor.B = (float)tempv.z;
4073 break; 4063 break;
4074 4064
4075 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_ALPHA: 4065 case (int)ScriptBaseClass.PSYS_PART_START_ALPHA:
4076 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4066 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4077 prules.PartStartColor.A = (float)tempf; 4067 prules.PartStartColor.A = (float)tempf;
4078 break; 4068 break;
4079 4069
4080 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_COLOR: 4070 case (int)ScriptBaseClass.PSYS_PART_END_COLOR:
4081 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4071 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4082 //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1); 4072 //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1);
4083 4073
@@ -4086,36 +4076,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4086 prules.PartEndColor.B = (float)tempv.z; 4076 prules.PartEndColor.B = (float)tempv.z;
4087 break; 4077 break;
4088 4078
4089 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_ALPHA: 4079 case (int)ScriptBaseClass.PSYS_PART_END_ALPHA:
4090 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4080 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4091 prules.PartEndColor.A = (float)tempf; 4081 prules.PartEndColor.A = (float)tempf;
4092 break; 4082 break;
4093 4083
4094 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_SCALE: 4084 case (int)ScriptBaseClass.PSYS_PART_START_SCALE:
4095 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4085 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4096 prules.PartStartScaleX = (float)tempv.x; 4086 prules.PartStartScaleX = (float)tempv.x;
4097 prules.PartStartScaleY = (float)tempv.y; 4087 prules.PartStartScaleY = (float)tempv.y;
4098 break; 4088 break;
4099 4089
4100 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_SCALE: 4090 case (int)ScriptBaseClass.PSYS_PART_END_SCALE:
4101 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4091 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4102 prules.PartEndScaleX = (float)tempv.x; 4092 prules.PartEndScaleX = (float)tempv.x;
4103 prules.PartEndScaleY = (float)tempv.y; 4093 prules.PartEndScaleY = (float)tempv.y;
4104 break; 4094 break;
4105 4095
4106 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_MAX_AGE: 4096 case (int)ScriptBaseClass.PSYS_PART_MAX_AGE:
4107 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4097 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4108 prules.PartMaxAge = (float)tempf; 4098 prules.PartMaxAge = (float)tempf;
4109 break; 4099 break;
4110 4100
4111 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ACCEL: 4101 case (int)ScriptBaseClass.PSYS_SRC_ACCEL:
4112 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4102 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4113 prules.PartAcceleration.X = (float)tempv.x; 4103 prules.PartAcceleration.X = (float)tempv.x;
4114 prules.PartAcceleration.Y = (float)tempv.y; 4104 prules.PartAcceleration.Y = (float)tempv.y;
4115 prules.PartAcceleration.Z = (float)tempv.z; 4105 prules.PartAcceleration.Z = (float)tempv.z;
4116 break; 4106 break;
4117 4107
4118 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_PATTERN: 4108 case (int)ScriptBaseClass.PSYS_SRC_PATTERN:
4119 int tmpi = int.Parse(rules.Data[i + 1].ToString()); 4109 int tmpi = int.Parse(rules.Data[i + 1].ToString());
4120 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; 4110 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
4121 break; 4111 break;
@@ -4124,40 +4114,40 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4124 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture 4114 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture
4125 // "" = default texture. 4115 // "" = default texture.
4126 // 20080530 Updated to remove code duplication 4116 // 20080530 Updated to remove code duplication
4127 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TEXTURE: 4117 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
4128 prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); 4118 prules.Texture = KeyOrName(rules.Data[i + 1].ToString());
4129 break; 4119 break;
4130 4120
4131 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RATE: 4121 case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE:
4132 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4122 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4133 prules.BurstRate = (float)tempf; 4123 prules.BurstRate = (float)tempf;
4134 break; 4124 break;
4135 4125
4136 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_PART_COUNT: 4126 case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT:
4137 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); 4127 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString());
4138 break; 4128 break;
4139 4129
4140 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RADIUS: 4130 case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS:
4141 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4131 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4142 prules.BurstRadius = (float)tempf; 4132 prules.BurstRadius = (float)tempf;
4143 break; 4133 break;
4144 4134
4145 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MIN: 4135 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN:
4146 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4136 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4147 prules.BurstSpeedMin = (float)tempf; 4137 prules.BurstSpeedMin = (float)tempf;
4148 break; 4138 break;
4149 4139
4150 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MAX: 4140 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX:
4151 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4141 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4152 prules.BurstSpeedMax = (float)tempf; 4142 prules.BurstSpeedMax = (float)tempf;
4153 break; 4143 break;
4154 4144
4155 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_MAX_AGE: 4145 case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE:
4156 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4146 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4157 prules.MaxAge = (float)tempf; 4147 prules.MaxAge = (float)tempf;
4158 break; 4148 break;
4159 4149
4160 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TARGET_KEY: 4150 case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY:
4161 LLUUID key = LLUUID.Zero; 4151 LLUUID key = LLUUID.Zero;
4162 if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key)) 4152 if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key))
4163 { 4153 {
@@ -4169,7 +4159,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4169 } 4159 }
4170 break; 4160 break;
4171 4161
4172 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_OMEGA: 4162 case (int)ScriptBaseClass.PSYS_SRC_OMEGA:
4173 // AL: This is an assumption, since it is the only thing that would match. 4163 // AL: This is an assumption, since it is the only thing that would match.
4174 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4164 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4175 prules.AngularVelocity.X = (float)tempv.x; 4165 prules.AngularVelocity.X = (float)tempv.x;
@@ -4178,12 +4168,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4178 //cast?? prules.MaxAge = (float)rules[i + 1]; 4168 //cast?? prules.MaxAge = (float)rules[i + 1];
4179 break; 4169 break;
4180 4170
4181 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_BEGIN: 4171 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN:
4182 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4172 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4183 prules.InnerAngle = (float)tempf; 4173 prules.InnerAngle = (float)tempf;
4184 break; 4174 break;
4185 4175
4186 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_END: 4176 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END:
4187 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4177 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4188 prules.OuterAngle = (float)tempf; 4178 prules.OuterAngle = (float)tempf;
4189 break; 4179 break;
@@ -4444,9 +4434,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
4444 { 4434 {
4445 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, LLUUID.Zero); 4435 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, LLUUID.Zero);
4446 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(LLUUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) }; 4436 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(LLUUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
4447 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams( 4437 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
4448 "remote_data", resobj, 4438 "remote_data", resobj,
4449 new XDetectParams[0])); 4439 new DetectParams[0]));
4450 } 4440 }
4451 } 4441 }
4452 4442
@@ -5472,27 +5462,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5472 5462
5473 int permmask = 0; 5463 int permmask = 0;
5474 5464
5475 if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0 5465 if (mask == ScriptBaseClass.MASK_BASE)//0
5476 { 5466 {
5477 permmask = (int)m_host.BaseMask; 5467 permmask = (int)m_host.BaseMask;
5478 } 5468 }
5479 5469
5480 else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1 5470 else if (mask == ScriptBaseClass.MASK_OWNER)//1
5481 { 5471 {
5482 permmask = (int)m_host.OwnerMask; 5472 permmask = (int)m_host.OwnerMask;
5483 } 5473 }
5484 5474
5485 else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2 5475 else if (mask == ScriptBaseClass.MASK_GROUP)//2
5486 { 5476 {
5487 permmask = (int)m_host.GroupMask; 5477 permmask = (int)m_host.GroupMask;
5488 } 5478 }
5489 5479
5490 else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3 5480 else if (mask == ScriptBaseClass.MASK_EVERYONE)//3
5491 { 5481 {
5492 permmask = (int)m_host.EveryoneMask; 5482 permmask = (int)m_host.EveryoneMask;
5493 } 5483 }
5494 5484
5495 else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4 5485 else if (mask == ScriptBaseClass.MASK_NEXT)//4
5496 { 5486 {
5497 permmask = (int)m_host.NextOwnerMask; 5487 permmask = (int)m_host.NextOwnerMask;
5498 } 5488 }
@@ -5511,27 +5501,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5511 { 5501 {
5512 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) 5502 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
5513 { 5503 {
5514 if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0 5504 if (mask == ScriptBaseClass.MASK_BASE)//0
5515 { 5505 {
5516 m_host.BaseMask = (uint)value; 5506 m_host.BaseMask = (uint)value;
5517 } 5507 }
5518 5508
5519 else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1 5509 else if (mask == ScriptBaseClass.MASK_OWNER)//1
5520 { 5510 {
5521 m_host.OwnerMask = (uint)value; 5511 m_host.OwnerMask = (uint)value;
5522 } 5512 }
5523 5513
5524 else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2 5514 else if (mask == ScriptBaseClass.MASK_GROUP)//2
5525 { 5515 {
5526 m_host.GroupMask = (uint)value; 5516 m_host.GroupMask = (uint)value;
5527 } 5517 }
5528 5518
5529 else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3 5519 else if (mask == ScriptBaseClass.MASK_EVERYONE)//3
5530 { 5520 {
5531 m_host.EveryoneMask = (uint)value; 5521 m_host.EveryoneMask = (uint)value;
5532 } 5522 }
5533 5523
5534 else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4 5524 else if (mask == ScriptBaseClass.MASK_NEXT)//4
5535 { 5525 {
5536 m_host.NextOwnerMask = (uint)value; 5526 m_host.NextOwnerMask = (uint)value;
5537 } 5527 }
@@ -5635,12 +5625,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5635 } 5625 }
5636 LLUUID rq = LLUUID.Random(); 5626 LLUUID rq = LLUUID.Random();
5637 5627
5638 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 5628 LLUUID tid = AsyncCommands.
5639 m_Dataserver.RegisterRequest(m_localID, 5629 DataserverPlugin.RegisterRequest(m_localID,
5640 m_itemID, rq.ToString()); 5630 m_itemID, rq.ToString());
5641 5631
5642 m_ScriptEngine.m_ASYNCLSLCommandManager. 5632 AsyncCommands.
5643 m_Dataserver.DataserverReply(rq.ToString(), reply); 5633 DataserverPlugin.DataserverReply(rq.ToString(), reply);
5644 5634
5645 return tid.ToString(); 5635 return tid.ToString();
5646 } 5636 }
@@ -5943,27 +5933,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5943 LSL_Types.list nums = LSL_Types.list.ToDoubleList(src); 5933 LSL_Types.list nums = LSL_Types.list.ToDoubleList(src);
5944 switch (operation) 5934 switch (operation)
5945 { 5935 {
5946 case BuiltIn_Commands_BaseClass.LIST_STAT_RANGE: 5936 case ScriptBaseClass.LIST_STAT_RANGE:
5947 return nums.Range(); 5937 return nums.Range();
5948 case BuiltIn_Commands_BaseClass.LIST_STAT_MIN: 5938 case ScriptBaseClass.LIST_STAT_MIN:
5949 return nums.Min(); 5939 return nums.Min();
5950 case BuiltIn_Commands_BaseClass.LIST_STAT_MAX: 5940 case ScriptBaseClass.LIST_STAT_MAX:
5951 return nums.Max(); 5941 return nums.Max();
5952 case BuiltIn_Commands_BaseClass.LIST_STAT_MEAN: 5942 case ScriptBaseClass.LIST_STAT_MEAN:
5953 return nums.Mean(); 5943 return nums.Mean();
5954 case BuiltIn_Commands_BaseClass.LIST_STAT_MEDIAN: 5944 case ScriptBaseClass.LIST_STAT_MEDIAN:
5955 return nums.Median(); 5945 return nums.Median();
5956 case BuiltIn_Commands_BaseClass.LIST_STAT_NUM_COUNT: 5946 case ScriptBaseClass.LIST_STAT_NUM_COUNT:
5957 return nums.NumericLength(); 5947 return nums.NumericLength();
5958 case BuiltIn_Commands_BaseClass.LIST_STAT_STD_DEV: 5948 case ScriptBaseClass.LIST_STAT_STD_DEV:
5959 return nums.StdDev(); 5949 return nums.StdDev();
5960 case BuiltIn_Commands_BaseClass.LIST_STAT_SUM: 5950 case ScriptBaseClass.LIST_STAT_SUM:
5961 return nums.Sum(); 5951 return nums.Sum();
5962 case BuiltIn_Commands_BaseClass.LIST_STAT_SUM_SQUARES: 5952 case ScriptBaseClass.LIST_STAT_SUM_SQUARES:
5963 return nums.SumSqrs(); 5953 return nums.SumSqrs();
5964 case BuiltIn_Commands_BaseClass.LIST_STAT_GEOMETRIC_MEAN: 5954 case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN:
5965 return nums.GeometricMean(); 5955 return nums.GeometricMean();
5966 case BuiltIn_Commands_BaseClass.LIST_STAT_HARMONIC_MEAN: 5956 case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN:
5967 return nums.HarmonicMean(); 5957 return nums.HarmonicMean();
5968 default: 5958 default:
5969 return 0.0; 5959 return 0.0;
@@ -6230,9 +6220,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6230 public string llStringTrim(string src, int type) 6220 public string llStringTrim(string src, int type)
6231 { 6221 {
6232 m_host.AddScriptLPS(1); 6222 m_host.AddScriptLPS(1);
6233 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); } 6223 if (type == (int)ScriptBaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); }
6234 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); } 6224 if (type == (int)ScriptBaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); }
6235 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM) { return src.Trim(); } 6225 if (type == (int)ScriptBaseClass.STRING_TRIM) { return src.Trim(); }
6236 return src; 6226 return src;
6237 } 6227 }
6238 6228
@@ -6331,7 +6321,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6331 6321
6332 internal void ShoutError(string msg) 6322 internal void ShoutError(string msg)
6333 { 6323 {
6334 llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL, msg); 6324 llShout(ScriptBaseClass.DEBUG_CHANNEL, msg);
6335 } 6325 }
6336 6326
6337 6327
@@ -6366,13 +6356,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6366 { 6356 {
6367 if (item.Type == 7 && item.Name == name) 6357 if (item.Type == 7 && item.Name == name)
6368 { 6358 {
6369 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 6359 LLUUID tid = AsyncCommands.
6370 m_Dataserver.RegisterRequest(m_localID, 6360 DataserverPlugin.RegisterRequest(m_localID,
6371 m_itemID, item.AssetID.ToString()); 6361 m_itemID, item.AssetID.ToString());
6372 if (NotecardCache.IsCached(item.AssetID)) 6362 if (NotecardCache.IsCached(item.AssetID))
6373 { 6363 {
6374 m_ScriptEngine.m_ASYNCLSLCommandManager. 6364 AsyncCommands.
6375 m_Dataserver.DataserverReply(item.AssetID.ToString(), 6365 DataserverPlugin.DataserverReply(item.AssetID.ToString(),
6376 NotecardCache.GetLines(item.AssetID).ToString()); 6366 NotecardCache.GetLines(item.AssetID).ToString());
6377 return tid.ToString(); 6367 return tid.ToString();
6378 } 6368 }
@@ -6383,8 +6373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6383 string data = enc.GetString(a.Data); 6373 string data = enc.GetString(a.Data);
6384 //Console.WriteLine(data); 6374 //Console.WriteLine(data);
6385 NotecardCache.Cache(id, data); 6375 NotecardCache.Cache(id, data);
6386 m_ScriptEngine.m_ASYNCLSLCommandManager. 6376 AsyncCommands.
6387 m_Dataserver.DataserverReply(id.ToString(), 6377 DataserverPlugin.DataserverReply(id.ToString(),
6388 NotecardCache.GetLines(id).ToString()); 6378 NotecardCache.GetLines(id).ToString());
6389 }); 6379 });
6390 6380
@@ -6402,13 +6392,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6402 { 6392 {
6403 if (item.Type == 7 && item.Name == name) 6393 if (item.Type == 7 && item.Name == name)
6404 { 6394 {
6405 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 6395 LLUUID tid = AsyncCommands.
6406 m_Dataserver.RegisterRequest(m_localID, 6396 DataserverPlugin.RegisterRequest(m_localID,
6407 m_itemID, item.AssetID.ToString()); 6397 m_itemID, item.AssetID.ToString());
6408 if (NotecardCache.IsCached(item.AssetID)) 6398 if (NotecardCache.IsCached(item.AssetID))
6409 { 6399 {
6410 m_ScriptEngine.m_ASYNCLSLCommandManager. 6400 AsyncCommands.
6411 m_Dataserver.DataserverReply(item.AssetID.ToString(), 6401 DataserverPlugin.DataserverReply(item.AssetID.ToString(),
6412 NotecardCache.GetLine(item.AssetID, line)); 6402 NotecardCache.GetLine(item.AssetID, line));
6413 return tid.ToString(); 6403 return tid.ToString();
6414 } 6404 }
@@ -6419,8 +6409,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6419 string data = enc.GetString(a.Data); 6409 string data = enc.GetString(a.Data);
6420 //Console.WriteLine(data); 6410 //Console.WriteLine(data);
6421 NotecardCache.Cache(id, data); 6411 NotecardCache.Cache(id, data);
6422 m_ScriptEngine.m_ASYNCLSLCommandManager. 6412 AsyncCommands.
6423 m_Dataserver.DataserverReply(id.ToString(), 6413 DataserverPlugin.DataserverReply(id.ToString(),
6424 NotecardCache.GetLine(id, line)); 6414 NotecardCache.GetLine(id, line));
6425 }); 6415 });
6426 6416
diff --git a/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index bc4e8ba..dbb78a4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -31,25 +31,25 @@ using Nini.Config;
31using OpenSim.Framework.Console; 31using OpenSim.Framework.Console;
32using OpenSim.Region.Environment.Interfaces; 32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.XEngine.Script; 34using OpenSim.Region.ScriptEngine.Shared;
35using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
36using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
35 39
36namespace OpenSim.Region.ScriptEngine.XEngine 40namespace OpenSim.Region.ScriptEngine.Shared.Api
37{ 41{
38 [Serializable] 42 [Serializable]
39 public class OSSL_ScriptCommands : MarshalByRefObject, IOSSL_ScriptCommands 43 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
40 { 44 {
41 internal XEngine m_ScriptEngine; 45 internal IScriptEngine m_ScriptEngine;
42 internal XScriptInstance m_Instance;
43 internal SceneObjectPart m_host; 46 internal SceneObjectPart m_host;
44 internal uint m_localID; 47 internal uint m_localID;
45 internal LLUUID m_itemID; 48 internal LLUUID m_itemID;
46 49
47 public OSSL_ScriptCommands(XEngine scriptEngine, 50 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
48 XScriptInstance instance, SceneObjectPart host,
49 uint localID, LLUUID itemID)
50 { 51 {
51 m_ScriptEngine = scriptEngine; 52 m_ScriptEngine = ScriptEngine;
52 m_Instance = instance;
53 m_host = host; 53 m_host = host;
54 m_localID = localID; 54 m_localID = localID;
55 m_itemID = itemID; 55 m_itemID = itemID;
@@ -62,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
62 62
63 public int osTerrainSetHeight(int x, int y, double val) 63 public int osTerrainSetHeight(int x, int y, double val)
64 { 64 {
65 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 65 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
66 { 66 {
67 OSSLError("osTerrainSetHeight: permission denied"); 67 OSSLError("osTerrainSetHeight: permission denied");
68 return 0; 68 return 0;
@@ -85,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
85 85
86 public double osTerrainGetHeight(int x, int y) 86 public double osTerrainGetHeight(int x, int y)
87 { 87 {
88 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 88 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
89 { 89 {
90 OSSLError("osTerrainGetHeight: permission denied"); 90 OSSLError("osTerrainGetHeight: permission denied");
91 return 0.0; 91 return 0.0;
@@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
100 100
101 public int osRegionRestart(double seconds) 101 public int osRegionRestart(double seconds)
102 { 102 {
103 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 103 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
104 { 104 {
105 OSSLError("osRegionRestart: permission denied"); 105 OSSLError("osRegionRestart: permission denied");
106 return 0; 106 return 0;
@@ -120,7 +120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
120 120
121 public void osRegionNotice(string msg) 121 public void osRegionNotice(string msg)
122 { 122 {
123 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 123 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
124 { 124 {
125 OSSLError("osRegionNotice: permission denied"); 125 OSSLError("osRegionNotice: permission denied");
126 return; 126 return;
@@ -132,7 +132,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
132 132
133 public void osSetRot(LLUUID target, Quaternion rotation) 133 public void osSetRot(LLUUID target, Quaternion rotation)
134 { 134 {
135 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 135 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
136 { 136 {
137 OSSLError("osSetRot: permission denied"); 137 OSSLError("osSetRot: permission denied");
138 return; 138 return;
@@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
152 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, 152 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
153 int timer) 153 int timer)
154 { 154 {
155 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 155 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
156 { 156 {
157 OSSLError("osSetDynamicTextureURL: permission denied"); 157 OSSLError("osSetDynamicTextureURL: permission denied");
158 return String.Empty; 158 return String.Empty;
@@ -178,7 +178,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
178 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, 178 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
179 int timer, int alpha) 179 int timer, int alpha)
180 { 180 {
181 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 181 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
182 { 182 {
183 OSSLError("osSetDynamicTextureURLBlend: permission denied"); 183 OSSLError("osSetDynamicTextureURLBlend: permission denied");
184 return String.Empty; 184 return String.Empty;
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
204 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, 204 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
205 int timer) 205 int timer)
206 { 206 {
207 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 207 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
208 { 208 {
209 OSSLError("osSetDynamicTextureData: permission denied"); 209 OSSLError("osSetDynamicTextureData: permission denied");
210 return String.Empty; 210 return String.Empty;
@@ -233,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
233 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, 233 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
234 int timer, int alpha) 234 int timer, int alpha)
235 { 235 {
236 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 236 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
237 { 237 {
238 OSSLError("osSetDynamicTextureDataBlend: permission denied"); 238 OSSLError("osSetDynamicTextureDataBlend: permission denied");
239 return String.Empty; 239 return String.Empty;
@@ -262,7 +262,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
262 public bool osConsoleCommand(string command) 262 public bool osConsoleCommand(string command)
263 { 263 {
264 m_host.AddScriptLPS(1); 264 m_host.AddScriptLPS(1);
265 if (m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowosConsoleCommand", false)) 265 if (m_ScriptEngine.Config.GetBoolean("AllowosConsoleCommand", false))
266 { 266 {
267 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) 267 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
268 { 268 {
@@ -275,7 +275,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
275 } 275 }
276 public void osSetPrimFloatOnWater(int floatYN) 276 public void osSetPrimFloatOnWater(int floatYN)
277 { 277 {
278 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 278 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
279 { 279 {
280 OSSLError("osSetPrimFloatOnWater: permission denied"); 280 OSSLError("osSetPrimFloatOnWater: permission denied");
281 return; 281 return;
@@ -294,7 +294,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
294 // Adam's super super custom animation functions 294 // Adam's super super custom animation functions
295 public void osAvatarPlayAnimation(string avatar, string animation) 295 public void osAvatarPlayAnimation(string avatar, string animation)
296 { 296 {
297 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 297 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
298 { 298 {
299 OSSLError("osAvatarPlayAnimation: permission denied"); 299 OSSLError("osAvatarPlayAnimation: permission denied");
300 return; 300 return;
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
310 310
311 public void osAvatarStopAnimation(string avatar, string animation) 311 public void osAvatarStopAnimation(string avatar, string animation)
312 { 312 {
313 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 313 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
314 { 314 {
315 OSSLError("osAvatarStopAnimation: permission denied"); 315 OSSLError("osAvatarStopAnimation: permission denied");
316 return; 316 return;
@@ -327,7 +327,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
327 //Texture draw functions 327 //Texture draw functions
328 public string osMovePen(string drawList, int x, int y) 328 public string osMovePen(string drawList, int x, int y)
329 { 329 {
330 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 330 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
331 { 331 {
332 OSSLError("osMovePen: permission denied"); 332 OSSLError("osMovePen: permission denied");
333 return String.Empty; 333 return String.Empty;
@@ -340,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
340 340
341 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) 341 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
342 { 342 {
343 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 343 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
344 { 344 {
345 OSSLError("osDrawLine: permission denied"); 345 OSSLError("osDrawLine: permission denied");
346 return String.Empty; 346 return String.Empty;
@@ -353,7 +353,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
353 353
354 public string osDrawLine(string drawList, int endX, int endY) 354 public string osDrawLine(string drawList, int endX, int endY)
355 { 355 {
356 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 356 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
357 { 357 {
358 OSSLError("osDrawLine: permission denied"); 358 OSSLError("osDrawLine: permission denied");
359 return String.Empty; 359 return String.Empty;
@@ -366,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
366 366
367 public string osDrawText(string drawList, string text) 367 public string osDrawText(string drawList, string text)
368 { 368 {
369 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 369 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
370 { 370 {
371 OSSLError("osDrawText: permission denied"); 371 OSSLError("osDrawText: permission denied");
372 return String.Empty; 372 return String.Empty;
@@ -379,7 +379,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
379 379
380 public string osDrawEllipse(string drawList, int width, int height) 380 public string osDrawEllipse(string drawList, int width, int height)
381 { 381 {
382 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 382 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
383 { 383 {
384 OSSLError("osDrawEllipse: permission denied"); 384 OSSLError("osDrawEllipse: permission denied");
385 return String.Empty; 385 return String.Empty;
@@ -392,7 +392,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
392 392
393 public string osDrawRectangle(string drawList, int width, int height) 393 public string osDrawRectangle(string drawList, int width, int height)
394 { 394 {
395 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 395 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
396 { 396 {
397 OSSLError("osDrawRectangle: permission denied"); 397 OSSLError("osDrawRectangle: permission denied");
398 return String.Empty; 398 return String.Empty;
@@ -405,7 +405,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
405 405
406 public string osDrawFilledRectangle(string drawList, int width, int height) 406 public string osDrawFilledRectangle(string drawList, int width, int height)
407 { 407 {
408 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 408 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
409 { 409 {
410 OSSLError("osDrawFilledRectangle: permission denied"); 410 OSSLError("osDrawFilledRectangle: permission denied");
411 return String.Empty; 411 return String.Empty;
@@ -418,7 +418,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
418 418
419 public string osSetFontSize(string drawList, int fontSize) 419 public string osSetFontSize(string drawList, int fontSize)
420 { 420 {
421 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 421 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
422 { 422 {
423 OSSLError("osSetFontSize: permission denied"); 423 OSSLError("osSetFontSize: permission denied");
424 return String.Empty; 424 return String.Empty;
@@ -431,7 +431,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
431 431
432 public string osSetPenSize(string drawList, int penSize) 432 public string osSetPenSize(string drawList, int penSize)
433 { 433 {
434 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 434 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
435 { 435 {
436 OSSLError("osSetPenSize: permission denied"); 436 OSSLError("osSetPenSize: permission denied");
437 return String.Empty; 437 return String.Empty;
@@ -444,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
444 444
445 public string osSetPenColour(string drawList, string colour) 445 public string osSetPenColour(string drawList, string colour)
446 { 446 {
447 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 447 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
448 { 448 {
449 OSSLError("osSetPenColour: permission denied"); 449 OSSLError("osSetPenColour: permission denied");
450 return String.Empty; 450 return String.Empty;
@@ -457,7 +457,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
457 457
458 public string osDrawImage(string drawList, int width, int height, string imageUrl) 458 public string osDrawImage(string drawList, int width, int height, string imageUrl)
459 { 459 {
460 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 460 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
461 { 461 {
462 OSSLError("osDrawImage: permission denied"); 462 OSSLError("osDrawImage: permission denied");
463 return String.Empty; 463 return String.Empty;
@@ -470,7 +470,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
470 470
471 public void osSetStateEvents(int events) 471 public void osSetStateEvents(int events)
472 { 472 {
473 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 473 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
474 { 474 {
475 OSSLError("osSetStateEvents: permission denied"); 475 OSSLError("osSetStateEvents: permission denied");
476 return; 476 return;
@@ -481,7 +481,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
481 481
482 public void osSetRegionWaterHeight(double height) 482 public void osSetRegionWaterHeight(double height)
483 { 483 {
484 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 484 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
485 { 485 {
486 OSSLError("osSetRegionWaterHeight: permission denied"); 486 OSSLError("osSetRegionWaterHeight: permission denied");
487 return; 487 return;
@@ -498,7 +498,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
498 498
499 public double osList2Double(LSL_Types.list src, int index) 499 public double osList2Double(LSL_Types.list src, int index)
500 { 500 {
501 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 501 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
502 { 502 {
503 OSSLError("osList2Double: permission denied"); 503 OSSLError("osList2Double: permission denied");
504 return 0.0; 504 return 0.0;
@@ -518,7 +518,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
518 518
519 public void osSetParcelMediaURL(string url) 519 public void osSetParcelMediaURL(string url)
520 { 520 {
521 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false)) 521 if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
522 { 522 {
523 OSSLError("osSetParcelMediaURL: permission denied"); 523 OSSLError("osSetParcelMediaURL: permission denied");
524 return; 524 return;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs
index 47ab420..6c88ae86 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs
@@ -29,9 +29,10 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Region.ScriptEngine.XEngine.Script; 32using OpenSim.Region.ScriptEngine.Shared;
33using OpenSim.Region.ScriptEngine.Shared.Api;
33 34
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 35namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
35{ 36{
36 public class Dataserver 37 public class Dataserver
37 { 38 {
@@ -94,10 +95,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
94 } 95 }
95 96
96 m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID, 97 m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID,
97 new XEventParams("dataserver", new Object[] 98 new EventParams("dataserver", new Object[]
98 { new LSL_Types.LSLString(ds.ID.ToString()), 99 { new LSL_Types.LSLString(ds.ID.ToString()),
99 new LSL_Types.LSLString(reply)}, 100 new LSL_Types.LSLString(reply)},
100 new XDetectParams[0])); 101 new DetectParams[0]));
101 } 102 }
102 103
103 public void RemoveEvents(uint localID, LLUUID itemID) 104 public void RemoveEvents(uint localID, LLUUID itemID)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
index 089e016..92f603d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
@@ -28,9 +28,11 @@
28using System; 28using System;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.HttpRequest; 30using OpenSim.Region.Environment.Modules.Scripting.HttpRequest;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.ScriptEngine.Interfaces;
33using OpenSim.Region.ScriptEngine.Shared.Api;
32 34
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 35namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
34{ 36{
35 public class HttpRequest 37 public class HttpRequest
36 { 38 {
@@ -75,11 +77,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
75 new LSL_Types.LSLString(httpInfo.response_body) 77 new LSL_Types.LSLString(httpInfo.response_body)
76 }; 78 };
77 79
78 foreach (XEngine xe in XEngine.ScriptEngines) 80 foreach (AsyncCommandManager m in m_CmdManager.Managers)
79 { 81 {
80 if (xe.PostObjectEvent(httpInfo.localID, 82 if (m.m_ScriptEngine.PostObjectEvent(httpInfo.localID,
81 new XEventParams("http_response", 83 new EventParams("http_response",
82 resobj, new XDetectParams[0]))) 84 resobj, new DetectParams[0])))
83 break; 85 break;
84 } 86 }
85 httpInfo = iHttpReq.GetNextCompletedRequest(); 87 httpInfo = iHttpReq.GetNextCompletedRequest();
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
index 1144c00..11b45b1 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
@@ -29,9 +29,10 @@ using System;
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Region.Environment.Interfaces; 30using OpenSim.Region.Environment.Interfaces;
31using OpenSim.Region.Environment.Modules.Scripting.WorldComm; 31using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
32using OpenSim.Region.ScriptEngine.XEngine.Script; 32using OpenSim.Region.ScriptEngine.Shared;
33using OpenSim.Region.ScriptEngine.Shared.Api;
33 34
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 35namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
35{ 36{
36 public class Listener 37 public class Listener
37 { 38 {
@@ -66,9 +67,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
66 }; 67 };
67 68
68 m_CmdManager.m_ScriptEngine.PostScriptEvent( 69 m_CmdManager.m_ScriptEngine.PostScriptEvent(
69 lInfo.GetItemID(), new XEventParams( 70 lInfo.GetItemID(), new EventParams(
70 "listen", resobj, 71 "listen", resobj,
71 new XDetectParams[0])); 72 new DetectParams[0]));
72 } 73 }
73 } 74 }
74 } 75 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 8a25098..5833512 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -30,9 +30,10 @@ using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes; 32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Region.ScriptEngine.XEngine.Script; 33using OpenSim.Region.ScriptEngine.Shared;
34using OpenSim.Region.ScriptEngine.Shared.Api;
34 35
35namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 36namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
36{ 37{
37 public class SensorRepeat 38 public class SensorRepeat
38 { 39 {
@@ -72,8 +73,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
72 string name, LLUUID keyID, int type, double range, 73 string name, LLUUID keyID, int type, double range,
73 double arc, double sec, SceneObjectPart host) 74 double arc, double sec, SceneObjectPart host)
74 { 75 {
75 Console.WriteLine("SetSensorEvent");
76
77 // Always remove first, in case this is a re-set 76 // Always remove first, in case this is a re-set
78 UnSetSenseRepeaterEvents(m_localID, m_itemID); 77 UnSetSenseRepeaterEvents(m_localID, m_itemID);
79 if (sec == 0) // Disabling timer 78 if (sec == 0) // Disabling timer
@@ -163,7 +162,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
163 Dictionary<LLUUID, LSL_Types.list> Obj = null; 162 Dictionary<LLUUID, LSL_Types.list> Obj = null;
164 if (!SenseEvents.TryGetValue(m_localID, out Obj)) 163 if (!SenseEvents.TryGetValue(m_localID, out Obj))
165 { 164 {
166 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
167 return null; 165 return null;
168 } 166 }
169 lock (Obj) 167 lock (Obj)
@@ -172,7 +170,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
172 LSL_Types.list SenseList = null; 170 LSL_Types.list SenseList = null;
173 if (!Obj.TryGetValue(m_itemID, out SenseList)) 171 if (!Obj.TryGetValue(m_itemID, out SenseList))
174 { 172 {
175 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
176 return null; 173 return null;
177 } 174 }
178 return SenseList; 175 return SenseList;
@@ -182,15 +179,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
182 179
183 private void SensorSweep(SenseRepeatClass ts) 180 private void SensorSweep(SenseRepeatClass ts)
184 { 181 {
185 //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
186 SceneObjectPart SensePoint = ts.host; 182 SceneObjectPart SensePoint = ts.host;
187 183
188 if (SensePoint == null) 184 if (SensePoint == null)
189 { 185 {
190 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
191 return; 186 return;
192 } 187 }
193 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
194 188
195 LLVector3 sensorPos = SensePoint.AbsolutePosition; 189 LLVector3 sensorPos = SensePoint.AbsolutePosition;
196 LLVector3 regionPos = new LLVector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0); 190 LLVector3 regionPos = new LLVector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
@@ -220,7 +214,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
220 objtype |= 0x04; // passive non-moving 214 objtype |= 0x04; // passive non-moving
221 else 215 else
222 objtype |= 0x02; // active moving 216 objtype |= 0x02; // active moving
223 if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ... 217
218 SceneObjectPart part = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
219
220 if (part != null && part.ContainsScripts()) objtype |= 0x08; // Scripted. It COULD have one hidden ...
224 221
225 if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type)) 222 if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type))
226 { 223 {
@@ -288,7 +285,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
288 } 285 }
289 } 286 }
290 } 287 }
291 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
292 288
293 lock (SenseLock) 289 lock (SenseLock)
294 { 290 {
@@ -311,24 +307,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
311 // send a "no_sensor" 307 // send a "no_sensor"
312 // Add it to queue 308 // Add it to queue
313 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 309 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
314 new XEventParams("no_sensor", new Object[0], 310 new EventParams("no_sensor", new Object[0],
315 new XDetectParams[0])); 311 new DetectParams[0]));
316 } 312 }
317 else 313 else
318 { 314 {
319 XDetectParams[] detect = 315 DetectParams[] detect =
320 new XDetectParams[SensedObjects.Length]; 316 new DetectParams[SensedObjects.Length];
321 317
322 int idx; 318 int idx;
323 for (idx = 0; idx < SensedObjects.Length; idx++) 319 for (idx = 0; idx < SensedObjects.Length; idx++)
324 { 320 {
325 detect[idx] = new XDetectParams(); 321 detect[idx] = new DetectParams();
326 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]); 322 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]);
327 detect[idx].Populate(m_CmdManager.m_ScriptEngine.World); 323 detect[idx].Populate(m_CmdManager.m_ScriptEngine.World);
328 } 324 }
329 325
330 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 326 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
331 new XEventParams("sensor", 327 new EventParams("sensor",
332 new Object[] { 328 new Object[] {
333 new LSL_Types.LSLInteger(SensedObjects.Length) }, 329 new LSL_Types.LSLInteger(SensedObjects.Length) },
334 detect)); 330 detect));
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index 3dd875a..36e992b 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -29,8 +29,9 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Region.ScriptEngine.Shared.Api;
32 33
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 34namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
34{ 35{
35 public class Timer 36 public class Timer
36 { 37 {
@@ -110,8 +111,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
110 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 111 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
111 // Add it to queue 112 // Add it to queue
112 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 113 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
113 new XEventParams("timer", new Object[0], 114 new EventParams("timer", new Object[0],
114 new XDetectParams[0])); 115 new DetectParams[0]));
115 // set next interval 116 // set next interval
116 117
117 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 118 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
index 288349e..89bf51c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
@@ -28,9 +28,11 @@
28using System; 28using System;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.XMLRPC; 30using OpenSim.Region.Environment.Modules.Scripting.XMLRPC;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Interfaces;
32using OpenSim.Region.ScriptEngine.Shared;
33using OpenSim.Region.ScriptEngine.Shared.Api;
32 34
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins 35namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
34{ 36{
35 public class XmlRequest 37 public class XmlRequest
36 { 38 {
@@ -69,12 +71,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
69 new LSL_Types.LSLString(rInfo.GetStrVal()) 71 new LSL_Types.LSLString(rInfo.GetStrVal())
70 }; 72 };
71 73
72 foreach (XEngine xe in XEngine.ScriptEngines) 74 foreach (AsyncCommandManager m in m_CmdManager.Managers)
73 { 75 {
74 if (xe.PostScriptEvent( 76 if (m.m_ScriptEngine.PostScriptEvent(
75 rInfo.GetItemID(), new XEventParams( 77 rInfo.GetItemID(), new EventParams(
76 "remote_data", resobj, 78 "remote_data", resobj,
77 new XDetectParams[0]))) 79 new DetectParams[0])))
78 break; 80 break;
79 } 81 }
80 82
@@ -98,12 +100,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
98 new LSL_Types.LSLString(srdInfo.sdata) 100 new LSL_Types.LSLString(srdInfo.sdata)
99 }; 101 };
100 102
101 foreach (XEngine xe in XEngine.ScriptEngines) 103 foreach (AsyncCommandManager m in m_CmdManager.Managers)
102 { 104 {
103 if (xe.PostScriptEvent( 105 if (m.m_ScriptEngine.PostScriptEvent(
104 srdInfo.m_itemID, new XEventParams( 106 srdInfo.m_itemID, new EventParams(
105 "remote_data", resobj, 107 "remote_data", resobj,
106 new XDetectParams[0]))) 108 new DetectParams[0])))
107 break; 109 break;
108 } 110 }
109 111
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 9e8965c..75672a1 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -25,20 +25,16 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Region.Environment.Interfaces; 28using System;
29using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
30using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
29 31
30namespace OpenSim.Region.ScriptEngine.XEngine.Script 32
33namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
31{ 34{
32 public interface ILSL_ScriptCommands 35 public interface ILSL_Api
33 { 36 {
34 // Interface used for loading and executing scripts
35
36 string State { get; set ; }
37
38 void state(string newState); 37 void state(string newState);
39
40 ICommander GetCommander(string name);
41
42 void llSay(int channelID, string text); 38 void llSay(int channelID, string text);
43 double llSin(double f); 39 double llSin(double f);
44 double llCos(double f); 40 double llCos(double f);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 82d4673..1e14c63 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -25,9 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28namespace OpenSim.Region.ScriptEngine.XEngine.Script 28namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
29{ 29{
30 public interface IOSSL_ScriptCommands 30 public interface IOSSL_Api
31 { 31 {
32 //OpenSim functions 32 //OpenSim functions
33 string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); 33 string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
new file mode 100644
index 0000000..69be69b
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -0,0 +1,421 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
30using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
31
32namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
33{
34 public partial class ScriptBaseClass : MarshalByRefObject
35 {
36 // LSL CONSTANTS
37 public const int TRUE = 1;
38 public const int FALSE = 0;
39
40 public const int STATUS_PHYSICS = 1;
41 public const int STATUS_ROTATE_X = 2;
42 public const int STATUS_ROTATE_Y = 4;
43 public const int STATUS_ROTATE_Z = 8;
44 public const int STATUS_PHANTOM = 16;
45 public const int STATUS_SANDBOX = 32;
46 public const int STATUS_BLOCK_GRAB = 64;
47 public const int STATUS_DIE_AT_EDGE = 128;
48 public const int STATUS_RETURN_AT_EDGE = 256;
49 public const int STATUS_CAST_SHADOWS = 512;
50
51 public const int AGENT = 1;
52 public const int ACTIVE = 2;
53 public const int PASSIVE = 4;
54 public const int SCRIPTED = 8;
55
56 public const int CONTROL_FWD = 1;
57 public const int CONTROL_BACK = 2;
58 public const int CONTROL_LEFT = 4;
59 public const int CONTROL_RIGHT = 8;
60 public const int CONTROL_UP = 16;
61 public const int CONTROL_DOWN = 32;
62 public const int CONTROL_ROT_LEFT = 256;
63 public const int CONTROL_ROT_RIGHT = 512;
64 public const int CONTROL_LBUTTON = 268435456;
65 public const int CONTROL_ML_LBUTTON = 1073741824;
66
67 //Permissions
68 public const int PERMISSION_DEBIT = 2;
69 public const int PERMISSION_TAKE_CONTROLS = 4;
70 public const int PERMISSION_REMAP_CONTROLS = 8;
71 public const int PERMISSION_TRIGGER_ANIMATION = 16;
72 public const int PERMISSION_ATTACH = 32;
73 public const int PERMISSION_RELEASE_OWNERSHIP = 64;
74 public const int PERMISSION_CHANGE_LINKS = 128;
75 public const int PERMISSION_CHANGE_JOINTS = 256;
76 public const int PERMISSION_CHANGE_PERMISSIONS = 512;
77 public const int PERMISSION_TRACK_CAMERA = 1024;
78
79 public const int AGENT_FLYING = 1;
80 public const int AGENT_ATTACHMENTS = 2;
81 public const int AGENT_SCRIPTED = 4;
82 public const int AGENT_MOUSELOOK = 8;
83 public const int AGENT_SITTING = 16;
84 public const int AGENT_ON_OBJECT = 32;
85 public const int AGENT_AWAY = 64;
86 public const int AGENT_WALKING = 128;
87 public const int AGENT_IN_AIR = 256;
88 public const int AGENT_TYPING = 512;
89 public const int AGENT_CROUCHING = 1024;
90 public const int AGENT_BUSY = 2048;
91 public const int AGENT_ALWAYS_RUN = 4096;
92
93 //Particle Systems
94 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
95 public const int PSYS_PART_INTERP_SCALE_MASK = 2;
96 public const int PSYS_PART_BOUNCE_MASK = 4;
97 public const int PSYS_PART_WIND_MASK = 8;
98 public const int PSYS_PART_FOLLOW_SRC_MASK = 16;
99 public const int PSYS_PART_FOLLOW_VELOCITY_MASK = 32;
100 public const int PSYS_PART_TARGET_POS_MASK = 64;
101 public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
102 public const int PSYS_PART_EMISSIVE_MASK = 256;
103 public const int PSYS_PART_FLAGS = 0;
104 public const int PSYS_PART_START_COLOR = 1;
105 public const int PSYS_PART_START_ALPHA = 2;
106 public const int PSYS_PART_END_COLOR = 3;
107 public const int PSYS_PART_END_ALPHA = 4;
108 public const int PSYS_PART_START_SCALE = 5;
109 public const int PSYS_PART_END_SCALE = 6;
110 public const int PSYS_PART_MAX_AGE = 7;
111 public const int PSYS_SRC_ACCEL = 8;
112 public const int PSYS_SRC_PATTERN = 9;
113 public const int PSYS_SRC_INNERANGLE = 10;
114 public const int PSYS_SRC_OUTERANGLE = 11;
115 public const int PSYS_SRC_TEXTURE = 12;
116 public const int PSYS_SRC_BURST_RATE = 13;
117 public const int PSYS_SRC_BURST_PART_COUNT = 15;
118 public const int PSYS_SRC_BURST_RADIUS = 16;
119 public const int PSYS_SRC_BURST_SPEED_MIN = 17;
120 public const int PSYS_SRC_BURST_SPEED_MAX = 18;
121 public const int PSYS_SRC_MAX_AGE = 19;
122 public const int PSYS_SRC_TARGET_KEY = 20;
123 public const int PSYS_SRC_OMEGA = 21;
124 public const int PSYS_SRC_ANGLE_BEGIN = 22;
125 public const int PSYS_SRC_ANGLE_END = 23;
126 public const int PSYS_SRC_PATTERN_DROP = 1;
127 public const int PSYS_SRC_PATTERN_EXPLODE = 2;
128 public const int PSYS_SRC_PATTERN_ANGLE = 4;
129 public const int PSYS_SRC_PATTERN_ANGLE_CONE = 8;
130 public const int PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16;
131
132 public const int VEHICLE_TYPE_NONE = 0;
133 public const int VEHICLE_TYPE_SLED = 1;
134 public const int VEHICLE_TYPE_CAR = 2;
135 public const int VEHICLE_TYPE_BOAT = 3;
136 public const int VEHICLE_TYPE_AIRPLANE = 4;
137 public const int VEHICLE_TYPE_BALLOON = 5;
138 public const int VEHICLE_LINEAR_FRICTION_TIMESCALE = 16;
139 public const int VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17;
140 public const int VEHICLE_LINEAR_MOTOR_DIRECTION = 18;
141 public const int VEHICLE_LINEAR_MOTOR_OFFSET = 20;
142 public const int VEHICLE_ANGULAR_MOTOR_DIRECTION = 19;
143 public const int VEHICLE_HOVER_HEIGHT = 24;
144 public const int VEHICLE_HOVER_EFFICIENCY = 25;
145 public const int VEHICLE_HOVER_TIMESCALE = 26;
146 public const int VEHICLE_BUOYANCY = 27;
147 public const int VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28;
148 public const int VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29;
149 public const int VEHICLE_LINEAR_MOTOR_TIMESCALE = 30;
150 public const int VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31;
151 public const int VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32;
152 public const int VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33;
153 public const int VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34;
154 public const int VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35;
155 public const int VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36;
156 public const int VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37;
157 public const int VEHICLE_BANKING_EFFICIENCY = 38;
158 public const int VEHICLE_BANKING_MIX = 39;
159 public const int VEHICLE_BANKING_TIMESCALE = 40;
160 public const int VEHICLE_REFERENCE_FRAME = 44;
161 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
162 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
163 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
164 public const int VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 8;
165 public const int VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 16;
166 public const int VEHICLE_FLAG_HOVER_UP_ONLY = 32;
167 public const int VEHICLE_FLAG_LIMIT_MOTOR_UP = 64;
168 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
169 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
170 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
171
172 public const int INVENTORY_ALL = -1;
173 public const int INVENTORY_NONE = -1;
174 public const int INVENTORY_TEXTURE = 0;
175 public const int INVENTORY_SOUND = 1;
176 public const int INVENTORY_LANDMARK = 3;
177 public const int INVENTORY_CLOTHING = 5;
178 public const int INVENTORY_OBJECT = 6;
179 public const int INVENTORY_NOTECARD = 7;
180 public const int INVENTORY_SCRIPT = 10;
181 public const int INVENTORY_BODYPART = 13;
182 public const int INVENTORY_ANIMATION = 20;
183 public const int INVENTORY_GESTURE = 21;
184
185 public const int ATTACH_CHEST = 1;
186 public const int ATTACH_HEAD = 2;
187 public const int ATTACH_LSHOULDER = 3;
188 public const int ATTACH_RSHOULDER = 4;
189 public const int ATTACH_LHAND = 5;
190 public const int ATTACH_RHAND = 6;
191 public const int ATTACH_LFOOT = 7;
192 public const int ATTACH_RFOOT = 8;
193 public const int ATTACH_BACK = 9;
194 public const int ATTACH_PELVIS = 10;
195 public const int ATTACH_MOUTH = 11;
196 public const int ATTACH_CHIN = 12;
197 public const int ATTACH_LEAR = 13;
198 public const int ATTACH_REAR = 14;
199 public const int ATTACH_LEYE = 15;
200 public const int ATTACH_REYE = 16;
201 public const int ATTACH_NOSE = 17;
202 public const int ATTACH_RUARM = 18;
203 public const int ATTACH_RLARM = 19;
204 public const int ATTACH_LUARM = 20;
205 public const int ATTACH_LLARM = 21;
206 public const int ATTACH_RHIP = 22;
207 public const int ATTACH_RULEG = 23;
208 public const int ATTACH_RLLEG = 24;
209 public const int ATTACH_LHIP = 25;
210 public const int ATTACH_LULEG = 26;
211 public const int ATTACH_LLLEG = 27;
212 public const int ATTACH_BELLY = 28;
213 public const int ATTACH_RPEC = 29;
214 public const int ATTACH_LPEC = 30;
215
216 public const int LAND_LEVEL = 0;
217 public const int LAND_RAISE = 1;
218 public const int LAND_LOWER = 2;
219 public const int LAND_SMOOTH = 3;
220 public const int LAND_NOISE = 4;
221 public const int LAND_REVERT = 5;
222 public const int LAND_SMALL_BRUSH = 1;
223 public const int LAND_MEDIUM_BRUSH = 2;
224 public const int LAND_LARGE_BRUSH = 3;
225
226 //Agent Dataserver
227 public const int DATA_ONLINE = 1;
228 public const int DATA_NAME = 2;
229 public const int DATA_BORN = 3;
230 public const int DATA_RATING = 4;
231 public const int DATA_SIM_POS = 5;
232 public const int DATA_SIM_STATUS = 6;
233 public const int DATA_SIM_RATING = 7;
234 public const int DATA_PAYINFO = 8;
235
236 public const int ANIM_ON = 1;
237 public const int LOOP = 2;
238 public const int REVERSE = 4;
239 public const int PING_PONG = 8;
240 public const int SMOOTH = 16;
241 public const int ROTATE = 32;
242 public const int SCALE = 64;
243 public const int ALL_SIDES = -1;
244 public const int LINK_SET = -1;
245 public const int LINK_ROOT = 1;
246 public const int LINK_ALL_OTHERS = -2;
247 public const int LINK_ALL_CHILDREN = -3;
248 public const int LINK_THIS = -4;
249 public const int CHANGED_INVENTORY = 1;
250 public const int CHANGED_COLOR = 2;
251 public const int CHANGED_SHAPE = 4;
252 public const int CHANGED_SCALE = 8;
253 public const int CHANGED_TEXTURE = 16;
254 public const int CHANGED_LINK = 32;
255 public const int CHANGED_ALLOWED_DROP = 64;
256 public const int CHANGED_OWNER = 128;
257 public const int CHANGED_REGION_RESTART = 256;
258 public const int TYPE_INVALID = 0;
259 public const int TYPE_INTEGER = 1;
260 public const int TYPE_double = 2;
261 public const int TYPE_STRING = 3;
262 public const int TYPE_KEY = 4;
263 public const int TYPE_VECTOR = 5;
264 public const int TYPE_ROTATION = 6;
265
266 //XML RPC Remote Data Channel
267 public const int REMOTE_DATA_CHANNEL = 1;
268 public const int REMOTE_DATA_REQUEST = 2;
269 public const int REMOTE_DATA_REPLY = 3;
270
271 //llHTTPRequest
272 public const int HTTP_METHOD = 0;
273 public const int HTTP_MIMETYPE = 1;
274 public const int HTTP_BODY_MAXLENGTH = 2;
275 public const int HTTP_VERIFY_CERT = 3;
276
277 public const int PRIM_MATERIAL = 2;
278 public const int PRIM_PHYSICS = 3;
279 public const int PRIM_TEMP_ON_REZ = 4;
280 public const int PRIM_PHANTOM = 5;
281 public const int PRIM_POSITION = 6;
282 public const int PRIM_SIZE = 7;
283 public const int PRIM_ROTATION = 8;
284 public const int PRIM_TYPE = 9;
285 public const int PRIM_TEXTURE = 17;
286 public const int PRIM_COLOR = 18;
287 public const int PRIM_BUMP_SHINY = 19;
288 public const int PRIM_FULLBRIGHT = 20;
289 public const int PRIM_FLEXIBLE = 21;
290 public const int PRIM_TEXGEN = 22;
291 public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
292 public const int PRIM_POINT_LIGHT = 23; // Huh?
293 public const int PRIM_TEXGEN_DEFAULT = 0;
294 public const int PRIM_TEXGEN_PLANAR = 1;
295
296 public const int PRIM_TYPE_BOX = 0;
297 public const int PRIM_TYPE_CYLINDER = 1;
298 public const int PRIM_TYPE_PRISM = 2;
299 public const int PRIM_TYPE_SPHERE = 3;
300 public const int PRIM_TYPE_TORUS = 4;
301 public const int PRIM_TYPE_TUBE = 5;
302 public const int PRIM_TYPE_RING = 6;
303 public const int PRIM_TYPE_SCULPT = 7;
304
305 public const int PRIM_HOLE_DEFAULT = 0;
306 public const int PRIM_HOLE_CIRCLE = 16;
307 public const int PRIM_HOLE_SQUARE = 32;
308 public const int PRIM_HOLE_TRIANGLE = 48;
309
310 public const int PRIM_MATERIAL_STONE = 0;
311 public const int PRIM_MATERIAL_METAL = 1;
312 public const int PRIM_MATERIAL_GLASS = 2;
313 public const int PRIM_MATERIAL_WOOD = 3;
314 public const int PRIM_MATERIAL_FLESH = 4;
315 public const int PRIM_MATERIAL_PLASTIC = 5;
316 public const int PRIM_MATERIAL_RUBBER = 6;
317 public const int PRIM_MATERIAL_LIGHT = 7;
318
319 public const int PRIM_SHINY_NONE = 0;
320 public const int PRIM_SHINY_LOW = 1;
321 public const int PRIM_SHINY_MEDIUM = 2;
322 public const int PRIM_SHINY_HIGH = 3;
323 public const int PRIM_BUMP_NONE = 0;
324 public const int PRIM_BUMP_BRIGHT = 1;
325 public const int PRIM_BUMP_DARK = 2;
326 public const int PRIM_BUMP_WOOD = 3;
327 public const int PRIM_BUMP_BARK = 4;
328 public const int PRIM_BUMP_BRICKS = 5;
329 public const int PRIM_BUMP_CHECKER = 6;
330 public const int PRIM_BUMP_CONCRETE = 7;
331 public const int PRIM_BUMP_TILE = 8;
332 public const int PRIM_BUMP_STONE = 9;
333 public const int PRIM_BUMP_DISKS = 10;
334 public const int PRIM_BUMP_GRAVEL = 11;
335 public const int PRIM_BUMP_BLOBS = 12;
336 public const int PRIM_BUMP_SIDING = 13;
337 public const int PRIM_BUMP_LARGETILE = 14;
338 public const int PRIM_BUMP_STUCCO = 15;
339 public const int PRIM_BUMP_SUCTION = 16;
340 public const int PRIM_BUMP_WEAVE = 17;
341
342 public const int PRIM_SCULPT_TYPE_SPHERE = 1;
343 public const int PRIM_SCULPT_TYPE_TORUS = 2;
344 public const int PRIM_SCULPT_TYPE_PLANE = 3;
345 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
346
347 public const int MASK_BASE = 0;
348 public const int MASK_OWNER = 1;
349 public const int MASK_GROUP = 2;
350 public const int MASK_EVERYONE = 3;
351 public const int MASK_NEXT = 4;
352
353 public const int PERM_TRANSFER = 8192;
354 public const int PERM_MODIFY = 16384;
355 public const int PERM_COPY = 32768;
356 public const int PERM_MOVE = 524288;
357 public const int PERM_ALL = 2147483647;
358
359 public const int PARCEL_MEDIA_COMMAND_STOP = 0;
360 public const int PARCEL_MEDIA_COMMAND_PAUSE = 1;
361 public const int PARCEL_MEDIA_COMMAND_PLAY = 2;
362 public const int PARCEL_MEDIA_COMMAND_LOOP = 3;
363 public const int PARCEL_MEDIA_COMMAND_TEXTURE = 4;
364 public const int PARCEL_MEDIA_COMMAND_URL = 5;
365 public const int PARCEL_MEDIA_COMMAND_TIME = 6;
366 public const int PARCEL_MEDIA_COMMAND_AGENT = 7;
367 public const int PARCEL_MEDIA_COMMAND_UNLOAD = 8;
368 public const int PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
369
370 public const int PAY_HIDE = -1;
371 public const int PAY_DEFAULT = -2;
372
373 public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
374 public const string EOF = "\n\n\n";
375 public const double PI = 3.14159274f;
376 public const double TWO_PI = 6.28318548f;
377 public const double PI_BY_TWO = 1.57079637f;
378 public const double DEG_TO_RAD = 0.01745329238f;
379 public const double RAD_TO_DEG = 57.29578f;
380 public const double SQRT2 = 1.414213538f;
381 public const int STRING_TRIM_HEAD = 1;
382 public const int STRING_TRIM_TAIL = 2;
383 public const int STRING_TRIM = 3;
384 public const int LIST_STAT_RANGE = 0;
385 public const int LIST_STAT_MIN = 1;
386 public const int LIST_STAT_MAX = 2;
387 public const int LIST_STAT_MEAN = 3;
388 public const int LIST_STAT_MEDIAN = 4;
389 public const int LIST_STAT_STD_DEV = 5;
390 public const int LIST_STAT_SUM = 6;
391 public const int LIST_STAT_SUM_SQUARES = 7;
392 public const int LIST_STAT_NUM_COUNT = 8;
393 public const int LIST_STAT_GEOMETRIC_MEAN = 9;
394 public const int LIST_STAT_HARMONIC_MEAN = 100;
395
396 //ParcelPrim Categories
397 public const int PARCEL_COUNT_TOTAL = 0;
398 public const int PARCEL_COUNT_OWNER = 1;
399 public const int PARCEL_COUNT_GROUP = 2;
400 public const int PARCEL_COUNT_OTHER = 3;
401 public const int PARCEL_COUNT_SELECTED = 4;
402 public const int PARCEL_COUNT_TEMP = 5;
403
404 public const int DEBUG_CHANNEL = 0x7FFFFFFF;
405 public const int PUBLIC_CHANNEL = 0x00000000;
406
407 public const int OBJECT_NAME = 1;
408 public const int OBJECT_DESC = 2;
409 public const int OBJECT_POS = 3;
410 public const int OBJECT_ROT = 4;
411 public const int OBJECT_VELOCITY = 5;
412 public const int OBJECT_OWNER = 6;
413 public const int OBJECT_GROUP = 7;
414 public const int OBJECT_CREATOR = 8;
415
416 // Can not be public const?
417 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
418 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
419
420 }
421}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index fc9f8fc..7b3907f 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -31,100 +31,25 @@ using System.Threading;
31using System.Reflection; 31using System.Reflection;
32using System.Collections; 32using System.Collections;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.ScriptEngine.Interfaces;
35using integer = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.LSLInteger; 35using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
36using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
36using key = System.String; 37using key = System.String;
37using vector = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.Vector3; 38using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
38using rotation = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.Quaternion; 39using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
39 40
40namespace OpenSim.Region.ScriptEngine.XEngine.Script 41namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
41{ 42{
42 public class BuiltIn_Commands_BaseClass : MarshalByRefObject, IOSSL_ScriptCommands, ILSL_ScriptCommands, IScript 43 public partial class ScriptBaseClass : MarshalByRefObject
43 { 44 {
44 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 45 public ILSL_Api m_LSL_Functions;
45 46
46 // Object never expires 47 public void ApiTypeLSL(IScriptApi api)
47 public override Object InitializeLifetimeService()
48 { 48 {
49 //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); 49 if(!(api is ILSL_Api))
50 // return null; 50 return;
51 ILease lease = (ILease)base.InitializeLifetimeService();
52 51
53 if (lease.CurrentState == LeaseState.Initial) 52 m_LSL_Functions = (ILSL_Api)api;
54 {
55 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
56 //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
57 //lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
58 }
59 return lease;
60 }
61
62 public ILSL_ScriptCommands m_LSL_Functions;
63 public IOSSL_ScriptCommands m_OSSL_Functions;
64
65 public BuiltIn_Commands_BaseClass()
66 {
67 }
68
69 public Type Start(ILSL_ScriptCommands LSL_Functions, IOSSL_ScriptCommands OSSL_Functions)
70 {
71 m_LSL_Functions = LSL_Functions;
72 m_OSSL_Functions = OSSL_Functions;
73 m_InitialValues=GetVars();
74 return GetType();
75 }
76
77 private Dictionary<string, object> m_InitialValues =
78 new Dictionary<string, object>();
79 private Dictionary<string, FieldInfo> m_Fields =
80 new Dictionary<string, FieldInfo>();
81
82 public Dictionary<string, object> GetVars()
83 {
84 Dictionary<string, object> vars = new Dictionary<string, object>();
85
86 if (m_Fields == null)
87 return vars;
88
89 m_Fields.Clear();
90
91 Type t = GetType();
92
93 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
94 BindingFlags.Public |
95 BindingFlags.Instance |
96 BindingFlags.DeclaredOnly);
97
98 foreach (FieldInfo field in fields)
99 {
100 m_Fields[field.Name]=field;
101
102 vars[field.Name]=field.GetValue(this);
103 }
104
105 return vars;
106 }
107
108 public void SetVars(Dictionary<string, object> vars)
109 {
110 foreach (KeyValuePair<string, object> var in vars)
111 {
112 if (m_Fields.ContainsKey(var.Key))
113 {
114 m_Fields[var.Key].SetValue(this, var.Value);
115 }
116 }
117 }
118
119 public void ResetVars()
120 {
121 SetVars(m_InitialValues);
122 }
123
124 public string State
125 {
126 get { return m_LSL_Functions.State; }
127 set { m_LSL_Functions.State = value; }
128 } 53 }
129 54
130 public void state(string newState) 55 public void state(string newState)
@@ -132,26 +57,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
132 m_LSL_Functions.state(newState); 57 m_LSL_Functions.state(newState);
133 } 58 }
134 59
135 public void llSay(int channelID, string text)
136 {
137 m_LSL_Functions.llSay(channelID, text);
138 }
139
140 //
141 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
142 // 60 //
143 // They are only forwarders to LSL_BuiltIn_Commands.cs 61 // Script functions
144 // 62 //
145 63 public void llSay(int channelID, string text)
146 public ICommander GetCommander(string name)
147 { 64 {
148 return m_LSL_Functions.GetCommander(name); 65 m_LSL_Functions.llSay(channelID, text);
149 } 66 }
150 67
151 public double llSin(double f) 68 public double llSin(double f)
152 { 69 {
153 return m_LSL_Functions.llSin(f); 70 return m_LSL_Functions.llSin(f);
154 } 71 }
72
155 public double llCos(double f) 73 public double llCos(double f)
156 { 74 {
157 return m_LSL_Functions.llCos(f); 75 return m_LSL_Functions.llCos(f);
@@ -262,9 +180,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
262 m_LSL_Functions.llWhisper(channelID, text); 180 m_LSL_Functions.llWhisper(channelID, text);
263 } 181 }
264 182
265 //
266 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
267 //
268 public void llShout(int channelID, string text) 183 public void llShout(int channelID, string text)
269 { 184 {
270 m_LSL_Functions.llShout(channelID, text); 185 m_LSL_Functions.llShout(channelID, text);
@@ -355,9 +270,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
355 return m_LSL_Functions.llDetectedLinkNumber(number); 270 return m_LSL_Functions.llDetectedLinkNumber(number);
356 } 271 }
357 272
358 //
359 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
360 //
361 public void llDie() 273 public void llDie()
362 { 274 {
363 m_LSL_Functions.llDie(); 275 m_LSL_Functions.llDie();
@@ -443,9 +355,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
443 return m_LSL_Functions.llGetTexture(face); 355 return m_LSL_Functions.llGetTexture(face);
444 } 356 }
445 357
446 //
447 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
448 //
449 public void llSetPos(vector pos) 358 public void llSetPos(vector pos)
450 { 359 {
451 m_LSL_Functions.llSetPos(pos); 360 m_LSL_Functions.llSetPos(pos);
@@ -521,9 +430,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
521 m_LSL_Functions.llApplyImpulse(force, local); 430 m_LSL_Functions.llApplyImpulse(force, local);
522 } 431 }
523 432
524 //
525 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
526 //
527 public void llApplyRotationalImpulse(vector force, int local) 433 public void llApplyRotationalImpulse(vector force, int local)
528 { 434 {
529 m_LSL_Functions.llApplyRotationalImpulse(force, local); 435 m_LSL_Functions.llApplyRotationalImpulse(force, local);
@@ -614,9 +520,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
614 m_LSL_Functions.llPlaySoundSlave(sound, volume); 520 m_LSL_Functions.llPlaySoundSlave(sound, volume);
615 } 521 }
616 522
617 //
618 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
619 //
620 public void llTriggerSound(string sound, double volume) 523 public void llTriggerSound(string sound, double volume)
621 { 524 {
622 m_LSL_Functions.llTriggerSound(sound, volume); 525 m_LSL_Functions.llTriggerSound(sound, volume);
@@ -707,9 +610,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
707 m_LSL_Functions.llSleep(sec); 610 m_LSL_Functions.llSleep(sec);
708 } 611 }
709 612
710 //
711 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
712 //
713 public double llGetMass() 613 public double llGetMass()
714 { 614 {
715 return m_LSL_Functions.llGetMass(); 615 return m_LSL_Functions.llGetMass();
@@ -805,9 +705,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
805 m_LSL_Functions.llRotLookAt(target, strength, damping); 705 m_LSL_Functions.llRotLookAt(target, strength, damping);
806 } 706 }
807 707
808 //
809 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
810 //
811 public LSL_Types.LSLInteger llStringLength(string str) 708 public LSL_Types.LSLInteger llStringLength(string str)
812 { 709 {
813 return m_LSL_Functions.llStringLength(str); 710 return m_LSL_Functions.llStringLength(str);
@@ -908,9 +805,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
908 return m_LSL_Functions.llGetInventoryName(type, number); 805 return m_LSL_Functions.llGetInventoryName(type, number);
909 } 806 }
910 807
911 //
912 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
913 //
914 public void llSetScriptState(string name, int run) 808 public void llSetScriptState(string name, int run)
915 { 809 {
916 m_LSL_Functions.llSetScriptState(name, run); 810 m_LSL_Functions.llSetScriptState(name, run);
@@ -1016,9 +910,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1016 return m_LSL_Functions.llGetNumberOfSides(); 910 return m_LSL_Functions.llGetNumberOfSides();
1017 } 911 }
1018 912
1019 //
1020 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1021 //
1022 public rotation llAxisAngle2Rot(vector axis, double angle) 913 public rotation llAxisAngle2Rot(vector axis, double angle)
1023 { 914 {
1024 return m_LSL_Functions.llAxisAngle2Rot(axis, angle); 915 return m_LSL_Functions.llAxisAngle2Rot(axis, angle);
@@ -1104,9 +995,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1104 return m_LSL_Functions.llGetListLength(src); 995 return m_LSL_Functions.llGetListLength(src);
1105 } 996 }
1106 997
1107 //
1108 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1109 //
1110 public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index) 998 public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index)
1111 { 999 {
1112 return m_LSL_Functions.llList2Integer(src, index); 1000 return m_LSL_Functions.llList2Integer(src, index);
@@ -1207,9 +1095,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1207 return m_LSL_Functions.llGetAgentInfo(id); 1095 return m_LSL_Functions.llGetAgentInfo(id);
1208 } 1096 }
1209 1097
1210 //
1211 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1212 //
1213 public void llAdjustSoundVolume(double volume) 1098 public void llAdjustSoundVolume(double volume)
1214 { 1099 {
1215 m_LSL_Functions.llAdjustSoundVolume(volume); 1100 m_LSL_Functions.llAdjustSoundVolume(volume);
@@ -1320,9 +1205,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1320 return m_LSL_Functions.llGetRegionFPS(); 1205 return m_LSL_Functions.llGetRegionFPS();
1321 } 1206 }
1322 1207
1323 //
1324 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1325 //
1326 public void llParticleSystem(LSL_Types.list rules) 1208 public void llParticleSystem(LSL_Types.list rules)
1327 { 1209 {
1328 m_LSL_Functions.llParticleSystem(rules); 1210 m_LSL_Functions.llParticleSystem(rules);
@@ -1453,9 +1335,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1453 m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); 1335 m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param);
1454 } 1336 }
1455 1337
1456 //
1457 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1458 //
1459 public void llOpenRemoteDataChannel() 1338 public void llOpenRemoteDataChannel()
1460 { 1339 {
1461 m_LSL_Functions.llOpenRemoteDataChannel(); 1340 m_LSL_Functions.llOpenRemoteDataChannel();
@@ -1590,9 +1469,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1590 return m_LSL_Functions.llGetPrimitiveParams(rules); 1469 return m_LSL_Functions.llGetPrimitiveParams(rules);
1591 } 1470 }
1592 1471
1593 //
1594 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1595 //
1596 public string llIntegerToBase64(int number) 1472 public string llIntegerToBase64(int number)
1597 { 1473 {
1598 return m_LSL_Functions.llIntegerToBase64(number); 1474 return m_LSL_Functions.llIntegerToBase64(number);
@@ -1698,9 +1574,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1698 return m_LSL_Functions.llModPow(a, b, c); 1574 return m_LSL_Functions.llModPow(a, b, c);
1699 } 1575 }
1700 1576
1701 //
1702 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1703 //
1704 public LSL_Types.LSLInteger llGetInventoryType(string name) 1577 public LSL_Types.LSLInteger llGetInventoryType(string name)
1705 { 1578 {
1706 return m_LSL_Functions.llGetInventoryType(name); 1579 return m_LSL_Functions.llGetInventoryType(name);
@@ -1826,9 +1699,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1826 return m_LSL_Functions.llGetObjectPrimCount(object_id); 1699 return m_LSL_Functions.llGetObjectPrimCount(object_id);
1827 } 1700 }
1828 1701
1829 //
1830 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1831 //
1832 public LSL_Types.LSLInteger llGetParcelMaxPrims(vector pos, int sim_wide) 1702 public LSL_Types.LSLInteger llGetParcelMaxPrims(vector pos, int sim_wide)
1833 { 1703 {
1834 return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); 1704 return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide);
@@ -1858,540 +1728,5 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1858 { 1728 {
1859 return m_LSL_Functions.llList2Float(src, index); 1729 return m_LSL_Functions.llList2Float(src, index);
1860 } 1730 }
1861
1862 // LSL CONSTANTS
1863 public const int TRUE = 1;
1864 public const int FALSE = 0;
1865
1866 public const int STATUS_PHYSICS = 1;
1867 public const int STATUS_ROTATE_X = 2;
1868 public const int STATUS_ROTATE_Y = 4;
1869 public const int STATUS_ROTATE_Z = 8;
1870 public const int STATUS_PHANTOM = 16;
1871 public const int STATUS_SANDBOX = 32;
1872 public const int STATUS_BLOCK_GRAB = 64;
1873 public const int STATUS_DIE_AT_EDGE = 128;
1874 public const int STATUS_RETURN_AT_EDGE = 256;
1875 public const int STATUS_CAST_SHADOWS = 512;
1876
1877 public const int AGENT = 1;
1878 public const int ACTIVE = 2;
1879 public const int PASSIVE = 4;
1880 public const int SCRIPTED = 8;
1881
1882 public const int CONTROL_FWD = 1;
1883 public const int CONTROL_BACK = 2;
1884 public const int CONTROL_LEFT = 4;
1885 public const int CONTROL_RIGHT = 8;
1886 public const int CONTROL_UP = 16;
1887 public const int CONTROL_DOWN = 32;
1888 public const int CONTROL_ROT_LEFT = 256;
1889 public const int CONTROL_ROT_RIGHT = 512;
1890 public const int CONTROL_LBUTTON = 268435456;
1891 public const int CONTROL_ML_LBUTTON = 1073741824;
1892
1893 //Permissions
1894 public const int PERMISSION_DEBIT = 2;
1895 public const int PERMISSION_TAKE_CONTROLS = 4;
1896 public const int PERMISSION_REMAP_CONTROLS = 8;
1897 public const int PERMISSION_TRIGGER_ANIMATION = 16;
1898 public const int PERMISSION_ATTACH = 32;
1899 public const int PERMISSION_RELEASE_OWNERSHIP = 64;
1900 public const int PERMISSION_CHANGE_LINKS = 128;
1901 public const int PERMISSION_CHANGE_JOINTS = 256;
1902 public const int PERMISSION_CHANGE_PERMISSIONS = 512;
1903 public const int PERMISSION_TRACK_CAMERA = 1024;
1904
1905 public const int AGENT_FLYING = 1;
1906 public const int AGENT_ATTACHMENTS = 2;
1907 public const int AGENT_SCRIPTED = 4;
1908 public const int AGENT_MOUSELOOK = 8;
1909 public const int AGENT_SITTING = 16;
1910 public const int AGENT_ON_OBJECT = 32;
1911 public const int AGENT_AWAY = 64;
1912 public const int AGENT_WALKING = 128;
1913 public const int AGENT_IN_AIR = 256;
1914 public const int AGENT_TYPING = 512;
1915 public const int AGENT_CROUCHING = 1024;
1916 public const int AGENT_BUSY = 2048;
1917 public const int AGENT_ALWAYS_RUN = 4096;
1918
1919 //Particle Systems
1920 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
1921 public const int PSYS_PART_INTERP_SCALE_MASK = 2;
1922 public const int PSYS_PART_BOUNCE_MASK = 4;
1923 public const int PSYS_PART_WIND_MASK = 8;
1924 public const int PSYS_PART_FOLLOW_SRC_MASK = 16;
1925 public const int PSYS_PART_FOLLOW_VELOCITY_MASK = 32;
1926 public const int PSYS_PART_TARGET_POS_MASK = 64;
1927 public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
1928 public const int PSYS_PART_EMISSIVE_MASK = 256;
1929 public const int PSYS_PART_FLAGS = 0;
1930 public const int PSYS_PART_START_COLOR = 1;
1931 public const int PSYS_PART_START_ALPHA = 2;
1932 public const int PSYS_PART_END_COLOR = 3;
1933 public const int PSYS_PART_END_ALPHA = 4;
1934 public const int PSYS_PART_START_SCALE = 5;
1935 public const int PSYS_PART_END_SCALE = 6;
1936 public const int PSYS_PART_MAX_AGE = 7;
1937 public const int PSYS_SRC_ACCEL = 8;
1938 public const int PSYS_SRC_PATTERN = 9;
1939 public const int PSYS_SRC_INNERANGLE = 10;
1940 public const int PSYS_SRC_OUTERANGLE = 11;
1941 public const int PSYS_SRC_TEXTURE = 12;
1942 public const int PSYS_SRC_BURST_RATE = 13;
1943 public const int PSYS_SRC_BURST_PART_COUNT = 15;
1944 public const int PSYS_SRC_BURST_RADIUS = 16;
1945 public const int PSYS_SRC_BURST_SPEED_MIN = 17;
1946 public const int PSYS_SRC_BURST_SPEED_MAX = 18;
1947 public const int PSYS_SRC_MAX_AGE = 19;
1948 public const int PSYS_SRC_TARGET_KEY = 20;
1949 public const int PSYS_SRC_OMEGA = 21;
1950 public const int PSYS_SRC_ANGLE_BEGIN = 22;
1951 public const int PSYS_SRC_ANGLE_END = 23;
1952 public const int PSYS_SRC_PATTERN_DROP = 1;
1953 public const int PSYS_SRC_PATTERN_EXPLODE = 2;
1954 public const int PSYS_SRC_PATTERN_ANGLE = 4;
1955 public const int PSYS_SRC_PATTERN_ANGLE_CONE = 8;
1956 public const int PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16;
1957
1958 public const int VEHICLE_TYPE_NONE = 0;
1959 public const int VEHICLE_TYPE_SLED = 1;
1960 public const int VEHICLE_TYPE_CAR = 2;
1961 public const int VEHICLE_TYPE_BOAT = 3;
1962 public const int VEHICLE_TYPE_AIRPLANE = 4;
1963 public const int VEHICLE_TYPE_BALLOON = 5;
1964 public const int VEHICLE_LINEAR_FRICTION_TIMESCALE = 16;
1965 public const int VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17;
1966 public const int VEHICLE_LINEAR_MOTOR_DIRECTION = 18;
1967 public const int VEHICLE_LINEAR_MOTOR_OFFSET = 20;
1968 public const int VEHICLE_ANGULAR_MOTOR_DIRECTION = 19;
1969 public const int VEHICLE_HOVER_HEIGHT = 24;
1970 public const int VEHICLE_HOVER_EFFICIENCY = 25;
1971 public const int VEHICLE_HOVER_TIMESCALE = 26;
1972 public const int VEHICLE_BUOYANCY = 27;
1973 public const int VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28;
1974 public const int VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29;
1975 public const int VEHICLE_LINEAR_MOTOR_TIMESCALE = 30;
1976 public const int VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31;
1977 public const int VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32;
1978 public const int VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33;
1979 public const int VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34;
1980 public const int VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35;
1981 public const int VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36;
1982 public const int VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37;
1983 public const int VEHICLE_BANKING_EFFICIENCY = 38;
1984 public const int VEHICLE_BANKING_MIX = 39;
1985 public const int VEHICLE_BANKING_TIMESCALE = 40;
1986 public const int VEHICLE_REFERENCE_FRAME = 44;
1987 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
1988 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
1989 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
1990 public const int VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 8;
1991 public const int VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 16;
1992 public const int VEHICLE_FLAG_HOVER_UP_ONLY = 32;
1993 public const int VEHICLE_FLAG_LIMIT_MOTOR_UP = 64;
1994 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
1995 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
1996 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
1997
1998 public const int INVENTORY_ALL = -1;
1999 public const int INVENTORY_NONE = -1;
2000 public const int INVENTORY_TEXTURE = 0;
2001 public const int INVENTORY_SOUND = 1;
2002 public const int INVENTORY_LANDMARK = 3;
2003 public const int INVENTORY_CLOTHING = 5;
2004 public const int INVENTORY_OBJECT = 6;
2005 public const int INVENTORY_NOTECARD = 7;
2006 public const int INVENTORY_SCRIPT = 10;
2007 public const int INVENTORY_BODYPART = 13;
2008 public const int INVENTORY_ANIMATION = 20;
2009 public const int INVENTORY_GESTURE = 21;
2010
2011 public const int ATTACH_CHEST = 1;
2012 public const int ATTACH_HEAD = 2;
2013 public const int ATTACH_LSHOULDER = 3;
2014 public const int ATTACH_RSHOULDER = 4;
2015 public const int ATTACH_LHAND = 5;
2016 public const int ATTACH_RHAND = 6;
2017 public const int ATTACH_LFOOT = 7;
2018 public const int ATTACH_RFOOT = 8;
2019 public const int ATTACH_BACK = 9;
2020 public const int ATTACH_PELVIS = 10;
2021 public const int ATTACH_MOUTH = 11;
2022 public const int ATTACH_CHIN = 12;
2023 public const int ATTACH_LEAR = 13;
2024 public const int ATTACH_REAR = 14;
2025 public const int ATTACH_LEYE = 15;
2026 public const int ATTACH_REYE = 16;
2027 public const int ATTACH_NOSE = 17;
2028 public const int ATTACH_RUARM = 18;
2029 public const int ATTACH_RLARM = 19;
2030 public const int ATTACH_LUARM = 20;
2031 public const int ATTACH_LLARM = 21;
2032 public const int ATTACH_RHIP = 22;
2033 public const int ATTACH_RULEG = 23;
2034 public const int ATTACH_RLLEG = 24;
2035 public const int ATTACH_LHIP = 25;
2036 public const int ATTACH_LULEG = 26;
2037 public const int ATTACH_LLLEG = 27;
2038 public const int ATTACH_BELLY = 28;
2039 public const int ATTACH_RPEC = 29;
2040 public const int ATTACH_LPEC = 30;
2041
2042 public const int LAND_LEVEL = 0;
2043 public const int LAND_RAISE = 1;
2044 public const int LAND_LOWER = 2;
2045 public const int LAND_SMOOTH = 3;
2046 public const int LAND_NOISE = 4;
2047 public const int LAND_REVERT = 5;
2048 public const int LAND_SMALL_BRUSH = 1;
2049 public const int LAND_MEDIUM_BRUSH = 2;
2050 public const int LAND_LARGE_BRUSH = 3;
2051
2052 //Agent Dataserver
2053 public const int DATA_ONLINE = 1;
2054 public const int DATA_NAME = 2;
2055 public const int DATA_BORN = 3;
2056 public const int DATA_RATING = 4;
2057 public const int DATA_SIM_POS = 5;
2058 public const int DATA_SIM_STATUS = 6;
2059 public const int DATA_SIM_RATING = 7;
2060 public const int DATA_PAYINFO = 8;
2061
2062 public const int ANIM_ON = 1;
2063 public const int LOOP = 2;
2064 public const int REVERSE = 4;
2065 public const int PING_PONG = 8;
2066 public const int SMOOTH = 16;
2067 public const int ROTATE = 32;
2068 public const int SCALE = 64;
2069 public const int ALL_SIDES = -1;
2070 public const int LINK_SET = -1;
2071 public const int LINK_ROOT = 1;
2072 public const int LINK_ALL_OTHERS = -2;
2073 public const int LINK_ALL_CHILDREN = -3;
2074 public const int LINK_THIS = -4;
2075 public const int CHANGED_INVENTORY = 1;
2076 public const int CHANGED_COLOR = 2;
2077 public const int CHANGED_SHAPE = 4;
2078 public const int CHANGED_SCALE = 8;
2079 public const int CHANGED_TEXTURE = 16;
2080 public const int CHANGED_LINK = 32;
2081 public const int CHANGED_ALLOWED_DROP = 64;
2082 public const int CHANGED_OWNER = 128;
2083 public const int CHANGED_REGION_RESTART = 256;
2084 public const int TYPE_INVALID = 0;
2085 public const int TYPE_INTEGER = 1;
2086 public const int TYPE_double = 2;
2087 public const int TYPE_STRING = 3;
2088 public const int TYPE_KEY = 4;
2089 public const int TYPE_VECTOR = 5;
2090 public const int TYPE_ROTATION = 6;
2091
2092 //XML RPC Remote Data Channel
2093 public const int REMOTE_DATA_CHANNEL = 1;
2094 public const int REMOTE_DATA_REQUEST = 2;
2095 public const int REMOTE_DATA_REPLY = 3;
2096
2097 //llHTTPRequest
2098 public const int HTTP_METHOD = 0;
2099 public const int HTTP_MIMETYPE = 1;
2100 public const int HTTP_BODY_MAXLENGTH = 2;
2101 public const int HTTP_VERIFY_CERT = 3;
2102
2103 public const int PRIM_MATERIAL = 2;
2104 public const int PRIM_PHYSICS = 3;
2105 public const int PRIM_TEMP_ON_REZ = 4;
2106 public const int PRIM_PHANTOM = 5;
2107 public const int PRIM_POSITION = 6;
2108 public const int PRIM_SIZE = 7;
2109 public const int PRIM_ROTATION = 8;
2110 public const int PRIM_TYPE = 9;
2111 public const int PRIM_TEXTURE = 17;
2112 public const int PRIM_COLOR = 18;
2113 public const int PRIM_BUMP_SHINY = 19;
2114 public const int PRIM_FULLBRIGHT = 20;
2115 public const int PRIM_FLEXIBLE = 21;
2116 public const int PRIM_TEXGEN = 22;
2117 public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
2118 public const int PRIM_POINT_LIGHT = 23; // Huh?
2119 public const int PRIM_TEXGEN_DEFAULT = 0;
2120 public const int PRIM_TEXGEN_PLANAR = 1;
2121
2122 public const int PRIM_TYPE_BOX = 0;
2123 public const int PRIM_TYPE_CYLINDER = 1;
2124 public const int PRIM_TYPE_PRISM = 2;
2125 public const int PRIM_TYPE_SPHERE = 3;
2126 public const int PRIM_TYPE_TORUS = 4;
2127 public const int PRIM_TYPE_TUBE = 5;
2128 public const int PRIM_TYPE_RING = 6;
2129 public const int PRIM_TYPE_SCULPT = 7;
2130
2131 public const int PRIM_HOLE_DEFAULT = 0;
2132 public const int PRIM_HOLE_CIRCLE = 16;
2133 public const int PRIM_HOLE_SQUARE = 32;
2134 public const int PRIM_HOLE_TRIANGLE = 48;
2135
2136 public const int PRIM_MATERIAL_STONE = 0;
2137 public const int PRIM_MATERIAL_METAL = 1;
2138 public const int PRIM_MATERIAL_GLASS = 2;
2139 public const int PRIM_MATERIAL_WOOD = 3;
2140 public const int PRIM_MATERIAL_FLESH = 4;
2141 public const int PRIM_MATERIAL_PLASTIC = 5;
2142 public const int PRIM_MATERIAL_RUBBER = 6;
2143 public const int PRIM_MATERIAL_LIGHT = 7;
2144
2145 public const int PRIM_SHINY_NONE = 0;
2146 public const int PRIM_SHINY_LOW = 1;
2147 public const int PRIM_SHINY_MEDIUM = 2;
2148 public const int PRIM_SHINY_HIGH = 3;
2149 public const int PRIM_BUMP_NONE = 0;
2150 public const int PRIM_BUMP_BRIGHT = 1;
2151 public const int PRIM_BUMP_DARK = 2;
2152 public const int PRIM_BUMP_WOOD = 3;
2153 public const int PRIM_BUMP_BARK = 4;
2154 public const int PRIM_BUMP_BRICKS = 5;
2155 public const int PRIM_BUMP_CHECKER = 6;
2156 public const int PRIM_BUMP_CONCRETE = 7;
2157 public const int PRIM_BUMP_TILE = 8;
2158 public const int PRIM_BUMP_STONE = 9;
2159 public const int PRIM_BUMP_DISKS = 10;
2160 public const int PRIM_BUMP_GRAVEL = 11;
2161 public const int PRIM_BUMP_BLOBS = 12;
2162 public const int PRIM_BUMP_SIDING = 13;
2163 public const int PRIM_BUMP_LARGETILE = 14;
2164 public const int PRIM_BUMP_STUCCO = 15;
2165 public const int PRIM_BUMP_SUCTION = 16;
2166 public const int PRIM_BUMP_WEAVE = 17;
2167
2168 public const int PRIM_SCULPT_TYPE_SPHERE = 1;
2169 public const int PRIM_SCULPT_TYPE_TORUS = 2;
2170 public const int PRIM_SCULPT_TYPE_PLANE = 3;
2171 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
2172
2173 public const int MASK_BASE = 0;
2174 public const int MASK_OWNER = 1;
2175 public const int MASK_GROUP = 2;
2176 public const int MASK_EVERYONE = 3;
2177 public const int MASK_NEXT = 4;
2178
2179 public const int PERM_TRANSFER = 8192;
2180 public const int PERM_MODIFY = 16384;
2181 public const int PERM_COPY = 32768;
2182 public const int PERM_MOVE = 524288;
2183 public const int PERM_ALL = 2147483647;
2184
2185 public const int PARCEL_MEDIA_COMMAND_STOP = 0;
2186 public const int PARCEL_MEDIA_COMMAND_PAUSE = 1;
2187 public const int PARCEL_MEDIA_COMMAND_PLAY = 2;
2188 public const int PARCEL_MEDIA_COMMAND_LOOP = 3;
2189 public const int PARCEL_MEDIA_COMMAND_TEXTURE = 4;
2190 public const int PARCEL_MEDIA_COMMAND_URL = 5;
2191 public const int PARCEL_MEDIA_COMMAND_TIME = 6;
2192 public const int PARCEL_MEDIA_COMMAND_AGENT = 7;
2193 public const int PARCEL_MEDIA_COMMAND_UNLOAD = 8;
2194 public const int PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
2195
2196 public const int PAY_HIDE = -1;
2197 public const int PAY_DEFAULT = -2;
2198
2199 public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
2200 public const string EOF = "\n\n\n";
2201 public const double PI = 3.14159274f;
2202 public const double TWO_PI = 6.28318548f;
2203 public const double PI_BY_TWO = 1.57079637f;
2204 public const double DEG_TO_RAD = 0.01745329238f;
2205 public const double RAD_TO_DEG = 57.29578f;
2206 public const double SQRT2 = 1.414213538f;
2207 public const int STRING_TRIM_HEAD = 1;
2208 public const int STRING_TRIM_TAIL = 2;
2209 public const int STRING_TRIM = 3;
2210 public const int LIST_STAT_RANGE = 0;
2211 public const int LIST_STAT_MIN = 1;
2212 public const int LIST_STAT_MAX = 2;
2213 public const int LIST_STAT_MEAN = 3;
2214 public const int LIST_STAT_MEDIAN = 4;
2215 public const int LIST_STAT_STD_DEV = 5;
2216 public const int LIST_STAT_SUM = 6;
2217 public const int LIST_STAT_SUM_SQUARES = 7;
2218 public const int LIST_STAT_NUM_COUNT = 8;
2219 public const int LIST_STAT_GEOMETRIC_MEAN = 9;
2220 public const int LIST_STAT_HARMONIC_MEAN = 100;
2221
2222 //ParcelPrim Categories
2223 public const int PARCEL_COUNT_TOTAL = 0;
2224 public const int PARCEL_COUNT_OWNER = 1;
2225 public const int PARCEL_COUNT_GROUP = 2;
2226 public const int PARCEL_COUNT_OTHER = 3;
2227 public const int PARCEL_COUNT_SELECTED = 4;
2228 public const int PARCEL_COUNT_TEMP = 5;
2229
2230 public const int DEBUG_CHANNEL = 0x7FFFFFFF;
2231 public const int PUBLIC_CHANNEL = 0x00000000;
2232
2233 public const int OBJECT_NAME = 1;
2234 public const int OBJECT_DESC = 2;
2235 public const int OBJECT_POS = 3;
2236 public const int OBJECT_ROT = 4;
2237 public const int OBJECT_VELOCITY = 5;
2238 public const int OBJECT_OWNER = 6;
2239 public const int OBJECT_GROUP = 7;
2240 public const int OBJECT_CREATOR = 8;
2241
2242 // Can not be public const?
2243 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
2244 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
2245
2246
2247 //
2248 // OSSL
2249 //
2250 // FIXME: Refactor so we don't need to pull the script engine
2251 // into the app domain
2252 //
2253
2254 public void osSetRegionWaterHeight(double height)
2255 {
2256 m_OSSL_Functions.osSetRegionWaterHeight(height);
2257 }
2258
2259 public double osList2Double(LSL_Types.list src, int index)
2260 {
2261 return m_OSSL_Functions.osList2Double(src, index);
2262 }
2263
2264 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
2265 int timer)
2266 {
2267 return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
2268 }
2269
2270 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
2271 int timer)
2272 {
2273 return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
2274 }
2275
2276 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
2277 int timer, int alpha)
2278 {
2279 return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
2280 }
2281
2282 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
2283 int timer, int alpha)
2284 {
2285 return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
2286 }
2287
2288 public double osTerrainGetHeight(int x, int y)
2289 {
2290 return m_OSSL_Functions.osTerrainGetHeight(x, y);
2291 }
2292
2293 public int osTerrainSetHeight(int x, int y, double val)
2294 {
2295 return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
2296 }
2297
2298 public int osRegionRestart(double seconds)
2299 {
2300 return m_OSSL_Functions.osRegionRestart(seconds);
2301 }
2302
2303 public void osRegionNotice(string msg)
2304 {
2305 m_OSSL_Functions.osRegionNotice(msg);
2306 }
2307
2308 public bool osConsoleCommand(string Command)
2309 {
2310 return m_OSSL_Functions.osConsoleCommand(Command);
2311 }
2312
2313 public void osSetParcelMediaURL(string url)
2314 {
2315 m_OSSL_Functions.osSetParcelMediaURL(url);
2316 }
2317
2318 public void osSetPrimFloatOnWater(int floatYN)
2319 {
2320 m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
2321 }
2322
2323 // Animation Functions
2324
2325 public void osAvatarPlayAnimation(string avatar, string animation)
2326 {
2327 m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
2328 }
2329
2330 public void osAvatarStopAnimation(string avatar, string animation)
2331 {
2332 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
2333 }
2334
2335
2336 //Texture Draw functions
2337
2338 public string osMovePen(string drawList, int x, int y)
2339 {
2340 return m_OSSL_Functions.osMovePen(drawList, x, y);
2341 }
2342
2343 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
2344 {
2345 return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
2346 }
2347
2348 public string osDrawLine(string drawList, int endX, int endY)
2349 {
2350 return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
2351 }
2352
2353 public string osDrawText(string drawList, string text)
2354 {
2355 return m_OSSL_Functions.osDrawText(drawList, text);
2356 }
2357
2358 public string osDrawEllipse(string drawList, int width, int height)
2359 {
2360 return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
2361 }
2362
2363 public string osDrawRectangle(string drawList, int width, int height)
2364 {
2365 return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
2366 }
2367
2368 public string osDrawFilledRectangle(string drawList, int width, int height)
2369 {
2370 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
2371 }
2372
2373 public string osSetFontSize(string drawList, int fontSize)
2374 {
2375 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
2376 }
2377
2378 public string osSetPenSize(string drawList, int penSize)
2379 {
2380 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
2381 }
2382
2383 public string osSetPenColour(string drawList, string colour)
2384 {
2385 return m_OSSL_Functions.osSetPenColour(drawList, colour);
2386 }
2387
2388 public string osDrawImage(string drawList, int width, int height, string imageUrl)
2389 {
2390 return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
2391 }
2392 public void osSetStateEvents(int events)
2393 {
2394 m_OSSL_Functions.osSetStateEvents(events);
2395 }
2396 } 1731 }
2397} 1732}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
new file mode 100644
index 0000000..168804d
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -0,0 +1,199 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.ScriptEngine.Interfaces;
36using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
37using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
38using key = System.String;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41
42namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
43{
44 public partial class ScriptBaseClass : MarshalByRefObject
45 {
46 public IOSSL_Api m_OSSL_Functions;
47
48 public void ApiTypeOSSL(IScriptApi api)
49 {
50 if(!(api is IOSSL_Api))
51 return;
52
53 m_OSSL_Functions = (IOSSL_Api)api;
54 }
55
56 public void osSetRegionWaterHeight(double height)
57 {
58 m_OSSL_Functions.osSetRegionWaterHeight(height);
59 }
60
61 public double osList2Double(LSL_Types.list src, int index)
62 {
63 return m_OSSL_Functions.osList2Double(src, index);
64 }
65
66 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
67 int timer)
68 {
69 return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
70 }
71
72 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
73 int timer)
74 {
75 return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
76 }
77
78 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
79 int timer, int alpha)
80 {
81 return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
82 }
83
84 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
85 int timer, int alpha)
86 {
87 return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
88 }
89
90 public double osTerrainGetHeight(int x, int y)
91 {
92 return m_OSSL_Functions.osTerrainGetHeight(x, y);
93 }
94
95 public int osTerrainSetHeight(int x, int y, double val)
96 {
97 return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
98 }
99
100 public int osRegionRestart(double seconds)
101 {
102 return m_OSSL_Functions.osRegionRestart(seconds);
103 }
104
105 public void osRegionNotice(string msg)
106 {
107 m_OSSL_Functions.osRegionNotice(msg);
108 }
109
110 public bool osConsoleCommand(string Command)
111 {
112 return m_OSSL_Functions.osConsoleCommand(Command);
113 }
114
115 public void osSetParcelMediaURL(string url)
116 {
117 m_OSSL_Functions.osSetParcelMediaURL(url);
118 }
119
120 public void osSetPrimFloatOnWater(int floatYN)
121 {
122 m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
123 }
124
125 // Animation Functions
126
127 public void osAvatarPlayAnimation(string avatar, string animation)
128 {
129 m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
130 }
131
132 public void osAvatarStopAnimation(string avatar, string animation)
133 {
134 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
135 }
136
137
138 //Texture Draw functions
139
140 public string osMovePen(string drawList, int x, int y)
141 {
142 return m_OSSL_Functions.osMovePen(drawList, x, y);
143 }
144
145 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
146 {
147 return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
148 }
149
150 public string osDrawLine(string drawList, int endX, int endY)
151 {
152 return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
153 }
154
155 public string osDrawText(string drawList, string text)
156 {
157 return m_OSSL_Functions.osDrawText(drawList, text);
158 }
159
160 public string osDrawEllipse(string drawList, int width, int height)
161 {
162 return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
163 }
164
165 public string osDrawRectangle(string drawList, int width, int height)
166 {
167 return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
168 }
169
170 public string osDrawFilledRectangle(string drawList, int width, int height)
171 {
172 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
173 }
174
175 public string osSetFontSize(string drawList, int fontSize)
176 {
177 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
178 }
179
180 public string osSetPenSize(string drawList, int penSize)
181 {
182 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
183 }
184
185 public string osSetPenColour(string drawList, string colour)
186 {
187 return m_OSSL_Functions.osSetPenColour(drawList, colour);
188 }
189
190 public string osDrawImage(string drawList, int width, int height, string imageUrl)
191 {
192 return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
193 }
194 public void osSetStateEvents(int events)
195 {
196 m_OSSL_Functions.osSetStateEvents(events);
197 }
198 }
199}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj
new file mode 100644
index 0000000..870da9f
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj
@@ -0,0 +1,161 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>9.0.21022</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{21BC44EA-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.ScriptEngine.Shared.Api.Runtime</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.ScriptEngine.Shared.Api.Runtime</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\..\..\..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="log4net.dll" >
70 <HintPath>..\..\..\..\..\..\bin\log4net.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Nini.dll" >
74 <HintPath>..\..\..\..\..\..\bin\Nini.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Nini.dll" >
78 <HintPath>..\..\..\..\..\..\bin\Nini.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="RAIL.dll" >
82 <HintPath>..\..\..\..\..\..\bin\RAIL.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="System" >
86 <HintPath>System.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 <Reference Include="System.Data" >
90 <HintPath>System.Data.dll</HintPath>
91 <Private>False</Private>
92 </Reference>
93 <Reference Include="System.Web" >
94 <HintPath>System.Web.dll</HintPath>
95 <Private>False</Private>
96 </Reference>
97 <Reference Include="System.Xml" >
98 <HintPath>System.Xml.dll</HintPath>
99 <Private>False</Private>
100 </Reference>
101 </ItemGroup>
102 <ItemGroup>
103 <ProjectReference Include="..\..\..\..\Application\OpenSim.csproj">
104 <Name>OpenSim</Name>
105 <Project>{438A9556-0000-0000-0000-000000000000}</Project>
106 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
107 <Private>False</Private>
108 </ProjectReference>
109 <ProjectReference Include="..\..\..\..\..\Framework\OpenSim.Framework.csproj">
110 <Name>OpenSim.Framework</Name>
111 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
112 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
113 <Private>False</Private>
114 </ProjectReference>
115 <ProjectReference Include="..\..\..\..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
116 <Name>OpenSim.Framework.Communications</Name>
117 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
118 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
119 <Private>False</Private>
120 </ProjectReference>
121 <ProjectReference Include="..\..\..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
122 <Name>OpenSim.Framework.Console</Name>
123 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
124 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
125 <Private>False</Private>
126 </ProjectReference>
127 <ProjectReference Include="..\..\..\..\Environment\OpenSim.Region.Environment.csproj">
128 <Name>OpenSim.Region.Environment</Name>
129 <Project>{DCBA491C-0000-0000-0000-000000000000}</Project>
130 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
131 <Private>False</Private>
132 </ProjectReference>
133 <ProjectReference Include="..\..\OpenSim.Region.ScriptEngine.Shared.csproj">
134 <Name>OpenSim.Region.ScriptEngine.Shared</Name>
135 <Project>{D9F1B557-0000-0000-0000-000000000000}</Project>
136 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
137 <Private>False</Private>
138 </ProjectReference>
139 </ItemGroup>
140 <ItemGroup>
141 <Compile Include="LSL_Constants.cs">
142 <SubType>Code</SubType>
143 </Compile>
144 <Compile Include="LSL_Stub.cs">
145 <SubType>Code</SubType>
146 </Compile>
147 <Compile Include="OSSL_Stub.cs">
148 <SubType>Code</SubType>
149 </Compile>
150 <Compile Include="ScriptBase.cs">
151 <SubType>Code</SubType>
152 </Compile>
153 </ItemGroup>
154 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
155 <PropertyGroup>
156 <PreBuildEvent>
157 </PreBuildEvent>
158 <PostBuildEvent>
159 </PostBuildEvent>
160 </PropertyGroup>
161</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user
new file mode 100644
index 0000000..c28f556
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\Data\OpenSim\bin\</ReferencePath>
6 <LastOpenVersion>9.0.21022</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build
new file mode 100644
index 0000000..c3af05c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build
@@ -0,0 +1,62 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}" flatten="true">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <copy todir="${project::get-base-directory()}/${build.dir}">
11 <fileset basedir=".">
12 </fileset>
13 </copy>
14 <csc target="library" debug="${build.debug}" unsafe="False" warnaserror="False" define="TRACE;DEBUG" main="" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
15 <resources prefix="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" dynamicprefix="true" >
16 </resources>
17 <sources failonempty="true">
18 <include name="LSL_Constants.cs" />
19 <include name="LSL_Stub.cs" />
20 <include name="OSSL_Stub.cs" />
21 <include name="ScriptBase.cs" />
22 </sources>
23 <references basedir="${project::get-base-directory()}">
24 <lib>
25 <include name="${project::get-base-directory()}" />
26 <include name="${project::get-base-directory()}/${build.dir}" />
27 </lib>
28 <include name="../../../../../../bin/Axiom.MathLib.dll" />
29 <include name="../../../../../../bin/libsecondlife.dll" />
30 <include name="../../../../../../bin/log4net.dll" />
31 <include name="../../../../../../bin/Nini.dll" />
32 <include name="../../../../../../bin/Nini.dll" />
33 <include name="../../../../../../bin/OpenSim.exe" />
34 <include name="../../../../../../bin/OpenSim.Framework.dll" />
35 <include name="../../../../../../bin/OpenSim.Framework.Communications.dll" />
36 <include name="../../../../../../bin/OpenSim.Framework.Console.dll" />
37 <include name="../../../../../../bin/OpenSim.Region.Environment.dll" />
38 <include name="../../../../../../bin/OpenSim.Region.ScriptEngine.Shared.dll" />
39 <include name="../../../../../../bin/RAIL.dll" />
40 <include name="System.dll" />
41 <include name="System.Data.dll" />
42 <include name="System.Web.dll" />
43 <include name="System.Xml.dll" />
44 </references>
45 </csc>
46 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../../../bin/" />
47 <mkdir dir="${project::get-base-directory()}/../../../../../../bin/"/>
48 <copy todir="${project::get-base-directory()}/../../../../../../bin/">
49 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
50 <include name="*.dll"/>
51 <include name="*.exe"/>
52 <include name="*.mdb"/>
53 </fileset>
54 </copy>
55 </target>
56 <target name="clean">
57 <delete dir="${obj.dir}" failonerror="false" />
58 <delete dir="${bin.dir}" failonerror="false" />
59 </target>
60 <target name="doc" description="Creates documentation.">
61 </target>
62</project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
new file mode 100644
index 0000000..37bedfc
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
@@ -0,0 +1,43 @@
1<Project name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" description="" standardNamespace="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" newfilesearch="None" enableviewstate="True" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4 <Output directory="./../../../../../../bin/" assembly="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
5 <Build debugmode="True" target="Library" />
6 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
7 <CodeGeneration compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="TRACE;DEBUG" generatexmldocumentation="False" win32Icon="" ctype="CSharpCompilerParameters" />
8 </Configuration>
9 <Configuration name="Release" ctype="DotNetProjectConfiguration">
10 <Output directory="./../../../../../../bin/" assembly="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
11 <Build debugmode="True" target="Library" />
12 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
13 <CodeGeneration compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="TRACE" generatexmldocumentation="False" win32Icon="" ctype="CSharpCompilerParameters" />
14 </Configuration>
15 </Configurations>
16 <DeploymentInformation target="" script="" strategy="File">
17 <excludeFiles />
18 </DeploymentInformation>
19 <Contents>
20 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
22 <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
23 <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
24 </Contents>
25 <References>
26 <ProjectReference type="Assembly" refto="../../../../../../bin/Axiom.MathLib.dll" localcopy="False" />
27 <ProjectReference type="Assembly" refto="../../../../../../bin/libsecondlife.dll" localcopy="False" />
28 <ProjectReference type="Assembly" refto="../../../../../../bin/log4net.dll" localcopy="False" />
29 <ProjectReference type="Assembly" refto="../../../../../../bin/Nini.dll" localcopy="False" />
30 <ProjectReference type="Assembly" refto="../../../../../../bin/Nini.dll" localcopy="False" />
31 <ProjectReference type="Project" localcopy="False" refto="OpenSim" />
32 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework" />
33 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework.Communications" />
34 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework.Console" />
35 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Region.Environment" />
36 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Region.ScriptEngine.Shared" />
37 <ProjectReference type="Assembly" refto="../../../../../../bin/RAIL.dll" localcopy="False" />
38 <ProjectReference type="Gac" localcopy="False" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
39 <ProjectReference type="Gac" localcopy="False" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
40 <ProjectReference type="Gac" localcopy="False" refto="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
41 <ProjectReference type="Gac" localcopy="False" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
42 </References>
43</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
new file mode 100644
index 0000000..aa2c9c2
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.ScriptEngine.Interfaces;
35using OpenSim.Region.ScriptEngine.Shared;
36
37namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
38{
39 public partial class ScriptBaseClass : MarshalByRefObject, IScript
40 {
41 private Dictionary<string,MethodInfo> inits = new Dictionary<string,MethodInfo>();
42
43 public ScriptBaseClass()
44 {
45 MethodInfo[] myArrayMethodInfo = GetType().GetMethods(BindingFlags.Public|BindingFlags.Instance);
46
47 foreach(MethodInfo mi in myArrayMethodInfo)
48 {
49 if(mi.Name.Length > 7 && mi.Name.Substring(0, 7) == "ApiType")
50 {
51 string type=mi.Name.Substring(7);
52 inits[type]=mi;
53 }
54 }
55 }
56
57 public string[] GetApis()
58 {
59 string[] apis = new string[inits.Count];
60 inits.Keys.CopyTo(apis, 0);
61 return apis;
62 }
63
64 public void InitApi(string api, IScriptApi data)
65 {
66 if(!inits.ContainsKey(api))
67 return;
68
69 MethodInfo mi = inits[api];
70
71 Object[] args = new Object[1];
72 args[0] = data;
73
74 mi.Invoke(this, args);
75 }
76
77 private Dictionary<string, object> m_InitialValues =
78 new Dictionary<string, object>();
79 private Dictionary<string, FieldInfo> m_Fields =
80 new Dictionary<string, FieldInfo>();
81
82 public Dictionary<string, object> GetVars()
83 {
84 Dictionary<string, object> vars = new Dictionary<string, object>();
85
86 if (m_Fields == null)
87 return vars;
88
89 m_Fields.Clear();
90
91 Type t = GetType();
92
93 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
94 BindingFlags.Public |
95 BindingFlags.Instance |
96 BindingFlags.DeclaredOnly);
97
98 foreach (FieldInfo field in fields)
99 {
100 m_Fields[field.Name]=field;
101
102 vars[field.Name]=field.GetValue(this);
103 }
104
105 return vars;
106 }
107
108 public void SetVars(Dictionary<string, object> vars)
109 {
110 foreach (KeyValuePair<string, object> var in vars)
111 {
112 if (m_Fields.ContainsKey(var.Key))
113 {
114 m_Fields[var.Key].SetValue(this, var.Value);
115 }
116 }
117 }
118
119 public void ResetVars()
120 {
121 SetVars(m_InitialValues);
122 }
123 }
124}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs
new file mode 100644
index 0000000..27ab04e
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs
@@ -0,0 +1,218 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33using System.Text;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 public class Atom : IUnifiable
38 {
39 private static Dictionary<string, Atom> _atomStore = new Dictionary<string, Atom>();
40 public readonly string _name;
41 public readonly Atom _module;
42
43 /// <summary>
44 /// You should not call this constructor, but use Atom.a instead.
45 /// </summary>
46 /// <param name="name"></param>
47 /// <param name="module"></param>
48 private Atom(string name, Atom module)
49 {
50 _name = name;
51 _module = module;
52 }
53
54 /// <summary>
55 /// Return the unique Atom object for name where module is null. You should use this to create
56 /// an Atom instead of calling the Atom constructor.
57 /// </summary>
58 /// <param name="name"></param>
59 /// <returns></returns>
60 public static Atom a(string name)
61 {
62 Atom atom;
63 if (!_atomStore.TryGetValue(name, out atom))
64 {
65 atom = new Atom(name, null);
66 _atomStore[name] = atom;
67 }
68 return atom;
69 }
70
71 /// <summary>
72 /// Return an Atom object with the name and module. If module is null or Atom.NIL,
73 /// this behaves like Atom.a(name) and returns the unique object where the module is null.
74 /// If module is not null or Atom.NIL, this may or may not be the same object as another Atom
75 /// with the same name and module.
76 /// </summary>
77 /// <param name="name"></param>
78 /// <param name="module"></param>
79 /// <returns></returns>
80 public static Atom a(string name, Atom module)
81 {
82 if (module == null || module == Atom.NIL)
83 return a(name);
84 return new Atom(name, module);
85 }
86
87 /// <summary>
88 /// If Obj is an Atom unify its _module with Module. If the Atom's _module is null, use Atom.NIL.
89 /// </summary>
90 /// <param name="Atom"></param>
91 /// <param name="Module"></param>
92 /// <returns></returns>
93 public static IEnumerable<bool> module(object Obj, object Module)
94 {
95 Obj = YP.getValue(Obj);
96 if (Obj is Atom)
97 {
98 if (((Atom)Obj)._module == null)
99 return YP.unify(Module, Atom.NIL);
100 else
101 return YP.unify(Module, ((Atom)Obj)._module);
102 }
103 return YP.fail();
104 }
105
106 public static readonly Atom NIL = Atom.a("[]");
107 public static readonly Atom DOT = Atom.a(".");
108 public static readonly Atom F = Atom.a("f");
109 public static readonly Atom SLASH = Atom.a("/");
110 public static readonly Atom HAT = Atom.a("^");
111 public static readonly Atom RULE = Atom.a(":-");
112
113 public IEnumerable<bool> unify(object arg)
114 {
115 arg = YP.getValue(arg);
116 if (arg is Atom)
117 return Equals(arg) ? YP.succeed() : YP.fail();
118 else if (arg is Variable)
119 return ((Variable)arg).unify(this);
120 else
121 return YP.fail();
122 }
123
124 public void addUniqueVariables(List<Variable> variableSet)
125 {
126 // Atom does not contain variables.
127 }
128
129 public object makeCopy(Variable.CopyStore copyStore)
130 {
131 // Atom does not contain variables that need to be copied.
132 return this;
133 }
134
135 public bool termEqual(object term)
136 {
137 return Equals(YP.getValue(term));
138 }
139
140 public bool ground()
141 {
142 // Atom is always ground.
143 return true;
144 }
145
146 public override bool Equals(object obj)
147 {
148 if (obj is Atom)
149 {
150 if (_module == null && ((Atom)obj)._module == null)
151 // When _declaringClass is null, we always use an identical object from _atomStore.
152 return this == obj;
153 // Otherwise, ignore _declaringClass and do a normal string compare on the _name.
154 return _name == ((Atom)obj)._name;
155 }
156 return false;
157 }
158
159 public override string ToString()
160 {
161 return _name;
162 }
163
164 public override int GetHashCode()
165 {
166 // Debug: need to check _declaringClass.
167 return _name.GetHashCode();
168 }
169
170 public string toQuotedString()
171 {
172 if (_name.Length == 0)
173 return "''";
174 else if (this == Atom.NIL)
175 return "[]";
176
177 StringBuilder result = new StringBuilder(_name.Length);
178 bool useQuotes = false;
179 foreach (char c in _name)
180 {
181 int cInt = (int)c;
182 if (c == '\'')
183 {
184 result.Append("''");
185 useQuotes = true;
186 }
187 else if (c == '_' || cInt >= (int)'a' && cInt <= (int)'z' ||
188 cInt >= (int)'A' && cInt <= (int)'Z' || cInt >= (int)'0' && cInt <= (int)'9')
189 result.Append(c);
190 else
191 {
192 // Debug: Need to handle non-printable chars.
193 result.Append(c);
194 useQuotes = true;
195 }
196 }
197
198 if (!useQuotes && (int)_name[0] >= (int)'a' && (int)_name[0] <= (int)'z')
199 return result.ToString();
200 else
201 {
202 // Surround in single quotes.
203 result.Append('\'');
204 return "'" + result;
205 }
206 }
207
208 /// <summary>
209 /// Return true if _name is lexicographically less than atom._name.
210 /// </summary>
211 /// <param name="atom"></param>
212 /// <returns></returns>
213 public bool lessThan(Atom atom)
214 {
215 return _name.CompareTo(atom._name) < 0;
216 }
217 }
218}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
new file mode 100644
index 0000000..70c1b5a
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
@@ -0,0 +1,234 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// A BagofAnswers holds answers for bagof and setof.
39 /// </summary>
40 public class BagofAnswers
41 {
42 private object _template;
43 private Variable[] _freeVariables;
44 private Dictionary<object[], List<object>> _bagForFreeVariables;
45 private List<object> _findallBagArray;
46 private static TermArrayEqualityComparer _termArrayEqualityComparer =
47 new TermArrayEqualityComparer();
48
49 /// <summary>
50 /// To get the free variables, split off any existential qualifiers from Goal such as the X in
51 /// "X ^ f(Y)", get the set of unbound variables in Goal that are not qualifiers, then remove
52 /// the unbound variables that are qualifiers as well as the unbound variables in Template.
53 /// </summary>
54 /// <param name="Template"></param>
55 /// <param name="Goal"></param>
56 public BagofAnswers(object Template, object Goal)
57 {
58 _template = Template;
59
60 // First get the set of variables that are not free variables.
61 List<Variable> variableSet = new List<Variable>();
62 YP.addUniqueVariables(Template, variableSet);
63 object UnqualifiedGoal = YP.getValue(Goal);
64 while (UnqualifiedGoal is Functor2 && ((Functor2)UnqualifiedGoal)._name == Atom.HAT)
65 {
66 YP.addUniqueVariables(((Functor2)UnqualifiedGoal)._arg1, variableSet);
67 UnqualifiedGoal = YP.getValue(((Functor2)UnqualifiedGoal)._arg2);
68 }
69
70 // Remember how many non-free variables there are so we can find the unique free variables
71 // that are added.
72 int nNonFreeVariables = variableSet.Count;
73 YP.addUniqueVariables(UnqualifiedGoal, variableSet);
74 int nFreeVariables = variableSet.Count - nNonFreeVariables;
75 if (nFreeVariables == 0)
76 {
77 // There were no free variables added, so we won't waste time with _bagForFreeVariables.
78 _freeVariables = null;
79 _findallBagArray = new List<object>();
80 }
81 else
82 {
83 // Copy the free variables.
84 _freeVariables = new Variable[nFreeVariables];
85 for (int i = 0; i < nFreeVariables; ++i)
86 _freeVariables[i] = variableSet[i + nNonFreeVariables];
87
88 _bagForFreeVariables = new Dictionary<object[], List<object>>(_termArrayEqualityComparer);
89 }
90 }
91
92 public void add()
93 {
94 if (_freeVariables == null)
95 // The goal has bound the values in _template but we don't bother with _freeVariables.
96 _findallBagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
97 else
98 {
99 // The goal has bound the values in _template and _freeVariables.
100 // Find the entry for this set of _freeVariables values.
101 object[] freeVariableValues = new object[_freeVariables.Length];
102 for (int i = 0; i < _freeVariables.Length; ++i)
103 freeVariableValues[i] = YP.getValue(_freeVariables[i]);
104 List<object> bagArray;
105 if (!_bagForFreeVariables.TryGetValue(freeVariableValues, out bagArray))
106 {
107 bagArray = new List<object>();
108 _bagForFreeVariables[freeVariableValues] = bagArray;
109 }
110
111 // Now copy the template and add to the bag for the freeVariables values.
112 bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
113 }
114 }
115
116 /// <summary>
117 /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag.
118 /// </summary>
119 /// <param name="bagArrayVariable">this is unified with the List<object> of matches for template that
120 /// corresponds to the bindings for freeVariables. Be very careful: this does not unify with a Prolog
121 /// list.</param>
122 /// <returns></returns>
123 public IEnumerable<bool> resultArray(Variable bagArrayVariable)
124 {
125 if (_freeVariables == null)
126 {
127 // No unbound free variables, so we only filled one bag. If empty, bagof fails.
128 if (_findallBagArray.Count > 0)
129 {
130 foreach (bool l1 in bagArrayVariable.unify(_findallBagArray))
131 yield return false;
132 }
133 }
134 else
135 {
136 foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables)
137 {
138 foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key))
139 {
140 foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value))
141 yield return false;
142 }
143 // Debug: Should we free memory of the answers already returned?
144 }
145 }
146 }
147
148 /// <summary>
149 /// For each result, unify the _freeVariables and unify Bag with the associated bag.
150 /// </summary>
151 /// <param name="Bag"></param>
152 /// <returns></returns>
153 public IEnumerable<bool> result(object Bag)
154 {
155 Variable bagArrayVariable = new Variable();
156 foreach (bool l1 in resultArray(bagArrayVariable))
157 {
158 foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue())))
159 yield return false;
160 }
161 }
162
163 /// <summary>
164 /// For each result, unify the _freeVariables and unify Bag with the associated bag which is sorted
165 /// with duplicates removed, as in setof.
166 /// </summary>
167 /// <param name="Bag"></param>
168 /// <returns></returns>
169 public IEnumerable<bool> resultSet(object Bag)
170 {
171 Variable bagArrayVariable = new Variable();
172 foreach (bool l1 in resultArray(bagArrayVariable))
173 {
174 List<object> bagArray = (List<object>)bagArrayVariable.getValue();
175 YP.sortArray(bagArray);
176 foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray)))
177 yield return false;
178 }
179 }
180
181 public static IEnumerable<bool> bagofArray
182 (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable)
183 {
184 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
185 foreach (bool l1 in goalIterator)
186 bagOfAnswers.add();
187 return bagOfAnswers.resultArray(bagArrayVariable);
188 }
189
190 public static IEnumerable<bool> bagof
191 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
192 {
193 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
194 foreach (bool l1 in goalIterator)
195 bagOfAnswers.add();
196 return bagOfAnswers.result(Bag);
197 }
198
199 public static IEnumerable<bool> setof
200 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
201 {
202 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
203 foreach (bool l1 in goalIterator)
204 bagOfAnswers.add();
205 return bagOfAnswers.resultSet(Bag);
206 }
207
208 /// <summary>
209 /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual.
210 /// </summary>
211 private class TermArrayEqualityComparer : IEqualityComparer<object[]>
212 {
213 public bool Equals(object[] array1, object[] array2)
214 {
215 if (array1.Length != array2.Length)
216 return false;
217 for (int i = 0; i < array1.Length; ++i)
218 {
219 if (!YP.termEqual(array1[i], array2[i]))
220 return false;
221 }
222 return true;
223 }
224
225 public int GetHashCode(object[] array)
226 {
227 int hashCode = 0;
228 for (int i = 0; i < array.Length; ++i)
229 hashCode ^= array[i].GetHashCode();
230 return hashCode;
231 }
232 }
233 }
234}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
new file mode 100644
index 0000000..28709e1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
@@ -0,0 +1,103 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// A FindallAnswers holds answers for findall.
39 /// </summary>
40 public class FindallAnswers
41 {
42 private object _template;
43 private List<object> _bagArray;
44
45 public FindallAnswers(object Template)
46 {
47 _template = Template;
48 _bagArray = new List<object>();
49 }
50
51 public void add()
52 {
53 _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
54 }
55
56 public List<object> resultArray()
57 {
58 return _bagArray;
59 }
60
61 /// <summary>
62 /// Unify Bag with the result. This frees the internal answers, so you can only call this once.
63 /// </summary>
64 /// <param name="Bag"></param>
65 /// <returns></returns>
66 public IEnumerable<bool> result(object Bag)
67 {
68 object result = ListPair.make(_bagArray);
69 // Try to free the memory.
70 _bagArray = null;
71 return YP.unify(Bag, result);
72 }
73
74 /// <summary>
75 /// This is a simplified findall when the goal is a single call.
76 /// </summary>
77 /// <param name="Template"></param>
78 /// <param name="goal"></param>
79 /// <param name="Bag"></param>
80 /// <returns></returns>
81 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
82 {
83 FindallAnswers findallAnswers = new FindallAnswers(Template);
84 foreach (bool l1 in goal)
85 findallAnswers.add();
86 return findallAnswers.result(Bag);
87 }
88
89 /// <summary>
90 /// Like findall, except return an array of the results.
91 /// </summary>
92 /// <param name="template"></param>
93 /// <param name="goal"></param>
94 /// <returns></returns>
95 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
96 {
97 FindallAnswers findallAnswers = new FindallAnswers(Template);
98 foreach (bool l1 in goal)
99 findallAnswers.add();
100 return findallAnswers.resultArray();
101 }
102 }
103}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
new file mode 100644
index 0000000..8ef8de0
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
@@ -0,0 +1,188 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object[] _args;
40
41 public Functor(Atom name, object[] args)
42 {
43 if (args.Length <= 3)
44 {
45 if (args.Length == 0)
46 throw new Exception("For arity 0 functor, just use name as an Atom");
47 else if (args.Length == 1)
48 throw new Exception("For arity 1 functor, use Functor1");
49 else if (args.Length == 2)
50 throw new Exception("For arity 2 functor, use Functor2");
51 else if (args.Length == 3)
52 throw new Exception("For arity 3 functor, use Functor3");
53 else
54 // (This shouldn't happen, but include it for completeness.
55 throw new Exception("Cannot create a Functor of arity " + args.Length);
56 }
57
58 _name = name;
59 _args = args;
60 }
61
62 public Functor(string name, object[] args)
63 : this(Atom.a(name), args)
64 {
65 }
66
67 /// <summary>
68 /// Return an Atom, Functor1, Functor2, Functor3 or Functor depending on the
69 /// length of args.
70 /// Note that this is different than the Functor constructor which requires
71 /// the length of args to be greater than 3.
72 /// </summary>
73 /// <param name="name"></param>
74 /// <param name="args"></param>
75 /// <returns></returns>
76 public static object make(Atom name, object[] args)
77 {
78 if (args.Length <= 0)
79 return name;
80 else if (args.Length == 1)
81 return new Functor1(name, args[0]);
82 else if (args.Length == 2)
83 return new Functor2(name, args[0], args[1]);
84 else if (args.Length == 3)
85 return new Functor3(name, args[0], args[1], args[2]);
86 else
87 return new Functor(name, args);
88 }
89
90 /// <summary>
91 /// Call the main make, first converting name to an Atom.
92 /// </summary>
93 /// <param name="name"></param>
94 /// <param name="args"></param>
95 /// <returns></returns>
96 public static object make(string name, object[] args)
97 {
98 return make(Atom.a(name), args);
99 }
100
101 public IEnumerable<bool> unify(object arg)
102 {
103 arg = YP.getValue(arg);
104 if (arg is Functor)
105 {
106 Functor argFunctor = (Functor)arg;
107 if (_name.Equals(argFunctor._name))
108 return YP.unifyArrays(_args, argFunctor._args);
109 else
110 return YP.fail();
111 }
112 else if (arg is Variable)
113 return ((Variable)arg).unify(this);
114 else
115 return YP.fail();
116 }
117
118 public override string ToString()
119 {
120 string result = _name + "(" + YP.getValue(_args[0]);
121 for (int i = 1; i < _args.Length; ++i)
122 result += ", " + YP.getValue(_args[i]);
123 result += ")";
124 return result;
125 }
126
127 public bool termEqual(object term)
128 {
129 term = YP.getValue(term);
130 if (term is Functor)
131 {
132 Functor termFunctor = (Functor)term;
133 if (_name.Equals(termFunctor._name) && _args.Length == termFunctor._args.Length)
134 {
135 for (int i = 0; i < _args.Length; ++i)
136 {
137 if (!YP.termEqual(_args[i], termFunctor._args[i]))
138 return false;
139 }
140 return true;
141 }
142 }
143 return false;
144 }
145
146 public bool lessThan(Functor functor)
147 {
148 // Do the equal check first since it is faster.
149 if (!_name.Equals(functor._name))
150 return _name.lessThan(functor._name);
151
152 if (_args.Length != functor._args.Length)
153 return _args.Length < functor._args.Length;
154
155 for (int i = 0; i < _args.Length; ++i)
156 {
157 if (!YP.termEqual(_args[i], functor._args[i]))
158 return YP.termLessThan(_args[i], functor._args[i]);
159 }
160
161 return false;
162 }
163
164 public bool ground()
165 {
166 for (int i = 0; i < _args.Length; ++i)
167 {
168 if (!YP.ground(_args[i]))
169 return false;
170 }
171 return true;
172 }
173
174 public void addUniqueVariables(List<Variable> variableSet)
175 {
176 for (int i = 0; i < _args.Length; ++i)
177 YP.addUniqueVariables(_args[i], variableSet);
178 }
179
180 public object makeCopy(Variable.CopyStore copyStore)
181 {
182 object[] argsCopy = new object[_args.Length];
183 for (int i = 0; i < _args.Length; ++i)
184 argsCopy[i] = YP.makeCopy(_args[i], copyStore);
185 return new Functor(_name, argsCopy);
186 }
187 }
188}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
new file mode 100644
index 0000000..3c0c1c4
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor1 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40
41 public Functor1(Atom name, object arg1)
42 {
43 _name = name;
44 _arg1 = arg1;
45 }
46
47 public Functor1(string name, object arg1)
48 : this(Atom.a(name), arg1)
49 {
50 }
51
52 public IEnumerable<bool> unify(object arg)
53 {
54 arg = YP.getValue(arg);
55 if (arg is Functor1)
56 {
57 Functor1 argFunctor = (Functor1)arg;
58 if (_name.Equals(argFunctor._name))
59 {
60 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
61 yield return false;
62 }
63 }
64 else if (arg is Variable)
65 {
66 foreach (bool l1 in ((Variable)arg).unify(this))
67 yield return false;
68 }
69 }
70
71 public override string ToString()
72 {
73 return _name + "(" + YP.getValue(_arg1) + ")";
74 }
75
76 public bool termEqual(object term)
77 {
78 term = YP.getValue(term);
79 if (term is Functor1)
80 {
81 Functor1 termFunctor = (Functor1)term;
82 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1);
83 }
84 return false;
85 }
86
87 public bool lessThan(Functor1 functor)
88 {
89 // Do the equal check first since it is faster.
90 if (!_name.Equals(functor._name))
91 return _name.lessThan(functor._name);
92
93 return YP.termLessThan(_arg1, functor._arg1);
94 }
95
96 public bool ground()
97 {
98 return YP.ground(_arg1);
99 }
100
101 public void addUniqueVariables(List<Variable> variableSet)
102 {
103 YP.addUniqueVariables(_arg1, variableSet);
104 }
105
106 public object makeCopy(Variable.CopyStore copyStore)
107 {
108 return new Functor1(_name, YP.makeCopy(_arg1, copyStore));
109 }
110 }
111}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
new file mode 100644
index 0000000..596b763
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
@@ -0,0 +1,154 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor2 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40 public readonly object _arg2;
41
42 public Functor2(Atom name, object arg1, object arg2)
43 {
44 _name = name;
45 _arg1 = arg1;
46 _arg2 = arg2;
47 }
48
49 public Functor2(string name, object arg1, object arg2)
50 : this(Atom.a(name), arg1, arg2)
51 {
52 }
53
54 public IEnumerable<bool> unify(object arg)
55 {
56 arg = YP.getValue(arg);
57 if (arg is Functor2)
58 {
59 Functor2 argFunctor = (Functor2)arg;
60 if (_name.Equals(argFunctor._name))
61 {
62 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
63 {
64 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
65 yield return false;
66 }
67 }
68 }
69 else if (arg is Variable)
70 {
71 foreach (bool l1 in ((Variable)arg).unify(this))
72 yield return false;
73 }
74 }
75
76 public override string ToString()
77 {
78 if (_name == Atom.DOT)
79 return listPairToString(this);
80 else
81 return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ")";
82 }
83
84 public bool termEqual(object term)
85 {
86 term = YP.getValue(term);
87 if (term is Functor2)
88 {
89 Functor2 termFunctor = (Functor2)term;
90 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1)
91 && YP.termEqual(_arg2, termFunctor._arg2);
92 }
93 return false;
94 }
95
96 public bool lessThan(Functor2 functor)
97 {
98 // Do the equal check first since it is faster.
99 if (!_name.Equals(functor._name))
100 return _name.lessThan(functor._name);
101
102 if (!YP.termEqual(_arg1, functor._arg1))
103 return YP.termLessThan(_arg1, functor._arg1);
104
105 return YP.termLessThan(_arg2, functor._arg2);
106 }
107
108 public bool ground()
109 {
110 return YP.ground(_arg1) && YP.ground(_arg2);
111 }
112
113 public void addUniqueVariables(List<Variable> variableSet)
114 {
115 YP.addUniqueVariables(_arg1, variableSet);
116 YP.addUniqueVariables(_arg2, variableSet);
117 }
118
119 public object makeCopy(Variable.CopyStore copyStore)
120 {
121 return new Functor2(_name, YP.makeCopy(_arg1, copyStore),
122 YP.makeCopy(_arg2, copyStore));
123 }
124
125 private static string listPairToString(Functor2 listPair)
126 {
127 string result = "[";
128 while (true)
129 {
130 object head = YP.getValue(listPair._arg1);
131 object tail = YP.getValue(listPair._arg2);
132 if (tail == (object)Atom.NIL)
133 {
134 result += head;
135 break;
136 }
137 else if (tail is Functor2 && ((Functor2)tail)._name == Atom.DOT)
138 {
139 result += head + ", ";
140 listPair = (Functor2)tail;
141 // Loop again.
142 }
143 else
144 {
145 // The list is not terminated with NIL.
146 result += head + "|" + tail;
147 break;
148 }
149 }
150 result += "]";
151 return result;
152 }
153 }
154}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
new file mode 100644
index 0000000..041cceb
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
@@ -0,0 +1,133 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor3 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40 public readonly object _arg2;
41 public readonly object _arg3;
42
43 public Functor3(Atom name, object arg1, object arg2, object arg3)
44 {
45 _name = name;
46 _arg1 = arg1;
47 _arg2 = arg2;
48 _arg3 = arg3;
49 }
50
51 public Functor3(string name, object arg1, object arg2, object arg3)
52 : this(Atom.a(name), arg1, arg2, arg3)
53 {
54 }
55
56 public IEnumerable<bool> unify(object arg)
57 {
58 arg = YP.getValue(arg);
59 if (arg is Functor3)
60 {
61 Functor3 argFunctor = (Functor3)arg;
62 if (_name.Equals(argFunctor._name))
63 {
64 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
65 {
66 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
67 {
68 foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3))
69 yield return false;
70 }
71 }
72 }
73 }
74 else if (arg is Variable)
75 {
76 foreach (bool l1 in ((Variable)arg).unify(this))
77 yield return false;
78 }
79 }
80
81 public override string ToString()
82 {
83 return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " +
84 YP.getValue(_arg3) + ")";
85 }
86
87 public bool termEqual(object term)
88 {
89 term = YP.getValue(term);
90 if (term is Functor3)
91 {
92 Functor3 termFunctor = (Functor3)term;
93 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1)
94 && YP.termEqual(_arg2, termFunctor._arg2)
95 && YP.termEqual(_arg3, termFunctor._arg3);
96 }
97 return false;
98 }
99
100 public bool lessThan(Functor3 functor)
101 {
102 // Do the equal check first since it is faster.
103 if (!_name.Equals(functor._name))
104 return _name.lessThan(functor._name);
105
106 if (!YP.termEqual(_arg1, functor._arg1))
107 return YP.termLessThan(_arg1, functor._arg1);
108
109 if (!YP.termEqual(_arg2, functor._arg2))
110 return YP.termLessThan(_arg2, functor._arg2);
111
112 return YP.termLessThan(_arg3, functor._arg3);
113 }
114
115 public bool ground()
116 {
117 return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3);
118 }
119
120 public void addUniqueVariables(List<Variable> variableSet)
121 {
122 YP.addUniqueVariables(_arg1, variableSet);
123 YP.addUniqueVariables(_arg2, variableSet);
124 YP.addUniqueVariables(_arg3, variableSet);
125 }
126
127 public object makeCopy(Variable.CopyStore copyStore)
128 {
129 return new Functor3(_name, YP.makeCopy(_arg1, copyStore),
130 YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore));
131 }
132 }
133}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
new file mode 100644
index 0000000..1be73f7
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
@@ -0,0 +1,288 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// An IndexedAnswers holds answers to a query based on the values of index arguments.
39 /// </summary>
40 public class IndexedAnswers : YP.IClause
41 {
42 // addAnswer adds the answer here and indexes it later.
43 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 // is a list of the matching answers. The signature is implicit in the pattern on non-null index args.
46 private Dictionary<HashedList, List<object[]>> _indexedAnswers =
47 new Dictionary<HashedList, List<object[]>>();
48 // Keeps track of whether we have started adding entries to _indexedAnswers for the signature.
49 private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>();
50 private const int MAX_INDEX_ARGS = 31;
51
52 public IndexedAnswers()
53 {
54 }
55
56 /// <summary>
57 /// Elements of answer must be ground, since arguments with unbound variables make this
58 /// into a dynamic rule which we don't index.
59 /// </summary>
60 /// <param name="answer"></param>
61 public void addAnswer(object[] answer)
62 {
63 // Store a copy of the answer array.
64 object[] answerCopy = new object[answer.Length];
65 Variable.CopyStore copyStore = new Variable.CopyStore();
66 for (int i = 0; i < answer.Length; ++i)
67 answerCopy[i] = YP.makeCopy(answer[i], copyStore);
68 if (copyStore.getNUniqueVariables() > 0)
69 throw new InvalidOperationException
70 ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() +
71 " unbound variables");
72 _allAnswers.Add(answerCopy);
73
74 // If match has already indexed answers for a signature, we need to add
75 // this to the existing indexed answers.
76 foreach (int signature in _gotAnswersForSignature.Keys)
77 indexAnswerForSignature(answerCopy, signature);
78 }
79
80 private void indexAnswerForSignature(object[] answer, int signature)
81 {
82 // First find out which of the answer values can be used as an index.
83 object[] indexValues = new object[answer.Length];
84 for (int i = 0; i < answer.Length; ++i)
85 {
86 // We limit the number of indexed args in a 32-bit signature.
87 if (i >= MAX_INDEX_ARGS)
88 indexValues[i] = null;
89 else
90 indexValues[i] = getIndexValue(YP.getValue(answer[i]));
91 }
92
93 // We need an entry in indexArgs from indexValues for each 1 bit in signature.
94 HashedList indexArgs = new HashedList(indexValues.Length);
95 for (int i = 0; i < indexValues.Length; ++i)
96 {
97 if ((signature & (1 << i)) == 0)
98 indexArgs.Add(null);
99 else
100 {
101 if (indexValues[i] == null)
102 // The signature wants an index value here, but we don't have one so
103 // we can't add it as an answer for this signature.
104 return;
105 else
106 indexArgs.Add(indexValues[i]);
107 }
108 }
109
110 // Add the answer to the answers list for indexArgs, creating the entry if needed.
111 List<object[]> answers;
112 if (!_indexedAnswers.TryGetValue(indexArgs, out answers))
113 {
114 answers = new List<object[]>();
115 _indexedAnswers[indexArgs] = answers;
116 }
117 answers.Add(answer);
118 }
119
120 public IEnumerable<bool> match(object[] arguments)
121 {
122 // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for
123 // each non-null index arg.
124 HashedList indexArgs = new HashedList(arguments.Length);
125 bool gotAllIndexArgs = true;
126 int signature = 0;
127 for (int i = 0; i < arguments.Length; ++i)
128 {
129 object indexValue = null;
130 if (i < MAX_INDEX_ARGS)
131 {
132 // We limit the number of args in a 32-bit signature.
133 indexValue = getIndexValue(YP.getValue(arguments[i]));
134 if (indexValue != null)
135 signature += (1 << i);
136 }
137 if (indexValue == null)
138 gotAllIndexArgs = false;
139 indexArgs.Add(indexValue);
140 }
141
142 List<object[]> answers;
143 if (signature == 0)
144 // No index args, so we have to match from _allAnswers.
145 answers = _allAnswers;
146 else
147 {
148 if (!_gotAnswersForSignature.ContainsKey(signature))
149 {
150 // We need to create the entry in _indexedAnswers.
151 foreach (object[] answer in _allAnswers)
152 indexAnswerForSignature(answer, signature);
153 // Mark that we did this signature.
154 _gotAnswersForSignature[signature] = null;
155 }
156 if (!_indexedAnswers.TryGetValue(indexArgs, out answers))
157 yield break;
158 }
159
160 if (gotAllIndexArgs)
161 {
162 // All the arguments were already bound, so we don't need to do bindings.
163 yield return false;
164 yield break;
165 }
166
167 // Find matches in answers.
168 IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length];
169 foreach (object[] answer in answers)
170 {
171 bool gotMatch = true;
172 int nIterators = 0;
173 // Try to bind all the arguments.
174 for (int i = 0; i < arguments.Length; ++i)
175 {
176 if (indexArgs[i] != null)
177 // We already matched this argument by looking up _indexedAnswers.
178 continue;
179
180 IEnumerator<bool> iterator = YP.unify(arguments[i], answer[i]).GetEnumerator();
181 iterators[nIterators++] = iterator;
182 // MoveNext() is true if YP.unify succeeds.
183 if (!iterator.MoveNext())
184 {
185 gotMatch = false;
186 break;
187 }
188 }
189
190 try
191 {
192 if (gotMatch)
193 yield return false;
194 }
195 finally
196 {
197 // Manually finalize all the iterators.
198 for (int i = 0; i < nIterators; ++i)
199 iterators[i].Dispose();
200 }
201 }
202 }
203
204 /// <summary>
205 /// A HashedList extends an ArrayList with methods to get a hash and to check equality
206 /// based on the elements of the list.
207 /// </summary>
208 public class HashedList : ArrayList
209 {
210 private bool _gotHashCode = false;
211 private int _hashCode;
212
213 public HashedList()
214 : base()
215 {
216 }
217
218 public HashedList(int capacity)
219 : base(capacity)
220 {
221 }
222
223 public HashedList(ICollection c)
224 : base(c)
225 {
226 }
227
228 // Debug: Should override all the other methods that change this.
229 public override int Add(object value)
230 {
231 _gotHashCode = false;
232 return base.Add(value);
233 }
234
235 public override int GetHashCode()
236 {
237 if (!_gotHashCode)
238 {
239 int hashCode = 1;
240 foreach (object obj in this)
241 hashCode = 31 * hashCode + (obj == null ? 0 : obj.GetHashCode());
242 _hashCode = hashCode;
243 _gotHashCode = true;
244 }
245 return _hashCode;
246 }
247
248 public override bool Equals(object obj)
249 {
250 if (!(obj is ArrayList))
251 return false;
252
253 ArrayList objList = (ArrayList)obj;
254 if (objList.Count != Count)
255 return false;
256
257 for (int i = 0; i < Count; ++i)
258 {
259 object value = objList[i];
260 if (value == null)
261 {
262 if (this[i] != null)
263 return false;
264 }
265 else
266 {
267 if (!value.Equals(this[i]))
268 return false;
269 }
270 }
271 return true;
272 }
273 }
274
275 /// <summary>
276 /// If we keep an index on value, return the value, or null if we don't index it.
277 /// </summary>
278 /// <param name="value">the term to examine. Assume you already called YP.getValue(value)</param>
279 /// <returns></returns>
280 public static object getIndexValue(object value)
281 {
282 if (value is Atom || value is string || value is Int32 || value is DateTime)
283 return value;
284 else
285 return null;
286 }
287 }
288}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
new file mode 100644
index 0000000..83ace2d
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
@@ -0,0 +1,156 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class ListPair : Functor2
37 {
38 public ListPair(object head, object tail) : base(Atom.DOT, head, tail)
39 {
40 }
41
42 public static object make(List<object> list)
43 {
44 if (list.Count <= 0)
45 return Atom.NIL;
46
47 object result = Atom.NIL;
48 // Start from the end.
49 for (int i = list.Count - 1; i >= 0; --i)
50 result = new ListPair(list[i], result);
51 return result;
52 }
53
54 public static object make(object[] array)
55 {
56 if (array.Length <= 0)
57 return Atom.NIL;
58
59 object result = Atom.NIL;
60 // Start from the end.
61 for (int i = array.Length - 1; i >= 0; --i)
62 result = new ListPair(array[i], result);
63 return result;
64 }
65
66 /// <summary>
67 /// Return a ListPair version of array, where repeated elements
68 /// (according to YP.termEqual) are removed.
69 /// </summary>
70 /// <param name="array"></param>
71 /// <returns></returns>
72 public static object makeWithoutRepeatedTerms(object[] array)
73 {
74 if (array.Length <= 0)
75 return Atom.NIL;
76
77 // Start from the end.
78 object previousTerm = array[array.Length - 1];
79 object result = new ListPair(previousTerm, Atom.NIL);
80 for (int i = array.Length - 2; i >= 0; --i)
81 {
82 object term = array[i];
83 if (YP.termEqual(term, previousTerm))
84 continue;
85 result = new ListPair(term, result);
86 previousTerm = term;
87 }
88 return result;
89 }
90
91 /// <summary>
92 /// Return a ListPair version of array, where repeated elements
93 /// (according to YP.termEqual) are removed.
94 /// </summary>
95 /// <param name="array"></param>
96 /// <returns></returns>
97 public static object makeWithoutRepeatedTerms(List<object> array)
98 {
99 if (array.Count <= 0)
100 return Atom.NIL;
101
102 // Start from the end.
103 object previousTerm = array[array.Count - 1];
104 object result = new ListPair(previousTerm, Atom.NIL);
105 for (int i = array.Count - 2; i >= 0; --i)
106 {
107 object term = array[i];
108 if (YP.termEqual(term, previousTerm))
109 continue;
110 result = new ListPair(term, result);
111 previousTerm = term;
112 }
113 return result;
114 }
115
116 public static object make(object element1)
117 {
118 return new ListPair(element1, Atom.NIL);
119 }
120
121 public static object make(object element1, object element2)
122 {
123 return new ListPair(element1, new ListPair(element2, Atom.NIL));
124 }
125
126 public static object make(object element1, object element2, object element3)
127 {
128 return new ListPair(element1,
129 new ListPair(element2, new ListPair(element3, Atom.NIL)));
130 }
131
132 /// <summary>
133 /// Return an array of the elements in list or null if it is not
134 /// a proper list. If list is Atom.NIL, return an array of zero elements.
135 /// This does not call YP.getValue on each element.
136 /// </summary>
137 /// <param name="list"></param>
138 /// <returns></returns>
139 public static object[] toArray(object list)
140 {
141 list = YP.getValue(list);
142 if (list.Equals(Atom.NIL))
143 return new object[0];
144
145 List<object> result = new List<object>();
146 for (object element = list;
147 element is Functor2 && ((Functor2)element)._name == Atom.DOT;
148 element = YP.getValue(((Functor2)element)._arg2))
149 result.Add(((Functor2)element)._arg1);
150
151 if (result.Count <= 0)
152 return null;
153 return result.ToArray();
154 }
155 }
156}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
new file mode 100644
index 0000000..105b556
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
@@ -0,0 +1,4457 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Parser
37 {
38 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
39 {
40 // Debug: Simple implementation for now.
41 YP.write(Format);
42 YP.write(Arguments);
43 YP.nl();
44 yield return false;
45 }
46
47 // Debug: Hand-modify this central predicate to do tail recursion.
48 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
49 {
50 bool repeat = true;
51 while (repeat)
52 {
53 repeat = false;
54 {
55 object C1 = arg1;
56 object Dict = arg2;
57 object Tokens = arg3;
58 Variable C2 = new Variable();
59 if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
60 {
61 if (YP.greaterThanOrEqual(C1, 0))
62 {
63 foreach (bool l4 in YP.get_code(C2))
64 {
65#if false
66 foreach (bool l5 in read_tokens(C2, Dict, Tokens))
67 {
68 yield return false;
69 }
70#endif
71 arg1 = YP.getValue(C2);
72 arg2 = YP.getValue(Dict);
73 arg3 = YP.getValue(Tokens);
74 repeat = true;
75 }
76 }
77 goto cutIf1;
78 }
79 if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
80 {
81 if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
82 {
83 foreach (bool l4 in read_identifier(C1, Dict, Tokens))
84 {
85 yield return false;
86 }
87 goto cutIf2;
88 }
89 }
90 if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
91 {
92 if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
93 {
94 foreach (bool l4 in read_variable(C1, Dict, Tokens))
95 {
96 yield return false;
97 }
98 goto cutIf3;
99 }
100 }
101 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
102 {
103 if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
104 {
105 foreach (bool l4 in read_number(C1, Dict, Tokens))
106 {
107 yield return false;
108 }
109 goto cutIf4;
110 }
111 }
112 if (YP.lessThan(C1, 127))
113 {
114 foreach (bool l3 in read_special(C1, Dict, Tokens))
115 {
116 yield return false;
117 }
118 goto cutIf5;
119 }
120 if (YP.lessThanOrEqual(C1, 160))
121 {
122 foreach (bool l3 in YP.get_code(C2))
123 {
124#if false
125 foreach (bool l4 in read_tokens(C2, Dict, Tokens))
126 {
127 yield return false;
128 }
129#endif
130 arg1 = YP.getValue(C2);
131 arg2 = YP.getValue(Dict);
132 arg3 = YP.getValue(Tokens);
133 repeat = true;
134 }
135 goto cutIf6;
136 }
137 if (YP.greaterThanOrEqual(C1, 223))
138 {
139 if (YP.notEqual(C1, 247))
140 {
141 foreach (bool l4 in read_identifier(C1, Dict, Tokens))
142 {
143 yield return false;
144 }
145 goto cutIf7;
146 }
147 }
148 if (YP.greaterThanOrEqual(C1, 192))
149 {
150 if (YP.notEqual(C1, 215))
151 {
152 foreach (bool l4 in read_variable(C1, Dict, Tokens))
153 {
154 yield return false;
155 }
156 goto cutIf8;
157 }
158 }
159 if (YP.notEqual(C1, 170))
160 {
161 if (YP.notEqual(C1, 186))
162 {
163 foreach (bool l4 in read_symbol(C1, Dict, Tokens))
164 {
165 yield return false;
166 }
167 goto cutIf9;
168 }
169 }
170 foreach (bool l2 in read_identifier(C1, Dict, Tokens))
171 {
172 yield return false;
173 }
174 cutIf9:
175 cutIf8:
176 cutIf7:
177 cutIf6:
178 cutIf5:
179 cutIf4:
180 cutIf3:
181 cutIf2:
182 cutIf1:
183 { }
184 }
185 }
186 }
187
188 // Compiler output follows.
189
190 class YPInnerClass { }
191 static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
192
193 public static IEnumerable<bool> parseInput(object TermList)
194 {
195 {
196 Variable TermAndVariables = new Variable();
197 FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
198 foreach (bool l2 in parseInputHelper(TermAndVariables))
199 {
200 findallAnswers1.add();
201 }
202 foreach (bool l2 in findallAnswers1.result(TermList))
203 {
204 yield return false;
205 }
206 }
207 }
208
209 public static IEnumerable<bool> parseInputHelper(object arg1)
210 {
211 {
212 Variable Term = new Variable();
213 Variable Variables = new Variable();
214 Variable Answer = new Variable();
215 Variable x4 = new Variable();
216 foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables)))
217 {
218 foreach (bool l3 in YP.repeat())
219 {
220 foreach (bool l4 in portable_read3(Answer, Variables, x4))
221 {
222 foreach (bool l5 in remove_pos(Answer, Term))
223 {
224 if (YP.termEqual(Term, Atom.a(@"end_of_file")))
225 {
226 yield break;
227 goto cutIf1;
228 }
229 yield return false;
230 cutIf1:
231 { }
232 }
233 }
234 }
235 }
236 }
237 }
238
239 public static IEnumerable<bool> clear_errors()
240 {
241 {
242 yield return false;
243 }
244 }
245
246 public static IEnumerable<bool> remove_pos(object arg1, object arg2)
247 {
248 {
249 Variable X = new Variable();
250 foreach (bool l2 in YP.unify(arg1, X))
251 {
252 foreach (bool l3 in YP.unify(arg2, X))
253 {
254 if (YP.var(X))
255 {
256 yield return true;
257 yield break;
258 }
259 }
260 }
261 }
262 {
263 object X = arg2;
264 Variable _Pos = new Variable();
265 Variable _Name = new Variable();
266 foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X)))
267 {
268 if (YP.var(X))
269 {
270 yield return true;
271 yield break;
272 }
273 }
274 }
275 {
276 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
277 {
278 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
279 {
280 yield return true;
281 yield break;
282 }
283 }
284 }
285 {
286 Variable H = new Variable();
287 Variable T = new Variable();
288 Variable NH = new Variable();
289 Variable NT = new Variable();
290 foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
291 {
292 foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT)))
293 {
294 foreach (bool l4 in remove_pos(H, NH))
295 {
296 foreach (bool l5 in remove_pos(T, NT))
297 {
298 yield return false;
299 }
300 }
301 yield break;
302 }
303 }
304 }
305 {
306 Variable A = new Variable();
307 Variable B = new Variable();
308 Variable NA = new Variable();
309 Variable NB = new Variable();
310 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
311 {
312 foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB)))
313 {
314 foreach (bool l4 in remove_pos(A, NA))
315 {
316 foreach (bool l5 in remove_pos(B, NB))
317 {
318 yield return false;
319 }
320 }
321 yield break;
322 }
323 }
324 }
325 {
326 Variable Atom_1 = new Variable();
327 Variable _F = new Variable();
328 foreach (bool l2 in YP.unify(arg1, Atom_1))
329 {
330 foreach (bool l3 in YP.unify(arg2, Atom_1))
331 {
332 foreach (bool l4 in YP.functor(Atom_1, _F, 0))
333 {
334 yield return false;
335 }
336 }
337 }
338 }
339 {
340 object Term = arg1;
341 object NewTerm = arg2;
342 Variable Func = new Variable();
343 Variable _Pos = new Variable();
344 Variable Args = new Variable();
345 Variable NArgs = new Variable();
346 if (YP.nonvar(Term))
347 {
348 foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args))))
349 {
350 foreach (bool l4 in remove_pos(Args, NArgs))
351 {
352 foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs)))
353 {
354 yield return false;
355 }
356 }
357 }
358 }
359 }
360 }
361
362 public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax)
363 {
364 {
365 foreach (bool l2 in portable_read(PosTerm, Syntax))
366 {
367 foreach (bool l3 in remove_pos(PosTerm, Term))
368 {
369 yield return false;
370 }
371 }
372 }
373 }
374
375 public static IEnumerable<bool> portable_read(object Answer, object Syntax)
376 {
377 {
378 Variable Tokens = new Variable();
379 Variable ParseTokens = new Variable();
380 foreach (bool l2 in read_tokens1(Tokens))
381 {
382 foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
383 {
384 foreach (bool l4 in parse2(ParseTokens, Answer))
385 {
386 yield return false;
387 }
388 }
389 }
390 }
391 }
392
393 public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax)
394 {
395 {
396 Variable Tokens = new Variable();
397 Variable ParseTokens = new Variable();
398 foreach (bool l2 in read_tokens2(Tokens, Variables))
399 {
400 foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
401 {
402 foreach (bool l4 in parse2(ParseTokens, Answer))
403 {
404 yield return false;
405 }
406 }
407 }
408 }
409 }
410
411 public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3)
412 {
413 {
414 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
415 {
416 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
417 {
418 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
419 {
420 yield return false;
421 }
422 }
423 }
424 }
425 {
426 object Ys = arg2;
427 Variable S = new Variable();
428 Variable E = new Variable();
429 Variable Xs = new Variable();
430 Variable Zs = new Variable();
431 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs)))
432 {
433 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs)))
434 {
435 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
436 {
437 yield return false;
438 }
439 yield break;
440 }
441 }
442 }
443 {
444 Variable Pos = new Variable();
445 Variable Xs = new Variable();
446 Variable Ys = new Variable();
447 Variable Pos2 = new Variable();
448 Variable Zs = new Variable();
449 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs)))
450 {
451 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys)))
452 {
453 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs)))
454 {
455 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
456 {
457 foreach (bool l6 in remove_comments(Xs, Ys, Zs))
458 {
459 yield return false;
460 }
461 }
462 yield break;
463 }
464 }
465 }
466 }
467 {
468 Variable Pos = new Variable();
469 Variable Xs = new Variable();
470 Variable Ys = new Variable();
471 Variable Pos2 = new Variable();
472 Variable Zs = new Variable();
473 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs)))
474 {
475 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys)))
476 {
477 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs)))
478 {
479 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
480 {
481 foreach (bool l6 in remove_comments(Xs, Ys, Zs))
482 {
483 yield return false;
484 }
485 }
486 yield break;
487 }
488 }
489 }
490 }
491 {
492 object Zs = arg3;
493 Variable Token = new Variable();
494 Variable Xs = new Variable();
495 Variable Ys = new Variable();
496 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs)))
497 {
498 foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys)))
499 {
500 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
501 {
502 yield return false;
503 }
504 }
505 }
506 }
507 }
508
509 public static IEnumerable<bool> expect(object Token, object arg2, object arg3)
510 {
511 {
512 object Rest = arg3;
513 foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest)))
514 {
515 yield return true;
516 yield break;
517 }
518 }
519 {
520 object S0 = arg2;
521 object x3 = arg3;
522 foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"or"), new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), Atom.NIL)))), S0))
523 {
524 yield return false;
525 }
526 }
527 }
528
529 public static IEnumerable<bool> parse2(object Tokens, object Answer)
530 {
531 {
532 Variable Term = new Variable();
533 Variable LeftOver = new Variable();
534 foreach (bool l2 in clear_errors())
535 {
536 foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver))
537 {
538 foreach (bool l4 in all_read(LeftOver))
539 {
540 foreach (bool l5 in YP.unify(Answer, Term))
541 {
542 yield return false;
543 }
544 yield break;
545 }
546 }
547 foreach (bool l3 in syntax_error(Tokens))
548 {
549 yield return false;
550 }
551 }
552 }
553 }
554
555 public static IEnumerable<bool> all_read(object arg1)
556 {
557 {
558 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
559 {
560 yield return false;
561 }
562 }
563 {
564 Variable Token = new Variable();
565 Variable S = new Variable();
566 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
567 {
568 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"after"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(Token, S)))
569 {
570 yield return false;
571 }
572 }
573 }
574 }
575
576 public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4)
577 {
578 {
579 object x1 = arg2;
580 object x2 = arg3;
581 object x3 = arg4;
582 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
583 {
584 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL))
585 {
586 yield return false;
587 }
588 }
589 }
590 {
591 object Precedence = arg2;
592 object Term = arg3;
593 object LeftOver = arg4;
594 Variable Token = new Variable();
595 Variable RestTokens = new Variable();
596 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens)))
597 {
598 foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver))
599 {
600 yield return false;
601 }
602 }
603 }
604 }
605
606 public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5)
607 {
608 {
609 object S0 = arg2;
610 object x2 = arg3;
611 object x3 = arg4;
612 object x4 = arg5;
613 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
614 {
615 foreach (bool l3 in cannot_start(Atom.a(@"}"), S0))
616 {
617 yield return false;
618 }
619 }
620 }
621 {
622 object S0 = arg2;
623 object x2 = arg3;
624 object x3 = arg4;
625 object x4 = arg5;
626 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
627 {
628 foreach (bool l3 in cannot_start(Atom.a(@"]"), S0))
629 {
630 yield return false;
631 }
632 }
633 }
634 {
635 object S0 = arg2;
636 object x2 = arg3;
637 object x3 = arg4;
638 object x4 = arg5;
639 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
640 {
641 foreach (bool l3 in cannot_start(Atom.a(@")"), S0))
642 {
643 yield return false;
644 }
645 }
646 }
647 {
648 object S0 = arg2;
649 object x2 = arg3;
650 object x3 = arg4;
651 object x4 = arg5;
652 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
653 {
654 foreach (bool l3 in cannot_start(Atom.a(@","), S0))
655 {
656 yield return false;
657 }
658 }
659 }
660 {
661 object S0 = arg2;
662 object x2 = arg3;
663 object x3 = arg4;
664 object x4 = arg5;
665 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
666 {
667 foreach (bool l3 in cannot_start(Atom.a(@"|"), S0))
668 {
669 yield return false;
670 }
671 }
672 }
673 {
674 object S0 = arg2;
675 object Precedence = arg3;
676 object Answer = arg4;
677 object S = arg5;
678 Variable Chars = new Variable();
679 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars)))
680 {
681 foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S))
682 {
683 yield return false;
684 }
685 }
686 }
687 {
688 object S0 = arg2;
689 object Precedence = arg3;
690 object Answer = arg4;
691 object S = arg5;
692 Variable Number = new Variable();
693 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number)))
694 {
695 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
696 {
697 yield return false;
698 }
699 }
700 }
701 {
702 object Precedence = arg3;
703 object Answer = arg4;
704 object S = arg5;
705 Variable S1 = new Variable();
706 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
707 {
708 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1)))
709 {
710 foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S))
711 {
712 yield return false;
713 }
714 yield break;
715 }
716 }
717 }
718 {
719 object S1 = arg2;
720 object Precedence = arg3;
721 object Answer = arg4;
722 object S = arg5;
723 Variable Arg1 = new Variable();
724 Variable S2 = new Variable();
725 Variable RestArgs = new Variable();
726 Variable S3 = new Variable();
727 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
728 {
729 foreach (bool l3 in parse(S1, 999, Arg1, S2))
730 {
731 foreach (bool l4 in read_list(S2, RestArgs, S3))
732 {
733 foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S))
734 {
735 yield return false;
736 }
737 yield break;
738 }
739 }
740 }
741 }
742 {
743 object S1 = arg2;
744 object Precedence = arg3;
745 object Answer = arg4;
746 object S = arg5;
747 Variable Term = new Variable();
748 Variable S2 = new Variable();
749 Variable S3 = new Variable();
750 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
751 {
752 foreach (bool l3 in parse(S1, 1200, Term, S2))
753 {
754 foreach (bool l4 in expect(Atom.a(@")"), S2, S3))
755 {
756 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
757 {
758 yield return false;
759 }
760 yield break;
761 }
762 }
763 }
764 }
765 {
766 object S1 = arg2;
767 object Precedence = arg3;
768 object Answer = arg4;
769 object S = arg5;
770 Variable Term = new Variable();
771 Variable S2 = new Variable();
772 Variable S3 = new Variable();
773 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
774 {
775 foreach (bool l3 in parse(S1, 1200, Term, S2))
776 {
777 foreach (bool l4 in expect(Atom.a(@")"), S2, S3))
778 {
779 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
780 {
781 yield return false;
782 }
783 yield break;
784 }
785 }
786 }
787 }
788 {
789 object Precedence = arg3;
790 object Answer = arg4;
791 object S = arg5;
792 Variable _Pos = new Variable();
793 Variable S1 = new Variable();
794 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos)))
795 {
796 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1)))
797 {
798 foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S))
799 {
800 yield return false;
801 }
802 yield break;
803 }
804 }
805 }
806 {
807 object S1 = arg2;
808 object Precedence = arg3;
809 object Answer = arg4;
810 object S = arg5;
811 Variable Pos = new Variable();
812 Variable Term = new Variable();
813 Variable S2 = new Variable();
814 Variable S3 = new Variable();
815 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos)))
816 {
817 foreach (bool l3 in parse(S1, 1200, Term, S2))
818 {
819 foreach (bool l4 in expect(Atom.a(@"}"), S2, S3))
820 {
821 foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S))
822 {
823 yield return false;
824 }
825 yield break;
826 }
827 }
828 }
829 }
830 {
831 object Precedence = arg3;
832 object Answer = arg4;
833 object S = arg5;
834 Variable Variable_1 = new Variable();
835 Variable Name = new Variable();
836 Variable Pos = new Variable();
837 Variable S1 = new Variable();
838 Variable Arg1 = new Variable();
839 Variable S2 = new Variable();
840 Variable RestArgs = new Variable();
841 Variable S3 = new Variable();
842 Variable Term = new Variable();
843 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos)))
844 {
845 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1)))
846 {
847 foreach (bool l4 in parse(S1, 999, Arg1, S2))
848 {
849 foreach (bool l5 in read_args(S2, RestArgs, S3))
850 {
851 foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a(@"call"), new ListPair(new Functor3(@"$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs)))))
852 {
853 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
854 {
855 yield return false;
856 }
857 }
858 yield break;
859 }
860 }
861 yield break;
862 }
863 }
864 }
865 {
866 object S0 = arg2;
867 object Precedence = arg3;
868 object Answer = arg4;
869 object S = arg5;
870 Variable Variable_1 = new Variable();
871 Variable Name = new Variable();
872 Variable Pos = new Variable();
873 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos)))
874 {
875 foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
876 {
877 yield return false;
878 }
879 }
880 }
881 {
882 object S0 = arg2;
883 object Precedence = arg3;
884 object Answer = arg4;
885 object S = arg5;
886 Variable Atom_1 = new Variable();
887 Variable P = new Variable();
888 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P)))
889 {
890 foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S))
891 {
892 yield return false;
893 }
894 }
895 }
896 }
897
898 public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S)
899 {
900 {
901 Variable _Pos = new Variable();
902 Variable Number = new Variable();
903 Variable S1 = new Variable();
904 Variable Negative = new Variable();
905 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos)))
906 {
907 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1)))
908 {
909 foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
910 {
911 foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S))
912 {
913 yield return false;
914 }
915 }
916 yield break;
917 }
918 }
919 }
920 {
921 Variable Functor_1 = new Variable();
922 Variable Pos = new Variable();
923 Variable S1 = new Variable();
924 Variable Arg1 = new Variable();
925 Variable S2 = new Variable();
926 Variable RestArgs = new Variable();
927 Variable S3 = new Variable();
928 Variable Term = new Variable();
929 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos)))
930 {
931 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1)))
932 {
933 foreach (bool l4 in parse(S1, 999, Arg1, S2))
934 {
935 foreach (bool l5 in read_args(S2, RestArgs, S3))
936 {
937 foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs)))))
938 {
939 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
940 {
941 yield return false;
942 }
943 }
944 yield break;
945 }
946 }
947 yield break;
948 }
949 }
950 }
951 {
952 object S0 = arg2;
953 Variable Op = new Variable();
954 Variable Pos = new Variable();
955 Variable Oprec = new Variable();
956 Variable Aprec = new Variable();
957 Variable Flag = new Variable();
958 Variable Term = new Variable();
959 Variable Arg = new Variable();
960 Variable S1 = new Variable();
961 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos)))
962 {
963 foreach (bool l3 in prefixop(Op, Oprec, Aprec))
964 {
965 foreach (bool l4 in possible_right_operand(S0, Flag))
966 {
967 if (YP.lessThan(Flag, 0))
968 {
969 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL))))
970 {
971 foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S))
972 {
973 yield return false;
974 }
975 }
976 goto cutIf1;
977 }
978 if (YP.greaterThan(Oprec, Precedence))
979 {
980 foreach (bool l6 in syntax_error(new ListPair(Atom.a(@"prefix"), new ListPair(Atom.a(@"operator"), new ListPair(Op, new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"context"), new ListPair(Atom.a(@"with"), new ListPair(Atom.a(@"precedence"), new ListPair(Precedence, Atom.NIL)))))))), S0))
981 {
982 yield return false;
983 }
984 goto cutIf2;
985 }
986 if (YP.greaterThan(Flag, 0))
987 {
988 foreach (bool l6 in parse(S0, Aprec, Arg, S1))
989 {
990 foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL)))))
991 {
992 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
993 {
994 yield return false;
995 }
996 }
997 yield break;
998 }
999 goto cutIf3;
1000 }
1001 foreach (bool l5 in peepop(S0, S1))
1002 {
1003 foreach (bool l6 in prefix_is_atom(S1, Oprec))
1004 {
1005 foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S))
1006 {
1007 yield return false;
1008 }
1009 }
1010 }
1011 foreach (bool l5 in parse(S0, Aprec, Arg, S1))
1012 {
1013 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL)))))
1014 {
1015 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1016 {
1017 yield return false;
1018 }
1019 }
1020 yield break;
1021 }
1022 cutIf3:
1023 cutIf2:
1024 cutIf1:
1025 { }
1026 }
1027 yield break;
1028 }
1029 }
1030 }
1031 {
1032 object S0 = arg2;
1033 Variable Atom_1 = new Variable();
1034 Variable Pos = new Variable();
1035 Variable Term = new Variable();
1036 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos)))
1037 {
1038 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
1039 {
1040 foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
1041 {
1042 yield return false;
1043 }
1044 }
1045 }
1046 }
1047 }
1048
1049 public static IEnumerable<bool> cannot_start(object Token, object S0)
1050 {
1051 {
1052 foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"cannot"), new ListPair(Atom.a(@"start"), new ListPair(Atom.a(@"an"), new ListPair(Atom.a(@"expression"), Atom.NIL))))), S0))
1053 {
1054 yield return false;
1055 }
1056 }
1057 }
1058
1059 public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3)
1060 {
1061 {
1062 object S = arg3;
1063 Variable S1 = new Variable();
1064 Variable Term = new Variable();
1065 Variable Rest = new Variable();
1066 Variable S2 = new Variable();
1067 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1)))
1068 {
1069 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
1070 {
1071 foreach (bool l4 in parse(S1, 999, Term, S2))
1072 {
1073 foreach (bool l5 in read_args(S2, Rest, S))
1074 {
1075 yield return false;
1076 }
1077 yield break;
1078 }
1079 yield break;
1080 }
1081 }
1082 }
1083 {
1084 object S = arg3;
1085 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S)))
1086 {
1087 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1088 {
1089 yield return true;
1090 yield break;
1091 }
1092 }
1093 }
1094 {
1095 object S = arg1;
1096 object x2 = arg2;
1097 object x3 = arg3;
1098 foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", or )"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"arguments"), Atom.NIL)))), S))
1099 {
1100 yield return false;
1101 }
1102 }
1103 }
1104
1105 public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3)
1106 {
1107 {
1108 object x1 = arg2;
1109 object x2 = arg3;
1110 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1111 {
1112 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), Atom.NIL))
1113 {
1114 yield return false;
1115 }
1116 }
1117 }
1118 {
1119 object Rest = arg2;
1120 object S = arg3;
1121 Variable Token = new Variable();
1122 Variable S1 = new Variable();
1123 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
1124 {
1125 foreach (bool l3 in read_list4(Token, S1, Rest, S))
1126 {
1127 yield return false;
1128 }
1129 }
1130 }
1131 }
1132
1133 public static IEnumerable<bool> read_list4(object arg1, object arg2, object arg3, object arg4)
1134 {
1135 {
1136 object S1 = arg2;
1137 object S = arg4;
1138 Variable Term = new Variable();
1139 Variable Rest = new Variable();
1140 Variable S2 = new Variable();
1141 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1142 {
1143 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest)))
1144 {
1145 foreach (bool l4 in parse(S1, 999, Term, S2))
1146 {
1147 foreach (bool l5 in read_list(S2, Rest, S))
1148 {
1149 yield return false;
1150 }
1151 yield break;
1152 }
1153 yield break;
1154 }
1155 }
1156 }
1157 {
1158 object S1 = arg2;
1159 object Rest = arg3;
1160 object S = arg4;
1161 Variable S2 = new Variable();
1162 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1163 {
1164 foreach (bool l3 in parse(S1, 999, Rest, S2))
1165 {
1166 foreach (bool l4 in expect(Atom.a(@"]"), S2, S))
1167 {
1168 yield return false;
1169 }
1170 yield break;
1171 }
1172 yield break;
1173 }
1174 }
1175 {
1176 Variable S1 = new Variable();
1177 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1178 {
1179 foreach (bool l3 in YP.unify(arg2, S1))
1180 {
1181 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1182 {
1183 foreach (bool l5 in YP.unify(arg4, S1))
1184 {
1185 yield return true;
1186 yield break;
1187 }
1188 }
1189 }
1190 }
1191 }
1192 {
1193 object Token = arg1;
1194 object S1 = arg2;
1195 object x3 = arg3;
1196 object x4 = arg4;
1197 foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), new ListPair(Token, S1)))
1198 {
1199 yield return false;
1200 }
1201 }
1202 }
1203
1204 public static IEnumerable<bool> possible_right_operand(object arg1, object arg2)
1205 {
1206 {
1207 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1208 {
1209 foreach (bool l3 in YP.unify(arg2, -1))
1210 {
1211 yield return false;
1212 }
1213 }
1214 }
1215 {
1216 object Flag = arg2;
1217 Variable H = new Variable();
1218 Variable T = new Variable();
1219 foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
1220 {
1221 foreach (bool l3 in possible_right_operand3(H, Flag, T))
1222 {
1223 yield return false;
1224 }
1225 }
1226 }
1227 }
1228
1229 public static IEnumerable<bool> possible_right_operand3(object arg1, object arg2, object arg3)
1230 {
1231 {
1232 object x4 = arg3;
1233 Variable x1 = new Variable();
1234 Variable x2 = new Variable();
1235 Variable x3 = new Variable();
1236 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3)))
1237 {
1238 foreach (bool l3 in YP.unify(arg2, 1))
1239 {
1240 yield return false;
1241 }
1242 }
1243 }
1244 {
1245 object x2 = arg3;
1246 Variable x1 = new Variable();
1247 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1)))
1248 {
1249 foreach (bool l3 in YP.unify(arg2, 1))
1250 {
1251 yield return false;
1252 }
1253 }
1254 }
1255 {
1256 object x2 = arg3;
1257 Variable x1 = new Variable();
1258 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1)))
1259 {
1260 foreach (bool l3 in YP.unify(arg2, 1))
1261 {
1262 yield return false;
1263 }
1264 }
1265 }
1266 {
1267 object x1 = arg3;
1268 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
1269 {
1270 foreach (bool l3 in YP.unify(arg2, 1))
1271 {
1272 yield return false;
1273 }
1274 }
1275 }
1276 {
1277 object x1 = arg3;
1278 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
1279 {
1280 foreach (bool l3 in YP.unify(arg2, 0))
1281 {
1282 yield return false;
1283 }
1284 }
1285 }
1286 {
1287 object x1 = arg3;
1288 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1289 {
1290 foreach (bool l3 in YP.unify(arg2, -1))
1291 {
1292 yield return false;
1293 }
1294 }
1295 }
1296 {
1297 Variable x1 = new Variable();
1298 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1299 {
1300 foreach (bool l3 in YP.unify(arg2, 0))
1301 {
1302 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1)))
1303 {
1304 yield return true;
1305 yield break;
1306 }
1307 }
1308 }
1309 }
1310 {
1311 object x1 = arg3;
1312 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1313 {
1314 foreach (bool l3 in YP.unify(arg2, 1))
1315 {
1316 yield return false;
1317 }
1318 }
1319 }
1320 {
1321 object x1 = arg3;
1322 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1323 {
1324 foreach (bool l3 in YP.unify(arg2, -1))
1325 {
1326 yield return false;
1327 }
1328 }
1329 }
1330 {
1331 Variable x1 = new Variable();
1332 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1333 {
1334 foreach (bool l3 in YP.unify(arg2, 0))
1335 {
1336 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1)))
1337 {
1338 yield return true;
1339 yield break;
1340 }
1341 }
1342 }
1343 }
1344 {
1345 object x1 = arg3;
1346 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1347 {
1348 foreach (bool l3 in YP.unify(arg2, 1))
1349 {
1350 yield return false;
1351 }
1352 }
1353 }
1354 {
1355 object x1 = arg3;
1356 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1357 {
1358 foreach (bool l3 in YP.unify(arg2, -1))
1359 {
1360 yield return false;
1361 }
1362 }
1363 }
1364 {
1365 object x1 = arg3;
1366 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1367 {
1368 foreach (bool l3 in YP.unify(arg2, -1))
1369 {
1370 yield return false;
1371 }
1372 }
1373 }
1374 {
1375 object x1 = arg3;
1376 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1377 {
1378 foreach (bool l3 in YP.unify(arg2, -1))
1379 {
1380 yield return false;
1381 }
1382 }
1383 }
1384 {
1385 object x3 = arg3;
1386 Variable x1 = new Variable();
1387 Variable x2 = new Variable();
1388 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2)))
1389 {
1390 foreach (bool l3 in YP.unify(arg2, 0))
1391 {
1392 yield return false;
1393 }
1394 }
1395 }
1396 }
1397
1398 public static IEnumerable<bool> peepop(object arg1, object arg2)
1399 {
1400 {
1401 Variable F = new Variable();
1402 Variable Pos = new Variable();
1403 Variable S1 = new Variable();
1404 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1))))
1405 {
1406 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1))))
1407 {
1408 yield return true;
1409 yield break;
1410 }
1411 }
1412 }
1413 {
1414 Variable F = new Variable();
1415 Variable Pos = new Variable();
1416 Variable S1 = new Variable();
1417 Variable L = new Variable();
1418 Variable P = new Variable();
1419 Variable R = new Variable();
1420 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1)))
1421 {
1422 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, P, R }), S1)))
1423 {
1424 foreach (bool l4 in infixop(F, L, P, R))
1425 {
1426 yield return false;
1427 }
1428 }
1429 }
1430 }
1431 {
1432 Variable F = new Variable();
1433 Variable Pos = new Variable();
1434 Variable S1 = new Variable();
1435 Variable L = new Variable();
1436 Variable P = new Variable();
1437 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1)))
1438 {
1439 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1)))
1440 {
1441 foreach (bool l4 in postfixop(F, L, P))
1442 {
1443 yield return false;
1444 }
1445 }
1446 }
1447 }
1448 {
1449 Variable S0 = new Variable();
1450 foreach (bool l2 in YP.unify(arg1, S0))
1451 {
1452 foreach (bool l3 in YP.unify(arg2, S0))
1453 {
1454 yield return false;
1455 }
1456 }
1457 }
1458 }
1459
1460 public static IEnumerable<bool> prefix_is_atom(object arg1, object arg2)
1461 {
1462 {
1463 object Precedence = arg2;
1464 Variable Token = new Variable();
1465 Variable x2 = new Variable();
1466 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, x2)))
1467 {
1468 foreach (bool l3 in prefix_is_atom(Token, Precedence))
1469 {
1470 yield return false;
1471 }
1472 }
1473 }
1474 {
1475 object P = arg2;
1476 Variable x1 = new Variable();
1477 Variable L = new Variable();
1478 Variable x3 = new Variable();
1479 Variable x4 = new Variable();
1480 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 })))
1481 {
1482 if (YP.greaterThanOrEqual(L, P))
1483 {
1484 yield return false;
1485 }
1486 }
1487 }
1488 {
1489 object P = arg2;
1490 Variable x1 = new Variable();
1491 Variable L = new Variable();
1492 Variable x3 = new Variable();
1493 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3)))
1494 {
1495 if (YP.greaterThanOrEqual(L, P))
1496 {
1497 yield return false;
1498 }
1499 }
1500 }
1501 {
1502 object x1 = arg2;
1503 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1504 {
1505 yield return false;
1506 }
1507 }
1508 {
1509 object x1 = arg2;
1510 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1511 {
1512 yield return false;
1513 }
1514 }
1515 {
1516 object x1 = arg2;
1517 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1518 {
1519 yield return false;
1520 }
1521 }
1522 {
1523 object P = arg2;
1524 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1525 {
1526 if (YP.greaterThanOrEqual(1100, P))
1527 {
1528 yield return false;
1529 }
1530 }
1531 }
1532 {
1533 object P = arg2;
1534 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1535 {
1536 if (YP.greaterThanOrEqual(1000, P))
1537 {
1538 yield return false;
1539 }
1540 }
1541 }
1542 {
1543 object x1 = arg2;
1544 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1545 {
1546 yield return false;
1547 }
1548 }
1549 }
1550
1551 public static IEnumerable<bool> exprtl0(object arg1, object arg2, object arg3, object arg4, object arg5)
1552 {
1553 {
1554 object x2 = arg3;
1555 Variable Term = new Variable();
1556 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1557 {
1558 foreach (bool l3 in YP.unify(arg2, Term))
1559 {
1560 foreach (bool l4 in YP.unify(arg4, Term))
1561 {
1562 foreach (bool l5 in YP.unify(arg5, Atom.NIL))
1563 {
1564 yield return false;
1565 }
1566 }
1567 }
1568 }
1569 }
1570 {
1571 object Term = arg2;
1572 object Precedence = arg3;
1573 object Answer = arg4;
1574 object S = arg5;
1575 Variable Token = new Variable();
1576 Variable S1 = new Variable();
1577 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
1578 {
1579 foreach (bool l3 in exprtl0_6(Token, Term, Precedence, Answer, S, S1))
1580 {
1581 yield return false;
1582 }
1583 }
1584 }
1585 }
1586
1587 public static IEnumerable<bool> exprtl0_6(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1588 {
1589 {
1590 object x2 = arg3;
1591 object S1 = arg6;
1592 Variable Term = new Variable();
1593 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1594 {
1595 foreach (bool l3 in YP.unify(arg2, Term))
1596 {
1597 foreach (bool l4 in YP.unify(arg4, Term))
1598 {
1599 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1)))
1600 {
1601 yield return false;
1602 }
1603 }
1604 }
1605 }
1606 }
1607 {
1608 object x2 = arg3;
1609 object S1 = arg6;
1610 Variable Term = new Variable();
1611 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1612 {
1613 foreach (bool l3 in YP.unify(arg2, Term))
1614 {
1615 foreach (bool l4 in YP.unify(arg4, Term))
1616 {
1617 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1)))
1618 {
1619 yield return false;
1620 }
1621 }
1622 }
1623 }
1624 }
1625 {
1626 object x2 = arg3;
1627 object S1 = arg6;
1628 Variable Term = new Variable();
1629 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1630 {
1631 foreach (bool l3 in YP.unify(arg2, Term))
1632 {
1633 foreach (bool l4 in YP.unify(arg4, Term))
1634 {
1635 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1)))
1636 {
1637 yield return false;
1638 }
1639 }
1640 }
1641 }
1642 }
1643 {
1644 object Term = arg2;
1645 object Precedence = arg3;
1646 object Answer = arg4;
1647 object S = arg5;
1648 object S1 = arg6;
1649 Variable Next = new Variable();
1650 Variable S2 = new Variable();
1651 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1652 {
1653 if (YP.greaterThanOrEqual(Precedence, 1000))
1654 {
1655 foreach (bool l4 in parse(S1, 1000, Next, S2))
1656 {
1657 foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S))
1658 {
1659 yield return false;
1660 }
1661 yield break;
1662 }
1663 goto cutIf1;
1664 }
1665 foreach (bool l3 in YP.unify(Answer, Term))
1666 {
1667 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1)))
1668 {
1669 yield return false;
1670 }
1671 }
1672 cutIf1:
1673 { }
1674 }
1675 }
1676 {
1677 object Term = arg2;
1678 object Precedence = arg3;
1679 object Answer = arg4;
1680 object S = arg5;
1681 object S1 = arg6;
1682 Variable Next = new Variable();
1683 Variable S2 = new Variable();
1684 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1685 {
1686 if (YP.greaterThanOrEqual(Precedence, 1100))
1687 {
1688 foreach (bool l4 in parse(S1, 1100, Next, S2))
1689 {
1690 foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S))
1691 {
1692 yield return false;
1693 }
1694 yield break;
1695 }
1696 goto cutIf2;
1697 }
1698 foreach (bool l3 in YP.unify(Answer, Term))
1699 {
1700 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1)))
1701 {
1702 yield return false;
1703 }
1704 }
1705 cutIf2:
1706 { }
1707 }
1708 }
1709 {
1710 object x2 = arg2;
1711 object x3 = arg3;
1712 object x4 = arg4;
1713 object x5 = arg5;
1714 object S1 = arg6;
1715 Variable S = new Variable();
1716 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S)))
1717 {
1718 foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1))
1719 {
1720 yield return false;
1721 }
1722 }
1723 }
1724 {
1725 object x2 = arg2;
1726 object x3 = arg3;
1727 object x4 = arg4;
1728 object x5 = arg5;
1729 object S1 = arg6;
1730 Variable N = new Variable();
1731 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N)))
1732 {
1733 foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1))
1734 {
1735 yield return false;
1736 }
1737 }
1738 }
1739 {
1740 object Term = arg2;
1741 object Precedence = arg3;
1742 object Answer = arg4;
1743 object S = arg5;
1744 Variable S1 = new Variable();
1745 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1746 {
1747 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1)))
1748 {
1749 foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1))
1750 {
1751 yield return false;
1752 }
1753 yield break;
1754 }
1755 }
1756 }
1757 {
1758 object x1 = arg2;
1759 object x2 = arg3;
1760 object x3 = arg4;
1761 object x4 = arg5;
1762 object S1 = arg6;
1763 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1764 {
1765 foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1))
1766 {
1767 yield return false;
1768 }
1769 }
1770 }
1771 {
1772 object Term = arg2;
1773 object Precedence = arg3;
1774 object Answer = arg4;
1775 object S = arg5;
1776 Variable S1 = new Variable();
1777 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1778 {
1779 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1)))
1780 {
1781 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1))
1782 {
1783 yield return false;
1784 }
1785 yield break;
1786 }
1787 }
1788 }
1789 {
1790 object x1 = arg2;
1791 object x2 = arg3;
1792 object x3 = arg4;
1793 object x4 = arg5;
1794 object S1 = arg6;
1795 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1796 {
1797 foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1))
1798 {
1799 yield return false;
1800 }
1801 }
1802 }
1803 {
1804 object x1 = arg2;
1805 object x2 = arg3;
1806 object x3 = arg4;
1807 object x4 = arg5;
1808 object S1 = arg6;
1809 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
1810 {
1811 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1))
1812 {
1813 yield return false;
1814 }
1815 }
1816 }
1817 {
1818 object x1 = arg2;
1819 object x2 = arg3;
1820 object x3 = arg4;
1821 object x4 = arg5;
1822 object S1 = arg6;
1823 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
1824 {
1825 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1))
1826 {
1827 yield return false;
1828 }
1829 }
1830 }
1831 {
1832 object x4 = arg2;
1833 object x5 = arg3;
1834 object x6 = arg4;
1835 object x7 = arg5;
1836 object S1 = arg6;
1837 Variable A = new Variable();
1838 Variable B = new Variable();
1839 Variable P = new Variable();
1840 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P)))
1841 {
1842 foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1))
1843 {
1844 yield return false;
1845 }
1846 }
1847 }
1848 {
1849 object Term = arg2;
1850 object Precedence = arg3;
1851 object Answer = arg4;
1852 object S = arg5;
1853 object S1 = arg6;
1854 Variable F = new Variable();
1855 Variable P = new Variable();
1856 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P)))
1857 {
1858 foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1))
1859 {
1860 yield return false;
1861 }
1862 }
1863 }
1864 }
1865
1866 public static IEnumerable<bool> exprtl0_atom(object arg1, object arg2, object arg3, object arg4, object arg5, object S1)
1867 {
1868 {
1869 object Term = arg2;
1870 object Precedence = arg3;
1871 object Answer = arg4;
1872 object S = arg5;
1873 Variable F = new Variable();
1874 Variable Pos = new Variable();
1875 Variable L1 = new Variable();
1876 Variable O1 = new Variable();
1877 Variable R1 = new Variable();
1878 Variable L2 = new Variable();
1879 Variable O2 = new Variable();
1880 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1881 {
1882 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2))
1883 {
1884 foreach (bool l4 in prefix_is_atom(S1, Precedence))
1885 {
1886 foreach (bool l5 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1887 {
1888 yield return false;
1889 }
1890 yield break;
1891 }
1892 foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S))
1893 {
1894 yield return false;
1895 }
1896 foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1897 {
1898 yield return false;
1899 }
1900 yield break;
1901 }
1902 }
1903 }
1904 {
1905 object Term = arg2;
1906 object Precedence = arg3;
1907 object Answer = arg4;
1908 object S = arg5;
1909 Variable F = new Variable();
1910 Variable Pos = new Variable();
1911 Variable L1 = new Variable();
1912 Variable O1 = new Variable();
1913 Variable R1 = new Variable();
1914 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1915 {
1916 foreach (bool l3 in infixop(F, L1, O1, R1))
1917 {
1918 foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S))
1919 {
1920 yield return false;
1921 }
1922 yield break;
1923 }
1924 }
1925 }
1926 {
1927 object Term = arg2;
1928 object Precedence = arg3;
1929 object Answer = arg4;
1930 object S = arg5;
1931 Variable F = new Variable();
1932 Variable Pos = new Variable();
1933 Variable L2 = new Variable();
1934 Variable O2 = new Variable();
1935 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1936 {
1937 foreach (bool l3 in postfixop(F, L2, O2))
1938 {
1939 foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1940 {
1941 yield return false;
1942 }
1943 yield break;
1944 }
1945 }
1946 }
1947 {
1948 object X = arg1;
1949 object x2 = arg2;
1950 object x3 = arg3;
1951 object x4 = arg4;
1952 object x5 = arg5;
1953 Variable x7 = new Variable();
1954 foreach (bool l2 in syntax_error(new ListPair(new Functor2(@"-", Atom.a(@"non"), Atom.a(@"operator")), new ListPair(X, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(new Functor2(@"atom", X, x7), S1)))
1955 {
1956 yield return false;
1957 }
1958 yield break;
1959 }
1960 }
1961
1962 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens)
1963 {
1964 {
1965 foreach (bool l2 in syntax_error(new ListPair(Type, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL))), new ListPair(Token, Tokens)))
1966 {
1967 yield return false;
1968 }
1969 }
1970 }
1971
1972 public static IEnumerable<bool> exprtl(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1973 {
1974 {
1975 object x1 = arg2;
1976 object x3 = arg4;
1977 Variable Term = new Variable();
1978 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1979 {
1980 foreach (bool l3 in YP.unify(arg3, Term))
1981 {
1982 foreach (bool l4 in YP.unify(arg5, Term))
1983 {
1984 foreach (bool l5 in YP.unify(arg6, Atom.NIL))
1985 {
1986 yield return false;
1987 }
1988 }
1989 }
1990 }
1991 }
1992 {
1993 object C = arg2;
1994 object Term = arg3;
1995 object Precedence = arg4;
1996 object Answer = arg5;
1997 object S = arg6;
1998 Variable Token = new Variable();
1999 Variable Tokens = new Variable();
2000 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Tokens)))
2001 {
2002 foreach (bool l3 in exprtl_7(Token, C, Term, Precedence, Answer, S, Tokens))
2003 {
2004 yield return false;
2005 }
2006 }
2007 }
2008 }
2009
2010 public static IEnumerable<bool> exprtl_7(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7)
2011 {
2012 {
2013 object C = arg2;
2014 object Term = arg3;
2015 object Precedence = arg4;
2016 object Answer = arg5;
2017 object S = arg6;
2018 object S1 = arg7;
2019 Variable F = new Variable();
2020 Variable Pos = new Variable();
2021 Variable L = new Variable();
2022 Variable O = new Variable();
2023 Variable R = new Variable();
2024 Variable Other = new Variable();
2025 Variable S2 = new Variable();
2026 Variable Expr = new Variable();
2027 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R })))
2028 {
2029 if (YP.greaterThanOrEqual(Precedence, O))
2030 {
2031 if (YP.lessThanOrEqual(C, L))
2032 {
2033 foreach (bool l5 in parse(S1, R, Other, S2))
2034 {
2035 foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL))))))
2036 {
2037 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2038 {
2039 yield return false;
2040 }
2041 }
2042 }
2043 yield break;
2044 }
2045 }
2046 }
2047 }
2048 {
2049 object C = arg2;
2050 object Term = arg3;
2051 object Precedence = arg4;
2052 object Answer = arg5;
2053 object S = arg6;
2054 object S1 = arg7;
2055 Variable F = new Variable();
2056 Variable Pos = new Variable();
2057 Variable L = new Variable();
2058 Variable O = new Variable();
2059 Variable Expr = new Variable();
2060 Variable S2 = new Variable();
2061 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O)))
2062 {
2063 if (YP.greaterThanOrEqual(Precedence, O))
2064 {
2065 if (YP.lessThanOrEqual(C, L))
2066 {
2067 foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL)))))
2068 {
2069 foreach (bool l6 in peepop(S1, S2))
2070 {
2071 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2072 {
2073 yield return false;
2074 }
2075 }
2076 }
2077 yield break;
2078 }
2079 }
2080 }
2081 }
2082 {
2083 object C = arg2;
2084 object Term = arg3;
2085 object Precedence = arg4;
2086 object Answer = arg5;
2087 object S = arg6;
2088 object S1 = arg7;
2089 Variable Next = new Variable();
2090 Variable S2 = new Variable();
2091 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
2092 {
2093 if (YP.greaterThanOrEqual(Precedence, 1000))
2094 {
2095 if (YP.lessThan(C, 1000))
2096 {
2097 foreach (bool l5 in parse(S1, 1000, Next, S2))
2098 {
2099 foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S))
2100 {
2101 yield return false;
2102 }
2103 }
2104 yield break;
2105 }
2106 }
2107 }
2108 }
2109 {
2110 object C = arg2;
2111 object Term = arg3;
2112 object Precedence = arg4;
2113 object Answer = arg5;
2114 object S = arg6;
2115 object S1 = arg7;
2116 Variable Next = new Variable();
2117 Variable S2 = new Variable();
2118 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
2119 {
2120 if (YP.greaterThanOrEqual(Precedence, 1100))
2121 {
2122 if (YP.lessThan(C, 1100))
2123 {
2124 foreach (bool l5 in parse(S1, 1100, Next, S2))
2125 {
2126 foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S))
2127 {
2128 yield return false;
2129 }
2130 }
2131 yield break;
2132 }
2133 }
2134 }
2135 }
2136 {
2137 object Token = arg1;
2138 object x2 = arg2;
2139 object x4 = arg4;
2140 object Tokens = arg7;
2141 Variable Term = new Variable();
2142 foreach (bool l2 in YP.unify(arg3, Term))
2143 {
2144 foreach (bool l3 in YP.unify(arg5, Term))
2145 {
2146 foreach (bool l4 in YP.unify(arg6, new ListPair(Token, Tokens)))
2147 {
2148 yield return false;
2149 }
2150 }
2151 }
2152 }
2153 }
2154
2155 public static IEnumerable<bool> syntax_error(object _Message, object _List)
2156 {
2157 {
2158 yield break;
2159 }
2160 }
2161
2162 public static IEnumerable<bool> syntax_error(object _List)
2163 {
2164 {
2165 yield break;
2166 }
2167 }
2168
2169 public static IEnumerable<bool> prefixop(object F, object O, object Q)
2170 {
2171 {
2172 foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F))
2173 {
2174 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2175 {
2176 yield return false;
2177 }
2178 goto cutIf1;
2179 }
2180 foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F))
2181 {
2182 foreach (bool l3 in YP.unify(Q, O))
2183 {
2184 yield return false;
2185 }
2186 goto cutIf2;
2187 }
2188 cutIf2:
2189 cutIf1:
2190 { }
2191 }
2192 }
2193
2194 public static IEnumerable<bool> postfixop(object F, object P, object O)
2195 {
2196 {
2197 foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F))
2198 {
2199 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2200 {
2201 yield return false;
2202 }
2203 goto cutIf1;
2204 }
2205 foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F))
2206 {
2207 foreach (bool l3 in YP.unify(P, O))
2208 {
2209 yield return false;
2210 }
2211 goto cutIf2;
2212 }
2213 cutIf2:
2214 cutIf1:
2215 { }
2216 }
2217 }
2218
2219 public static IEnumerable<bool> infixop(object F, object P, object O, object Q)
2220 {
2221 {
2222 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F))
2223 {
2224 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2225 {
2226 foreach (bool l4 in YP.unify(Q, O))
2227 {
2228 yield return false;
2229 }
2230 }
2231 goto cutIf1;
2232 }
2233 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F))
2234 {
2235 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2236 {
2237 foreach (bool l4 in YP.unify(Q, P))
2238 {
2239 yield return false;
2240 }
2241 }
2242 goto cutIf2;
2243 }
2244 foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F))
2245 {
2246 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2247 {
2248 foreach (bool l4 in YP.unify(P, O))
2249 {
2250 yield return false;
2251 }
2252 }
2253 goto cutIf3;
2254 }
2255 cutIf3:
2256 cutIf2:
2257 cutIf1:
2258 { }
2259 }
2260 }
2261
2262 public static IEnumerable<bool> ambigop(object F, object Precedence, object L1, object O1, object R1, object L2, object O2)
2263 {
2264 {
2265 foreach (bool l2 in postfixop(F, L2, O2))
2266 {
2267 if (YP.lessThanOrEqual(O2, Precedence))
2268 {
2269 foreach (bool l4 in infixop(F, L1, O1, R1))
2270 {
2271 if (YP.lessThanOrEqual(O1, Precedence))
2272 {
2273 yield return false;
2274 }
2275 }
2276 }
2277 }
2278 }
2279 }
2280
2281 public static IEnumerable<bool> read_tokens1(object arg1)
2282 {
2283 {
2284 object TokenList = arg1;
2285 Variable C1 = new Variable();
2286 Variable _X = new Variable();
2287 Variable ListOfTokens = new Variable();
2288 foreach (bool l2 in YP.get_code(C1))
2289 {
2290 foreach (bool l3 in read_tokens(C1, _X, ListOfTokens))
2291 {
2292 foreach (bool l4 in YP.unify(TokenList, ListOfTokens))
2293 {
2294 yield return false;
2295 }
2296 yield break;
2297 }
2298 }
2299 }
2300 {
2301 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL)))
2302 {
2303 yield return false;
2304 }
2305 }
2306 }
2307
2308 public static IEnumerable<bool> read_tokens2(object arg1, object arg2)
2309 {
2310 {
2311 object TokenList = arg1;
2312 object Dictionary = arg2;
2313 Variable C1 = new Variable();
2314 Variable Dict = new Variable();
2315 Variable ListOfTokens = new Variable();
2316 foreach (bool l2 in YP.get_code(C1))
2317 {
2318 foreach (bool l3 in read_tokens(C1, Dict, ListOfTokens))
2319 {
2320 foreach (bool l4 in terminate_list(Dict))
2321 {
2322 foreach (bool l5 in YP.unify(Dictionary, Dict))
2323 {
2324 foreach (bool l6 in YP.unify(TokenList, ListOfTokens))
2325 {
2326 yield return false;
2327 }
2328 }
2329 yield break;
2330 }
2331 }
2332 }
2333 }
2334 {
2335 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL)))
2336 {
2337 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2338 {
2339 yield return false;
2340 }
2341 }
2342 }
2343 }
2344
2345 public static IEnumerable<bool> terminate_list(object arg1)
2346 {
2347 {
2348 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
2349 {
2350 yield return false;
2351 }
2352 }
2353 {
2354 Variable x1 = new Variable();
2355 Variable Tail = new Variable();
2356 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Tail)))
2357 {
2358 foreach (bool l3 in terminate_list(Tail))
2359 {
2360 yield return false;
2361 }
2362 }
2363 }
2364 }
2365
2366 public static IEnumerable<bool> read_special(object arg1, object Dict, object arg3)
2367 {
2368 {
2369 object Tokens = arg3;
2370 foreach (bool l2 in YP.unify(arg1, 95))
2371 {
2372 foreach (bool l3 in read_variable(95, Dict, Tokens))
2373 {
2374 yield return false;
2375 }
2376 }
2377 }
2378 {
2379 object Tokens = arg3;
2380 foreach (bool l2 in YP.unify(arg1, 247))
2381 {
2382 foreach (bool l3 in read_symbol(247, Dict, Tokens))
2383 {
2384 yield return false;
2385 }
2386 }
2387 }
2388 {
2389 object Tokens = arg3;
2390 foreach (bool l2 in YP.unify(arg1, 215))
2391 {
2392 foreach (bool l3 in read_symbol(215, Dict, Tokens))
2393 {
2394 yield return false;
2395 }
2396 }
2397 }
2398 {
2399 Variable StartPos = new Variable();
2400 Variable EndPos = new Variable();
2401 Variable Tokens = new Variable();
2402 Variable Ch = new Variable();
2403 Variable NextCh = new Variable();
2404 foreach (bool l2 in YP.unify(arg1, 37))
2405 {
2406 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens)))
2407 {
2408 foreach (bool l4 in get_current_position(StartPos))
2409 {
2410 foreach (bool l5 in YP.repeat())
2411 {
2412 foreach (bool l6 in YP.get_code(Ch))
2413 {
2414 if (YP.lessThan(Ch, new ListPair(32, Atom.NIL)))
2415 {
2416 if (YP.notEqual(Ch, 9))
2417 {
2418 if (YP.termNotEqual(Ch, -1))
2419 {
2420 foreach (bool l10 in get_current_position(EndPos))
2421 {
2422 foreach (bool l11 in YP.get_code(NextCh))
2423 {
2424 foreach (bool l12 in read_tokens(NextCh, Dict, Tokens))
2425 {
2426 yield return false;
2427 }
2428 }
2429 }
2430 }
2431 yield break;
2432 }
2433 }
2434 }
2435 }
2436 }
2437 }
2438 }
2439 }
2440 {
2441 object T = arg3;
2442 Variable C2 = new Variable();
2443 Variable StartPos = new Variable();
2444 Variable EndPos = new Variable();
2445 Variable Tokens = new Variable();
2446 Variable StartPos1 = new Variable();
2447 Variable NextCh = new Variable();
2448 Variable Chars = new Variable();
2449 foreach (bool l2 in YP.unify(arg1, 47))
2450 {
2451 foreach (bool l3 in YP.get_code(C2))
2452 {
2453 if (YP.equal(C2, new ListPair(42, Atom.NIL)))
2454 {
2455 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens)))
2456 {
2457 foreach (bool l6 in get_current_position(StartPos1))
2458 {
2459 foreach (bool l7 in YP.unify(StartPos, YP.subtract(StartPos1, 1)))
2460 {
2461 foreach (bool l8 in read_solidus(32, NextCh))
2462 {
2463 foreach (bool l9 in get_current_position(EndPos))
2464 {
2465 foreach (bool l10 in read_tokens(NextCh, Dict, Tokens))
2466 {
2467 yield return false;
2468 }
2469 }
2470 }
2471 }
2472 }
2473 }
2474 goto cutIf1;
2475 }
2476 foreach (bool l4 in YP.unify(T, Tokens))
2477 {
2478 foreach (bool l5 in rest_symbol(C2, Chars, NextCh))
2479 {
2480 foreach (bool l6 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(47, Chars)))
2481 {
2482 yield return false;
2483 }
2484 }
2485 }
2486 cutIf1:
2487 { }
2488 }
2489 }
2490 }
2491 {
2492 Variable Pos = new Variable();
2493 Variable Tokens = new Variable();
2494 Variable NextCh = new Variable();
2495 foreach (bool l2 in YP.unify(arg1, 33))
2496 {
2497 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens)))
2498 {
2499 foreach (bool l4 in get_current_position(Pos))
2500 {
2501 foreach (bool l5 in YP.get_code(NextCh))
2502 {
2503 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2504 {
2505 yield return false;
2506 }
2507 }
2508 }
2509 }
2510 }
2511 }
2512 {
2513 Variable Tokens = new Variable();
2514 Variable NextCh = new Variable();
2515 foreach (bool l2 in YP.unify(arg1, 40))
2516 {
2517 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens)))
2518 {
2519 foreach (bool l4 in YP.get_code(NextCh))
2520 {
2521 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2522 {
2523 yield return false;
2524 }
2525 }
2526 }
2527 }
2528 }
2529 {
2530 Variable Tokens = new Variable();
2531 Variable NextCh = new Variable();
2532 foreach (bool l2 in YP.unify(arg1, 41))
2533 {
2534 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@")"), Tokens)))
2535 {
2536 foreach (bool l4 in YP.get_code(NextCh))
2537 {
2538 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2539 {
2540 yield return false;
2541 }
2542 }
2543 }
2544 }
2545 }
2546 {
2547 Variable Tokens = new Variable();
2548 Variable NextCh = new Variable();
2549 foreach (bool l2 in YP.unify(arg1, 44))
2550 {
2551 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@","), Tokens)))
2552 {
2553 foreach (bool l4 in YP.get_code(NextCh))
2554 {
2555 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2556 {
2557 yield return false;
2558 }
2559 }
2560 }
2561 }
2562 }
2563 {
2564 Variable Pos = new Variable();
2565 Variable Tokens = new Variable();
2566 Variable NextCh = new Variable();
2567 foreach (bool l2 in YP.unify(arg1, 59))
2568 {
2569 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens)))
2570 {
2571 foreach (bool l4 in get_current_position(Pos))
2572 {
2573 foreach (bool l5 in YP.get_code(NextCh))
2574 {
2575 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2576 {
2577 yield return false;
2578 }
2579 }
2580 }
2581 }
2582 }
2583 }
2584 {
2585 Variable Pos = new Variable();
2586 Variable Tokens = new Variable();
2587 Variable NextCh = new Variable();
2588 foreach (bool l2 in YP.unify(arg1, 91))
2589 {
2590 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens)))
2591 {
2592 foreach (bool l4 in get_current_position(Pos))
2593 {
2594 foreach (bool l5 in YP.get_code(NextCh))
2595 {
2596 foreach (bool l6 in read_tokens(NextCh, Dict, Tokens))
2597 {
2598 yield return false;
2599 }
2600 }
2601 }
2602 }
2603 }
2604 }
2605 {
2606 Variable Pos = new Variable();
2607 Variable Tokens = new Variable();
2608 Variable NextCh = new Variable();
2609 foreach (bool l2 in YP.unify(arg1, 93))
2610 {
2611 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens)))
2612 {
2613 foreach (bool l4 in get_current_position(Pos))
2614 {
2615 foreach (bool l5 in YP.get_code(NextCh))
2616 {
2617 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2618 {
2619 yield return false;
2620 }
2621 }
2622 }
2623 }
2624 }
2625 }
2626 {
2627 Variable Pos = new Variable();
2628 Variable Tokens = new Variable();
2629 Variable NextCh = new Variable();
2630 foreach (bool l2 in YP.unify(arg1, 123))
2631 {
2632 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens)))
2633 {
2634 foreach (bool l4 in get_current_position(Pos))
2635 {
2636 foreach (bool l5 in YP.get_code(NextCh))
2637 {
2638 foreach (bool l6 in read_tokens(NextCh, Dict, Tokens))
2639 {
2640 yield return false;
2641 }
2642 }
2643 }
2644 }
2645 }
2646 }
2647 {
2648 Variable Tokens = new Variable();
2649 Variable NextCh = new Variable();
2650 foreach (bool l2 in YP.unify(arg1, 124))
2651 {
2652 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens)))
2653 {
2654 foreach (bool l4 in YP.get_code(NextCh))
2655 {
2656 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2657 {
2658 yield return false;
2659 }
2660 }
2661 }
2662 }
2663 }
2664 {
2665 Variable Tokens = new Variable();
2666 Variable NextCh = new Variable();
2667 foreach (bool l2 in YP.unify(arg1, 125))
2668 {
2669 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens)))
2670 {
2671 foreach (bool l4 in YP.get_code(NextCh))
2672 {
2673 foreach (bool l5 in read_after_atom(NextCh, Dict, Tokens))
2674 {
2675 yield return false;
2676 }
2677 }
2678 }
2679 }
2680 }
2681 {
2682 object Tokens = arg3;
2683 Variable NextCh = new Variable();
2684 foreach (bool l2 in YP.unify(arg1, 46))
2685 {
2686 foreach (bool l3 in YP.get_code(NextCh))
2687 {
2688 foreach (bool l4 in read_fullstop(NextCh, Dict, Tokens))
2689 {
2690 yield return false;
2691 }
2692 }
2693 }
2694 }
2695 {
2696 Variable Chars = new Variable();
2697 Variable Tokens = new Variable();
2698 Variable NextCh = new Variable();
2699 foreach (bool l2 in YP.unify(arg1, 34))
2700 {
2701 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens)))
2702 {
2703 foreach (bool l4 in read_string(Chars, 34, NextCh))
2704 {
2705 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2706 {
2707 yield return false;
2708 }
2709 }
2710 }
2711 }
2712 }
2713 {
2714 object Tokens = arg3;
2715 Variable Chars = new Variable();
2716 Variable NextCh = new Variable();
2717 foreach (bool l2 in YP.unify(arg1, 39))
2718 {
2719 foreach (bool l3 in read_string(Chars, 39, NextCh))
2720 {
2721 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, Chars))
2722 {
2723 yield return false;
2724 }
2725 }
2726 }
2727 }
2728 {
2729 object Tokens = arg3;
2730 foreach (bool l2 in YP.unify(arg1, 35))
2731 {
2732 foreach (bool l3 in read_symbol(35, Dict, Tokens))
2733 {
2734 yield return false;
2735 }
2736 }
2737 }
2738 {
2739 object Tokens = arg3;
2740 foreach (bool l2 in YP.unify(arg1, 36))
2741 {
2742 foreach (bool l3 in read_symbol(36, Dict, Tokens))
2743 {
2744 yield return false;
2745 }
2746 }
2747 }
2748 {
2749 object Tokens = arg3;
2750 foreach (bool l2 in YP.unify(arg1, 38))
2751 {
2752 foreach (bool l3 in read_symbol(38, Dict, Tokens))
2753 {
2754 yield return false;
2755 }
2756 }
2757 }
2758 {
2759 object Tokens = arg3;
2760 foreach (bool l2 in YP.unify(arg1, 42))
2761 {
2762 foreach (bool l3 in read_symbol(42, Dict, Tokens))
2763 {
2764 yield return false;
2765 }
2766 }
2767 }
2768 {
2769 object Tokens = arg3;
2770 foreach (bool l2 in YP.unify(arg1, 43))
2771 {
2772 foreach (bool l3 in read_symbol(43, Dict, Tokens))
2773 {
2774 yield return false;
2775 }
2776 }
2777 }
2778 {
2779 object Tokens = arg3;
2780 foreach (bool l2 in YP.unify(arg1, 45))
2781 {
2782 foreach (bool l3 in read_symbol(45, Dict, Tokens))
2783 {
2784 yield return false;
2785 }
2786 }
2787 }
2788 {
2789 object Tokens = arg3;
2790 foreach (bool l2 in YP.unify(arg1, 58))
2791 {
2792 foreach (bool l3 in read_symbol(58, Dict, Tokens))
2793 {
2794 yield return false;
2795 }
2796 }
2797 }
2798 {
2799 object Tokens = arg3;
2800 foreach (bool l2 in YP.unify(arg1, 60))
2801 {
2802 foreach (bool l3 in read_symbol(60, Dict, Tokens))
2803 {
2804 yield return false;
2805 }
2806 }
2807 }
2808 {
2809 object Tokens = arg3;
2810 foreach (bool l2 in YP.unify(arg1, 61))
2811 {
2812 foreach (bool l3 in read_symbol(61, Dict, Tokens))
2813 {
2814 yield return false;
2815 }
2816 }
2817 }
2818 {
2819 object Tokens = arg3;
2820 foreach (bool l2 in YP.unify(arg1, 62))
2821 {
2822 foreach (bool l3 in read_symbol(62, Dict, Tokens))
2823 {
2824 yield return false;
2825 }
2826 }
2827 }
2828 {
2829 object Tokens = arg3;
2830 foreach (bool l2 in YP.unify(arg1, 63))
2831 {
2832 foreach (bool l3 in read_symbol(63, Dict, Tokens))
2833 {
2834 yield return false;
2835 }
2836 }
2837 }
2838 {
2839 object Tokens = arg3;
2840 foreach (bool l2 in YP.unify(arg1, 64))
2841 {
2842 foreach (bool l3 in read_symbol(64, Dict, Tokens))
2843 {
2844 yield return false;
2845 }
2846 }
2847 }
2848 {
2849 object Tokens = arg3;
2850 foreach (bool l2 in YP.unify(arg1, 92))
2851 {
2852 foreach (bool l3 in read_symbol(92, Dict, Tokens))
2853 {
2854 yield return false;
2855 }
2856 }
2857 }
2858 {
2859 object Tokens = arg3;
2860 foreach (bool l2 in YP.unify(arg1, 94))
2861 {
2862 foreach (bool l3 in read_symbol(94, Dict, Tokens))
2863 {
2864 yield return false;
2865 }
2866 }
2867 }
2868 {
2869 object Tokens = arg3;
2870 foreach (bool l2 in YP.unify(arg1, 96))
2871 {
2872 foreach (bool l3 in read_symbol(96, Dict, Tokens))
2873 {
2874 yield return false;
2875 }
2876 }
2877 }
2878 {
2879 object Tokens = arg3;
2880 foreach (bool l2 in YP.unify(arg1, 126))
2881 {
2882 foreach (bool l3 in read_symbol(126, Dict, Tokens))
2883 {
2884 yield return false;
2885 }
2886 }
2887 }
2888 }
2889
2890 public static IEnumerable<bool> read_symbol(object C1, object Dict, object Tokens)
2891 {
2892 {
2893 Variable C2 = new Variable();
2894 Variable Chars = new Variable();
2895 Variable NextCh = new Variable();
2896 foreach (bool l2 in YP.get_code(C2))
2897 {
2898 foreach (bool l3 in rest_symbol(C2, Chars, NextCh))
2899 {
2900 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(C1, Chars)))
2901 {
2902 yield return false;
2903 }
2904 }
2905 }
2906 }
2907 }
2908
2909 public static IEnumerable<bool> rest_symbol(object arg1, object arg2, object arg3)
2910 {
2911 {
2912 object C2 = arg1;
2913 object LastCh = arg3;
2914 Variable Chars = new Variable();
2915 Variable NextCh = new Variable();
2916 foreach (bool l2 in YP.unify(arg2, new ListPair(C2, Chars)))
2917 {
2918 if (YP.greaterThan(C2, 160))
2919 {
2920 if (YP.lessThan(C2, 192))
2921 {
2922 if (YP.notEqual(C2, 186))
2923 {
2924 if (YP.notEqual(C2, 170))
2925 {
2926 foreach (bool l7 in YP.get_code(NextCh))
2927 {
2928 foreach (bool l8 in rest_symbol(NextCh, Chars, LastCh))
2929 {
2930 yield return false;
2931 }
2932 }
2933 yield break;
2934 }
2935 }
2936 }
2937 goto cutIf1;
2938 }
2939 foreach (bool l3 in symbol_char(C2))
2940 {
2941 foreach (bool l4 in YP.get_code(NextCh))
2942 {
2943 foreach (bool l5 in rest_symbol(NextCh, Chars, LastCh))
2944 {
2945 yield return false;
2946 }
2947 }
2948 yield break;
2949 }
2950 cutIf1:
2951 { }
2952 }
2953 }
2954 {
2955 Variable C2 = new Variable();
2956 foreach (bool l2 in YP.unify(arg1, C2))
2957 {
2958 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2959 {
2960 foreach (bool l4 in YP.unify(arg3, C2))
2961 {
2962 yield return false;
2963 }
2964 }
2965 }
2966 }
2967 }
2968
2969 public static IEnumerable<bool> symbol_char(object arg1)
2970 {
2971 {
2972 foreach (bool l2 in YP.unify(arg1, 35))
2973 {
2974 yield return false;
2975 }
2976 }
2977 {
2978 foreach (bool l2 in YP.unify(arg1, 36))
2979 {
2980 yield return false;
2981 }
2982 }
2983 {
2984 foreach (bool l2 in YP.unify(arg1, 38))
2985 {
2986 yield return false;
2987 }
2988 }
2989 {
2990 foreach (bool l2 in YP.unify(arg1, 42))
2991 {
2992 yield return false;
2993 }
2994 }
2995 {
2996 foreach (bool l2 in YP.unify(arg1, 43))
2997 {
2998 yield return false;
2999 }
3000 }
3001 {
3002 foreach (bool l2 in YP.unify(arg1, 45))
3003 {
3004 yield return false;
3005 }
3006 }
3007 {
3008 foreach (bool l2 in YP.unify(arg1, 46))
3009 {
3010 yield return false;
3011 }
3012 }
3013 {
3014 foreach (bool l2 in YP.unify(arg1, 47))
3015 {
3016 yield return false;
3017 }
3018 }
3019 {
3020 foreach (bool l2 in YP.unify(arg1, 58))
3021 {
3022 yield return false;
3023 }
3024 }
3025 {
3026 foreach (bool l2 in YP.unify(arg1, 60))
3027 {
3028 yield return false;
3029 }
3030 }
3031 {
3032 foreach (bool l2 in YP.unify(arg1, 61))
3033 {
3034 yield return false;
3035 }
3036 }
3037 {
3038 foreach (bool l2 in YP.unify(arg1, 62))
3039 {
3040 yield return false;
3041 }
3042 }
3043 {
3044 foreach (bool l2 in YP.unify(arg1, 63))
3045 {
3046 yield return false;
3047 }
3048 }
3049 {
3050 foreach (bool l2 in YP.unify(arg1, 64))
3051 {
3052 yield return false;
3053 }
3054 }
3055 {
3056 foreach (bool l2 in YP.unify(arg1, 92))
3057 {
3058 yield return false;
3059 }
3060 }
3061 {
3062 foreach (bool l2 in YP.unify(arg1, 94))
3063 {
3064 yield return false;
3065 }
3066 }
3067 {
3068 foreach (bool l2 in YP.unify(arg1, 96))
3069 {
3070 yield return false;
3071 }
3072 }
3073 {
3074 foreach (bool l2 in YP.unify(arg1, 126))
3075 {
3076 yield return false;
3077 }
3078 }
3079 }
3080
3081 public static IEnumerable<bool> get_current_position(object Pos)
3082 {
3083 {
3084 foreach (bool l2 in YP.unify(Pos, 0))
3085 {
3086 yield return false;
3087 }
3088 }
3089 }
3090
3091 public static IEnumerable<bool> read_after_atom4(object Ch, object Dict, object arg3, object Chars)
3092 {
3093 {
3094 Variable Atom_1 = new Variable();
3095 Variable Pos = new Variable();
3096 Variable Tokens = new Variable();
3097 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens)))
3098 {
3099 foreach (bool l3 in YP.unify(Pos, 0))
3100 {
3101 foreach (bool l4 in YP.atom_codes(Atom_1, Chars))
3102 {
3103 foreach (bool l5 in read_after_atom(Ch, Dict, Tokens))
3104 {
3105 yield return false;
3106 }
3107 }
3108 }
3109 }
3110 }
3111 }
3112
3113 public static IEnumerable<bool> read_after_atom(object arg1, object Dict, object arg3)
3114 {
3115 {
3116 Variable Tokens = new Variable();
3117 Variable NextCh = new Variable();
3118 foreach (bool l2 in YP.unify(arg1, 40))
3119 {
3120 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens)))
3121 {
3122 foreach (bool l4 in YP.get_code(NextCh))
3123 {
3124 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
3125 {
3126 yield return false;
3127 }
3128 }
3129 yield break;
3130 }
3131 }
3132 }
3133 {
3134 object Ch = arg1;
3135 object Tokens = arg3;
3136 foreach (bool l2 in read_tokens(Ch, Dict, Tokens))
3137 {
3138 yield return false;
3139 }
3140 }
3141 }
3142
3143 public static IEnumerable<bool> read_string(object Chars, object Quote, object NextCh)
3144 {
3145 {
3146 Variable Ch = new Variable();
3147 Variable Char = new Variable();
3148 Variable Next = new Variable();
3149 foreach (bool l2 in YP.get_code(Ch))
3150 {
3151 foreach (bool l3 in read_char(Ch, Quote, Char, Next))
3152 {
3153 foreach (bool l4 in rest_string5(Char, Next, Chars, Quote, NextCh))
3154 {
3155 yield return false;
3156 }
3157 }
3158 }
3159 }
3160 }
3161
3162 public static IEnumerable<bool> rest_string5(object arg1, object arg2, object arg3, object arg4, object arg5)
3163 {
3164 {
3165 object _X = arg4;
3166 Variable NextCh = new Variable();
3167 foreach (bool l2 in YP.unify(arg1, -1))
3168 {
3169 foreach (bool l3 in YP.unify(arg2, NextCh))
3170 {
3171 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
3172 {
3173 foreach (bool l5 in YP.unify(arg5, NextCh))
3174 {
3175 yield return true;
3176 yield break;
3177 }
3178 }
3179 }
3180 }
3181 }
3182 {
3183 object Char = arg1;
3184 object Next = arg2;
3185 object Quote = arg4;
3186 object NextCh = arg5;
3187 Variable Chars = new Variable();
3188 Variable Char2 = new Variable();
3189 Variable Next2 = new Variable();
3190 foreach (bool l2 in YP.unify(arg3, new ListPair(Char, Chars)))
3191 {
3192 foreach (bool l3 in read_char(Next, Quote, Char2, Next2))
3193 {
3194 foreach (bool l4 in rest_string5(Char2, Next2, Chars, Quote, NextCh))
3195 {
3196 yield return false;
3197 }
3198 }
3199 }
3200 }
3201 }
3202
3203 public static IEnumerable<bool> escape_char(object arg1, object arg2)
3204 {
3205 {
3206 foreach (bool l2 in YP.unify(arg1, 110))
3207 {
3208 foreach (bool l3 in YP.unify(arg2, 10))
3209 {
3210 yield return false;
3211 }
3212 }
3213 }
3214 {
3215 foreach (bool l2 in YP.unify(arg1, 78))
3216 {
3217 foreach (bool l3 in YP.unify(arg2, 10))
3218 {
3219 yield return false;
3220 }
3221 }
3222 }
3223 {
3224 foreach (bool l2 in YP.unify(arg1, 116))
3225 {
3226 foreach (bool l3 in YP.unify(arg2, 9))
3227 {
3228 yield return false;
3229 }
3230 }
3231 }
3232 {
3233 foreach (bool l2 in YP.unify(arg1, 84))
3234 {
3235 foreach (bool l3 in YP.unify(arg2, 9))
3236 {
3237 yield return false;
3238 }
3239 }
3240 }
3241 {
3242 foreach (bool l2 in YP.unify(arg1, 114))
3243 {
3244 foreach (bool l3 in YP.unify(arg2, 13))
3245 {
3246 yield return false;
3247 }
3248 }
3249 }
3250 {
3251 foreach (bool l2 in YP.unify(arg1, 82))
3252 {
3253 foreach (bool l3 in YP.unify(arg2, 13))
3254 {
3255 yield return false;
3256 }
3257 }
3258 }
3259 {
3260 foreach (bool l2 in YP.unify(arg1, 118))
3261 {
3262 foreach (bool l3 in YP.unify(arg2, 11))
3263 {
3264 yield return false;
3265 }
3266 }
3267 }
3268 {
3269 foreach (bool l2 in YP.unify(arg1, 86))
3270 {
3271 foreach (bool l3 in YP.unify(arg2, 11))
3272 {
3273 yield return false;
3274 }
3275 }
3276 }
3277 {
3278 foreach (bool l2 in YP.unify(arg1, 98))
3279 {
3280 foreach (bool l3 in YP.unify(arg2, 8))
3281 {
3282 yield return false;
3283 }
3284 }
3285 }
3286 {
3287 foreach (bool l2 in YP.unify(arg1, 66))
3288 {
3289 foreach (bool l3 in YP.unify(arg2, 8))
3290 {
3291 yield return false;
3292 }
3293 }
3294 }
3295 {
3296 foreach (bool l2 in YP.unify(arg1, 102))
3297 {
3298 foreach (bool l3 in YP.unify(arg2, 12))
3299 {
3300 yield return false;
3301 }
3302 }
3303 }
3304 {
3305 foreach (bool l2 in YP.unify(arg1, 70))
3306 {
3307 foreach (bool l3 in YP.unify(arg2, 12))
3308 {
3309 yield return false;
3310 }
3311 }
3312 }
3313 {
3314 foreach (bool l2 in YP.unify(arg1, 101))
3315 {
3316 foreach (bool l3 in YP.unify(arg2, 27))
3317 {
3318 yield return false;
3319 }
3320 }
3321 }
3322 {
3323 foreach (bool l2 in YP.unify(arg1, 69))
3324 {
3325 foreach (bool l3 in YP.unify(arg2, 27))
3326 {
3327 yield return false;
3328 }
3329 }
3330 }
3331 {
3332 foreach (bool l2 in YP.unify(arg1, 100))
3333 {
3334 foreach (bool l3 in YP.unify(arg2, 127))
3335 {
3336 yield return false;
3337 }
3338 }
3339 }
3340 {
3341 foreach (bool l2 in YP.unify(arg1, 68))
3342 {
3343 foreach (bool l3 in YP.unify(arg2, 127))
3344 {
3345 yield return false;
3346 }
3347 }
3348 }
3349 {
3350 foreach (bool l2 in YP.unify(arg1, 115))
3351 {
3352 foreach (bool l3 in YP.unify(arg2, 32))
3353 {
3354 yield return false;
3355 }
3356 }
3357 }
3358 {
3359 foreach (bool l2 in YP.unify(arg1, 83))
3360 {
3361 foreach (bool l3 in YP.unify(arg2, 32))
3362 {
3363 yield return false;
3364 }
3365 }
3366 }
3367 {
3368 foreach (bool l2 in YP.unify(arg1, 122))
3369 {
3370 foreach (bool l3 in YP.unify(arg2, -1))
3371 {
3372 yield return false;
3373 }
3374 }
3375 }
3376 {
3377 foreach (bool l2 in YP.unify(arg1, 90))
3378 {
3379 foreach (bool l3 in YP.unify(arg2, -1))
3380 {
3381 yield return false;
3382 }
3383 }
3384 }
3385 }
3386
3387 public static IEnumerable<bool> read_variable(object C1, object Dict, object arg3)
3388 {
3389 {
3390 Variable Var = new Variable();
3391 Variable Name = new Variable();
3392 Variable StartPos = new Variable();
3393 Variable Tokens = new Variable();
3394 Variable Chars = new Variable();
3395 Variable NextCh = new Variable();
3396 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens)))
3397 {
3398 foreach (bool l3 in get_current_position(StartPos))
3399 {
3400 foreach (bool l4 in read_name(C1, Chars, NextCh))
3401 {
3402 foreach (bool l5 in YP.atom_codes(Name, Chars))
3403 {
3404 if (YP.termEqual(Name, Atom.a(@"_")))
3405 {
3406 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3407 {
3408 yield return false;
3409 }
3410 goto cutIf1;
3411 }
3412 foreach (bool l6 in read_lookup(Dict, Name, Var))
3413 {
3414 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3415 {
3416 yield return false;
3417 }
3418 }
3419 cutIf1:
3420 { }
3421 }
3422 }
3423 }
3424 }
3425 }
3426 }
3427
3428 public static IEnumerable<bool> read_lookup(object arg1, object Name, object Var)
3429 {
3430 {
3431 Variable N = new Variable();
3432 Variable V = new Variable();
3433 Variable L = new Variable();
3434 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L)))
3435 {
3436 foreach (bool l3 in YP.unify(N, Name))
3437 {
3438 foreach (bool l4 in YP.unify(V, Var))
3439 {
3440 yield return false;
3441 }
3442 goto cutIf1;
3443 }
3444 foreach (bool l3 in read_lookup(L, Name, Var))
3445 {
3446 yield return false;
3447 }
3448 cutIf1:
3449 { }
3450 }
3451 }
3452 }
3453
3454 public static IEnumerable<bool> read_solidus(object Ch, object LastCh)
3455 {
3456 {
3457 Variable NextCh = new Variable();
3458 if (YP.equal(Ch, 42))
3459 {
3460 foreach (bool l3 in YP.get_code(NextCh))
3461 {
3462 if (YP.equal(NextCh, 47))
3463 {
3464 foreach (bool l5 in YP.get_code(LastCh))
3465 {
3466 yield return false;
3467 }
3468 goto cutIf2;
3469 }
3470 foreach (bool l4 in read_solidus(NextCh, LastCh))
3471 {
3472 yield return false;
3473 }
3474 cutIf2:
3475 { }
3476 }
3477 goto cutIf1;
3478 }
3479 if (YP.notEqual(Ch, -1))
3480 {
3481 foreach (bool l3 in YP.get_code(NextCh))
3482 {
3483 foreach (bool l4 in read_solidus(NextCh, LastCh))
3484 {
3485 yield return false;
3486 }
3487 }
3488 goto cutIf3;
3489 }
3490 foreach (bool l2 in YP.unify(LastCh, Ch))
3491 {
3492 foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL))
3493 {
3494 yield return false;
3495 }
3496 }
3497 cutIf3:
3498 cutIf1:
3499 { }
3500 }
3501 }
3502
3503 public static IEnumerable<bool> read_identifier(object C1, object Dict, object Tokens)
3504 {
3505 {
3506 Variable Chars = new Variable();
3507 Variable NextCh = new Variable();
3508 foreach (bool l2 in read_name(C1, Chars, NextCh))
3509 {
3510 foreach (bool l3 in read_after_atom4(NextCh, Dict, Tokens, Chars))
3511 {
3512 yield return false;
3513 }
3514 }
3515 }
3516 }
3517
3518 public static IEnumerable<bool> read_name(object C1, object arg2, object LastCh)
3519 {
3520 {
3521 Variable Chars = new Variable();
3522 Variable C2 = new Variable();
3523 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3524 {
3525 foreach (bool l3 in YP.get_code(C2))
3526 {
3527 if (YP.greaterThanOrEqual(C2, new ListPair(97, Atom.NIL)))
3528 {
3529 if (YP.lessThanOrEqual(C2, new ListPair(122, Atom.NIL)))
3530 {
3531 foreach (bool l6 in read_name(C2, Chars, LastCh))
3532 {
3533 yield return false;
3534 }
3535 goto cutIf2;
3536 }
3537 if (YP.lessThan(C2, 192))
3538 {
3539 if (YP.notEqual(YP.bitwiseOr(C2, 16), 186))
3540 {
3541 foreach (bool l7 in YP.unify(Chars, Atom.NIL))
3542 {
3543 foreach (bool l8 in YP.unify(LastCh, C2))
3544 {
3545 yield return false;
3546 }
3547 }
3548 goto cutIf3;
3549 }
3550 }
3551 if (YP.equal(YP.bitwiseOr(C2, 32), 247))
3552 {
3553 foreach (bool l6 in YP.unify(Chars, Atom.NIL))
3554 {
3555 foreach (bool l7 in YP.unify(LastCh, C2))
3556 {
3557 yield return false;
3558 }
3559 }
3560 goto cutIf4;
3561 }
3562 foreach (bool l5 in read_name(C2, Chars, LastCh))
3563 {
3564 yield return false;
3565 }
3566 cutIf4:
3567 cutIf3:
3568 cutIf2:
3569 goto cutIf1;
3570 }
3571 if (YP.greaterThanOrEqual(C2, new ListPair(65, Atom.NIL)))
3572 {
3573 if (YP.greaterThan(C2, new ListPair(90, Atom.NIL)))
3574 {
3575 if (YP.notEqual(C2, new ListPair(95, Atom.NIL)))
3576 {
3577 foreach (bool l7 in YP.unify(Chars, Atom.NIL))
3578 {
3579 foreach (bool l8 in YP.unify(LastCh, C2))
3580 {
3581 yield return false;
3582 }
3583 }
3584 goto cutIf6;
3585 }
3586 }
3587 foreach (bool l5 in read_name(C2, Chars, LastCh))
3588 {
3589 yield return false;
3590 }
3591 cutIf6:
3592 goto cutIf5;
3593 }
3594 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3595 {
3596 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3597 {
3598 foreach (bool l6 in read_name(C2, Chars, LastCh))
3599 {
3600 yield return false;
3601 }
3602 goto cutIf7;
3603 }
3604 }
3605 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3606 {
3607 foreach (bool l5 in YP.unify(LastCh, C2))
3608 {
3609 yield return false;
3610 }
3611 }
3612 cutIf7:
3613 cutIf5:
3614 cutIf1:
3615 { }
3616 }
3617 }
3618 }
3619 }
3620
3621 public static IEnumerable<bool> read_fullstop(object Ch, object Dict, object Tokens)
3622 {
3623 {
3624 Variable Number = new Variable();
3625 Variable Tokens1 = new Variable();
3626 Variable Chars = new Variable();
3627 Variable NextCh = new Variable();
3628 if (YP.lessThanOrEqual(Ch, new ListPair(57, Atom.NIL)))
3629 {
3630 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL)))
3631 {
3632 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1)))
3633 {
3634 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch))
3635 {
3636 yield return false;
3637 }
3638 }
3639 goto cutIf1;
3640 }
3641 }
3642 if (YP.greaterThan(Ch, new ListPair(32, Atom.NIL)))
3643 {
3644 foreach (bool l3 in rest_symbol(Ch, Chars, NextCh))
3645 {
3646 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(46, Chars)))
3647 {
3648 yield return false;
3649 }
3650 }
3651 goto cutIf2;
3652 }
3653 if (YP.greaterThanOrEqual(Ch, 0))
3654 {
3655 foreach (bool l3 in YP.unify(Tokens, Atom.NIL))
3656 {
3657 yield return false;
3658 }
3659 goto cutIf3;
3660 }
3661 foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL))
3662 {
3663 }
3664 cutIf3:
3665 cutIf2:
3666 cutIf1:
3667 { }
3668 }
3669 }
3670
3671 public static IEnumerable<bool> read_float(object Number, object Dict, object Tokens, object Digits, object Digit)
3672 {
3673 {
3674 Variable Chars = new Variable();
3675 Variable Rest = new Variable();
3676 Variable NextCh = new Variable();
3677 foreach (bool l2 in prepend(Digits, Chars, Rest))
3678 {
3679 foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars))
3680 {
3681 foreach (bool l4 in YP.number_codes(Number, Chars))
3682 {
3683 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
3684 {
3685 yield return false;
3686 }
3687 }
3688 }
3689 }
3690 }
3691 }
3692
3693 public static IEnumerable<bool> prepend(object arg1, object arg2, object arg3)
3694 {
3695 {
3696 object X = arg3;
3697 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3698 {
3699 foreach (bool l3 in YP.unify(arg2, new ListPair(46, X)))
3700 {
3701 yield return false;
3702 }
3703 }
3704 }
3705 {
3706 object Y = arg3;
3707 Variable C = new Variable();
3708 Variable Cs = new Variable();
3709 Variable X = new Variable();
3710 foreach (bool l2 in YP.unify(arg1, new ListPair(C, Cs)))
3711 {
3712 foreach (bool l3 in YP.unify(arg2, new ListPair(C, X)))
3713 {
3714 foreach (bool l4 in prepend(Cs, X, Y))
3715 {
3716 yield return false;
3717 }
3718 }
3719 }
3720 }
3721 }
3722
3723 public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total)
3724 {
3725 {
3726 Variable Chars = new Variable();
3727 Variable C2 = new Variable();
3728 Variable C3 = new Variable();
3729 Variable C4 = new Variable();
3730 Variable More = new Variable();
3731 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3732 {
3733 foreach (bool l3 in YP.get_code(C2))
3734 {
3735 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3736 {
3737 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3738 {
3739 foreach (bool l6 in read_float(C2, Chars, NextCh, Total))
3740 {
3741 yield return false;
3742 }
3743 goto cutIf1;
3744 }
3745 }
3746 if (YP.equal(YP.bitwiseOr(C2, 32), new ListPair(101, Atom.NIL)))
3747 {
3748 foreach (bool l5 in YP.get_code(C3))
3749 {
3750 if (YP.equal(C3, new ListPair(45, Atom.NIL)))
3751 {
3752 foreach (bool l7 in YP.get_code(C4))
3753 {
3754 foreach (bool l8 in YP.unify(Chars, new ListPair(C2, new ListPair(45, More))))
3755 {
3756 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3757 {
3758 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3759 {
3760 foreach (bool l11 in read_exponent(C4, More, NextCh))
3761 {
3762 yield return false;
3763 }
3764 goto cutIf4;
3765 }
3766 }
3767 foreach (bool l9 in YP.unify(More, Atom.NIL))
3768 {
3769 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3770 {
3771 }
3772 }
3773 foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL)))
3774 {
3775 foreach (bool l10 in YP.unify(NextCh, C4))
3776 {
3777 yield return false;
3778 }
3779 }
3780 cutIf4:
3781 { }
3782 }
3783 }
3784 goto cutIf3;
3785 }
3786 if (YP.equal(C3, new ListPair(43, Atom.NIL)))
3787 {
3788 foreach (bool l7 in YP.get_code(C4))
3789 {
3790 foreach (bool l8 in YP.unify(Chars, new ListPair(C2, More)))
3791 {
3792 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3793 {
3794 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3795 {
3796 foreach (bool l11 in read_exponent(C4, More, NextCh))
3797 {
3798 yield return false;
3799 }
3800 goto cutIf6;
3801 }
3802 }
3803 foreach (bool l9 in YP.unify(More, Atom.NIL))
3804 {
3805 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3806 {
3807 }
3808 }
3809 foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL)))
3810 {
3811 foreach (bool l10 in YP.unify(NextCh, C4))
3812 {
3813 yield return false;
3814 }
3815 }
3816 cutIf6:
3817 { }
3818 }
3819 }
3820 goto cutIf5;
3821 }
3822 foreach (bool l6 in YP.unify(C4, C3))
3823 {
3824 foreach (bool l7 in YP.unify(Chars, new ListPair(C2, More)))
3825 {
3826 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3827 {
3828 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3829 {
3830 foreach (bool l10 in read_exponent(C4, More, NextCh))
3831 {
3832 yield return false;
3833 }
3834 goto cutIf7;
3835 }
3836 }
3837 foreach (bool l8 in YP.unify(More, Atom.NIL))
3838 {
3839 foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3840 {
3841 }
3842 }
3843 foreach (bool l8 in YP.unify(More, new ListPair(48, Atom.NIL)))
3844 {
3845 foreach (bool l9 in YP.unify(NextCh, C4))
3846 {
3847 yield return false;
3848 }
3849 }
3850 cutIf7:
3851 { }
3852 }
3853 }
3854 cutIf5:
3855 cutIf3:
3856 { }
3857 }
3858 goto cutIf2;
3859 }
3860 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3861 {
3862 foreach (bool l5 in YP.unify(NextCh, C2))
3863 {
3864 yield return false;
3865 }
3866 }
3867 cutIf2:
3868 cutIf1:
3869 { }
3870 }
3871 }
3872 }
3873 }
3874
3875 public static IEnumerable<bool> read_exponent(object C1, object arg2, object NextCh)
3876 {
3877 {
3878 Variable Chars = new Variable();
3879 Variable C2 = new Variable();
3880 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3881 {
3882 foreach (bool l3 in YP.get_code(C2))
3883 {
3884 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3885 {
3886 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3887 {
3888 foreach (bool l6 in read_exponent(C2, Chars, NextCh))
3889 {
3890 yield return false;
3891 }
3892 goto cutIf1;
3893 }
3894 }
3895 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3896 {
3897 foreach (bool l5 in YP.unify(NextCh, C2))
3898 {
3899 yield return false;
3900 }
3901 }
3902 cutIf1:
3903 { }
3904 }
3905 }
3906 }
3907 }
3908
3909 public static IEnumerable<bool> read_number(object C1, object Dict, object arg3)
3910 {
3911 {
3912 Variable Number = new Variable();
3913 Variable Tokens = new Variable();
3914 Variable C2 = new Variable();
3915 Variable N = new Variable();
3916 Variable C = new Variable();
3917 Variable C3 = new Variable();
3918 Variable Digits = new Variable();
3919 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens)))
3920 {
3921 foreach (bool l3 in read_number4(C1, C2, 0, N))
3922 {
3923 if (YP.equal(C2, 39))
3924 {
3925 if (YP.greaterThanOrEqual(N, 2))
3926 {
3927 if (YP.lessThanOrEqual(N, 36))
3928 {
3929 foreach (bool l7 in read_based(N, 0, Number, C))
3930 {
3931 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3932 {
3933 yield return false;
3934 }
3935 }
3936 goto cutIf2;
3937 }
3938 }
3939 if (YP.equal(N, 0))
3940 {
3941 foreach (bool l6 in YP.get_code(C3))
3942 {
3943 foreach (bool l7 in read_char(C3, -1, Number, C))
3944 {
3945 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3946 {
3947 yield return false;
3948 }
3949 }
3950 }
3951 goto cutIf3;
3952 }
3953 foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** ~d' read as ~d '~n"), new ListPair(N, new ListPair(N, Atom.NIL))))
3954 {
3955 foreach (bool l6 in YP.unify(Number, N))
3956 {
3957 foreach (bool l7 in YP.unify(C, C2))
3958 {
3959 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3960 {
3961 yield return false;
3962 }
3963 }
3964 }
3965 }
3966 cutIf3:
3967 cutIf2:
3968 goto cutIf1;
3969 }
3970 if (YP.equal(C2, 46))
3971 {
3972 foreach (bool l5 in YP.get_code(C3))
3973 {
3974 if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL)))
3975 {
3976 if (YP.lessThanOrEqual(C3, new ListPair(57, Atom.NIL)))
3977 {
3978 foreach (bool l8 in YP.number_codes(N, Digits))
3979 {
3980 foreach (bool l9 in read_float(Number, Dict, Tokens, Digits, C3))
3981 {
3982 yield return false;
3983 }
3984 }
3985 goto cutIf5;
3986 }
3987 }
3988 foreach (bool l6 in YP.unify(Number, N))
3989 {
3990 foreach (bool l7 in read_fullstop(C3, Dict, Tokens))
3991 {
3992 yield return false;
3993 }
3994 }
3995 cutIf5:
3996 { }
3997 }
3998 goto cutIf4;
3999 }
4000 foreach (bool l4 in YP.unify(Number, N))
4001 {
4002 foreach (bool l5 in read_tokens(C2, Dict, Tokens))
4003 {
4004 yield return false;
4005 }
4006 }
4007 cutIf4:
4008 cutIf1:
4009 { }
4010 }
4011 }
4012 }
4013 }
4014
4015 public static IEnumerable<bool> read_number4(object C0, object C, object N0, object N)
4016 {
4017 {
4018 Variable N1 = new Variable();
4019 Variable C1 = new Variable();
4020 if (YP.greaterThanOrEqual(C0, new ListPair(48, Atom.NIL)))
4021 {
4022 if (YP.lessThanOrEqual(C0, new ListPair(57, Atom.NIL)))
4023 {
4024 foreach (bool l4 in YP.unify(N1, YP.add(YP.subtract(YP.multiply(N0, 10), new ListPair(48, Atom.NIL)), C0)))
4025 {
4026 foreach (bool l5 in YP.get_code(C1))
4027 {
4028 foreach (bool l6 in read_number4(C1, C, N1, N))
4029 {
4030 yield return false;
4031 }
4032 }
4033 }
4034 goto cutIf1;
4035 }
4036 }
4037 if (YP.equal(C0, 95))
4038 {
4039 foreach (bool l3 in YP.get_code(C1))
4040 {
4041 foreach (bool l4 in read_number4(C1, C, N0, N))
4042 {
4043 yield return false;
4044 }
4045 }
4046 goto cutIf2;
4047 }
4048 foreach (bool l2 in YP.unify(C, C0))
4049 {
4050 foreach (bool l3 in YP.unify(N, N0))
4051 {
4052 yield return false;
4053 }
4054 }
4055 cutIf2:
4056 cutIf1:
4057 { }
4058 }
4059 }
4060
4061 public static IEnumerable<bool> read_based(object Base, object N0, object N, object C)
4062 {
4063 {
4064 Variable C1 = new Variable();
4065 Variable Digit = new Variable();
4066 Variable N1 = new Variable();
4067 foreach (bool l2 in YP.get_code(C1))
4068 {
4069 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
4070 {
4071 if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
4072 {
4073 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, new ListPair(48, Atom.NIL))))
4074 {
4075 if (YP.lessThan(Digit, Base))
4076 {
4077 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4078 {
4079 foreach (bool l8 in read_based(Base, N1, N, C))
4080 {
4081 yield return false;
4082 }
4083 }
4084 goto cutIf2;
4085 }
4086 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4087 {
4088 foreach (bool l7 in read_based(Base, N0, N, C))
4089 {
4090 yield return false;
4091 }
4092 goto cutIf3;
4093 }
4094 foreach (bool l6 in YP.unify(N, N0))
4095 {
4096 foreach (bool l7 in YP.unify(C, C1))
4097 {
4098 yield return false;
4099 }
4100 }
4101 cutIf3:
4102 cutIf2:
4103 { }
4104 }
4105 goto cutIf1;
4106 }
4107 }
4108 if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
4109 {
4110 if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
4111 {
4112 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(65, Atom.NIL), 10))))
4113 {
4114 if (YP.lessThan(Digit, Base))
4115 {
4116 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4117 {
4118 foreach (bool l8 in read_based(Base, N1, N, C))
4119 {
4120 yield return false;
4121 }
4122 }
4123 goto cutIf5;
4124 }
4125 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4126 {
4127 foreach (bool l7 in read_based(Base, N0, N, C))
4128 {
4129 yield return false;
4130 }
4131 goto cutIf6;
4132 }
4133 foreach (bool l6 in YP.unify(N, N0))
4134 {
4135 foreach (bool l7 in YP.unify(C, C1))
4136 {
4137 yield return false;
4138 }
4139 }
4140 cutIf6:
4141 cutIf5:
4142 { }
4143 }
4144 goto cutIf4;
4145 }
4146 }
4147 if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
4148 {
4149 if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
4150 {
4151 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(97, Atom.NIL), 10))))
4152 {
4153 if (YP.lessThan(Digit, Base))
4154 {
4155 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4156 {
4157 foreach (bool l8 in read_based(Base, N1, N, C))
4158 {
4159 yield return false;
4160 }
4161 }
4162 goto cutIf8;
4163 }
4164 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4165 {
4166 foreach (bool l7 in read_based(Base, N0, N, C))
4167 {
4168 yield return false;
4169 }
4170 goto cutIf9;
4171 }
4172 foreach (bool l6 in YP.unify(N, N0))
4173 {
4174 foreach (bool l7 in YP.unify(C, C1))
4175 {
4176 yield return false;
4177 }
4178 }
4179 cutIf9:
4180 cutIf8:
4181 { }
4182 }
4183 goto cutIf7;
4184 }
4185 }
4186 foreach (bool l3 in YP.unify(Digit, 99))
4187 {
4188 if (YP.lessThan(Digit, Base))
4189 {
4190 foreach (bool l5 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4191 {
4192 foreach (bool l6 in read_based(Base, N1, N, C))
4193 {
4194 yield return false;
4195 }
4196 }
4197 goto cutIf10;
4198 }
4199 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4200 {
4201 foreach (bool l5 in read_based(Base, N0, N, C))
4202 {
4203 yield return false;
4204 }
4205 goto cutIf11;
4206 }
4207 foreach (bool l4 in YP.unify(N, N0))
4208 {
4209 foreach (bool l5 in YP.unify(C, C1))
4210 {
4211 yield return false;
4212 }
4213 }
4214 cutIf11:
4215 cutIf10:
4216 { }
4217 }
4218 cutIf7:
4219 cutIf4:
4220 cutIf1:
4221 { }
4222 }
4223 }
4224 }
4225
4226 public static IEnumerable<bool> read_char(object Char, object Quote, object Result, object Next)
4227 {
4228 {
4229 Variable C1 = new Variable();
4230 Variable C2 = new Variable();
4231 Variable C3 = new Variable();
4232 Variable Ch = new Variable();
4233 if (YP.equal(Char, 92))
4234 {
4235 foreach (bool l3 in YP.get_code(C1))
4236 {
4237 if (YP.lessThan(C1, 0))
4238 {
4239 foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~cquoted~c~n"), new ListPair(Quote, new ListPair(Quote, Atom.NIL))))
4240 {
4241 foreach (bool l6 in YP.unify(Result, -1))
4242 {
4243 foreach (bool l7 in YP.unify(Next, C1))
4244 {
4245 yield return false;
4246 }
4247 }
4248 }
4249 goto cutIf2;
4250 }
4251 if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
4252 {
4253 foreach (bool l5 in YP.get_code(C2))
4254 {
4255 foreach (bool l6 in read_char(C2, Quote, Result, Next))
4256 {
4257 yield return false;
4258 }
4259 }
4260 goto cutIf3;
4261 }
4262 if (YP.equal(YP.bitwiseOr(C1, 32), new ListPair(99, Atom.NIL)))
4263 {
4264 foreach (bool l5 in YP.get_code(C2))
4265 {
4266 foreach (bool l6 in read_char(C2, Quote, Result, Next))
4267 {
4268 yield return false;
4269 }
4270 }
4271 goto cutIf4;
4272 }
4273 if (YP.lessThanOrEqual(C1, new ListPair(55, Atom.NIL)))
4274 {
4275 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
4276 {
4277 foreach (bool l6 in YP.get_code(C2))
4278 {
4279 if (YP.lessThanOrEqual(C2, new ListPair(55, Atom.NIL)))
4280 {
4281 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
4282 {
4283 foreach (bool l9 in YP.get_code(C3))
4284 {
4285 if (YP.lessThanOrEqual(C3, new ListPair(55, Atom.NIL)))
4286 {
4287 if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL)))
4288 {
4289 foreach (bool l12 in YP.get_code(Next))
4290 {
4291 foreach (bool l13 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(YP.add(YP.multiply(C1, 8), C2), 8), C3), YP.multiply(73, new ListPair(48, Atom.NIL)))))
4292 {
4293 yield return false;
4294 }
4295 }
4296 goto cutIf7;
4297 }
4298 }
4299 foreach (bool l10 in YP.unify(Next, C3))
4300 {
4301 foreach (bool l11 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(C1, 8), C2), YP.multiply(9, new ListPair(48, Atom.NIL)))))
4302 {
4303 yield return false;
4304 }
4305 }
4306 cutIf7:
4307 { }
4308 }
4309 goto cutIf6;
4310 }
4311 }
4312 foreach (bool l7 in YP.unify(Next, C2))
4313 {
4314 foreach (bool l8 in YP.unify(Result, YP.subtract(C1, new ListPair(48, Atom.NIL))))
4315 {
4316 yield return false;
4317 }
4318 }
4319 cutIf6:
4320 { }
4321 }
4322 goto cutIf5;
4323 }
4324 }
4325 if (YP.equal(C1, new ListPair(94, Atom.NIL)))
4326 {
4327 foreach (bool l5 in YP.get_code(C2))
4328 {
4329 if (YP.lessThan(C2, 0))
4330 {
4331 foreach (bool l7 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~c..~c^..~c~n"), new ListPair(Quote, new ListPair(92, new ListPair(Quote, Atom.NIL)))))
4332 {
4333 foreach (bool l8 in YP.unify(Result, -1))
4334 {
4335 foreach (bool l9 in YP.unify(Next, C2))
4336 {
4337 yield return false;
4338 }
4339 }
4340 }
4341 goto cutIf9;
4342 }
4343 if (YP.equal(C2, new ListPair(63, Atom.NIL)))
4344 {
4345 foreach (bool l7 in YP.unify(Result, 127))
4346 {
4347 foreach (bool l8 in YP.get_code(Next))
4348 {
4349 yield return false;
4350 }
4351 }
4352 goto cutIf10;
4353 }
4354 foreach (bool l6 in YP.unify(Result, YP.bitwiseAnd(C2, 31)))
4355 {
4356 foreach (bool l7 in YP.get_code(Next))
4357 {
4358 yield return false;
4359 }
4360 }
4361 cutIf10:
4362 cutIf9:
4363 { }
4364 }
4365 goto cutIf8;
4366 }
4367 foreach (bool l4 in escape_char(C1, Result))
4368 {
4369 foreach (bool l5 in YP.get_code(Next))
4370 {
4371 yield return false;
4372 }
4373 goto cutIf11;
4374 }
4375 foreach (bool l4 in YP.unify(Result, C1))
4376 {
4377 foreach (bool l5 in YP.get_code(Next))
4378 {
4379 yield return false;
4380 }
4381 }
4382 cutIf11:
4383 cutIf8:
4384 cutIf5:
4385 cutIf4:
4386 cutIf3:
4387 cutIf2:
4388 { }
4389 }
4390 goto cutIf1;
4391 }
4392 if (YP.equal(Char, Quote))
4393 {
4394 foreach (bool l3 in YP.get_code(Ch))
4395 {
4396 if (YP.equal(Ch, Quote))
4397 {
4398 foreach (bool l5 in YP.unify(Result, Quote))
4399 {
4400 foreach (bool l6 in YP.get_code(Next))
4401 {
4402 yield return false;
4403 }
4404 }
4405 goto cutIf13;
4406 }
4407 foreach (bool l4 in YP.unify(Result, -1))
4408 {
4409 foreach (bool l5 in YP.unify(Next, Ch))
4410 {
4411 yield return false;
4412 }
4413 }
4414 cutIf13:
4415 { }
4416 }
4417 goto cutIf12;
4418 }
4419 if (YP.lessThan(Char, new ListPair(32, Atom.NIL)))
4420 {
4421 if (YP.notEqual(Char, 9))
4422 {
4423 if (YP.notEqual(Char, 10))
4424 {
4425 if (YP.notEqual(Char, 13))
4426 {
4427 foreach (bool l6 in YP.unify(Result, -1))
4428 {
4429 foreach (bool l7 in YP.unify(Next, Char))
4430 {
4431 foreach (bool l8 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Strange character ~d ends ~ctoken~c~n"), new ListPair(Char, new ListPair(Quote, new ListPair(Quote, Atom.NIL)))))
4432 {
4433 yield return false;
4434 }
4435 }
4436 }
4437 goto cutIf14;
4438 }
4439 }
4440 }
4441 }
4442 foreach (bool l2 in YP.unify(Result, Char))
4443 {
4444 foreach (bool l3 in YP.get_code(Next))
4445 {
4446 yield return false;
4447 }
4448 }
4449 cutIf14:
4450 cutIf12:
4451 cutIf1:
4452 { }
4453 }
4454 }
4455
4456 }
4457}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
new file mode 100644
index 0000000..f29c751
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32
33namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
34{
35 /// <summary>
36 /// A PrologException is used as the exception thrown by YP.throw(Term).
37 /// </summary>
38 public class PrologException : Exception
39 {
40 public readonly object _term;
41
42 /// <summary>
43 /// Create a PrologException with the given Term. The printable exception message is the full Term.
44 /// </summary>
45 /// <param name="Term">the term of the exception</param>
46 /// </param>
47 public PrologException(object Term)
48 : base(YP.getValue(Term).ToString())
49 {
50 _term = YP.makeCopy(Term, new Variable.CopyStore());
51 }
52
53 /// <summary>
54 /// 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.
56 /// </summary>
57 /// <param name="ErrorTerm">the term of the exception</param>
58 /// <param name="Messsage">the message, converted to a string, to use as the printable exception message
59 /// </param>
60 public PrologException(object ErrorTerm, object Message)
61 : base(YP.getValue(Message).ToString())
62 {
63 _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore());
64 }
65
66 public object Term
67 {
68 get { return _term; }
69 }
70 }
71}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs
new file mode 100644
index 0000000..4b6112f
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32
33namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
34{
35 /// <summary>
36 /// An UndefinedPredicateException extends PrologException to create an existence_error exception.
37 /// </summary>
38 public class UndefinedPredicateException : PrologException
39 {
40 private Atom _predicateName;
41 private int _arity;
42
43 public UndefinedPredicateException(object message, Atom predicateName, int arity)
44 : base(new Functor2
45 (Atom.a("existence_error"), Atom.a("procedure"), new Functor2(Atom.a("/"), predicateName, arity)),
46 message)
47 {
48 _predicateName = predicateName;
49 _arity = arity;
50 }
51
52 public Atom PredicateName
53 {
54 get { return _predicateName; }
55 }
56
57 public int Arity
58 {
59 get { return _arity; }
60 }
61 }
62}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
new file mode 100644
index 0000000..2b5b0f1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
@@ -0,0 +1,196 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 public interface IUnifiable
38 {
39 IEnumerable<bool> unify(object arg);
40 void addUniqueVariables(List<Variable> variableSet);
41 object makeCopy(Variable.CopyStore copyStore);
42 bool termEqual(object term);
43 bool ground();
44 }
45
46 public class Variable : IUnifiable
47 {
48 // Use _isBound separate from _value so that it can be bound to any value,
49 // including null.
50 private bool _isBound = false;
51 private object _value;
52
53 public object getValue()
54 {
55 if (!_isBound)
56 return this;
57
58 object result = _value;
59 while (result is Variable)
60 {
61 if (!((Variable)result)._isBound)
62 return result;
63
64 // Keep following the Variable chain.
65 result = ((Variable)result)._value;
66 }
67
68 return result;
69 }
70
71 public IEnumerable<bool> unify(object arg)
72 {
73 if (!_isBound)
74 {
75 _value = YP.getValue(arg);
76 if (_value == this)
77 // We are unifying this unbound variable with itself, so leave it unbound.
78 yield return false;
79 else
80 {
81 _isBound = true;
82 try
83 {
84 yield return false;
85 }
86 finally
87 {
88 // Remove the binding.
89 _isBound = false;
90 }
91 }
92 }
93 else
94 {
95 foreach (bool l1 in YP.unify(this, arg))
96 yield return false;
97 }
98 }
99
100 public override string ToString()
101 {
102 object value = getValue();
103 if (value == this)
104 return "Variable";
105 else
106 return getValue().ToString();
107 }
108
109 /// <summary>
110 /// If bound, call YP.addUniqueVariables on the value. Otherwise, if this unbound
111 /// variable is not already in variableSet, add it.
112 /// </summary>
113 /// <param name="variableSet"></param>
114 public void addUniqueVariables(List<Variable> variableSet)
115 {
116 if (_isBound)
117 YP.addUniqueVariables(getValue(), variableSet);
118 else
119 {
120 if (variableSet.IndexOf(this) < 0)
121 variableSet.Add(this);
122 }
123 }
124
125 /// <summary>
126 /// If bound, return YP.makeCopy for the value, else return copyStore.getCopy(this).
127 /// However, if copyStore is null, just return this.
128 /// </summary>
129 /// <param name="copyStore"></param>
130 /// <returns></returns>
131 public object makeCopy(Variable.CopyStore copyStore)
132 {
133 if (_isBound)
134 return YP.makeCopy(getValue(), copyStore);
135 else
136 return copyStore == null ? this : copyStore.getCopy(this);
137 }
138
139 public bool termEqual(object term)
140 {
141 if (_isBound)
142 return YP.termEqual(getValue(), term);
143 else
144 return this == YP.getValue(term);
145 }
146
147 public bool ground()
148 {
149 if (_isBound)
150 // This is usually called by YP.ground which already did getValue, so this
151 // should never be reached, but check anyway.
152 return YP.ground(getValue());
153 else
154 return false;
155 }
156
157 /// <summary>
158 /// A CopyStore is used by makeCopy to track which Variable objects have
159 /// been copied.
160 /// </summary>
161 public class CopyStore
162 {
163 private List<Variable> _inVariableSet = new List<Variable>();
164 private List<Variable> _outVariableSet = new List<Variable>();
165
166 /// <summary>
167 /// If inVariable has already been copied, return its copy. Otherwise,
168 /// return a fresh Variable associated with inVariable.
169 /// </summary>
170 /// <param name="inVariable"></param>
171 /// <returns></returns>
172 public Variable getCopy(Variable inVariable)
173 {
174 int index = _inVariableSet.IndexOf(inVariable);
175 if (index >= 0)
176 return _outVariableSet[index];
177 else
178 {
179 Variable outVariable = new Variable();
180 _inVariableSet.Add(inVariable);
181 _outVariableSet.Add(outVariable);
182 return outVariable;
183 }
184 }
185
186 /// <summary>
187 /// Return the number of unique variables that have been copied.
188 /// </summary>
189 /// <returns></returns>
190 public int getNUniqueVariables()
191 {
192 return _inVariableSet.Count;
193 }
194 }
195 }
196}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
new file mode 100644
index 0000000..74704aa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
@@ -0,0 +1,1644 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34using System.IO;
35using System.Reflection;
36
37namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
38{
39 /// <summary>
40 /// YP has static methods for general functions in Yield Prolog such as <see cref="getValue"/>
41 /// and <see cref="unify"/>.
42 /// </summary>
43 public class YP
44 {
45 private static Fail _fail = new Fail();
46 private static Repeat _repeat = new Repeat();
47 private static Dictionary<NameArity, List<IClause>> _predicatesStore =
48 new Dictionary<NameArity, List<IClause>>();
49 private static TextWriter _outputStream = System.Console.Out;
50 private static TextReader _inputStream = System.Console.In;
51 private static List<object[]> _operatorTable = null;
52
53 /// <summary>
54 /// An IClause is used so that dynamic predicates can call match.
55 /// </summary>
56 public interface IClause
57 {
58 IEnumerable<bool> match(object[] args);
59 }
60
61 public static object getValue(object value)
62 {
63 if (value is Variable)
64 return ((Variable)value).getValue();
65 else
66 return value;
67 }
68
69 public static IEnumerable<bool> unify(object arg1, object arg2)
70 {
71 arg1 = getValue(arg1);
72 arg2 = getValue(arg2);
73 if (arg1 is IUnifiable)
74 return ((IUnifiable)arg1).unify(arg2);
75 else if (arg2 is IUnifiable)
76 return ((IUnifiable)arg2).unify(arg1);
77 else
78 {
79 // Arguments are "normal" types.
80 if (arg1.Equals(arg2))
81 return new Succeed();
82 else
83 return _fail;
84 }
85 }
86
87 /// <summary>
88 /// This is used for the lookup key in _factStore.
89 /// </summary>
90 public struct NameArity
91 {
92 public readonly Atom _name;
93 public readonly int _arity;
94
95 public NameArity(Atom name, int arity)
96 {
97 _name = name;
98 _arity = arity;
99 }
100
101 public override bool Equals(object obj)
102 {
103 if (obj is NameArity)
104 {
105 NameArity nameArity = (NameArity)obj;
106 return nameArity._name.Equals(_name) && nameArity._arity.Equals(_arity);
107 }
108 else
109 {
110 return false;
111 }
112 }
113
114 public override int GetHashCode()
115 {
116 return _name.GetHashCode() ^ _arity.GetHashCode();
117 }
118 }
119
120 /// <summary>
121 /// Convert term to an int.
122 /// 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.
124 /// </summary>
125 /// <param name="term"></param>
126 /// <returns></returns>
127 public static int convertInt(object term)
128 {
129 term = YP.getValue(term);
130 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
131 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
132 // Assume it is a char type like "a".
133 term = YP.getValue(((Functor2)term)._arg1);
134
135 return (int)term;
136 }
137
138 /// <summary>
139 /// 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
141 /// (to handle the char types like "a"). If can't convert, throw an exception.
142 /// </summary>
143 /// <param name="term"></param>
144 /// <returns></returns>
145 public static double convertDouble(object term)
146 {
147 term = YP.getValue(term);
148 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
149 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
150 // Assume it is a char type like "a".
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");
155
156 return Convert.ToDouble(term);
157 }
158
159 /// <summary>
160 /// If term is an integer, set intTerm.
161 /// If term is a single-element List, use its first element
162 /// (to handle the char types like "a"). Return true for success, false if can't convert.
163 /// We use a success return value because throwing an exception is inefficient.
164 /// </summary>
165 /// <param name="term"></param>
166 /// <returns></returns>
167 public static bool getInt(object term, out int intTerm)
168 {
169 term = YP.getValue(term);
170 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
171 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
172 // Assume it is a char type like "a".
173 term = YP.getValue(((Functor2)term)._arg1);
174
175 if (term is int)
176 {
177 intTerm = (int)term;
178 return true;
179 }
180
181 intTerm = 0;
182 return false;
183 }
184
185 public static bool equal(object x, object y)
186 {
187 x = YP.getValue(x);
188 if (x is DateTime)
189 return (DateTime)x == (DateTime)YP.getValue(y);
190 // Assume convertDouble converts an int to a double perfectly.
191 return YP.convertDouble(x) == YP.convertDouble(y);
192 }
193
194 public static bool notEqual(object x, object y)
195 {
196 x = YP.getValue(x);
197 if (x is DateTime)
198 return (DateTime)x != (DateTime)YP.getValue(y);
199 // Assume convertDouble converts an int to a double perfectly.
200 return YP.convertDouble(x) != YP.convertDouble(y);
201 }
202
203 public static bool greaterThan(object x, object y)
204 {
205 x = YP.getValue(x);
206 if (x is DateTime)
207 return (DateTime)x > (DateTime)YP.getValue(y);
208 // Assume convertDouble converts an int to a double perfectly.
209 return YP.convertDouble(x) > YP.convertDouble(y);
210 }
211
212 public static bool lessThan(object x, object y)
213 {
214 x = YP.getValue(x);
215 if (x is DateTime)
216 return (DateTime)x < (DateTime)YP.getValue(y);
217 // Assume convertDouble converts an int to a double perfectly.
218 return YP.convertDouble(x) < YP.convertDouble(y);
219 }
220
221 public static bool greaterThanOrEqual(object x, object y)
222 {
223 x = YP.getValue(x);
224 if (x is DateTime)
225 return (DateTime)x >= (DateTime)YP.getValue(y);
226 // Assume convertDouble converts an int to a double perfectly.
227 return YP.convertDouble(x) >= YP.convertDouble(y);
228 }
229
230 public static bool lessThanOrEqual(object x, object y)
231 {
232 x = YP.getValue(x);
233 if (x is DateTime)
234 return (DateTime)x <= (DateTime)YP.getValue(y);
235 // Assume convertDouble converts an int to a double perfectly.
236 return YP.convertDouble(x) <= YP.convertDouble(y);
237 }
238
239 public static object negate(object x)
240 {
241 int intX;
242 if (getInt(x, out intX))
243 return -intX;
244 return -convertDouble(x);
245 }
246
247 public static object abs(object x)
248 {
249 int intX;
250 if (getInt(x, out intX))
251 return Math.Abs(intX);
252 return Math.Abs(convertDouble(x));
253 }
254
255 public static object sign(object x)
256 {
257 int intX;
258 if (getInt(x, out intX))
259 return Math.Sign(intX);
260 return Math.Sign(convertDouble(x));
261 }
262
263 /// <summary>
264 /// The ISO standard returns an int.
265 /// </summary>
266 /// <param name="x"></param>
267 /// <returns></returns>
268 public static object floor(object x)
269 {
270 return (int)Math.Floor(convertDouble(x));
271 }
272
273 /// <summary>
274 /// The ISO standard returns an int.
275 /// </summary>
276 /// <param name="x"></param>
277 /// <returns></returns>
278 public static object truncate(object x)
279 {
280 return (int)Math.Truncate(convertDouble(x));
281 }
282
283 /// <summary>
284 /// The ISO standard returns an int.
285 /// </summary>
286 /// <param name="x"></param>
287 /// <returns></returns>
288 public static object round(object x)
289 {
290 return (int)Math.Round(convertDouble(x));
291 }
292
293 /// <summary>
294 /// The ISO standard returns an int.
295 /// </summary>
296 /// <param name="x"></param>
297 /// <returns></returns>
298 public static object ceiling(object x)
299 {
300 return (int)Math.Ceiling(convertDouble(x));
301 }
302
303 public static object sin(object x)
304 {
305 return Math.Sin(YP.convertDouble(x));
306 }
307
308 public static object cos(object x)
309 {
310 return Math.Cos(YP.convertDouble(x));
311 }
312
313 public static object atan(object x)
314 {
315 return Math.Atan(YP.convertDouble(x));
316 }
317
318 public static object exp(object x)
319 {
320 return Math.Exp(YP.convertDouble(x));
321 }
322
323 public static object log(object x)
324 {
325 return Math.Log(YP.convertDouble(x));
326 }
327
328 public static object sqrt(object x)
329 {
330 return Math.Sqrt(convertDouble(x));
331 }
332
333 public static object bitwiseComplement(object x)
334 {
335 return ~YP.convertInt(x);
336 }
337
338 public static object add(object x, object y)
339 {
340 int intX, intY;
341 if (getInt(x, out intX) && getInt(y, out intY))
342 return intX + intY;
343 return convertDouble(x) + convertDouble(y);
344 }
345
346 public static object subtract(object x, object y)
347 {
348 int intX, intY;
349 if (getInt(x, out intX) && getInt(y, out intY))
350 return intX - intY;
351 return convertDouble(x) - convertDouble(y);
352 }
353
354 public static object multiply(object x, object y)
355 {
356 int intX, intY;
357 if (getInt(x, out intX) && getInt(y, out intY))
358 return intX * intY;
359 return convertDouble(x) * convertDouble(y);
360 }
361
362 /// <summary>
363 /// Return floating point, even if both arguments are integer.
364 /// </summary>
365 /// <param name="x"></param>
366 /// <param name="y"></param>
367 /// <returns></returns>
368 public static object divide(object x, object y)
369 {
370 return convertDouble(x) / convertDouble(y);
371 }
372
373 public static object intDivide(object x, object y)
374 {
375 int intX, intY;
376 if (getInt(x, out intX) && getInt(y, out intY))
377 return intX / intY;
378 // Still allow passing a double, but treat as an int.
379 return (int)convertDouble(x) / (int)convertDouble(y);
380 }
381
382 public static object mod(object x, object y)
383 {
384 int intX, intY;
385 if (getInt(x, out intX) && getInt(y, out intY))
386 return intX % intY;
387 // Still allow passing a double, but treat as an int.
388 return (int)convertDouble(x) % (int)convertDouble(y);
389 }
390
391 public static object pow(object x, object y)
392 {
393 return Math.Pow(YP.convertDouble(x), YP.convertDouble(y));
394 }
395
396 public static object bitwiseShiftRight(object x, object y)
397 {
398 return YP.convertInt(x) >> YP.convertInt(y);
399 }
400
401 public static object bitwiseShiftLeft(object x, object y)
402 {
403 return YP.convertInt(x) << YP.convertInt(y);
404 }
405
406 public static object bitwiseAnd(object x, object y)
407 {
408 return YP.convertInt(x) & YP.convertInt(y);
409 }
410
411 public static object bitwiseOr(object x, object y)
412 {
413 return YP.convertInt(x) | YP.convertInt(y);
414 }
415
416 public static object min(object x, object y)
417 {
418 int intX, intY;
419 if (getInt(x, out intX) && getInt(y, out intY))
420 return Math.Min(intX, intY);
421 return Math.Min(convertDouble(x), convertDouble(y));
422 }
423
424 public static object max(object x, object y)
425 {
426 int intX, intY;
427 if (getInt(x, out intX) && getInt(y, out intY))
428 return Math.Max(intX, intY);
429 return Math.Max(convertDouble(x), convertDouble(y));
430 }
431
432 public static IEnumerable<bool> copy_term(object inTerm, object outTerm)
433 {
434 return YP.unify(outTerm, YP.makeCopy(inTerm, new Variable.CopyStore()));
435 }
436
437 public static void addUniqueVariables(object term, List<Variable> variableSet)
438 {
439 term = YP.getValue(term);
440 if (term is IUnifiable)
441 ((IUnifiable)term).addUniqueVariables(variableSet);
442 }
443
444 public static object makeCopy(object term, Variable.CopyStore copyStore)
445 {
446 term = YP.getValue(term);
447 if (term is IUnifiable)
448 return ((IUnifiable)term).makeCopy(copyStore);
449 else
450 // term is a "normal" type. Assume it is ground.
451 return term;
452 }
453
454 /// <summary>
455 /// Sort the array in place according to termLessThan. This does not remove duplicates
456 /// </summary>
457 /// <param name="array"></param>
458 public static void sortArray(object[] array)
459 {
460 Array.Sort(array, YP.compareTerms);
461 }
462
463 /// <summary>
464 /// Sort the array in place according to termLessThan. This does not remove duplicates
465 /// </summary>
466 /// <param name="array"></param>
467 public static void sortArray(List<object> array)
468 {
469 array.Sort(YP.compareTerms);
470 }
471
472 /// <summary>
473 /// Sort List according to termLessThan, remove duplicates and unify with Sorted.
474 /// </summary>
475 /// <param name="List"></param>
476 /// <param name="Sorted"></param>
477 /// <returns></returns>
478 public static IEnumerable<bool> sort(object List, object Sorted)
479 {
480 object[] array = ListPair.toArray(List);
481 if (array == null)
482 return YP.fail();
483 if (array.Length > 1)
484 sortArray(array);
485 return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
486 }
487
488
489
490 /// <summary>
491 /// Use YP.unify to unify each of the elements of the two arrays, and yield
492 /// once if they all unify.
493 /// </summary>
494 /// <param name="array1"></param>
495 /// <param name="array2"></param>
496 /// <returns></returns>
497 public static IEnumerable<bool> unifyArrays(object[] array1, object[] array2)
498 {
499 if (array1.Length != array2.Length)
500 yield break;
501
502 IEnumerator<bool>[] iterators = new IEnumerator<bool>[array1.Length];
503 bool gotMatch = true;
504 int nIterators = 0;
505 // Try to bind all the arguments.
506 for (int i = 0; i < array1.Length; ++i)
507 {
508 IEnumerator<bool> iterator = YP.unify(array1[i], array2[i]).GetEnumerator();
509 iterators[nIterators++] = iterator;
510 // MoveNext() is true if YP.unify succeeds.
511 if (!iterator.MoveNext())
512 {
513 gotMatch = false;
514 break;
515 }
516 }
517
518 try
519 {
520 if (gotMatch)
521 yield return false;
522 }
523 finally
524 {
525 // Manually finalize all the iterators.
526 for (int i = 0; i < nIterators; ++i)
527 iterators[i].Dispose();
528 }
529 }
530
531 /// <summary>
532 /// Return an iterator (which you can use in a for-in loop) which does
533 /// zero iterations. This returns a pre-existing iterator which is
534 /// more efficient than letting the compiler generate a new one.
535 /// </summary>
536 /// <returns></returns>
537 public static IEnumerable<bool> fail()
538 {
539 return _fail;
540 }
541
542 /// <summary>
543 /// Return an iterator (which you can use in a for-in loop) which does
544 /// one iteration. This returns a pre-existing iterator which is
545 /// more efficient than letting the compiler generate a new one.
546 /// </summary>
547 /// <returns></returns>
548 public static IEnumerable<bool> succeed()
549 {
550 return new Succeed();
551 }
552
553 /// <summary>
554 /// Return an iterator (which you can use in a for-in loop) which repeats
555 /// indefinitely. This returns a pre-existing iterator which is
556 /// more efficient than letting the compiler generate a new one.
557 /// </summary>
558 /// <returns></returns>
559 public static IEnumerable<bool> repeat()
560 {
561 return _repeat;
562 }
563
564 public static IEnumerable<bool> univ(object Term, object List)
565 {
566 Term = YP.getValue(Term);
567 List = YP.getValue(List);
568
569 if (nonvar(Term))
570 return YP.unify(new ListPair
571 (getFunctorName(Term), ListPair.make(getFunctorArgs(Term))), List);
572
573 Variable Name = new Variable();
574 Variable ArgList = new Variable();
575 foreach (bool l1 in new ListPair(Name, ArgList).unify(List))
576 {
577 object[] args = ListPair.toArray(ArgList);
578 if (args == null)
579 throw new Exception("Expected a list. Got: " + ArgList.getValue());
580 if (args.Length == 0)
581 // Return the Name, even if it is not an Atom.
582 return YP.unify(Term, Name);
583 if (!atom(Name))
584 throw new Exception("Expected an atom. Got: " + Name.getValue());
585
586 return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args));
587 }
588
589 return YP.fail();
590 }
591
592 public static IEnumerable<bool> functor(object Term, object FunctorName, object Arity)
593 {
594 Term = YP.getValue(Term);
595 FunctorName = YP.getValue(FunctorName);
596 Arity = YP.getValue(Arity);
597
598 if (!(Term is Variable))
599 {
600 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term)))
601 {
602 foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length))
603 yield return false;
604 }
605 }
606 else
607 throw new NotImplementedException("Debug: must finish functor/3");
608 }
609
610 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value)
611 {
612 if (YP.var(ArgNumber))
613 throw new NotImplementedException("Debug: must finish arg/3");
614 else
615 {
616 int argNumberInt = convertInt(ArgNumber);
617 if (argNumberInt < 0)
618 throw new Exception("ArgNumber must be non-negative");
619 object[] termArgs = YP.getFunctorArgs(Term);
620 // Silently fail if argNumberInt is out of range.
621 if (argNumberInt >= 1 && argNumberInt <= termArgs.Length)
622 {
623 // The first ArgNumber is at 1, not 0.
624 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
625 yield return false;
626 }
627 }
628 }
629
630 public static bool termEqual(object Term1, object Term2)
631 {
632 Term1 = YP.getValue(Term1);
633 if (Term1 is IUnifiable)
634 return ((IUnifiable)Term1).termEqual(Term2);
635 return Term1.Equals(YP.getValue(Term2));
636 }
637
638 public static bool termNotEqual(object Term1, object Term2)
639 {
640 return !termEqual(Term1, Term2);
641 }
642
643 public static bool termLessThan(object Term1, object Term2)
644 {
645 Term1 = YP.getValue(Term1);
646 Term2 = YP.getValue(Term2);
647 int term1TypeCode = getTypeCode(Term1);
648 int term2TypeCode = getTypeCode(Term2);
649 if (term1TypeCode != term2TypeCode)
650 return term1TypeCode < term2TypeCode;
651
652 // The terms are the same type code.
653 if (term1TypeCode == -2)
654 {
655 // Variable.
656 // We always check for equality first because we want to be sure
657 // that less than returns false if the terms are equal, in
658 // case that the less than check really behaves like less than or equal.
659 if ((Variable)Term1 != (Variable)Term2)
660 // The hash code should be unique to a Variable object.
661 return Term1.GetHashCode() < Term2.GetHashCode();
662 return false;
663 }
664 if (term1TypeCode == 0)
665 return ((Atom)Term1)._name.CompareTo(((Atom)Term2)._name) < 0;
666 if (term1TypeCode == 1)
667 return ((Functor1)Term1).lessThan((Functor1)Term2);
668 if (term1TypeCode == 2)
669 return ((Functor2)Term1).lessThan((Functor2)Term2);
670 if (term1TypeCode == 3)
671 return ((Functor3)Term1).lessThan((Functor3)Term2);
672 if (term1TypeCode == 4)
673 return ((Functor)Term1).lessThan((Functor)Term2);
674
675 // Type code is -1 for general objects. First compare their type names.
676 // Note that this puts Double before Int32 as required by ISO Prolog.
677 string term1TypeName = Term1.GetType().ToString();
678 string term2TypeName = Term2.GetType().ToString();
679 if (term1TypeName != term2TypeName)
680 return term1TypeName.CompareTo(term2TypeName) < 0;
681
682 // The terms are the same type name.
683 if (Term1 is int)
684 return (int)Term1 < (int)Term2;
685 else if (Term1 is double)
686 return (double)Term1 < (double)Term2;
687 else if (Term1 is DateTime)
688 return (DateTime)Term1 < (DateTime)Term2;
689 else if (Term1 is String)
690 return ((String)Term1).CompareTo((String)Term2) < 0;
691 // Debug: Should we try arrays, etc.?
692
693 if (!Term1.Equals(Term2))
694 // Could be equal or greater than.
695 return Term1.GetHashCode() < Term2.GetHashCode();
696 return false;
697 }
698
699 /// <summary>
700 /// Type code is -2 if term is a Variable, 0 if it is an Atom,
701 /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3,
702 /// 4 if it is Functor.
703 /// Otherwise, type code is -1.
704 /// This does not call YP.getValue(term).
705 /// </summary>
706 /// <param name="term"></param>
707 /// <returns></returns>
708 private static int getTypeCode(object term)
709 {
710 if (term is Variable)
711 return -2;
712 else if (term is Atom)
713 return 0;
714 else if (term is Functor1)
715 return 1;
716 else if (term is Functor2)
717 return 2;
718 else if (term is Functor3)
719 return 3;
720 else if (term is Functor)
721 return 4;
722 else
723 return -1;
724 }
725
726 public static bool termLessThanOrEqual(object Term1, object Term2)
727 {
728 if (YP.termEqual(Term1, Term2))
729 return true;
730 return YP.termLessThan(Term1, Term2);
731 }
732
733 public static bool termGreaterThan(object Term1, object Term2)
734 {
735 return !YP.termLessThanOrEqual(Term1, Term2);
736 }
737
738 public static bool termGreaterThanOrEqual(object Term1, object Term2)
739 {
740 // termLessThan should ensure that it returns false if terms are equal,
741 // so that this would return true.
742 return !YP.termLessThan(Term1, Term2);
743 }
744
745 public static int compareTerms(object Term1, object Term2)
746 {
747 if (YP.termEqual(Term1, Term2))
748 return 0;
749 else if (YP.termLessThan(Term1, Term2))
750 return -1;
751 else
752 return 1;
753 }
754
755 public static bool ground(object Term)
756 {
757 Term = YP.getValue(Term);
758 if (Term is IUnifiable)
759 return ((IUnifiable)Term).ground();
760 return true;
761 }
762
763 public static IEnumerable<bool> current_op
764 (object Priority, object Specifier, object Operator)
765 {
766 if (_operatorTable == null)
767 {
768 // Initialize.
769 _operatorTable = new List<object[]>();
770 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") });
771 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") });
772 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") });
773 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") });
774 _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") });
775 _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") });
776 _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") });
777 _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") });
778 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") });
779 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") });
780 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") });
781 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") });
782 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") });
783 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") });
784 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") });
785 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") });
786 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") });
787 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") });
788 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") });
789 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") });
790 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") });
791 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") });
792 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") });
793 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") });
794 _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") });
795 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") });
796 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") });
797 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") });
798 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") });
799 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") });
800 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") });
801 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") });
802 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") });
803 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") });
804 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") });
805 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") });
806 _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") });
807 _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") });
808 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") });
809 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") });
810 // Debug: This is hacked in to run the Prolog test suite until we implement op/3.
811 _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
812 }
813
814 object[] args = new object[] { Priority, Specifier, Operator };
815 foreach (object[] answer in _operatorTable)
816 {
817 foreach (bool l1 in YP.unifyArrays(args, answer))
818 yield return false;
819 }
820 }
821
822 public static IEnumerable<bool> atom_length(object atom, object Length)
823 {
824 return YP.unify(Length, ((Atom)YP.getValue(atom))._name.Length);
825 }
826
827 public static IEnumerable<bool> atom_concat(object Start, object End, object Whole)
828 {
829 // Debug: Should implement for var(Start) which is a kind of search.
830 // Debug: Should we try to preserve the _declaringClass?
831 return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name +
832 ((Atom)YP.getValue(End))._name));
833 }
834
835 public static IEnumerable<bool> sub_atom
836 (object atom, object Before, object Length, object After, object Sub_atom)
837 {
838 // Debug: Should implement for var(atom) which is a kind of search.
839 // Debug: Should we try to preserve the _declaringClass?
840 Atom atomAtom = (Atom)YP.getValue(atom);
841 int beforeInt = YP.convertInt(Before);
842 int lengthInt = YP.convertInt(Length);
843 if (beforeInt < 0)
844 throw new Exception("Before must be non-negative");
845 if (lengthInt < 0)
846 throw new Exception("Length must be non-negative");
847 int afterInt = atomAtom._name.Length - (beforeInt + lengthInt);
848 if (afterInt >= 0)
849 {
850 foreach (bool l1 in YP.unify(After, afterInt))
851 {
852 foreach (bool l2 in YP.unify
853 (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt))))
854 yield return false;
855 }
856 }
857 }
858
859 public static IEnumerable<bool> atom_codes(object atom, object List)
860 {
861 atom = YP.getValue(atom);
862 List = YP.getValue(List);
863
864 if (nonvar(atom))
865 {
866 string name = ((Atom)atom)._name;
867 object codeList = Atom.NIL;
868 // Start from the back to make the list.
869 for (int i = name.Length - 1; i >= 0; --i)
870 codeList = new ListPair((int)name[i], codeList);
871 return YP.unify(List, codeList);
872 }
873 {
874 object[] codeArray = ListPair.toArray(List);
875 char[] charArray = new char[codeArray.Length];
876 for (int i = 0; i < codeArray.Length; ++i)
877 charArray[i] = (char)YP.convertInt(codeArray[i]);
878 return YP.unify(atom, Atom.a(new String(charArray)));
879 }
880 }
881
882 public static IEnumerable<bool> number_codes(object number, object List)
883 {
884 number = YP.getValue(number);
885 List = YP.getValue(List);
886
887 if (nonvar(number))
888 {
889 string numberString = null;
890 // Try converting to an int first.
891 int intNumber;
892 if (YP.getInt(number, out intNumber))
893 numberString = intNumber.ToString();
894 else
895 numberString = YP.doubleToString(YP.convertDouble(number));
896
897 object codeList = Atom.NIL;
898 // Start from the back to make the list.
899 for (int i = numberString.Length - 1; i >= 0; --i)
900 codeList = new ListPair((int)numberString[i], codeList);
901 return YP.unify(List, codeList);
902 }
903 {
904 object[] codeArray = ListPair.toArray(List);
905 char[] charArray = new char[codeArray.Length];
906 for (int i = 0; i < codeArray.Length; ++i)
907 charArray[i] = (char)YP.convertInt(codeArray[i]);
908 String numberString = new String(charArray);
909 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
910 try
911 {
912 // Try an int first.
913 return YP.unify(number, Convert.ToInt32(numberString));
914 }
915 catch (FormatException) { }
916 return YP.unify(number, Convert.ToDouble(numberString));
917 }
918 }
919
920 /// <summary>
921 /// If term is an Atom or functor type, return its name.
922 /// Otherwise, return term.
923 /// </summary>
924 /// <param name="term"></param>
925 /// <returns></returns>
926 public static object getFunctorName(object term)
927 {
928 term = YP.getValue(term);
929 if (term is Functor1)
930 return ((Functor1)term)._name;
931 else if (term is Functor2)
932 return ((Functor2)term)._name;
933 else if (term is Functor3)
934 return ((Functor3)term)._name;
935 else if (term is Functor)
936 return ((Functor)term)._name;
937 else
938 return term;
939 }
940
941 /// <summary>
942 /// If term is an Atom or functor type, return an array of its args.
943 /// Otherwise, return an empty array.
944 /// </summary>
945 /// <param name="term"></param>
946 /// <returns></returns>
947 public static object[] getFunctorArgs(object term)
948 {
949 term = YP.getValue(term);
950 if (term is Functor1)
951 {
952 Functor1 functor = (Functor1)term;
953 return new object[] { functor._arg1 };
954 }
955 else if (term is Functor2)
956 {
957 Functor2 functor = (Functor2)term;
958 return new object[] { functor._arg1, functor._arg2 };
959 }
960 else if (term is Functor3)
961 {
962 Functor3 functor = (Functor3)term;
963 return new object[] { functor._arg1, functor._arg2, functor._arg3 };
964 }
965 else if (term is Functor) {
966 Functor functor = (Functor)term;
967 return functor._args;
968 }
969 else
970 return new object[0];
971 }
972
973 public static bool var(object Term)
974 {
975 return YP.getValue(Term) is Variable;
976 }
977
978 public static bool nonvar(object Term)
979 {
980 return !YP.var(Term);
981 }
982
983 public static bool atom(object Term)
984 {
985 return YP.getValue(Term) is Atom;
986 }
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
1001 public static bool number(object Term)
1002 {
1003 return YP.integer(Term) || YP.isFloat(Term);
1004 }
1005
1006 public static bool atomic(object Term)
1007 {
1008 return YP.atom(Term) || YP.number(Term);
1009 }
1010
1011 public static bool compound(object Term)
1012 {
1013 Term = getValue(Term);
1014 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor;
1015 }
1016
1017 public static void see(object input)
1018 {
1019 input = YP.getValue(input);
1020 if (input is TextReader)
1021 {
1022 _inputStream = (TextReader)input;
1023 return;
1024 }
1025 else if (input is Atom)
1026 {
1027 _inputStream = new StreamReader(((Atom)input)._name);
1028 return;
1029 }
1030 else if (input is String)
1031 {
1032 _inputStream = new StreamReader((String)input);
1033 return;
1034 }
1035 else
1036 throw new InvalidOperationException("Can't open stream for " + input);
1037 }
1038
1039 public static void seen()
1040 {
1041 if (_inputStream == Console.In)
1042 return;
1043 _inputStream.Close();
1044 _inputStream = Console.In;
1045 }
1046
1047 public static void tell(object output)
1048 {
1049 output = YP.getValue(output);
1050 if (output is TextWriter)
1051 {
1052 _outputStream = (TextWriter)output;
1053 return;
1054 }
1055 else if (output is Atom)
1056 {
1057 _outputStream = new StreamWriter(((Atom)output)._name);
1058 return;
1059 }
1060 else if (output is String)
1061 {
1062 _outputStream = new StreamWriter((String)output);
1063 return;
1064 }
1065 else
1066 throw new InvalidOperationException("Can't open stream for " + output);
1067 }
1068
1069 public static void told()
1070 {
1071 if (_outputStream == Console.Out)
1072 return;
1073 _outputStream.Close();
1074 _outputStream = Console.Out;
1075 }
1076
1077 public static IEnumerable<bool> current_output(object Stream)
1078 {
1079 return YP.unify(Stream, _outputStream);
1080 }
1081
1082 public static void write(object x)
1083 {
1084 x = YP.getValue(x);
1085 if (x is double)
1086 _outputStream.Write(doubleToString((double)x));
1087 else
1088 _outputStream.Write(x.ToString());
1089 }
1090
1091 /// <summary>
1092 /// Format x as a string, making sure that it will parse as an int later. I.e., for 1.0, don't just
1093 /// use "1" which will parse as an int.
1094 /// </summary>
1095 /// <param name="x"></param>
1096 /// <returns></returns>
1097 private static string doubleToString(double x)
1098 {
1099 string xString = x.ToString();
1100 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
1101 try
1102 {
1103 Convert.ToInt32(xString);
1104 // The string will parse as an int, not a double, so re-format so that it does.
1105 // Use float if possible, else exponential if it would be too big.
1106 return x.ToString(x >= 100000.0 ? "E1" : "f1");
1107 }
1108 catch (FormatException)
1109 {
1110 // Assume it will parse as a double.
1111 }
1112 return xString;
1113 }
1114
1115 public static void put_code(object x)
1116 {
1117 _outputStream.Write((char)YP.convertInt(x));
1118 }
1119
1120 public static void nl()
1121 {
1122 _outputStream.WriteLine();
1123 }
1124
1125 public static IEnumerable<bool> get_code(object code)
1126 {
1127 return YP.unify(code, _inputStream.Read());
1128 }
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>
1217 public static void assertFact(Atom name, object[] values)
1218 {
1219 NameArity nameArity = new NameArity(name, values.Length);
1220 List<IClause> clauses;
1221 IndexedAnswers indexedAnswers;
1222 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1223 {
1224 // Create an IndexedAnswers as the first clause of the predicate.
1225 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1226 clauses.Add(indexedAnswers = new IndexedAnswers());
1227 }
1228 else
1229 {
1230 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers;
1231 if (indexedAnswers == null)
1232 // The latest clause is not an IndexedAnswers, so add one.
1233 clauses.Add(indexedAnswers = new IndexedAnswers());
1234 }
1235
1236 indexedAnswers.addAnswer(values);
1237 }
1238
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)
1248 {
1249 List<IClause> clauses;
1250 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1251 throw new UndefinedPredicateException
1252 ("Undefined fact: " + name + "/" + arguments.Length, name,
1253 arguments.Length);
1254
1255 if (clauses.Count == 1)
1256 // Usually there is only one clause, so return it without needing to wrap it in an iterator.
1257 return clauses[0].match(arguments);
1258 else
1259 return matchAllClauses(clauses, arguments);
1260 }
1261
1262 /// <summary>
1263 /// Call match(arguments) for each IClause in clauses. We make this a separate
1264 /// function so that matchDynamic itself does not need to be an iterator object.
1265 /// </summary>
1266 /// <param name="clauses"></param>
1267 /// <param name="arguments"></param>
1268 /// <returns></returns>
1269 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments)
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?
1273 foreach (IClause clause in clauses)
1274 {
1275 foreach (bool lastCall in clause.match(arguments))
1276 {
1277 yield return false;
1278 if (lastCall)
1279 // This happens after a cut in a clause.
1280 yield break;
1281 }
1282 }
1283 }
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>
1304 public static void retractFact(Atom name, object[] arguments)
1305 {
1306 NameArity nameArity = new NameArity(name, arguments.Length);
1307 List<IClause> clauses;
1308 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1309 // Can't find, so ignore.
1310 return;
1311
1312 foreach (object arg in arguments)
1313 {
1314 if (!YP.var(arg))
1315 throw new InvalidOperationException("All arguments must be unbound");
1316 }
1317 // Set to a fresh empty IndexedAnswers.
1318 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1319 clauses.Add(new IndexedAnswers());
1320 }
1321
1322 public static IEnumerable<bool> current_predicate(object NameSlashArity)
1323 {
1324 NameSlashArity = YP.getValue(NameSlashArity);
1325 // First check if Name and Arity are nonvar so we can do a direct lookup.
1326 if (YP.ground(NameSlashArity))
1327 {
1328 if (NameSlashArity is Functor2)
1329 {
1330 Functor2 NameArityFunctor = (Functor2)NameSlashArity;
1331 if (NameArityFunctor._name == Atom.SLASH)
1332 {
1333 if (_predicatesStore.ContainsKey(new NameArity
1334 ((Atom)YP.getValue(NameArityFunctor._arg1),
1335 (int)YP.getValue(NameArityFunctor._arg2))))
1336 // The predicate is defined.
1337 yield return false;
1338 }
1339 }
1340 yield break;
1341 }
1342
1343 foreach (NameArity key in _predicatesStore.Keys)
1344 {
1345 foreach (bool l1 in YP.unify
1346 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity))
1347 yield return false;
1348 }
1349 }
1350
1351 /// <summary>
1352 /// Use YP.getFunctorName(Goal) and invoke the static method of this name in the
1353 /// declaringClass, using arguments from YP.getFunctorArgs(Goal).
1354 /// Note that Goal must be a simple functor, not a complex expression.
1355 /// If not found, this throws UndefinedPredicateException.
1356 /// </summary>
1357 /// <param name="Goal"></param>
1358 /// <param name="contextClass">the class for looking up default function references</param>
1359 /// <returns></returns>
1360 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass)
1361 {
1362 Goal = YP.getValue(Goal);
1363 if (Goal is Variable)
1364 throw new PrologException("instantiation_error", "Goal to call is an unbound variable");
1365#if true
1366 List<Variable> variableSetList = new List<Variable>();
1367 addUniqueVariables(Goal, variableSetList);
1368 Variable[] variableSet = variableSetList.ToArray();
1369
1370 // Use Atom.F since it is ignored.
1371 return YPCompiler.compileAnonymousClause
1372 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1373#else
1374 Atom name;
1375 object[] args;
1376 while (true)
1377 {
1378 name = (Atom)YP.getFunctorName(Goal);
1379 args = YP.getFunctorArgs(Goal);
1380 if (name == Atom.HAT && args.Length == 2)
1381 // Assume this is called from a bagof operation. Skip the leading qualifiers.
1382 Goal = YP.getValue(((Functor2)Goal)._arg2);
1383 else
1384 break;
1385 }
1386 try
1387 {
1388 return (IEnumerable<bool>)declaringClass.InvokeMember
1389 (name._name, BindingFlags.InvokeMethod, null, null, args);
1390 }
1391 catch (TargetInvocationException exception)
1392 {
1393 throw exception.InnerException;
1394 }
1395 catch (MissingMethodException)
1396 {
1397 throw new UndefinedPredicateException
1398 ("Cannot find predicate function: " + name + "/" + args.Length + " in " +
1399 declaringClass.FullName, name, args.Length);
1400 }
1401#endif
1402 }
1403
1404 public static void throwException(object Term)
1405 {
1406 throw new PrologException(Term);
1407 }
1408
1409 /// <summary>
1410 /// script_event calls hosting script with events as a callback method.
1411 /// </summary>
1412 /// <param name="script_event"></param>
1413 /// <param name="script_params"></param>
1414 /// <returns></returns>
1415 public static void script_event(object script_event, object script_params)
1416 {
1417 string function = ((Atom)YP.getValue(script_event))._name;
1418 object[] array = ListPair.toArray(script_params);
1419 if (array == null)
1420 return; // YP.fail();
1421 if (array.Length > 1)
1422 {
1423 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue
1424 //(localID, itemID, function, array);
1425 // sortArray(array);
1426 }
1427 //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
1428 }
1429
1430 /// <summary>
1431 /// An enumerator that does zero loops.
1432 /// </summary>
1433 private class Fail : IEnumerator<bool>, IEnumerable<bool>
1434 {
1435 public bool MoveNext()
1436 {
1437 return false;
1438 }
1439
1440 public IEnumerator<bool> GetEnumerator()
1441 {
1442 return (IEnumerator<bool>)this;
1443 }
1444
1445 IEnumerator IEnumerable.GetEnumerator()
1446 {
1447 return GetEnumerator();
1448 }
1449
1450 public bool Current
1451 {
1452 get { return true; }
1453 }
1454
1455 object IEnumerator.Current
1456 {
1457 get { return true; }
1458 }
1459
1460 public void Dispose()
1461 {
1462 }
1463
1464 public void Reset()
1465 {
1466 throw new NotImplementedException();
1467 }
1468 }
1469
1470 /// <summary>
1471 /// An enumerator that does one iteration.
1472 /// </summary>
1473 private class Succeed : IEnumerator<bool>, IEnumerable<bool>
1474 {
1475 private bool _didIteration = false;
1476
1477 public bool MoveNext()
1478 {
1479 if (!_didIteration)
1480 {
1481 _didIteration = true;
1482 return true;
1483 }
1484 else
1485 return false;
1486 }
1487
1488 public IEnumerator<bool> GetEnumerator()
1489 {
1490 return (IEnumerator<bool>)this;
1491 }
1492
1493 IEnumerator IEnumerable.GetEnumerator()
1494 {
1495 return GetEnumerator();
1496 }
1497
1498 public bool Current
1499 {
1500 get { return false; }
1501 }
1502
1503 object IEnumerator.Current
1504 {
1505 get { return false; }
1506 }
1507
1508 public void Dispose()
1509 {
1510 }
1511
1512 public void Reset()
1513 {
1514 throw new NotImplementedException();
1515 }
1516 }
1517
1518 /// <summary>
1519 /// An enumerator that repeats forever.
1520 /// </summary>
1521 private class Repeat : IEnumerator<bool>, IEnumerable<bool>
1522 {
1523 public bool MoveNext()
1524 {
1525 return true;
1526 }
1527
1528 public IEnumerator<bool> GetEnumerator()
1529 {
1530 return (IEnumerator<bool>)this;
1531 }
1532
1533 IEnumerator IEnumerable.GetEnumerator()
1534 {
1535 return GetEnumerator();
1536 }
1537
1538 public bool Current
1539 {
1540 get { return false; }
1541 }
1542
1543 object IEnumerator.Current
1544 {
1545 get { return false; }
1546 }
1547
1548 public void Dispose()
1549 {
1550 }
1551
1552 public void Reset()
1553 {
1554 throw new NotImplementedException();
1555 }
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 }
1643 }
1644}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
new file mode 100644
index 0000000..f2f8145
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
@@ -0,0 +1,5651 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.IO;
33using System.Collections;
34using System.Collections.Generic;
35using System.Text;
36using System.CodeDom.Compiler;
37
38namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
39{
40 public class YPCompiler
41 {
42 private class CompilerState
43 {
44 public IndexedAnswers _pred = new IndexedAnswers();
45 public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>();
46 public int _gensymCounter;
47 public bool _useFinalCutCode;
48 public Variable _finalCutCode;
49 public bool _codeUsesYield;
50 public Atom _determinism;
51 // a list of '='(Name, Variable)
52 public List<object> _variableNames;
53
54 // Make these static functions that explicitly take the State so Prolog can call it.
55
56 /// <summary>
57 /// Make a new CompilerState and bind it to State.
58 /// </summary>
59 /// <param name="State"></param>
60 /// <returns></returns>
61 public static IEnumerable<bool> make(object State)
62 {
63 return YP.unify(State, new CompilerState());
64 }
65
66 public static void assertPred(object State, object Pred, object Determinism)
67 {
68 State = YP.getValue(State);
69 object functorName = YP.getFunctorName(Pred);
70 object[] functorArgs = YP.getFunctorArgs(Pred);
71 // Debug: Should check if it's already asserted and is the same.
72 ((CompilerState)State)._pred.addAnswer
73 (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) });
74 }
75
76 public static void assertModuleForNameArity(object State, object Name, object Arity, object Module)
77 {
78 State = YP.getValue(State);
79 Name = YP.getValue(Name);
80 Arity = YP.getValue(Arity);
81 Module = YP.getValue(Module);
82 // If the Module Atom comes from the parser, it always has null _declaringClass.
83 if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int)
84 {
85 // Replace a previous entry if it exists.
86 ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] =
87 (Atom)Module;
88 }
89 }
90
91 public static void startFunction(object State, object Head)
92 {
93 State = YP.getValue(State);
94 ((CompilerState)State)._gensymCounter = 0;
95 ((CompilerState)State)._useFinalCutCode = false;
96 ((CompilerState)State)._finalCutCode = new Variable();
97 ((CompilerState)State)._codeUsesYield = false;
98 if (CompilerState.isDetNoneOut(State, Head))
99 ((CompilerState)State)._determinism = Atom.a("detNoneOut");
100 else if (CompilerState.isSemidetNoneOut(State, Head))
101 ((CompilerState)State)._determinism = Atom.a("semidetNoneOut");
102 else
103 ((CompilerState)State)._determinism = Atom.a("nondet");
104 }
105
106 public static void setCodeUsesYield(object State)
107 {
108 State = YP.getValue(State);
109 ((CompilerState)State)._codeUsesYield = true;
110 }
111
112 public static bool codeUsesYield(object State)
113 {
114 State = YP.getValue(State);
115 return ((CompilerState)State)._codeUsesYield;
116 }
117
118 public static bool determinismEquals(object State, object Term)
119 {
120 State = YP.getValue(State);
121 return YP.termEqual(((CompilerState)State)._determinism, Term);
122 }
123
124 /// <summary>
125 /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule.
126 /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc.
127 /// </summary>
128 /// <param name="State"></param>
129 /// <param name="rule"></param>
130 /// <param name="variableNameSuggestions"></param>
131 public static void newVariableNames(object State, object Rule, object VariableNameSuggestions)
132 {
133 State = YP.getValue(State);
134 List<Variable> variablesSet = new List<Variable>();
135 YP.addUniqueVariables(Rule, variablesSet);
136
137 ((CompilerState)State)._variableNames = new List<object>();
138 int xCounter = 0;
139 foreach (Variable variable in variablesSet)
140 ((CompilerState)State)._variableNames.Add
141 (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter),
142 variable));
143 }
144
145 private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter)
146 {
147 // Debug: should require named variables to start with _ or capital. Should
148 // check for duplicates and clashes with keywords.
149 for (object element = YP.getValue(variableNameSuggestions);
150 element is Functor2 && ((Functor2)element)._name == Atom.DOT;
151 element = YP.getValue(((Functor2)element)._arg2))
152 {
153 object suggestionPair = YP.getValue(((Functor2)element)._arg1);
154 if (sameVariable(variable, ((Functor2)suggestionPair)._arg2))
155 {
156 Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1);
157 if (suggestion.Equals(Atom.a("Atom")))
158 suggestion = Atom.a("Atom_1");
159 if (suggestion.Equals(Atom.a("Variable")))
160 suggestion = Atom.a("Variable_1");
161 if (suggestion.Equals(Atom.a("Functor")))
162 suggestion = Atom.a("Functor_1");
163 return suggestion;
164 }
165 }
166
167 return Atom.a("x" + xCounter);
168 }
169
170 /// <summary>
171 /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames
172 /// for variable.
173 /// </summary>
174 /// <param name="variable">a Variable</param>
175 /// <param name="State"></param>
176 /// <param name="Result">the assigned Name</param>
177 public static IEnumerable<bool> getVariableName(object State, object variable, object Result)
178 {
179 State = YP.getValue(State);
180 foreach (object variableInfo in ((CompilerState)State)._variableNames)
181 {
182 if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("=")))
183 {
184 if (sameVariable(variable, ((Functor2)variableInfo)._arg2))
185 return YP.unify(Result, ((Functor2)variableInfo)._arg1);
186 }
187 }
188
189 // We set up names for all unique variables, so this should never happen.
190 throw new PrologException(Atom.a("Can't find entry in _variableNames"));
191 }
192
193 public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList)
194 {
195 State = YP.getValue(State);
196 return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames));
197 }
198
199 public static IEnumerable<bool> gensym(object State, object Base, object Symbol)
200 {
201 State = YP.getValue(State);
202 return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter));
203 }
204
205 public static bool isDetNoneOut(object State, object Term)
206 {
207 State = YP.getValue(State);
208 object functorName = YP.getFunctorName(Term);
209 object[] functorArgs = YP.getFunctorArgs(Term);
210
211 Variable pred = new Variable();
212 foreach (bool l1 in ((CompilerState)State)._pred.match
213 (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") }))
214 {
215 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
216 {
217 return true;
218 }
219 }
220
221 return false;
222 }
223
224 public static bool isSemidetNoneOut(object State, object Term)
225 {
226 State = YP.getValue(State);
227 object functorName = YP.getFunctorName(Term);
228 object[] functorArgs = YP.getFunctorArgs(Term);
229
230 Variable pred = new Variable();
231 foreach (bool l1 in ((CompilerState)State)._pred.match
232 (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") }))
233 {
234 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
235 {
236 return true;
237 }
238 }
239
240 return false;
241 }
242
243 /// <summary>
244 /// Return false if any of args is out, otherwise true.
245 /// args is an array of ::(Type,Mode) where Mode is in or out.
246 /// </summary>
247 /// <param name="args"></param>
248 /// <returns></returns>
249 private static bool isNoneOut(object[] args)
250 {
251 foreach (object arg in args)
252 {
253 if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") &&
254 ((Functor2)arg)._arg2 == Atom.a("out"))
255 return false;
256 }
257 return true;
258 }
259
260 public static bool nameArityHasModule(object State, object Name, object Arity, object Module)
261 {
262 State = YP.getValue(State);
263 Name = YP.getValue(Name);
264 Arity = YP.getValue(Arity);
265 Module = YP.getValue(Module);
266 if (Name is Atom && Arity is int)
267 {
268 Atom FoundModule;
269 if (!((CompilerState)State)._moduleForNameArity.TryGetValue
270 (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule))
271 return false;
272 return FoundModule == Module;
273 }
274 return false;
275 }
276 }
277
278 /// <summary>
279 /// Use 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>
331 /// Use CodeDomProvider to compile the functionCode and return a YP.IClause.
332 /// The function name must be "function" and have nArgs arguments.
333 /// </summary>
334 /// <param name="functionCode">the code for the iterator, such as
335 /// "public static IEnumerable<bool> function() { yield return false; }"
336 /// </param>
337 /// <param name="nArgs">the number of args in the function</param>
338 /// <param name="declaringClass">if not null, then use the functionCode inside a class which
339 /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't
340 /// have to be qualified</param>
341 /// <returns>a new YP.IClause object on which you can call match(object[] args) where
342 /// args length is nArgs</returns>
343 public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass)
344 {
345 CompilerParameters parameters = new CompilerParameters();
346 // This gets the location of the System assembly.
347 parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location);
348 // This gets the location of this assembly which also has YieldProlog.YP, etc.
349 parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location);
350 if (declaringClass != null)
351 parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location);
352 parameters.GenerateInMemory = true;
353
354 StringBuilder sourceCode = new StringBuilder();
355 sourceCode.Append(@"
356using System;
357using System.Collections.Generic;
358using YieldProlog;
359
360namespace Temporary {
361 public class Temporary : YP.IClause {
362 public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" {
363");
364 sourceCode.Append(functionCode);
365 // Basically, match applies the args to function.
366 sourceCode.Append(@"
367 }
368 public IEnumerable<bool> match(object[] args) {
369 return Inner.function(");
370 if (nArgs >= 1)
371 sourceCode.Append("args[0]");
372 for (int i = 1; i < nArgs; ++i)
373 sourceCode.Append(", args[" + i + "]");
374 sourceCode.Append(@");
375 }
376 }
377}
378");
379
380 CompilerResults results = CodeDomProvider.CreateProvider
381 ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString());
382 if (results.Errors.Count > 0)
383 throw new Exception("Error evaluating code: " + results.Errors[0]);
384
385 // Return a new Temporary.Temporary object.
386 return (YP.IClause)results.CompiledAssembly.GetType
387 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
388 }
389
390 // Compiler output follows.
391
392 public class YPInnerClass { }
393 public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
394
395 public static void repeatWrite(object arg1, object N)
396 {
397 {
398 object _Value = arg1;
399 if (YP.termEqual(N, 0))
400 {
401 return;
402 }
403 }
404 {
405 object Value = arg1;
406 Variable NextN = new Variable();
407 YP.write(Value);
408 foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1)))
409 {
410 repeatWrite(Value, NextN);
411 return;
412 }
413 }
414 }
415
416 public static bool sameVariable(object Variable1, object Variable2)
417 {
418 {
419 if (YP.var(Variable1))
420 {
421 if (YP.var(Variable2))
422 {
423 if (YP.termEqual(Variable1, Variable2))
424 {
425 return true;
426 }
427 }
428 }
429 }
430 return false;
431 }
432
433 public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
434 {
435 {
436 Variable State = new Variable();
437 foreach (bool l2 in CompilerState.make(State))
438 {
439 CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det"));
440 CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
441 CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
442 CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
443 CompilerState.assertPred(State, new Functor1(@"var", 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"));
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"));
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"));
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"));
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"));
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"));
454 CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
455 CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
456 CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
457 processCompilerDirectives(RuleList, State);
458 foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass")))
459 {
460 yield return false;
461 }
462 foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
463 {
464 yield return false;
465 }
466 }
467 }
468 }
469
470 public static void processCompilerDirectives(object arg1, object arg2)
471 {
472 {
473 object _State = arg2;
474 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
475 {
476 return;
477 }
478 }
479 {
480 object State = arg2;
481 Variable Pred = new Variable();
482 Variable Determinism = new Variable();
483 Variable x3 = new Variable();
484 Variable RestRules = new Variable();
485 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules)))
486 {
487 CompilerState.assertPred(State, Pred, Determinism);
488 processCompilerDirectives(RestRules, State);
489 return;
490 }
491 }
492 {
493 object State = arg2;
494 Variable Module = new Variable();
495 Variable PredicateList = new Variable();
496 Variable x3 = new Variable();
497 Variable RestRules = new Variable();
498 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules)))
499 {
500 foreach (bool l3 in importPredicateList(State, Module, PredicateList))
501 {
502 processCompilerDirectives(RestRules, State);
503 return;
504 }
505 }
506 }
507 {
508 object State = arg2;
509 Variable x1 = new Variable();
510 Variable x2 = new Variable();
511 Variable RestRules = new Variable();
512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules)))
513 {
514 processCompilerDirectives(RestRules, State);
515 return;
516 }
517 }
518 {
519 object State = arg2;
520 Variable Head = new Variable();
521 Variable _Body = new Variable();
522 Variable x3 = new Variable();
523 Variable RestRules = new Variable();
524 Variable Name = new Variable();
525 Variable Arity = new Variable();
526 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules)))
527 {
528 foreach (bool l3 in YP.functor(Head, Name, Arity))
529 {
530 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
531 processCompilerDirectives(RestRules, State);
532 return;
533 }
534 }
535 }
536 {
537 object State = arg2;
538 Variable Fact = new Variable();
539 Variable x2 = new Variable();
540 Variable RestRules = new Variable();
541 Variable Name = new Variable();
542 Variable Arity = new Variable();
543 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules)))
544 {
545 foreach (bool l3 in YP.functor(Fact, Name, Arity))
546 {
547 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
548 processCompilerDirectives(RestRules, State);
549 return;
550 }
551 }
552 }
553 {
554 object State = arg2;
555 Variable x1 = new Variable();
556 Variable RestRules = new Variable();
557 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules)))
558 {
559 processCompilerDirectives(RestRules, State);
560 return;
561 }
562 }
563 }
564
565 public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
566 {
567 {
568 object _State = arg1;
569 object _Module = arg2;
570 foreach (bool l2 in YP.unify(arg3, Atom.NIL))
571 {
572 yield return true;
573 yield break;
574 }
575 }
576 {
577 object State = arg1;
578 object Module = arg2;
579 Variable Name = new Variable();
580 Variable Arity = new Variable();
581 Variable Rest = new Variable();
582 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest)))
583 {
584 CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
585 foreach (bool l3 in importPredicateList(State, Module, Rest))
586 {
587 yield return true;
588 yield break;
589 }
590 }
591 }
592 {
593 object State = arg1;
594 object Module = arg2;
595 Variable x3 = new Variable();
596 Variable Rest = new Variable();
597 foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
598 {
599 foreach (bool l3 in importPredicateList(State, Module, Rest))
600 {
601 yield return true;
602 yield break;
603 }
604 }
605 }
606 }
607
608 public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode)
609 {
610 {
611 Variable SamePredicateRuleList = new Variable();
612 Variable RestRules = new Variable();
613 foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules))
614 {
615 if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL))
616 {
617 foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode))
618 {
619 yield return false;
620 }
621 foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode))
622 {
623 yield return false;
624 }
625 }
626 }
627 }
628 }
629
630 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
631 {
632 {
633 Variable FirstRule = new Variable();
634 Variable x5 = new Variable();
635 Variable x6 = new Variable();
636 Variable x7 = new Variable();
637 Variable Head = new Variable();
638 Variable x9 = new Variable();
639 Variable ArgAssignments = new Variable();
640 Variable Calls = new Variable();
641 Variable Rule = new Variable();
642 Variable VariableNameSuggestions = new Variable();
643 Variable ClauseBag = new Variable();
644 Variable Name = new Variable();
645 Variable ArgsList = new Variable();
646 Variable FunctionArgNames = new Variable();
647 Variable MergedArgName = new Variable();
648 Variable ArgName = new Variable();
649 Variable MergedArgNames = new Variable();
650 Variable FunctionArgs = new Variable();
651 Variable BodyCode = new Variable();
652 Variable ReturnType = new Variable();
653 Variable BodyWithReturn = new Variable();
654 foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList))
655 {
656 foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7)))
657 {
658 goto cutIf1;
659 }
660 foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule))
661 {
662 CompilerState.startFunction(State, Head);
663 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
664 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
665 {
666 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
667 {
668 findallAnswers3.add();
669 }
670 }
671 foreach (bool l4 in findallAnswers3.result(ClauseBag))
672 {
673 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
674 {
675 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
676 {
677 FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
678 foreach (bool l7 in member(ArgName, FunctionArgNames))
679 {
680 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
681 {
682 findallAnswers4.add();
683 goto cutIf5;
684 }
685 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
686 {
687 findallAnswers4.add();
688 }
689 cutIf5:
690 { }
691 }
692 foreach (bool l7 in findallAnswers4.result(MergedArgNames))
693 {
694 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
695 {
696 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
697 {
698 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
699 {
700 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
701 {
702 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
703 {
704 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
705 {
706 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
707 {
708 yield return false;
709 }
710 }
711 goto cutIf7;
712 }
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))
736 {
737 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
738 {
739 yield return false;
740 }
741 }
742 cutIf9:
743 cutIf8:
744 cutIf7:
745 { }
746 }
747 goto cutIf6;
748 }
749 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
750 {
751 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
752 {
753 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
754 {
755 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
756 {
757 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
758 {
759 yield return false;
760 }
761 }
762 goto cutIf11;
763 }
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))
787 {
788 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
789 {
790 yield return false;
791 }
792 }
793 cutIf13:
794 cutIf12:
795 cutIf11:
796 { }
797 }
798 goto cutIf10;
799 }
800 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
801 {
802 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
803 {
804 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
805 {
806 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
807 {
808 yield return false;
809 }
810 }
811 goto cutIf14;
812 }
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))
836 {
837 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
838 {
839 yield return false;
840 }
841 }
842 cutIf16:
843 cutIf15:
844 cutIf14:
845 { }
846 }
847 cutIf10:
848 cutIf6:
849 { }
850 }
851 }
852 }
853 }
854 }
855 }
856 goto cutIf2;
857 }
858 foreach (bool l3 in YP.unify(Head, FirstRule))
859 {
860 CompilerState.startFunction(State, Head);
861 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
862 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
863 {
864 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
865 {
866 findallAnswers17.add();
867 }
868 }
869 foreach (bool l4 in findallAnswers17.result(ClauseBag))
870 {
871 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
872 {
873 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
874 {
875 FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
876 foreach (bool l7 in member(ArgName, FunctionArgNames))
877 {
878 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
879 {
880 findallAnswers18.add();
881 goto cutIf19;
882 }
883 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
884 {
885 findallAnswers18.add();
886 }
887 cutIf19:
888 { }
889 }
890 foreach (bool l7 in findallAnswers18.result(MergedArgNames))
891 {
892 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
893 {
894 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
895 {
896 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
897 {
898 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
899 {
900 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
901 {
902 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
903 {
904 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
905 {
906 yield return false;
907 }
908 }
909 goto cutIf21;
910 }
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))
934 {
935 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
936 {
937 yield return false;
938 }
939 }
940 cutIf23:
941 cutIf22:
942 cutIf21:
943 { }
944 }
945 goto cutIf20;
946 }
947 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
948 {
949 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
950 {
951 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
952 {
953 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
954 {
955 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
956 {
957 yield return false;
958 }
959 }
960 goto cutIf25;
961 }
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))
985 {
986 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
987 {
988 yield return false;
989 }
990 }
991 cutIf27:
992 cutIf26:
993 cutIf25:
994 { }
995 }
996 goto cutIf24;
997 }
998 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
999 {
1000 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1001 {
1002 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
1003 {
1004 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1005 {
1006 yield return false;
1007 }
1008 }
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;
1021 }
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))
1034 {
1035 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1036 {
1037 yield return false;
1038 }
1039 }
1040 cutIf30:
1041 cutIf29:
1042 cutIf28:
1043 { }
1044 }
1045 cutIf24:
1046 cutIf20:
1047 { }
1048 }
1049 }
1050 }
1051 }
1052 }
1053 }
1054 }
1055 cutIf2:
1056 cutIf1:
1057 { }
1058 }
1059 }
1060 }
1061
1062 public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3)
1063 {
1064 {
1065 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1066 {
1067 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1068 {
1069 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1070 {
1071 yield return true;
1072 yield break;
1073 }
1074 }
1075 }
1076 }
1077 {
1078 Variable First = new Variable();
1079 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL)))
1080 {
1081 foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL)))
1082 {
1083 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1084 {
1085 yield return true;
1086 yield break;
1087 }
1088 }
1089 }
1090 }
1091 {
1092 object SamePredicateRuleList = arg2;
1093 object RestRules = arg3;
1094 Variable First = new Variable();
1095 Variable Rest = new Variable();
1096 Variable FirstRule = new Variable();
1097 Variable x6 = new Variable();
1098 Variable SecondRule = new Variable();
1099 Variable x8 = new Variable();
1100 Variable x9 = new Variable();
1101 Variable FirstHead = new Variable();
1102 Variable x11 = new Variable();
1103 Variable SecondHead = new Variable();
1104 Variable x13 = new Variable();
1105 Variable Name = new Variable();
1106 Variable Arity = new Variable();
1107 Variable RestSamePredicates = new Variable();
1108 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1109 {
1110 foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First))
1111 {
1112 foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest))
1113 {
1114 foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule))
1115 {
1116 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1117 {
1118 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1119 {
1120 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1121 {
1122 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1123 {
1124 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1125 {
1126 yield return true;
1127 yield break;
1128 }
1129 }
1130 goto cutIf3;
1131 }
1132 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1133 {
1134 foreach (bool l9 in YP.unify(RestRules, Rest))
1135 {
1136 yield return true;
1137 yield break;
1138 }
1139 }
1140 cutIf3:
1141 { }
1142 }
1143 goto cutIf2;
1144 }
1145 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1146 {
1147 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1148 {
1149 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1150 {
1151 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1152 {
1153 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1154 {
1155 yield return true;
1156 yield break;
1157 }
1158 }
1159 goto cutIf4;
1160 }
1161 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1162 {
1163 foreach (bool l9 in YP.unify(RestRules, Rest))
1164 {
1165 yield return true;
1166 yield break;
1167 }
1168 }
1169 cutIf4:
1170 { }
1171 }
1172 }
1173 cutIf2:
1174 goto cutIf1;
1175 }
1176 foreach (bool l5 in YP.unify(FirstHead, FirstRule))
1177 {
1178 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1179 {
1180 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1181 {
1182 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1183 {
1184 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1185 {
1186 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1187 {
1188 yield return true;
1189 yield break;
1190 }
1191 }
1192 goto cutIf6;
1193 }
1194 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1195 {
1196 foreach (bool l9 in YP.unify(RestRules, Rest))
1197 {
1198 yield return true;
1199 yield break;
1200 }
1201 }
1202 cutIf6:
1203 { }
1204 }
1205 goto cutIf5;
1206 }
1207 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1208 {
1209 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1210 {
1211 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1212 {
1213 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1214 {
1215 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1216 {
1217 yield return true;
1218 yield break;
1219 }
1220 }
1221 goto cutIf7;
1222 }
1223 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1224 {
1225 foreach (bool l9 in YP.unify(RestRules, Rest))
1226 {
1227 yield return true;
1228 yield break;
1229 }
1230 }
1231 cutIf7:
1232 { }
1233 }
1234 }
1235 cutIf5:
1236 { }
1237 }
1238 cutIf1:
1239 { }
1240 }
1241 }
1242 }
1243 }
1244 }
1245
1246 public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3)
1247 {
1248 {
1249 object _MergedArgNames = arg2;
1250 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1251 {
1252 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1253 {
1254 yield return true;
1255 yield break;
1256 }
1257 }
1258 }
1259 {
1260 object MergedArgNames = arg2;
1261 Variable ArgAssignments = new Variable();
1262 Variable Calls = new Variable();
1263 Variable Rest = new Variable();
1264 Variable ClauseCode = new Variable();
1265 Variable RestResults = new Variable();
1266 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest)))
1267 {
1268 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults)))
1269 {
1270 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
1271 {
1272 foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults))
1273 {
1274 yield return true;
1275 yield break;
1276 }
1277 }
1278 }
1279 }
1280 }
1281 }
1282
1283 public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4)
1284 {
1285 {
1286 object _MergedArgNames = arg3;
1287 Variable In = new Variable();
1288 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1289 {
1290 foreach (bool l3 in YP.unify(arg2, In))
1291 {
1292 foreach (bool l4 in YP.unify(arg4, In))
1293 {
1294 yield return true;
1295 yield break;
1296 }
1297 }
1298 }
1299 }
1300 {
1301 object In = arg2;
1302 object MergedArgNames = arg3;
1303 object ClauseCode = arg4;
1304 Variable VariableName = new Variable();
1305 Variable ArgName = new Variable();
1306 Variable RestArgAssignments = new Variable();
1307 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments)))
1308 {
1309 foreach (bool l3 in member(VariableName, MergedArgNames))
1310 {
1311 foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode))
1312 {
1313 yield return true;
1314 yield break;
1315 }
1316 goto cutIf1;
1317 }
1318 foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode))
1319 {
1320 yield return true;
1321 yield break;
1322 }
1323 cutIf1:
1324 { }
1325 }
1326 }
1327 }
1328
1329 public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName)
1330 {
1331 {
1332 object _ArgName = arg1;
1333 foreach (bool l2 in YP.unify(arg2, Atom.NIL))
1334 {
1335 if (YP.nonvar(VariableName))
1336 {
1337 yield return true;
1338 yield break;
1339 }
1340 }
1341 }
1342 {
1343 object ArgName = arg1;
1344 Variable ArgAssignments = new Variable();
1345 Variable _Calls = new Variable();
1346 Variable RestClauseBag = new Variable();
1347 foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag)))
1348 {
1349 foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments))
1350 {
1351 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
1352 {
1353 yield return false;
1354 }
1355 }
1356 }
1357 }
1358 }
1359
1360 public static IEnumerable<bool> maplist_arg(object arg1, object arg2)
1361 {
1362 {
1363 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1364 {
1365 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1366 {
1367 yield return true;
1368 yield break;
1369 }
1370 }
1371 }
1372 {
1373 Variable First = new Variable();
1374 Variable Rest = new Variable();
1375 Variable RestResults = new Variable();
1376 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1377 {
1378 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults)))
1379 {
1380 foreach (bool l4 in maplist_arg(Rest, RestResults))
1381 {
1382 yield return true;
1383 yield break;
1384 }
1385 }
1386 }
1387 }
1388 }
1389
1390 public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3)
1391 {
1392 {
1393 object _StartArgNumber = arg2;
1394 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1395 {
1396 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1397 {
1398 yield return true;
1399 yield break;
1400 }
1401 }
1402 }
1403 {
1404 object StartArgNumber = arg2;
1405 Variable x1 = new Variable();
1406 Variable Rest = new Variable();
1407 Variable ArgName = new Variable();
1408 Variable RestFunctionArgs = new Variable();
1409 Variable NumberCodes = new Variable();
1410 Variable NumberAtom = new Variable();
1411 Variable NextArgNumber = new Variable();
1412 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest)))
1413 {
1414 foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs)))
1415 {
1416 foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes))
1417 {
1418 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1419 {
1420 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1421 {
1422 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
1423 {
1424 foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs))
1425 {
1426 yield return true;
1427 yield break;
1428 }
1429 }
1430 }
1431 }
1432 }
1433 }
1434 }
1435 }
1436 }
1437
1438 public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls)
1439 {
1440 {
1441 Variable Head = new Variable();
1442 Variable Body = new Variable();
1443 Variable x8 = new Variable();
1444 Variable HeadArgs = new Variable();
1445 Variable CompiledHeadArgs = new Variable();
1446 Variable BodyCode = new Variable();
1447 Variable VariableNamesList = new Variable();
1448 Variable ArgUnifications = new Variable();
1449 foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule))
1450 {
1451 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
1452 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
1453 {
1454 foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs))
1455 {
1456 foreach (bool l5 in compileRuleBody(Body, State, BodyCode))
1457 {
1458 foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList))
1459 {
1460 foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications))
1461 {
1462 foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls))
1463 {
1464 yield return true;
1465 yield break;
1466 }
1467 }
1468 }
1469 }
1470 }
1471 }
1472 }
1473 }
1474 {
1475 foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls))
1476 {
1477 yield return true;
1478 yield break;
1479 }
1480 }
1481 }
1482
1483 public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1484 {
1485 {
1486 object x1 = arg2;
1487 object x2 = arg3;
1488 object x3 = arg4;
1489 Variable BodyCode = new Variable();
1490 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1491 {
1492 foreach (bool l3 in YP.unify(arg5, BodyCode))
1493 {
1494 foreach (bool l4 in YP.unify(arg6, BodyCode))
1495 {
1496 yield return true;
1497 yield break;
1498 }
1499 }
1500 }
1501 }
1502 {
1503 object Index = arg3;
1504 object AllHeadArgs = arg4;
1505 object BodyCode = arg5;
1506 object ArgUnifications = arg6;
1507 Variable HeadArg = new Variable();
1508 Variable RestHeadArgs = new Variable();
1509 Variable x3 = new Variable();
1510 Variable RestCompiledHeadArgs = new Variable();
1511 Variable _ArgIndex1 = new Variable();
1512 Variable NextIndex = new Variable();
1513 foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs)))
1514 {
1515 foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs)))
1516 {
1517 foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1))
1518 {
1519 foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1)))
1520 {
1521 foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications))
1522 {
1523 yield return true;
1524 yield break;
1525 }
1526 }
1527 }
1528 }
1529 }
1530 }
1531 {
1532 object Index = arg3;
1533 object AllHeadArgs = arg4;
1534 object BodyCode = arg5;
1535 Variable _HeadArg = new Variable();
1536 Variable RestHeadArgs = new Variable();
1537 Variable CompiledHeadArg = new Variable();
1538 Variable RestCompiledHeadArgs = new Variable();
1539 Variable ArgName = new Variable();
1540 Variable RestArgUnifications = new Variable();
1541 Variable NumberCodes = new Variable();
1542 Variable NumberAtom = new Variable();
1543 Variable NextIndex = new Variable();
1544 foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs)))
1545 {
1546 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
1547 {
1548 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)))
1549 {
1550 foreach (bool l5 in YP.number_codes(Index, NumberCodes))
1551 {
1552 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
1553 {
1554 foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1555 {
1556 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
1557 {
1558 foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications))
1559 {
1560 yield return true;
1561 yield break;
1562 }
1563 }
1564 }
1565 }
1566 }
1567 }
1568 }
1569 }
1570 }
1571 }
1572
1573 public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1574 {
1575 {
1576 object _HeadArgs = arg2;
1577 Variable ArgAssignmentsIn = new Variable();
1578 Variable DeclarationsIn = new Variable();
1579 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1580 {
1581 foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn))
1582 {
1583 foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn))
1584 {
1585 foreach (bool l5 in YP.unify(arg5, DeclarationsIn))
1586 {
1587 foreach (bool l6 in YP.unify(arg6, DeclarationsIn))
1588 {
1589 yield return true;
1590 yield break;
1591 }
1592 }
1593 }
1594 }
1595 }
1596 }
1597 {
1598 object HeadArgs = arg2;
1599 object ArgAssignmentsIn = arg3;
1600 object ArgAssignmentsOut = arg4;
1601 object DeclarationsIn = arg5;
1602 object DeclarationsOut = arg6;
1603 Variable VariableName = new Variable();
1604 Variable Var = new Variable();
1605 Variable RestVariableNames = new Variable();
1606 Variable ArgIndex1 = new Variable();
1607 Variable NumberCodes = new Variable();
1608 Variable NumberAtom = new Variable();
1609 Variable ArgName = new Variable();
1610 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames)))
1611 {
1612 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
1613 {
1614 foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes))
1615 {
1616 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1617 {
1618 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1619 {
1620 foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1621 {
1622 yield return true;
1623 yield break;
1624 }
1625 }
1626 }
1627 }
1628 }
1629 }
1630 }
1631 {
1632 object HeadArgs = arg2;
1633 object ArgAssignmentsIn = arg3;
1634 object ArgAssignmentsOut = arg4;
1635 object DeclarationsIn = arg5;
1636 Variable VariableName = new Variable();
1637 Variable _Var = new Variable();
1638 Variable RestVariableNames = new Variable();
1639 Variable DeclarationsOut = new Variable();
1640 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames)))
1641 {
1642 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)))
1643 {
1644 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1645 {
1646 yield return true;
1647 yield break;
1648 }
1649 }
1650 }
1651 }
1652 }
1653
1654 public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3)
1655 {
1656 {
1657 Variable FirstHeadArgs = new Variable();
1658 Variable RestHeadArgs = new Variable();
1659 Variable x4 = new Variable();
1660 foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs)))
1661 {
1662 foreach (bool l3 in YP.unify(arg3, 1))
1663 {
1664 if (sameVariable(Var, FirstHeadArgs))
1665 {
1666 foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4))
1667 {
1668 goto cutIf1;
1669 }
1670 yield return false;
1671 cutIf1:
1672 yield break;
1673 }
1674 }
1675 }
1676 }
1677 {
1678 object Index = arg3;
1679 Variable x2 = new Variable();
1680 Variable RestHeadArgs = new Variable();
1681 Variable RestIndex = new Variable();
1682 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs)))
1683 {
1684 foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex))
1685 {
1686 foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex)))
1687 {
1688 yield return true;
1689 yield break;
1690 }
1691 }
1692 }
1693 }
1694 }
1695
1696 public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3)
1697 {
1698 {
1699 object A = arg1;
1700 object State = arg2;
1701 object PseudoCode = arg3;
1702 if (YP.var(A))
1703 {
1704 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode))
1705 {
1706 yield return true;
1707 yield break;
1708 }
1709 }
1710 }
1711 {
1712 object State = arg2;
1713 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1714 {
1715 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1716 {
1717 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1718 {
1719 yield return true;
1720 yield break;
1721 }
1722 }
1723 }
1724 }
1725 {
1726 object State = arg2;
1727 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1728 {
1729 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1730 {
1731 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1732 {
1733 yield return true;
1734 yield break;
1735 }
1736 }
1737 }
1738 }
1739 {
1740 object State = arg2;
1741 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1742 {
1743 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL))))
1744 {
1745 CompilerState.setCodeUsesYield(State);
1746 yield return true;
1747 yield break;
1748 }
1749 }
1750 }
1751 {
1752 object _State = arg2;
1753 Variable Name = new Variable();
1754 foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
1755 {
1756 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
1757 {
1758 yield return true;
1759 yield break;
1760 }
1761 }
1762 }
1763 {
1764 object State = arg2;
1765 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1766 {
1767 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1768 {
1769 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1770 {
1771 yield return true;
1772 yield break;
1773 }
1774 }
1775 }
1776 }
1777 {
1778 object State = arg2;
1779 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1780 {
1781 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1782 {
1783 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1784 {
1785 yield return true;
1786 yield break;
1787 }
1788 }
1789 }
1790 }
1791 {
1792 object State = arg2;
1793 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1794 {
1795 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
1796 {
1797 CompilerState.setCodeUsesYield(State);
1798 yield return true;
1799 yield break;
1800 }
1801 }
1802 }
1803 {
1804 object State = arg2;
1805 object PseudoCode = arg3;
1806 Variable A = new Variable();
1807 Variable B = new Variable();
1808 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
1809 {
1810 if (YP.var(A))
1811 {
1812 foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
1813 {
1814 yield return true;
1815 yield break;
1816 }
1817 }
1818 }
1819 }
1820 {
1821 object State = arg2;
1822 object PseudoCode = arg3;
1823 Variable A = new Variable();
1824 Variable T = new Variable();
1825 Variable B = new Variable();
1826 Variable C = new Variable();
1827 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C)))
1828 {
1829 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode))
1830 {
1831 yield return true;
1832 yield break;
1833 }
1834 }
1835 }
1836 {
1837 object State = arg2;
1838 object PseudoCode = arg3;
1839 Variable A = new Variable();
1840 Variable B = new Variable();
1841 Variable C = new Variable();
1842 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C)))
1843 {
1844 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode))
1845 {
1846 yield return true;
1847 yield break;
1848 }
1849 }
1850 }
1851 {
1852 object State = arg2;
1853 Variable A = new Variable();
1854 Variable B = new Variable();
1855 Variable ACode = new Variable();
1856 Variable BCode = new Variable();
1857 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1858 {
1859 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL)))
1860 {
1861 if (CompilerState.isSemidetNoneOut(State, A))
1862 {
1863 foreach (bool l5 in compileFunctorCall(A, State, ACode))
1864 {
1865 foreach (bool l6 in compileRuleBody(B, State, BCode))
1866 {
1867 yield return true;
1868 yield break;
1869 }
1870 }
1871 }
1872 }
1873 }
1874 }
1875 {
1876 object State = arg2;
1877 object PseudoCode = arg3;
1878 Variable A = new Variable();
1879 Variable B = new Variable();
1880 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1881 {
1882 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode))
1883 {
1884 yield return true;
1885 yield break;
1886 }
1887 }
1888 }
1889 {
1890 object State = arg2;
1891 object PseudoCode = arg3;
1892 Variable A = new Variable();
1893 Variable B = new Variable();
1894 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B)))
1895 {
1896 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode))
1897 {
1898 yield return true;
1899 yield break;
1900 }
1901 }
1902 }
1903 {
1904 object State = arg2;
1905 object PseudoCode = arg3;
1906 Variable A = new Variable();
1907 Variable T = new Variable();
1908 Variable B = new Variable();
1909 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B)))
1910 {
1911 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode))
1912 {
1913 yield return true;
1914 yield break;
1915 }
1916 }
1917 }
1918 {
1919 object State = arg2;
1920 object PseudoCode = arg3;
1921 Variable A = new Variable();
1922 Variable B = new Variable();
1923 Variable C = new Variable();
1924 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C)))
1925 {
1926 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode))
1927 {
1928 yield return true;
1929 yield break;
1930 }
1931 }
1932 }
1933 {
1934 object State = arg2;
1935 object PseudoCode = arg3;
1936 Variable A = new Variable();
1937 Variable ACode = new Variable();
1938 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A)))
1939 {
1940 foreach (bool l3 in compileRuleBody(A, State, ACode))
1941 {
1942 foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode))
1943 {
1944 yield return true;
1945 yield break;
1946 }
1947 }
1948 }
1949 }
1950 {
1951 object State = arg2;
1952 object PseudoCode = arg3;
1953 Variable Name = new Variable();
1954 Variable A = new Variable();
1955 Variable ACode = new Variable();
1956 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A)))
1957 {
1958 foreach (bool l3 in compileRuleBody(A, State, ACode))
1959 {
1960 foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode))
1961 {
1962 yield return true;
1963 yield break;
1964 }
1965 }
1966 }
1967 }
1968 {
1969 object _State = arg2;
1970 Variable x1 = new Variable();
1971 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1)))
1972 {
1973 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1974 {
1975 yield return true;
1976 yield break;
1977 }
1978 }
1979 }
1980 {
1981 object State = arg2;
1982 object PseudoCode = arg3;
1983 Variable A = new Variable();
1984 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A)))
1985 {
1986 foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
1987 {
1988 yield return true;
1989 yield break;
1990 }
1991 }
1992 }
1993 {
1994 object State = arg2;
1995 Variable A = new Variable();
1996 Variable Term = new Variable();
1997 Variable B = new Variable();
1998 Variable ACode = new Variable();
1999 Variable TermCode = new Variable();
2000 Variable BCode = new Variable();
2001 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B)))
2002 {
2003 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)))
2004 {
2005 foreach (bool l4 in compileTerm(A, State, ACode))
2006 {
2007 foreach (bool l5 in compileExpression(Term, State, TermCode))
2008 {
2009 foreach (bool l6 in compileRuleBody(B, State, BCode))
2010 {
2011 yield return true;
2012 yield break;
2013 }
2014 }
2015 }
2016 }
2017 }
2018 }
2019 {
2020 object State = arg2;
2021 Variable A = new Variable();
2022 Variable B = new Variable();
2023 Variable ACode = new Variable();
2024 Variable BCode = new Variable();
2025 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2026 {
2027 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2028 {
2029 if (CompilerState.isDetNoneOut(State, A))
2030 {
2031 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2032 {
2033 foreach (bool l6 in compileRuleBody(B, State, BCode))
2034 {
2035 yield return true;
2036 yield break;
2037 }
2038 }
2039 }
2040 }
2041 }
2042 }
2043 {
2044 object State = arg2;
2045 Variable A = new Variable();
2046 Variable B = new Variable();
2047 Variable ACode = new Variable();
2048 Variable BCode = new Variable();
2049 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2050 {
2051 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
2052 {
2053 if (CompilerState.isSemidetNoneOut(State, A))
2054 {
2055 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2056 {
2057 foreach (bool l6 in compileRuleBody(B, State, BCode))
2058 {
2059 yield return true;
2060 yield break;
2061 }
2062 }
2063 }
2064 }
2065 }
2066 }
2067 {
2068 object State = arg2;
2069 Variable ACode = new Variable();
2070 Variable B = new Variable();
2071 Variable BCode = new Variable();
2072 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
2073 {
2074 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2075 {
2076 foreach (bool l4 in compileRuleBody(B, State, BCode))
2077 {
2078 yield return true;
2079 yield break;
2080 }
2081 }
2082 }
2083 }
2084 {
2085 object State = arg2;
2086 Variable A = new Variable();
2087 Variable B = new Variable();
2088 Variable FunctionName = new Variable();
2089 Variable X1Code = new Variable();
2090 Variable X2Code = new Variable();
2091 Variable BCode = new Variable();
2092 Variable Name = new Variable();
2093 Variable X1 = new Variable();
2094 Variable X2 = new Variable();
2095 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2096 {
2097 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)))
2098 {
2099 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL)))))
2100 {
2101 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
2102 {
2103 foreach (bool l6 in compileExpression(X1, State, X1Code))
2104 {
2105 foreach (bool l7 in compileExpression(X2, State, X2Code))
2106 {
2107 foreach (bool l8 in compileRuleBody(B, State, BCode))
2108 {
2109 yield return true;
2110 yield break;
2111 }
2112 }
2113 }
2114 }
2115 }
2116 }
2117 }
2118 }
2119 {
2120 object State = arg2;
2121 object PseudoCode = arg3;
2122 Variable A = new Variable();
2123 Variable B = new Variable();
2124 Variable C = new Variable();
2125 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
2126 {
2127 foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
2128 {
2129 yield return true;
2130 yield break;
2131 }
2132 }
2133 }
2134 {
2135 object State = arg2;
2136 object PseudoCode = arg3;
2137 Variable Template = new Variable();
2138 Variable Goal = new Variable();
2139 Variable Bag = new Variable();
2140 Variable B = new Variable();
2141 Variable TemplateCode = new Variable();
2142 Variable FindallAnswers = new Variable();
2143 Variable GoalAndAddCode = new Variable();
2144 Variable BagCode = new Variable();
2145 Variable BCode = new Variable();
2146 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B)))
2147 {
2148 foreach (bool l3 in compileTerm(Template, State, TemplateCode))
2149 {
2150 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers))
2151 {
2152 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))
2153 {
2154 foreach (bool l6 in compileTerm(Bag, State, BagCode))
2155 {
2156 foreach (bool l7 in compileRuleBody(B, State, BCode))
2157 {
2158 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))
2159 {
2160 yield return true;
2161 yield break;
2162 }
2163 }
2164 }
2165 }
2166 }
2167 }
2168 }
2169 }
2170 {
2171 object State = arg2;
2172 object PseudoCode = arg3;
2173 Variable Template = new Variable();
2174 Variable Goal = new Variable();
2175 Variable Bag = new Variable();
2176 Variable B = new Variable();
2177 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B)))
2178 {
2179 foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode))
2180 {
2181 yield return true;
2182 yield break;
2183 }
2184 }
2185 }
2186 {
2187 object State = arg2;
2188 object PseudoCode = arg3;
2189 Variable Template = new Variable();
2190 Variable Goal = new Variable();
2191 Variable Bag = new Variable();
2192 Variable B = new Variable();
2193 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B)))
2194 {
2195 foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode))
2196 {
2197 yield return true;
2198 yield break;
2199 }
2200 }
2201 }
2202 {
2203 object State = arg2;
2204 Variable A = new Variable();
2205 Variable B = new Variable();
2206 Variable ATermCode = new Variable();
2207 Variable BCode = new Variable();
2208 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B)))
2209 {
2210 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)))
2211 {
2212 foreach (bool l4 in compileTerm(A, State, ATermCode))
2213 {
2214 foreach (bool l5 in compileRuleBody(B, State, BCode))
2215 {
2216 yield return true;
2217 yield break;
2218 }
2219 }
2220 }
2221 }
2222 }
2223 {
2224 object State = arg2;
2225 Variable A = 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();
2318 Variable ACode = new Variable();
2319 Variable BCode = new Variable();
2320 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2321 {
2322 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL)))
2323 {
2324 foreach (bool l4 in compileFunctorCall(A, State, ACode))
2325 {
2326 foreach (bool l5 in compileRuleBody(B, State, BCode))
2327 {
2328 yield return true;
2329 yield break;
2330 }
2331 }
2332 }
2333 }
2334 }
2335 {
2336 object State = arg2;
2337 object PseudoCode = arg3;
2338 Variable A = new Variable();
2339 Variable B = new Variable();
2340 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2341 {
2342 if (YP.var(A))
2343 {
2344 foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode))
2345 {
2346 yield return true;
2347 yield break;
2348 }
2349 }
2350 }
2351 }
2352 {
2353 object State = arg2;
2354 Variable A = new Variable();
2355 Variable T = new Variable();
2356 Variable B = new Variable();
2357 Variable CutIfLabel = new Variable();
2358 Variable Code = new Variable();
2359 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B)))
2360 {
2361 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL)))
2362 {
2363 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel))
2364 {
2365 foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code))
2366 {
2367 yield return true;
2368 yield break;
2369 }
2370 }
2371 }
2372 }
2373 }
2374 {
2375 object State = arg2;
2376 object PseudoCode = arg3;
2377 Variable A = new Variable();
2378 Variable B = new Variable();
2379 Variable ACode = new Variable();
2380 Variable BCode = new Variable();
2381 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2382 {
2383 foreach (bool l3 in compileRuleBody(A, State, ACode))
2384 {
2385 foreach (bool l4 in compileRuleBody(B, State, BCode))
2386 {
2387 foreach (bool l5 in append(ACode, BCode, PseudoCode))
2388 {
2389 yield return true;
2390 yield break;
2391 }
2392 }
2393 }
2394 }
2395 }
2396 {
2397 object A = arg1;
2398 object State = arg2;
2399 object PseudoCode = arg3;
2400 foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode))
2401 {
2402 yield return true;
2403 yield break;
2404 }
2405 }
2406 }
2407
2408 public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode)
2409 {
2410 {
2411 Variable TemplateCode = new Variable();
2412 Variable GoalTermCode = new Variable();
2413 Variable UnqualifiedGoal = new Variable();
2414 Variable BagofAnswers = new Variable();
2415 Variable GoalAndAddCode = new Variable();
2416 Variable BagCode = new Variable();
2417 Variable BCode = new Variable();
2418 foreach (bool l2 in compileTerm(Template, State, TemplateCode))
2419 {
2420 foreach (bool l3 in compileTerm(Goal, State, GoalTermCode))
2421 {
2422 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
2423 {
2424 foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers))
2425 {
2426 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))
2427 {
2428 foreach (bool l7 in compileTerm(Bag, State, BagCode))
2429 {
2430 foreach (bool l8 in compileRuleBody(B, State, BCode))
2431 {
2432 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))
2433 {
2434 yield return true;
2435 yield break;
2436 }
2437 }
2438 }
2439 }
2440 }
2441 }
2442 }
2443 }
2444 }
2445 }
2446
2447 public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2)
2448 {
2449 {
2450 object Goal = arg1;
2451 foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal)))
2452 {
2453 if (YP.var(Goal))
2454 {
2455 yield return true;
2456 yield break;
2457 }
2458 }
2459 }
2460 {
2461 object UnqualifiedGoal = arg2;
2462 Variable x1 = new Variable();
2463 Variable Goal = new Variable();
2464 foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal)))
2465 {
2466 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
2467 {
2468 yield return true;
2469 yield break;
2470 }
2471 }
2472 }
2473 {
2474 Variable UnqualifiedGoal = new Variable();
2475 foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal))
2476 {
2477 foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal))
2478 {
2479 yield return true;
2480 yield break;
2481 }
2482 }
2483 }
2484 }
2485
2486 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
2487 {
2488 {
2489 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:=")))
2490 {
2491 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal")))
2492 {
2493 yield return true;
2494 yield break;
2495 }
2496 }
2497 }
2498 {
2499 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\=")))
2500 {
2501 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual")))
2502 {
2503 yield return true;
2504 yield break;
2505 }
2506 }
2507 }
2508 {
2509 foreach (bool l2 in YP.unify(arg1, Atom.a(@">")))
2510 {
2511 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan")))
2512 {
2513 yield return true;
2514 yield break;
2515 }
2516 }
2517 }
2518 {
2519 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<")))
2520 {
2521 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan")))
2522 {
2523 yield return true;
2524 yield break;
2525 }
2526 }
2527 }
2528 {
2529 foreach (bool l2 in YP.unify(arg1, Atom.a(@">=")))
2530 {
2531 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual")))
2532 {
2533 yield return true;
2534 yield break;
2535 }
2536 }
2537 }
2538 {
2539 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<")))
2540 {
2541 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual")))
2542 {
2543 yield return true;
2544 yield break;
2545 }
2546 }
2547 }
2548 }
2549
2550 public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object PseudoCode)
2551 {
2552 {
2553 Variable FunctorName = new Variable();
2554 Variable FunctorArgs = new Variable();
2555 Variable x6 = new Variable();
2556 Variable Arity = new Variable();
2557 Variable CompiledArgs = new Variable();
2558 Variable FunctionName = new Variable();
2559 foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs)))
2560 {
2561 foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
2562 {
2563 foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
2564 {
2565 foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
2566 {
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)))
2577 {
2578 yield return true;
2579 yield break;
2580 }
2581 cutIf1:
2582 { }
2583 }
2584 }
2585 }
2586 }
2587 }
2588 }
2589
2590 public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4)
2591 {
2592 {
2593 object x1 = arg1;
2594 object Name = arg2;
2595 object Arity = arg3;
2596 object FunctionName = arg4;
2597 foreach (bool l2 in functorCallYPFunctionName(Name, Arity, FunctionName))
2598 {
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))
2610 {
2611 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
2612 {
2613 yield return true;
2614 yield break;
2615 }
2616 }
2617 }
2618 }
2619 {
2620 object _State = arg1;
2621 object _Arity = arg3;
2622 Variable Name = new Variable();
2623 foreach (bool l2 in YP.unify(arg2, Name))
2624 {
2625 foreach (bool l3 in YP.unify(arg4, Name))
2626 {
2627 foreach (bool l4 in Atom.module(Name, Atom.a(@"")))
2628 {
2629 yield return true;
2630 yield break;
2631 }
2632 }
2633 }
2634 }
2635 {
2636 object _State = arg1;
2637 object Name = arg2;
2638 object Arity = arg3;
2639 foreach (bool l2 in YP.unify(arg4, Atom.NIL))
2640 {
2641 foreach (bool l3 in Atom.module(Name, Atom.NIL))
2642 {
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")))
2684 {
2685 yield return true;
2686 yield break;
2687 }
2688 }
2689 }
2690 }
2691 {
2692 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=..")))
2693 {
2694 foreach (bool l3 in YP.unify(arg2, 2))
2695 {
2696 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ")))
2697 {
2698 yield return true;
2699 yield break;
2700 }
2701 }
2702 }
2703 }
2704 {
2705 foreach (bool l2 in YP.unify(arg1, Atom.a(@"var")))
2706 {
2707 foreach (bool l3 in YP.unify(arg2, 1))
2708 {
2709 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var")))
2710 {
2711 yield return true;
2712 yield break;
2713 }
2714 }
2715 }
2716 }
2717 {
2718 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar")))
2719 {
2720 foreach (bool l3 in YP.unify(arg2, 1))
2721 {
2722 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar")))
2723 {
2724 yield return true;
2725 yield break;
2726 }
2727 }
2728 }
2729 }
2730 {
2731 foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg")))
2732 {
2733 foreach (bool l3 in YP.unify(arg2, 3))
2734 {
2735 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg")))
2736 {
2737 yield return true;
2738 yield break;
2739 }
2740 }
2741 }
2742 }
2743 {
2744 foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor")))
2745 {
2746 foreach (bool l3 in YP.unify(arg2, 3))
2747 {
2748 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor")))
2749 {
2750 yield return true;
2751 yield break;
2752 }
2753 }
2754 }
2755 }
2756 {
2757 foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat")))
2758 {
2759 foreach (bool l3 in YP.unify(arg2, 0))
2760 {
2761 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat")))
2762 {
2763 yield return true;
2764 yield break;
2765 }
2766 }
2767 }
2768 }
2769 {
2770 foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code")))
2771 {
2772 foreach (bool l3 in YP.unify(arg2, 1))
2773 {
2774 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code")))
2775 {
2776 yield return true;
2777 yield break;
2778 }
2779 }
2780 }
2781 }
2782 {
2783 foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op")))
2784 {
2785 foreach (bool l3 in YP.unify(arg2, 3))
2786 {
2787 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op")))
2788 {
2789 yield return true;
2790 yield break;
2791 }
2792 }
2793 }
2794 }
2795 {
2796 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length")))
2797 {
2798 foreach (bool l3 in YP.unify(arg2, 2))
2799 {
2800 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length")))
2801 {
2802 yield return true;
2803 yield break;
2804 }
2805 }
2806 }
2807 }
2808 {
2809 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat")))
2810 {
2811 foreach (bool l3 in YP.unify(arg2, 3))
2812 {
2813 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat")))
2814 {
2815 yield return true;
2816 yield break;
2817 }
2818 }
2819 }
2820 }
2821 {
2822 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom")))
2823 {
2824 foreach (bool l3 in YP.unify(arg2, 5))
2825 {
2826 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom")))
2827 {
2828 yield return true;
2829 yield break;
2830 }
2831 }
2832 }
2833 }
2834 {
2835 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes")))
2836 {
2837 foreach (bool l3 in YP.unify(arg2, 2))
2838 {
2839 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes")))
2840 {
2841 yield return true;
2842 yield break;
2843 }
2844 }
2845 }
2846 }
2847 {
2848 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes")))
2849 {
2850 foreach (bool l3 in YP.unify(arg2, 2))
2851 {
2852 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes")))
2853 {
2854 yield return true;
2855 yield break;
2856 }
2857 }
2858 }
2859 }
2860 {
2861 foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term")))
2862 {
2863 foreach (bool l3 in YP.unify(arg2, 2))
2864 {
2865 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term")))
2866 {
2867 yield return true;
2868 yield break;
2869 }
2870 }
2871 }
2872 }
2873 {
2874 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort")))
2875 {
2876 foreach (bool l3 in YP.unify(arg2, 2))
2877 {
2878 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort")))
2879 {
2880 yield return true;
2881 yield break;
2882 }
2883 }
2884 }
2885 }
2886 {
2887 // Manually included : script_event for callback to LSL/C#
2888
2889 //object x1 = arg1;
2890 foreach (bool l2 in YP.unify(arg1, Atom.a(@"script_event")))
2891 {
2892 foreach (bool l3 in YP.unify(arg2, 2))
2893 {
2894 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.script_event")))
2895 {
2896 yield return true;
2897 yield break;
2898 }
2899 }
2900 }
2901 }
2902 {
2903 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl")))
2904 {
2905 foreach (bool l3 in YP.unify(arg2, 0))
2906 {
2907 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl")))
2908 {
2909 yield return true;
2910 yield break;
2911 }
2912 }
2913 }
2914 }
2915 {
2916 foreach (bool l2 in YP.unify(arg1, Atom.a(@"write")))
2917 {
2918 foreach (bool l3 in YP.unify(arg2, 1))
2919 {
2920 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write")))
2921 {
2922 yield return true;
2923 yield break;
2924 }
2925 }
2926 }
2927 }
2928 {
2929 foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code")))
2930 {
2931 foreach (bool l3 in YP.unify(arg2, 1))
2932 {
2933 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code")))
2934 {
2935 yield return true;
2936 yield break;
2937 }
2938 }
2939 }
2940 }
2941 {
2942 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom")))
2943 {
2944 foreach (bool l3 in YP.unify(arg2, 1))
2945 {
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")))
2956 {
2957 foreach (bool l3 in YP.unify(arg2, 1))
2958 {
2959 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer")))
2960 {
2961 yield return true;
2962 yield break;
2963 }
2964 }
2965 }
2966 }
2967 {
2968 foreach (bool l2 in YP.unify(arg1, Atom.a(@"float")))
2969 {
2970 foreach (bool l3 in YP.unify(arg2, 1))
2971 {
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")))
2986 {
2987 yield return true;
2988 yield break;
2989 }
2990 }
2991 }
2992 }
2993 {
2994 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic")))
2995 {
2996 foreach (bool l3 in YP.unify(arg2, 1))
2997 {
2998 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic")))
2999 {
3000 yield return true;
3001 yield break;
3002 }
3003 }
3004 }
3005 }
3006 {
3007 foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound")))
3008 {
3009 foreach (bool l3 in YP.unify(arg2, 1))
3010 {
3011 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound")))
3012 {
3013 yield return true;
3014 yield break;
3015 }
3016 }
3017 }
3018 }
3019 {
3020 foreach (bool l2 in YP.unify(arg1, Atom.a(@"==")))
3021 {
3022 foreach (bool l3 in YP.unify(arg2, 2))
3023 {
3024 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual")))
3025 {
3026 yield return true;
3027 yield break;
3028 }
3029 }
3030 }
3031 }
3032 {
3033 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\==")))
3034 {
3035 foreach (bool l3 in YP.unify(arg2, 2))
3036 {
3037 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual")))
3038 {
3039 yield return true;
3040 yield break;
3041 }
3042 }
3043 }
3044 }
3045 {
3046 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<")))
3047 {
3048 foreach (bool l3 in YP.unify(arg2, 2))
3049 {
3050 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan")))
3051 {
3052 yield return true;
3053 yield break;
3054 }
3055 }
3056 }
3057 }
3058 {
3059 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<")))
3060 {
3061 foreach (bool l3 in YP.unify(arg2, 2))
3062 {
3063 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual")))
3064 {
3065 yield return true;
3066 yield break;
3067 }
3068 }
3069 }
3070 }
3071 {
3072 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>")))
3073 {
3074 foreach (bool l3 in YP.unify(arg2, 2))
3075 {
3076 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan")))
3077 {
3078 yield return true;
3079 yield break;
3080 }
3081 }
3082 }
3083 }
3084 {
3085 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>=")))
3086 {
3087 foreach (bool l3 in YP.unify(arg2, 2))
3088 {
3089 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual")))
3090 {
3091 yield return true;
3092 yield break;
3093 }
3094 }
3095 }
3096 }
3097 {
3098 foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw")))
3099 {
3100 foreach (bool l3 in YP.unify(arg2, 1))
3101 {
3102 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
3103 {
3104 yield return true;
3105 yield break;
3106 }
3107 }
3108 }
3109 }
3110 }
3111
3112 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
3113 {
3114 {
3115 object Term = arg1;
3116 object State = arg2;
3117 Variable VariableName = new Variable();
3118 foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName)))
3119 {
3120 if (YP.var(Term))
3121 {
3122 foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName))
3123 {
3124 yield return true;
3125 yield break;
3126 }
3127 }
3128 }
3129 }
3130 {
3131 object _State = arg2;
3132 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3133 {
3134 foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL"))))
3135 {
3136 yield return true;
3137 yield break;
3138 }
3139 }
3140 }
3141 {
3142 object Term = arg1;
3143 object State = arg2;
3144 object Code = arg3;
3145 Variable ModuleCode = new Variable();
3146 if (YP.atom(Term))
3147 {
3148 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
3149 {
3150 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)))))
3151 {
3152 yield return true;
3153 yield break;
3154 }
3155 goto cutIf1;
3156 }
3157 foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL))))
3158 {
3159 yield return true;
3160 yield break;
3161 }
3162 cutIf1:
3163 { }
3164 }
3165 }
3166 {
3167 object State = arg2;
3168 Variable First = new Variable();
3169 Variable Rest = new Variable();
3170 Variable Arg1 = new Variable();
3171 Variable Arg2 = new Variable();
3172 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3173 {
3174 foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3175 {
3176 foreach (bool l4 in compileTerm(First, State, Arg1))
3177 {
3178 foreach (bool l5 in compileTerm(Rest, State, Arg2))
3179 {
3180 yield return true;
3181 yield break;
3182 }
3183 }
3184 }
3185 }
3186 }
3187 {
3188 object Term = arg1;
3189 object State = arg2;
3190 object Result = arg3;
3191 Variable Name = new Variable();
3192 Variable TermArgs = new Variable();
3193 Variable x6 = new Variable();
3194 Variable Arity = new Variable();
3195 Variable ModuleCode = new Variable();
3196 Variable NameCode = new Variable();
3197 Variable X1 = new Variable();
3198 Variable Arg1 = new Variable();
3199 Variable X2 = new Variable();
3200 Variable Arg2 = new Variable();
3201 Variable X3 = new Variable();
3202 Variable Arg3 = new Variable();
3203 Variable Args = new Variable();
3204 foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs)))
3205 {
3206 if (YP.termEqual(TermArgs, Atom.NIL))
3207 {
3208 foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name)))
3209 {
3210 yield return true;
3211 yield break;
3212 }
3213 goto cutIf2;
3214 }
3215 foreach (bool l3 in YP.functor(Term, x6, Arity))
3216 {
3217 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
3218 {
3219 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)))))
3220 {
3221 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3222 {
3223 foreach (bool l7 in compileTerm(X1, State, Arg1))
3224 {
3225 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3226 {
3227 yield return true;
3228 yield break;
3229 }
3230 }
3231 goto cutIf4;
3232 }
3233 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3234 {
3235 foreach (bool l7 in compileTerm(X1, State, Arg1))
3236 {
3237 foreach (bool l8 in compileTerm(X2, State, Arg2))
3238 {
3239 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3240 {
3241 yield return true;
3242 yield break;
3243 }
3244 }
3245 }
3246 goto cutIf5;
3247 }
3248 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3249 {
3250 foreach (bool l7 in compileTerm(X1, State, Arg1))
3251 {
3252 foreach (bool l8 in compileTerm(X2, State, Arg2))
3253 {
3254 foreach (bool l9 in compileTerm(X3, State, Arg3))
3255 {
3256 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)))))))
3257 {
3258 yield return true;
3259 yield break;
3260 }
3261 }
3262 }
3263 }
3264 }
3265 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
3266 {
3267 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3268 {
3269 yield return true;
3270 yield break;
3271 }
3272 }
3273 cutIf5:
3274 cutIf4:
3275 { }
3276 }
3277 goto cutIf3;
3278 }
3279 foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name)))
3280 {
3281 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3282 {
3283 foreach (bool l6 in compileTerm(X1, State, Arg1))
3284 {
3285 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3286 {
3287 yield return true;
3288 yield break;
3289 }
3290 }
3291 goto cutIf6;
3292 }
3293 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3294 {
3295 foreach (bool l6 in compileTerm(X1, State, Arg1))
3296 {
3297 foreach (bool l7 in compileTerm(X2, State, Arg2))
3298 {
3299 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3300 {
3301 yield return true;
3302 yield break;
3303 }
3304 }
3305 }
3306 goto cutIf7;
3307 }
3308 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3309 {
3310 foreach (bool l6 in compileTerm(X1, State, Arg1))
3311 {
3312 foreach (bool l7 in compileTerm(X2, State, Arg2))
3313 {
3314 foreach (bool l8 in compileTerm(X3, State, Arg3))
3315 {
3316 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)))))))
3317 {
3318 yield return true;
3319 yield break;
3320 }
3321 }
3322 }
3323 }
3324 }
3325 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
3326 {
3327 foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3328 {
3329 yield return true;
3330 yield break;
3331 }
3332 }
3333 cutIf7:
3334 cutIf6:
3335 { }
3336 }
3337 cutIf3:
3338 { }
3339 }
3340 cutIf2:
3341 { }
3342 }
3343 }
3344 }
3345
3346 public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode)
3347 {
3348 {
3349 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
3350 {
3351 foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL))))
3352 {
3353 yield return true;
3354 yield break;
3355 }
3356 }
3357 }
3358 }
3359
3360 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
3361 {
3362 {
3363 object _State = arg2;
3364 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3365 {
3366 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
3367 {
3368 yield return true;
3369 yield break;
3370 }
3371 }
3372 }
3373 {
3374 object State = arg2;
3375 Variable First = new Variable();
3376 Variable Rest = new Variable();
3377 Variable FirstResult = new Variable();
3378 Variable RestResults = new Variable();
3379 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3380 {
3381 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
3382 {
3383 foreach (bool l4 in compileTerm(First, State, FirstResult))
3384 {
3385 foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults))
3386 {
3387 yield return true;
3388 yield break;
3389 }
3390 }
3391 }
3392 }
3393 }
3394 }
3395
3396 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
3397 {
3398 {
3399 Variable Name = new Variable();
3400 Variable TermArgs = new Variable();
3401 Variable X1 = new Variable();
3402 Variable FunctionName = new Variable();
3403 Variable Arg1 = new Variable();
3404 Variable x9 = new Variable();
3405 Variable X2 = new Variable();
3406 Variable Arg2 = new Variable();
3407 Variable x12 = new Variable();
3408 Variable Arity = new Variable();
3409 if (YP.nonvar(Term))
3410 {
3411 foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
3412 {
3413 if (YP.atom(Name))
3414 {
3415 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3416 {
3417 foreach (bool l6 in unaryFunction(Name, FunctionName))
3418 {
3419 foreach (bool l7 in compileExpression(X1, State, Arg1))
3420 {
3421 foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL))))
3422 {
3423 yield return true;
3424 yield break;
3425 }
3426 }
3427 goto cutIf1;
3428 }
3429 }
3430 foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
3431 {
3432 foreach (bool l6 in compileTerm(Term, State, Result))
3433 {
3434 yield return true;
3435 yield break;
3436 }
3437 goto cutIf2;
3438 }
3439 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3440 {
3441 foreach (bool l6 in binaryFunction(Name, FunctionName))
3442 {
3443 foreach (bool l7 in compileExpression(X1, State, Arg1))
3444 {
3445 foreach (bool l8 in compileExpression(X2, State, Arg2))
3446 {
3447 foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3448 {
3449 yield return true;
3450 yield break;
3451 }
3452 }
3453 }
3454 goto cutIf3;
3455 }
3456 }
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")));
3460 yield return false;
3461 }
3462 cutIf3:
3463 cutIf2:
3464 cutIf1:
3465 { }
3466 }
3467 }
3468 }
3469 }
3470 {
3471 foreach (bool l2 in compileTerm(Term, State, Result))
3472 {
3473 yield return true;
3474 yield break;
3475 }
3476 }
3477 }
3478
3479 public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
3480 {
3481 {
3482 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3483 {
3484 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate")))
3485 {
3486 yield return true;
3487 yield break;
3488 }
3489 }
3490 }
3491 {
3492 foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs")))
3493 {
3494 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs")))
3495 {
3496 yield return true;
3497 yield break;
3498 }
3499 }
3500 }
3501 {
3502 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign")))
3503 {
3504 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign")))
3505 {
3506 yield return true;
3507 yield break;
3508 }
3509 }
3510 }
3511 {
3512 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3513 {
3514 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor")))
3515 {
3516 yield return true;
3517 yield break;
3518 }
3519 }
3520 }
3521 {
3522 foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate")))
3523 {
3524 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate")))
3525 {
3526 yield return true;
3527 yield break;
3528 }
3529 }
3530 }
3531 {
3532 foreach (bool l2 in YP.unify(arg1, Atom.a(@"round")))
3533 {
3534 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round")))
3535 {
3536 yield return true;
3537 yield break;
3538 }
3539 }
3540 }
3541 {
3542 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3543 {
3544 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling")))
3545 {
3546 yield return true;
3547 yield break;
3548 }
3549 }
3550 }
3551 {
3552 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin")))
3553 {
3554 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin")))
3555 {
3556 yield return true;
3557 yield break;
3558 }
3559 }
3560 }
3561 {
3562 foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos")))
3563 {
3564 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos")))
3565 {
3566 yield return true;
3567 yield break;
3568 }
3569 }
3570 }
3571 {
3572 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan")))
3573 {
3574 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan")))
3575 {
3576 yield return true;
3577 yield break;
3578 }
3579 }
3580 }
3581 {
3582 foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp")))
3583 {
3584 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp")))
3585 {
3586 yield return true;
3587 yield break;
3588 }
3589 }
3590 }
3591 {
3592 foreach (bool l2 in YP.unify(arg1, Atom.a(@"log")))
3593 {
3594 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log")))
3595 {
3596 yield return true;
3597 yield break;
3598 }
3599 }
3600 }
3601 {
3602 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt")))
3603 {
3604 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt")))
3605 {
3606 yield return true;
3607 yield break;
3608 }
3609 }
3610 }
3611 {
3612 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\")))
3613 {
3614 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement")))
3615 {
3616 yield return true;
3617 yield break;
3618 }
3619 }
3620 }
3621 }
3622
3623 public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
3624 {
3625 {
3626 foreach (bool l2 in YP.unify(arg1, Atom.a(@"+")))
3627 {
3628 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add")))
3629 {
3630 yield return true;
3631 yield break;
3632 }
3633 }
3634 }
3635 {
3636 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3637 {
3638 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract")))
3639 {
3640 yield return true;
3641 yield break;
3642 }
3643 }
3644 }
3645 {
3646 foreach (bool l2 in YP.unify(arg1, Atom.a(@"*")))
3647 {
3648 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply")))
3649 {
3650 yield return true;
3651 yield break;
3652 }
3653 }
3654 }
3655 {
3656 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/")))
3657 {
3658 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide")))
3659 {
3660 yield return true;
3661 yield break;
3662 }
3663 }
3664 }
3665 {
3666 foreach (bool l2 in YP.unify(arg1, Atom.a(@"//")))
3667 {
3668 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide")))
3669 {
3670 yield return true;
3671 yield break;
3672 }
3673 }
3674 }
3675 {
3676 foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod")))
3677 {
3678 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod")))
3679 {
3680 yield return true;
3681 yield break;
3682 }
3683 }
3684 }
3685 {
3686 foreach (bool l2 in YP.unify(arg1, Atom.a(@"**")))
3687 {
3688 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow")))
3689 {
3690 yield return true;
3691 yield break;
3692 }
3693 }
3694 }
3695 {
3696 foreach (bool l2 in YP.unify(arg1, Atom.a(@">>")))
3697 {
3698 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight")))
3699 {
3700 yield return true;
3701 yield break;
3702 }
3703 }
3704 }
3705 {
3706 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<")))
3707 {
3708 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft")))
3709 {
3710 yield return true;
3711 yield break;
3712 }
3713 }
3714 }
3715 {
3716 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\")))
3717 {
3718 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd")))
3719 {
3720 yield return true;
3721 yield break;
3722 }
3723 }
3724 }
3725 {
3726 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/")))
3727 {
3728 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr")))
3729 {
3730 yield return true;
3731 yield break;
3732 }
3733 }
3734 }
3735 {
3736 foreach (bool l2 in YP.unify(arg1, Atom.a(@"min")))
3737 {
3738 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min")))
3739 {
3740 yield return true;
3741 yield break;
3742 }
3743 }
3744 }
3745 {
3746 foreach (bool l2 in YP.unify(arg1, Atom.a(@"max")))
3747 {
3748 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max")))
3749 {
3750 yield return true;
3751 yield break;
3752 }
3753 }
3754 }
3755 }
3756
3757 public static void convertFunctionCSharp(object arg1)
3758 {
3759 {
3760 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
3761 {
3762 YP.write(Atom.a(@"public class YPInnerClass {}"));
3763 YP.nl();
3764 YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
3765 YP.nl();
3766 YP.nl();
3767 return;
3768 }
3769 }
3770 {
3771 Variable ReturnType = new Variable();
3772 Variable Name = new Variable();
3773 Variable ArgList = new Variable();
3774 Variable Body = new Variable();
3775 Variable Level = new Variable();
3776 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body })))
3777 {
3778 YP.write(Atom.a(@"public static "));
3779 YP.write(ReturnType);
3780 YP.write(Atom.a(@" "));
3781 YP.write(Name);
3782 YP.write(Atom.a(@"("));
3783 convertArgListCSharp(ArgList);
3784 YP.write(Atom.a(@") {"));
3785 YP.nl();
3786 foreach (bool l3 in YP.unify(Level, 1))
3787 {
3788 convertStatementListCSharp(Body, Level);
3789 YP.write(Atom.a(@"}"));
3790 YP.nl();
3791 YP.nl();
3792 return;
3793 }
3794 }
3795 }
3796 }
3797
3798 public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2)
3799 {
3800 {
3801 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3802 {
3803 yield return true;
3804 yield break;
3805 }
3806 }
3807 }
3808
3809 public static void convertStatementListCSharp(object arg1, object Level)
3810 {
3811 {
3812 Variable Name = new Variable();
3813 Variable Body = new Variable();
3814 Variable RestStatements = new Variable();
3815 Variable NewStatements = new Variable();
3816 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
3817 {
3818 foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements))
3819 {
3820 convertStatementListCSharp(NewStatements, Level);
3821 return;
3822 }
3823 }
3824 }
3825 {
3826 Variable Type = new Variable();
3827 Variable Name = new Variable();
3828 Variable Expression = new Variable();
3829 Variable RestStatements = new Variable();
3830 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements)))
3831 {
3832 convertIndentationCSharp(Level);
3833 YP.write(Type);
3834 YP.write(Atom.a(@" "));
3835 YP.write(Name);
3836 YP.write(Atom.a(@" = "));
3837 convertExpressionCSharp(Expression);
3838 YP.write(Atom.a(@";"));
3839 YP.nl();
3840 convertStatementListCSharp(RestStatements, Level);
3841 return;
3842 }
3843 }
3844 {
3845 Variable Name = new Variable();
3846 Variable Expression = new Variable();
3847 Variable RestStatements = new Variable();
3848 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
3849 {
3850 convertIndentationCSharp(Level);
3851 YP.write(Name);
3852 YP.write(Atom.a(@" = "));
3853 convertExpressionCSharp(Expression);
3854 YP.write(Atom.a(@";"));
3855 YP.nl();
3856 convertStatementListCSharp(RestStatements, Level);
3857 return;
3858 }
3859 }
3860 {
3861 Variable RestStatements = new Variable();
3862 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
3863 {
3864 convertIndentationCSharp(Level);
3865 YP.write(Atom.a(@"yield return true;"));
3866 YP.nl();
3867 convertStatementListCSharp(RestStatements, Level);
3868 return;
3869 }
3870 }
3871 {
3872 Variable RestStatements = new Variable();
3873 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
3874 {
3875 convertIndentationCSharp(Level);
3876 YP.write(Atom.a(@"yield return false;"));
3877 YP.nl();
3878 convertStatementListCSharp(RestStatements, Level);
3879 return;
3880 }
3881 }
3882 {
3883 Variable RestStatements = new Variable();
3884 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
3885 {
3886 convertIndentationCSharp(Level);
3887 YP.write(Atom.a(@"yield break;"));
3888 YP.nl();
3889 convertStatementListCSharp(RestStatements, Level);
3890 return;
3891 }
3892 }
3893 {
3894 Variable RestStatements = new Variable();
3895 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
3896 {
3897 convertIndentationCSharp(Level);
3898 YP.write(Atom.a(@"return;"));
3899 YP.nl();
3900 convertStatementListCSharp(RestStatements, Level);
3901 return;
3902 }
3903 }
3904 {
3905 Variable RestStatements = new Variable();
3906 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
3907 {
3908 convertIndentationCSharp(Level);
3909 YP.write(Atom.a(@"return true;"));
3910 YP.nl();
3911 convertStatementListCSharp(RestStatements, Level);
3912 return;
3913 }
3914 }
3915 {
3916 Variable RestStatements = new Variable();
3917 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
3918 {
3919 convertIndentationCSharp(Level);
3920 YP.write(Atom.a(@"return false;"));
3921 YP.nl();
3922 convertStatementListCSharp(RestStatements, Level);
3923 return;
3924 }
3925 }
3926 {
3927 Variable Name = new Variable();
3928 Variable RestStatements = new Variable();
3929 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements)))
3930 {
3931 convertIndentationCSharp(Level);
3932 YP.write(Name);
3933 YP.write(Atom.a(@":"));
3934 YP.nl();
3935 if (YP.termEqual(RestStatements, Atom.NIL))
3936 {
3937 convertIndentationCSharp(Level);
3938 YP.write(Atom.a(@"{}"));
3939 YP.nl();
3940 convertStatementListCSharp(RestStatements, Level);
3941 return;
3942 goto cutIf1;
3943 }
3944 convertStatementListCSharp(RestStatements, Level);
3945 return;
3946 cutIf1:
3947 { }
3948 }
3949 }
3950 {
3951 Variable Name = new Variable();
3952 Variable RestStatements = new Variable();
3953 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
3954 {
3955 convertIndentationCSharp(Level);
3956 YP.write(Atom.a(@"goto "));
3957 YP.write(Name);
3958 YP.write(Atom.a(@";"));
3959 YP.nl();
3960 convertStatementListCSharp(RestStatements, Level);
3961 return;
3962 }
3963 }
3964 {
3965 Variable Name = new Variable();
3966 Variable ArgList = new Variable();
3967 Variable RestStatements = new Variable();
3968 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
3969 {
3970 convertIndentationCSharp(Level);
3971 YP.write(Name);
3972 YP.write(Atom.a(@"("));
3973 convertArgListCSharp(ArgList);
3974 YP.write(Atom.a(@");"));
3975 YP.nl();
3976 convertStatementListCSharp(RestStatements, Level);
3977 return;
3978 }
3979 }
3980 {
3981 Variable Obj = new Variable();
3982 Variable Name = new Variable();
3983 Variable ArgList = new Variable();
3984 Variable RestStatements = new Variable();
3985 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
3986 {
3987 convertIndentationCSharp(Level);
3988 YP.write(Obj);
3989 YP.write(Atom.a(@"."));
3990 YP.write(Name);
3991 YP.write(Atom.a(@"("));
3992 convertArgListCSharp(ArgList);
3993 YP.write(Atom.a(@");"));
3994 YP.nl();
3995 convertStatementListCSharp(RestStatements, Level);
3996 return;
3997 }
3998 }
3999 {
4000 Variable Body = new Variable();
4001 Variable RestStatements = new Variable();
4002 Variable NextLevel = new Variable();
4003 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4004 {
4005 convertIndentationCSharp(Level);
4006 YP.write(Atom.a(@"{"));
4007 YP.nl();
4008 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4009 {
4010 convertStatementListCSharp(Body, NextLevel);
4011 convertIndentationCSharp(Level);
4012 YP.write(Atom.a(@"}"));
4013 YP.nl();
4014 convertStatementListCSharp(RestStatements, Level);
4015 return;
4016 }
4017 }
4018 }
4019 {
4020 Variable Expression = new Variable();
4021 Variable Body = new Variable();
4022 Variable RestStatements = new Variable();
4023 Variable NextLevel = new Variable();
4024 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4025 {
4026 convertIndentationCSharp(Level);
4027 YP.write(Atom.a(@"if ("));
4028 convertExpressionCSharp(Expression);
4029 YP.write(Atom.a(@") {"));
4030 YP.nl();
4031 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4032 {
4033 convertStatementListCSharp(Body, NextLevel);
4034 convertIndentationCSharp(Level);
4035 YP.write(Atom.a(@"}"));
4036 YP.nl();
4037 convertStatementListCSharp(RestStatements, Level);
4038 return;
4039 }
4040 }
4041 }
4042 {
4043 Variable Expression = new Variable();
4044 Variable Body = new Variable();
4045 Variable RestStatements = new Variable();
4046 Variable NextLevel = new Variable();
4047 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4048 {
4049 convertIndentationCSharp(Level);
4050 YP.write(Atom.a(@"foreach (bool l"));
4051 YP.write(Level);
4052 YP.write(Atom.a(@" in "));
4053 convertExpressionCSharp(Expression);
4054 YP.write(Atom.a(@") {"));
4055 YP.nl();
4056 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4057 {
4058 convertStatementListCSharp(Body, NextLevel);
4059 convertIndentationCSharp(Level);
4060 YP.write(Atom.a(@"}"));
4061 YP.nl();
4062 convertStatementListCSharp(RestStatements, Level);
4063 return;
4064 }
4065 }
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 }
4081 }
4082
4083 public static void convertIndentationCSharp(object Level)
4084 {
4085 {
4086 Variable N = new Variable();
4087 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4088 {
4089 repeatWrite(Atom.a(@" "), N);
4090 return;
4091 }
4092 }
4093 }
4094
4095 public static void convertArgListCSharp(object arg1)
4096 {
4097 {
4098 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4099 {
4100 return;
4101 }
4102 }
4103 {
4104 Variable Head = new Variable();
4105 Variable Tail = new Variable();
4106 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4107 {
4108 convertExpressionCSharp(Head);
4109 if (YP.termNotEqual(Tail, Atom.NIL))
4110 {
4111 YP.write(Atom.a(@", "));
4112 convertArgListCSharp(Tail);
4113 return;
4114 goto cutIf1;
4115 }
4116 convertArgListCSharp(Tail);
4117 return;
4118 cutIf1:
4119 { }
4120 }
4121 }
4122 }
4123
4124 public static void convertExpressionCSharp(object arg1)
4125 {
4126 {
4127 Variable X = new Variable();
4128 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4129 {
4130 YP.write(Atom.a(@"object "));
4131 YP.write(X);
4132 return;
4133 }
4134 }
4135 {
4136 Variable Name = new Variable();
4137 Variable ArgList = new Variable();
4138 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4139 {
4140 YP.write(Name);
4141 YP.write(Atom.a(@"("));
4142 convertArgListCSharp(ArgList);
4143 YP.write(Atom.a(@")"));
4144 return;
4145 }
4146 }
4147 {
4148 Variable Obj = new Variable();
4149 Variable Name = new Variable();
4150 Variable ArgList = new Variable();
4151 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4152 {
4153 YP.write(Obj);
4154 YP.write(Atom.a(@"."));
4155 YP.write(Name);
4156 YP.write(Atom.a(@"("));
4157 convertArgListCSharp(ArgList);
4158 YP.write(Atom.a(@")"));
4159 return;
4160 }
4161 }
4162 {
4163 Variable Name = new Variable();
4164 Variable ArgList = new Variable();
4165 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4166 {
4167 YP.write(Atom.a(@"new "));
4168 YP.write(Name);
4169 YP.write(Atom.a(@"("));
4170 convertArgListCSharp(ArgList);
4171 YP.write(Atom.a(@")"));
4172 return;
4173 }
4174 }
4175 {
4176 Variable Name = new Variable();
4177 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4178 {
4179 YP.write(Name);
4180 return;
4181 }
4182 }
4183 {
4184 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4185 {
4186 YP.write(Atom.a(@"null"));
4187 return;
4188 }
4189 }
4190 {
4191 Variable X = new Variable();
4192 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4193 {
4194 YP.write(Atom.a(@"!("));
4195 convertExpressionCSharp(X);
4196 YP.write(Atom.a(@")"));
4197 return;
4198 }
4199 }
4200 {
4201 Variable X = new Variable();
4202 Variable Y = new Variable();
4203 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4204 {
4205 YP.write(Atom.a(@"("));
4206 convertExpressionCSharp(X);
4207 YP.write(Atom.a(@") && ("));
4208 convertExpressionCSharp(Y);
4209 YP.write(Atom.a(@")"));
4210 return;
4211 }
4212 }
4213 {
4214 Variable ArgList = new Variable();
4215 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4216 {
4217 YP.write(Atom.a(@"new object[] {"));
4218 convertArgListCSharp(ArgList);
4219 YP.write(Atom.a(@"}"));
4220 return;
4221 }
4222 }
4223 {
4224 Variable X = new Variable();
4225 Variable Codes = new Variable();
4226 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4227 {
4228 if (YP.atom(X))
4229 {
4230 YP.write(Atom.a(@"@"""));
4231 foreach (bool l4 in YP.atom_codes(X, Codes))
4232 {
4233 convertStringCodesCSharp(Codes);
4234 YP.write(Atom.a(@""""));
4235 return;
4236 }
4237 }
4238 }
4239 }
4240 {
4241 Variable X = new Variable();
4242 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4243 {
4244 YP.write(X);
4245 return;
4246 }
4247 }
4248 }
4249
4250 public static void convertStringCodesCSharp(object arg1)
4251 {
4252 {
4253 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4254 {
4255 return;
4256 }
4257 }
4258 {
4259 Variable Code = new Variable();
4260 Variable RestCodes = new Variable();
4261 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4262 {
4263 if (YP.termEqual(Code, 34))
4264 {
4265 YP.put_code(34);
4266 YP.put_code(Code);
4267 convertStringCodesCSharp(RestCodes);
4268 return;
4269 goto cutIf1;
4270 }
4271 YP.put_code(Code);
4272 convertStringCodesCSharp(RestCodes);
4273 return;
4274 cutIf1:
4275 { }
4276 }
4277 }
4278 }
4279
4280 public static void convertFunctionJavascript(object arg1)
4281 {
4282 {
4283 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4284 {
4285 YP.write(Atom.a(@"function getDeclaringClass() { return null; }"));
4286 YP.nl();
4287 return;
4288 }
4289 }
4290 {
4291 Variable x1 = new Variable();
4292 Variable Name = new Variable();
4293 Variable ArgList = new Variable();
4294 Variable Body = new Variable();
4295 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4296 {
4297 YP.write(Atom.a(@"function "));
4298 YP.write(Name);
4299 YP.write(Atom.a(@"("));
4300 convertArgListJavascript(ArgList);
4301 YP.write(Atom.a(@") {"));
4302 YP.nl();
4303 convertStatementListJavascript(Body, 1);
4304 YP.write(Atom.a(@"}"));
4305 YP.nl();
4306 YP.nl();
4307 return;
4308 }
4309 }
4310 }
4311
4312 public static void convertStatementListJavascript(object arg1, object arg2)
4313 {
4314 {
4315 object x1 = arg2;
4316 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4317 {
4318 return;
4319 }
4320 }
4321 {
4322 object Level = arg2;
4323 Variable Name = new Variable();
4324 Variable Body = new Variable();
4325 Variable RestStatements = new Variable();
4326 Variable NextLevel = new Variable();
4327 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4328 {
4329 convertIndentationJavascript(Level);
4330 YP.write(Name);
4331 YP.write(Atom.a(@":"));
4332 YP.nl();
4333 convertIndentationJavascript(Level);
4334 YP.write(Atom.a(@"{"));
4335 YP.nl();
4336 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4337 {
4338 convertStatementListJavascript(Body, NextLevel);
4339 convertIndentationJavascript(Level);
4340 YP.write(Atom.a(@"}"));
4341 YP.nl();
4342 convertStatementListJavascript(RestStatements, Level);
4343 return;
4344 }
4345 }
4346 }
4347 {
4348 object Level = arg2;
4349 Variable _Type = new Variable();
4350 Variable Name = new Variable();
4351 Variable Expression = new Variable();
4352 Variable RestStatements = new Variable();
4353 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
4354 {
4355 convertIndentationJavascript(Level);
4356 YP.write(Atom.a(@"var "));
4357 YP.write(Name);
4358 YP.write(Atom.a(@" = "));
4359 convertExpressionJavascript(Expression);
4360 YP.write(Atom.a(@";"));
4361 YP.nl();
4362 convertStatementListJavascript(RestStatements, Level);
4363 return;
4364 }
4365 }
4366 {
4367 object Level = arg2;
4368 Variable Name = new Variable();
4369 Variable Expression = new Variable();
4370 Variable RestStatements = new Variable();
4371 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
4372 {
4373 convertIndentationJavascript(Level);
4374 YP.write(Name);
4375 YP.write(Atom.a(@" = "));
4376 convertExpressionJavascript(Expression);
4377 YP.write(Atom.a(@";"));
4378 YP.nl();
4379 convertStatementListJavascript(RestStatements, Level);
4380 return;
4381 }
4382 }
4383 {
4384 object Level = arg2;
4385 Variable RestStatements = new Variable();
4386 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
4387 {
4388 convertIndentationJavascript(Level);
4389 YP.write(Atom.a(@"yield true;"));
4390 YP.nl();
4391 convertStatementListJavascript(RestStatements, Level);
4392 return;
4393 }
4394 }
4395 {
4396 object Level = arg2;
4397 Variable RestStatements = new Variable();
4398 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
4399 {
4400 convertIndentationJavascript(Level);
4401 YP.write(Atom.a(@"yield false;"));
4402 YP.nl();
4403 convertStatementListJavascript(RestStatements, Level);
4404 return;
4405 }
4406 }
4407 {
4408 object Level = arg2;
4409 Variable RestStatements = new Variable();
4410 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
4411 {
4412 convertIndentationJavascript(Level);
4413 YP.write(Atom.a(@"return;"));
4414 YP.nl();
4415 convertStatementListJavascript(RestStatements, Level);
4416 return;
4417 }
4418 }
4419 {
4420 object Level = arg2;
4421 Variable RestStatements = new Variable();
4422 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
4423 {
4424 convertIndentationJavascript(Level);
4425 YP.write(Atom.a(@"return;"));
4426 YP.nl();
4427 convertStatementListJavascript(RestStatements, Level);
4428 return;
4429 }
4430 }
4431 {
4432 object Level = arg2;
4433 Variable RestStatements = new Variable();
4434 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
4435 {
4436 convertIndentationJavascript(Level);
4437 YP.write(Atom.a(@"return true;"));
4438 YP.nl();
4439 convertStatementListJavascript(RestStatements, Level);
4440 return;
4441 }
4442 }
4443 {
4444 object Level = arg2;
4445 Variable RestStatements = new Variable();
4446 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
4447 {
4448 convertIndentationJavascript(Level);
4449 YP.write(Atom.a(@"return false;"));
4450 YP.nl();
4451 convertStatementListJavascript(RestStatements, Level);
4452 return;
4453 }
4454 }
4455 {
4456 object Level = arg2;
4457 Variable Name = new Variable();
4458 Variable RestStatements = new Variable();
4459 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
4460 {
4461 convertIndentationJavascript(Level);
4462 YP.write(Atom.a(@"break "));
4463 YP.write(Name);
4464 YP.write(Atom.a(@";"));
4465 YP.nl();
4466 convertStatementListJavascript(RestStatements, Level);
4467 return;
4468 }
4469 }
4470 {
4471 object Level = arg2;
4472 Variable Name = new Variable();
4473 Variable ArgList = new Variable();
4474 Variable RestStatements = new Variable();
4475 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
4476 {
4477 convertIndentationJavascript(Level);
4478 YP.write(Name);
4479 YP.write(Atom.a(@"("));
4480 convertArgListJavascript(ArgList);
4481 YP.write(Atom.a(@");"));
4482 YP.nl();
4483 convertStatementListJavascript(RestStatements, Level);
4484 return;
4485 }
4486 }
4487 {
4488 object Level = arg2;
4489 Variable Obj = new Variable();
4490 Variable Name = new Variable();
4491 Variable ArgList = new Variable();
4492 Variable RestStatements = new Variable();
4493 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
4494 {
4495 convertIndentationJavascript(Level);
4496 YP.write(Obj);
4497 YP.write(Atom.a(@"."));
4498 YP.write(Name);
4499 YP.write(Atom.a(@"("));
4500 convertArgListJavascript(ArgList);
4501 YP.write(Atom.a(@");"));
4502 YP.nl();
4503 convertStatementListJavascript(RestStatements, Level);
4504 return;
4505 }
4506 }
4507 {
4508 object Level = arg2;
4509 Variable Body = new Variable();
4510 Variable RestStatements = new Variable();
4511 Variable NextLevel = new Variable();
4512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4513 {
4514 convertIndentationJavascript(Level);
4515 YP.write(Atom.a(@"{"));
4516 YP.nl();
4517 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4518 {
4519 convertStatementListJavascript(Body, NextLevel);
4520 convertIndentationJavascript(Level);
4521 YP.write(Atom.a(@"}"));
4522 YP.nl();
4523 convertStatementListJavascript(RestStatements, Level);
4524 return;
4525 }
4526 }
4527 }
4528 {
4529 object Level = arg2;
4530 Variable Expression = new Variable();
4531 Variable Body = new Variable();
4532 Variable RestStatements = new Variable();
4533 Variable NextLevel = new Variable();
4534 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4535 {
4536 convertIndentationJavascript(Level);
4537 YP.write(Atom.a(@"if ("));
4538 convertExpressionJavascript(Expression);
4539 YP.write(Atom.a(@") {"));
4540 YP.nl();
4541 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4542 {
4543 convertStatementListJavascript(Body, NextLevel);
4544 convertIndentationJavascript(Level);
4545 YP.write(Atom.a(@"}"));
4546 YP.nl();
4547 convertStatementListJavascript(RestStatements, Level);
4548 return;
4549 }
4550 }
4551 }
4552 {
4553 object Level = arg2;
4554 Variable Expression = new Variable();
4555 Variable Body = new Variable();
4556 Variable RestStatements = new Variable();
4557 Variable NextLevel = new Variable();
4558 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4559 {
4560 convertIndentationJavascript(Level);
4561 YP.write(Atom.a(@"for each (var l"));
4562 YP.write(Level);
4563 YP.write(Atom.a(@" in "));
4564 convertExpressionJavascript(Expression);
4565 YP.write(Atom.a(@") {"));
4566 YP.nl();
4567 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4568 {
4569 convertStatementListJavascript(Body, NextLevel);
4570 convertIndentationJavascript(Level);
4571 YP.write(Atom.a(@"}"));
4572 YP.nl();
4573 convertStatementListJavascript(RestStatements, Level);
4574 return;
4575 }
4576 }
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 }
4593 }
4594
4595 public static void convertIndentationJavascript(object Level)
4596 {
4597 {
4598 Variable N = new Variable();
4599 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4600 {
4601 repeatWrite(Atom.a(@" "), N);
4602 return;
4603 }
4604 }
4605 }
4606
4607 public static void convertArgListJavascript(object arg1)
4608 {
4609 {
4610 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4611 {
4612 return;
4613 }
4614 }
4615 {
4616 Variable Head = new Variable();
4617 Variable Tail = new Variable();
4618 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4619 {
4620 convertExpressionJavascript(Head);
4621 if (YP.termNotEqual(Tail, Atom.NIL))
4622 {
4623 YP.write(Atom.a(@", "));
4624 convertArgListJavascript(Tail);
4625 return;
4626 goto cutIf1;
4627 }
4628 convertArgListJavascript(Tail);
4629 return;
4630 cutIf1:
4631 { }
4632 }
4633 }
4634 }
4635
4636 public static void convertExpressionJavascript(object arg1)
4637 {
4638 {
4639 Variable X = new Variable();
4640 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4641 {
4642 YP.write(X);
4643 return;
4644 }
4645 }
4646 {
4647 Variable Name = new Variable();
4648 Variable ArgList = new Variable();
4649 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4650 {
4651 YP.write(Name);
4652 YP.write(Atom.a(@"("));
4653 convertArgListJavascript(ArgList);
4654 YP.write(Atom.a(@")"));
4655 return;
4656 }
4657 }
4658 {
4659 Variable Obj = new Variable();
4660 Variable Name = new Variable();
4661 Variable ArgList = new Variable();
4662 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4663 {
4664 YP.write(Obj);
4665 YP.write(Atom.a(@"."));
4666 YP.write(Name);
4667 YP.write(Atom.a(@"("));
4668 convertArgListJavascript(ArgList);
4669 YP.write(Atom.a(@")"));
4670 return;
4671 }
4672 }
4673 {
4674 Variable Name = new Variable();
4675 Variable ArgList = new Variable();
4676 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4677 {
4678 YP.write(Atom.a(@"new "));
4679 YP.write(Name);
4680 YP.write(Atom.a(@"("));
4681 convertArgListJavascript(ArgList);
4682 YP.write(Atom.a(@")"));
4683 return;
4684 }
4685 }
4686 {
4687 Variable Name = new Variable();
4688 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4689 {
4690 YP.write(Name);
4691 return;
4692 }
4693 }
4694 {
4695 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4696 {
4697 YP.write(Atom.a(@"null"));
4698 return;
4699 }
4700 }
4701 {
4702 Variable X = new Variable();
4703 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4704 {
4705 YP.write(Atom.a(@"!("));
4706 convertExpressionJavascript(X);
4707 YP.write(Atom.a(@")"));
4708 return;
4709 }
4710 }
4711 {
4712 Variable X = new Variable();
4713 Variable Y = new Variable();
4714 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4715 {
4716 YP.write(Atom.a(@"("));
4717 convertExpressionJavascript(X);
4718 YP.write(Atom.a(@") && ("));
4719 convertExpressionJavascript(Y);
4720 YP.write(Atom.a(@")"));
4721 return;
4722 }
4723 }
4724 {
4725 Variable ArgList = new Variable();
4726 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4727 {
4728 YP.write(Atom.a(@"["));
4729 convertArgListJavascript(ArgList);
4730 YP.write(Atom.a(@"]"));
4731 return;
4732 }
4733 }
4734 {
4735 Variable X = new Variable();
4736 Variable Codes = new Variable();
4737 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4738 {
4739 if (YP.atom(X))
4740 {
4741 YP.write(Atom.a(@""""));
4742 foreach (bool l4 in YP.atom_codes(X, Codes))
4743 {
4744 convertStringCodesJavascript(Codes);
4745 YP.write(Atom.a(@""""));
4746 return;
4747 }
4748 }
4749 }
4750 }
4751 {
4752 Variable X = new Variable();
4753 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4754 {
4755 YP.write(X);
4756 return;
4757 }
4758 }
4759 }
4760
4761 public static void convertStringCodesJavascript(object arg1)
4762 {
4763 {
4764 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4765 {
4766 return;
4767 }
4768 }
4769 {
4770 Variable Code = new Variable();
4771 Variable RestCodes = new Variable();
4772 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4773 {
4774 if (YP.termEqual(Code, 34))
4775 {
4776 YP.put_code(92);
4777 YP.put_code(Code);
4778 convertStringCodesJavascript(RestCodes);
4779 return;
4780 goto cutIf1;
4781 }
4782 if (YP.termEqual(Code, 92))
4783 {
4784 YP.put_code(92);
4785 YP.put_code(Code);
4786 convertStringCodesJavascript(RestCodes);
4787 return;
4788 goto cutIf1;
4789 }
4790 YP.put_code(Code);
4791 convertStringCodesJavascript(RestCodes);
4792 return;
4793 cutIf1:
4794 { }
4795 }
4796 }
4797 }
4798
4799 public static void convertFunctionPython(object arg1)
4800 {
4801 {
4802 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4803 {
4804 YP.write(Atom.a(@"def getDeclaringClass():"));
4805 YP.nl();
4806 YP.write(Atom.a(@" return None"));
4807 YP.nl();
4808 YP.nl();
4809 return;
4810 }
4811 }
4812 {
4813 Variable x1 = new Variable();
4814 Variable Name = new Variable();
4815 Variable ArgList = new Variable();
4816 Variable Body = new Variable();
4817 Variable Level = new Variable();
4818 Variable HasBreakableBlock = new Variable();
4819 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4820 {
4821 YP.write(Atom.a(@"def "));
4822 YP.write(Name);
4823 YP.write(Atom.a(@"("));
4824 convertArgListPython(ArgList);
4825 YP.write(Atom.a(@"):"));
4826 YP.nl();
4827 foreach (bool l3 in YP.unify(Level, 1))
4828 {
4829 if (hasBreakableBlockPython(Body))
4830 {
4831 foreach (bool l5 in YP.unify(HasBreakableBlock, 1))
4832 {
4833 if (YP.termEqual(HasBreakableBlock, 1))
4834 {
4835 convertIndentationPython(Level);
4836 YP.write(Atom.a(@"doBreak = False"));
4837 YP.nl();
4838 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
4839 {
4840 YP.nl();
4841 return;
4842 }
4843 goto cutIf2;
4844 }
4845 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4846 {
4847 YP.nl();
4848 return;
4849 }
4850 cutIf2:
4851 { }
4852 }
4853 goto cutIf1;
4854 }
4855 foreach (bool l4 in YP.unify(HasBreakableBlock, 0))
4856 {
4857 if (YP.termEqual(HasBreakableBlock, 1))
4858 {
4859 convertIndentationPython(Level);
4860 YP.write(Atom.a(@"doBreak = False"));
4861 YP.nl();
4862 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4863 {
4864 YP.nl();
4865 return;
4866 }
4867 goto cutIf3;
4868 }
4869 foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock))
4870 {
4871 YP.nl();
4872 return;
4873 }
4874 cutIf3:
4875 { }
4876 }
4877 cutIf1:
4878 { }
4879 }
4880 }
4881 }
4882 }
4883
4884 public static bool hasBreakableBlockPython(object arg1)
4885 {
4886 {
4887 Variable _Name = new Variable();
4888 Variable _Body = new Variable();
4889 Variable _RestStatements = new Variable();
4890 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements)))
4891 {
4892 return true;
4893 }
4894 }
4895 {
4896 Variable Body = new Variable();
4897 Variable _RestStatements = new Variable();
4898 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements)))
4899 {
4900 if (hasBreakableBlockPython(Body))
4901 {
4902 return true;
4903 }
4904 }
4905 }
4906 {
4907 Variable _Expression = new Variable();
4908 Variable Body = new Variable();
4909 Variable _RestStatements = new Variable();
4910 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements)))
4911 {
4912 if (hasBreakableBlockPython(Body))
4913 {
4914 return true;
4915 }
4916 }
4917 }
4918 {
4919 Variable _Expression = new Variable();
4920 Variable Body = new Variable();
4921 Variable _RestStatements = new Variable();
4922 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements)))
4923 {
4924 if (hasBreakableBlockPython(Body))
4925 {
4926 return true;
4927 }
4928 }
4929 }
4930 {
4931 Variable x1 = new Variable();
4932 Variable RestStatements = new Variable();
4933 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements)))
4934 {
4935 if (hasBreakableBlockPython(RestStatements))
4936 {
4937 return true;
4938 }
4939 }
4940 }
4941 return false;
4942 }
4943
4944 public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3)
4945 {
4946 {
4947 object x1 = arg2;
4948 object x2 = arg3;
4949 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4950 {
4951 yield return true;
4952 yield break;
4953 }
4954 }
4955 {
4956 object Level = arg2;
4957 object HasBreakableBlock = arg3;
4958 Variable Name = new Variable();
4959 Variable Body = new Variable();
4960 Variable RestStatements = new Variable();
4961 Variable NextLevel = new Variable();
4962 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4963 {
4964 convertIndentationPython(Level);
4965 YP.write(Name);
4966 YP.write(Atom.a(@" = False"));
4967 YP.nl();
4968 convertIndentationPython(Level);
4969 YP.write(Atom.a(@"for _ in [1]:"));
4970 YP.nl();
4971 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4972 {
4973 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
4974 {
4975 convertIndentationPython(Level);
4976 YP.write(Atom.a(@"if "));
4977 YP.write(Name);
4978 YP.write(Atom.a(@":"));
4979 YP.nl();
4980 convertIndentationPython(NextLevel);
4981 YP.write(Atom.a(@"doBreak = False"));
4982 YP.nl();
4983 convertIndentationPython(Level);
4984 YP.write(Atom.a(@"if doBreak:"));
4985 YP.nl();
4986 convertIndentationPython(NextLevel);
4987 YP.write(Atom.a(@"break"));
4988 YP.nl();
4989 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
4990 {
4991 yield return true;
4992 yield break;
4993 }
4994 }
4995 }
4996 }
4997 }
4998 {
4999 object Level = arg2;
5000 object HasBreakableBlock = arg3;
5001 Variable _Type = new Variable();
5002 Variable Name = new Variable();
5003 Variable Expression = new Variable();
5004 Variable RestStatements = new Variable();
5005 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
5006 {
5007 convertIndentationPython(Level);
5008 YP.write(Name);
5009 YP.write(Atom.a(@" = "));
5010 convertExpressionPython(Expression);
5011 YP.nl();
5012 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5013 {
5014 yield return true;
5015 yield break;
5016 }
5017 }
5018 }
5019 {
5020 object Level = arg2;
5021 object HasBreakableBlock = arg3;
5022 Variable Name = new Variable();
5023 Variable Expression = new Variable();
5024 Variable RestStatements = new Variable();
5025 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
5026 {
5027 convertIndentationPython(Level);
5028 YP.write(Name);
5029 YP.write(Atom.a(@" = "));
5030 convertExpressionPython(Expression);
5031 YP.nl();
5032 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5033 {
5034 yield return true;
5035 yield break;
5036 }
5037 }
5038 }
5039 {
5040 object Level = arg2;
5041 object HasBreakableBlock = arg3;
5042 Variable RestStatements = new Variable();
5043 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
5044 {
5045 convertIndentationPython(Level);
5046 YP.write(Atom.a(@"yield True"));
5047 YP.nl();
5048 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5049 {
5050 yield return true;
5051 yield break;
5052 }
5053 }
5054 }
5055 {
5056 object Level = arg2;
5057 object HasBreakableBlock = arg3;
5058 Variable RestStatements = new Variable();
5059 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
5060 {
5061 convertIndentationPython(Level);
5062 YP.write(Atom.a(@"yield False"));
5063 YP.nl();
5064 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5065 {
5066 yield return true;
5067 yield break;
5068 }
5069 }
5070 }
5071 {
5072 object Level = arg2;
5073 object HasBreakableBlock = arg3;
5074 Variable RestStatements = new Variable();
5075 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
5076 {
5077 convertIndentationPython(Level);
5078 YP.write(Atom.a(@"return"));
5079 YP.nl();
5080 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5081 {
5082 yield return true;
5083 yield break;
5084 }
5085 }
5086 }
5087 {
5088 object Level = arg2;
5089 object HasBreakableBlock = arg3;
5090 Variable RestStatements = new Variable();
5091 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
5092 {
5093 convertIndentationPython(Level);
5094 YP.write(Atom.a(@"return"));
5095 YP.nl();
5096 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5097 {
5098 yield return true;
5099 yield break;
5100 }
5101 }
5102 }
5103 {
5104 object Level = arg2;
5105 object HasBreakableBlock = arg3;
5106 Variable RestStatements = new Variable();
5107 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
5108 {
5109 convertIndentationPython(Level);
5110 YP.write(Atom.a(@"return True"));
5111 YP.nl();
5112 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5113 {
5114 yield return true;
5115 yield break;
5116 }
5117 }
5118 }
5119 {
5120 object Level = arg2;
5121 object HasBreakableBlock = arg3;
5122 Variable RestStatements = new Variable();
5123 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
5124 {
5125 convertIndentationPython(Level);
5126 YP.write(Atom.a(@"return False"));
5127 YP.nl();
5128 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5129 {
5130 yield return true;
5131 yield break;
5132 }
5133 }
5134 }
5135 {
5136 object Level = arg2;
5137 object HasBreakableBlock = arg3;
5138 Variable Name = new Variable();
5139 Variable RestStatements = new Variable();
5140 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
5141 {
5142 convertIndentationPython(Level);
5143 YP.write(Name);
5144 YP.write(Atom.a(@" = True"));
5145 YP.nl();
5146 convertIndentationPython(Level);
5147 YP.write(Atom.a(@"doBreak = True"));
5148 YP.nl();
5149 convertIndentationPython(Level);
5150 YP.write(Atom.a(@"break"));
5151 YP.nl();
5152 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5153 {
5154 yield return true;
5155 yield break;
5156 }
5157 }
5158 }
5159 {
5160 object Level = arg2;
5161 object HasBreakableBlock = arg3;
5162 Variable Name = new Variable();
5163 Variable ArgList = new Variable();
5164 Variable RestStatements = new Variable();
5165 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
5166 {
5167 convertIndentationPython(Level);
5168 YP.write(Name);
5169 YP.write(Atom.a(@"("));
5170 convertArgListPython(ArgList);
5171 YP.write(Atom.a(@")"));
5172 YP.nl();
5173 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5174 {
5175 yield return true;
5176 yield break;
5177 }
5178 }
5179 }
5180 {
5181 object Level = arg2;
5182 object HasBreakableBlock = arg3;
5183 Variable Obj = new Variable();
5184 Variable Name = new Variable();
5185 Variable ArgList = new Variable();
5186 Variable RestStatements = new Variable();
5187 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
5188 {
5189 convertIndentationPython(Level);
5190 YP.write(Obj);
5191 YP.write(Atom.a(@"."));
5192 YP.write(Name);
5193 YP.write(Atom.a(@"("));
5194 convertArgListPython(ArgList);
5195 YP.write(Atom.a(@")"));
5196 YP.nl();
5197 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5198 {
5199 yield return true;
5200 yield break;
5201 }
5202 }
5203 }
5204 {
5205 object Level = arg2;
5206 object HasBreakableBlock = arg3;
5207 Variable Body = new Variable();
5208 Variable RestStatements = new Variable();
5209 Variable NextLevel = new Variable();
5210 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
5211 {
5212 if (YP.termEqual(HasBreakableBlock, 1))
5213 {
5214 convertIndentationPython(Level);
5215 YP.write(Atom.a(@"for _ in [1]:"));
5216 YP.nl();
5217 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
5218 {
5219 foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5220 {
5221 if (YP.termEqual(HasBreakableBlock, 1))
5222 {
5223 if (YP.greaterThan(Level, 1))
5224 {
5225 convertIndentationPython(Level);
5226 YP.write(Atom.a(@"if doBreak:"));
5227 YP.nl();
5228 convertIndentationPython(NextLevel);
5229 YP.write(Atom.a(@"break"));
5230 YP.nl();
5231 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5232 {
5233 yield return true;
5234 yield break;
5235 }
5236 goto cutIf3;
5237 }
5238 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5239 {
5240 yield return true;
5241 yield break;
5242 }
5243 cutIf3:
5244 goto cutIf2;
5245 }
5246 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5247 {
5248 yield return true;
5249 yield break;
5250 }
5251 cutIf2:
5252 { }
5253 }
5254 }
5255 goto cutIf1;
5256 }
5257 foreach (bool l3 in YP.unify(NextLevel, Level))
5258 {
5259 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5260 {
5261 if (YP.termEqual(HasBreakableBlock, 1))
5262 {
5263 if (YP.greaterThan(Level, 1))
5264 {
5265 convertIndentationPython(Level);
5266 YP.write(Atom.a(@"if doBreak:"));
5267 YP.nl();
5268 convertIndentationPython(NextLevel);
5269 YP.write(Atom.a(@"break"));
5270 YP.nl();
5271 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5272 {
5273 yield return true;
5274 yield break;
5275 }
5276 goto cutIf5;
5277 }
5278 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5279 {
5280 yield return true;
5281 yield break;
5282 }
5283 cutIf5:
5284 goto cutIf4;
5285 }
5286 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5287 {
5288 yield return true;
5289 yield break;
5290 }
5291 cutIf4:
5292 { }
5293 }
5294 }
5295 cutIf1:
5296 { }
5297 }
5298 }
5299 {
5300 object Level = arg2;
5301 object HasBreakableBlock = arg3;
5302 Variable Expression = new Variable();
5303 Variable Body = new Variable();
5304 Variable RestStatements = new Variable();
5305 Variable NextLevel = new Variable();
5306 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
5307 {
5308 convertIndentationPython(Level);
5309 YP.write(Atom.a(@"if "));
5310 convertExpressionPython(Expression);
5311 YP.write(Atom.a(@":"));
5312 YP.nl();
5313 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5314 {
5315 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5316 {
5317 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5318 {
5319 yield return true;
5320 yield break;
5321 }
5322 }
5323 }
5324 }
5325 }
5326 {
5327 object Level = arg2;
5328 object HasBreakableBlock = arg3;
5329 Variable Expression = new Variable();
5330 Variable Body = new Variable();
5331 Variable RestStatements = new Variable();
5332 Variable NextLevel = new Variable();
5333 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
5334 {
5335 convertIndentationPython(Level);
5336 YP.write(Atom.a(@"for l"));
5337 YP.write(Level);
5338 YP.write(Atom.a(@" in "));
5339 convertExpressionPython(Expression);
5340 YP.write(Atom.a(@":"));
5341 YP.nl();
5342 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5343 {
5344 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5345 {
5346 if (YP.termEqual(HasBreakableBlock, 1))
5347 {
5348 convertIndentationPython(Level);
5349 YP.write(Atom.a(@"if doBreak:"));
5350 YP.nl();
5351 convertIndentationPython(NextLevel);
5352 YP.write(Atom.a(@"break"));
5353 YP.nl();
5354 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5355 {
5356 yield return true;
5357 yield break;
5358 }
5359 goto cutIf6;
5360 }
5361 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5362 {
5363 yield return true;
5364 yield break;
5365 }
5366 cutIf6:
5367 { }
5368 }
5369 }
5370 }
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 }
5390 }
5391
5392 public static void convertIndentationPython(object Level)
5393 {
5394 {
5395 Variable N = new Variable();
5396 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
5397 {
5398 repeatWrite(Atom.a(@" "), N);
5399 return;
5400 }
5401 }
5402 }
5403
5404 public static void convertArgListPython(object arg1)
5405 {
5406 {
5407 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5408 {
5409 return;
5410 }
5411 }
5412 {
5413 Variable Head = new Variable();
5414 Variable Tail = new Variable();
5415 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
5416 {
5417 convertExpressionPython(Head);
5418 if (YP.termNotEqual(Tail, Atom.NIL))
5419 {
5420 YP.write(Atom.a(@", "));
5421 convertArgListPython(Tail);
5422 return;
5423 goto cutIf1;
5424 }
5425 convertArgListPython(Tail);
5426 return;
5427 cutIf1:
5428 { }
5429 }
5430 }
5431 }
5432
5433 public static void convertExpressionPython(object arg1)
5434 {
5435 {
5436 Variable X = new Variable();
5437 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
5438 {
5439 YP.write(X);
5440 return;
5441 }
5442 }
5443 {
5444 Variable Name = new Variable();
5445 Variable ArgList = new Variable();
5446 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
5447 {
5448 YP.write(Name);
5449 YP.write(Atom.a(@"("));
5450 convertArgListPython(ArgList);
5451 YP.write(Atom.a(@")"));
5452 return;
5453 }
5454 }
5455 {
5456 Variable Obj = new Variable();
5457 Variable Name = new Variable();
5458 Variable ArgList = new Variable();
5459 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
5460 {
5461 YP.write(Obj);
5462 YP.write(Atom.a(@"."));
5463 YP.write(Name);
5464 YP.write(Atom.a(@"("));
5465 convertArgListPython(ArgList);
5466 YP.write(Atom.a(@")"));
5467 return;
5468 }
5469 }
5470 {
5471 Variable Name = new Variable();
5472 Variable ArgList = new Variable();
5473 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
5474 {
5475 YP.write(Name);
5476 YP.write(Atom.a(@"("));
5477 convertArgListPython(ArgList);
5478 YP.write(Atom.a(@")"));
5479 return;
5480 }
5481 }
5482 {
5483 Variable Name = new Variable();
5484 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
5485 {
5486 YP.write(Name);
5487 return;
5488 }
5489 }
5490 {
5491 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
5492 {
5493 YP.write(Atom.a(@"None"));
5494 return;
5495 }
5496 }
5497 {
5498 Variable X = new Variable();
5499 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
5500 {
5501 YP.write(Atom.a(@"not ("));
5502 convertExpressionPython(X);
5503 YP.write(Atom.a(@")"));
5504 return;
5505 }
5506 }
5507 {
5508 Variable X = new Variable();
5509 Variable Y = new Variable();
5510 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
5511 {
5512 YP.write(Atom.a(@"("));
5513 convertExpressionPython(X);
5514 YP.write(Atom.a(@") and ("));
5515 convertExpressionPython(Y);
5516 YP.write(Atom.a(@")"));
5517 return;
5518 }
5519 }
5520 {
5521 Variable ArgList = new Variable();
5522 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
5523 {
5524 YP.write(Atom.a(@"["));
5525 convertArgListPython(ArgList);
5526 YP.write(Atom.a(@"]"));
5527 return;
5528 }
5529 }
5530 {
5531 Variable X = new Variable();
5532 Variable Codes = new Variable();
5533 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5534 {
5535 if (YP.atom(X))
5536 {
5537 YP.write(Atom.a(@""""));
5538 foreach (bool l4 in YP.atom_codes(X, Codes))
5539 {
5540 convertStringCodesPython(Codes);
5541 YP.write(Atom.a(@""""));
5542 return;
5543 }
5544 }
5545 }
5546 }
5547 {
5548 Variable X = new Variable();
5549 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5550 {
5551 YP.write(X);
5552 return;
5553 }
5554 }
5555 }
5556
5557 public static void convertStringCodesPython(object arg1)
5558 {
5559 {
5560 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5561 {
5562 return;
5563 }
5564 }
5565 {
5566 Variable Code = new Variable();
5567 Variable RestCodes = new Variable();
5568 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
5569 {
5570 if (YP.termEqual(Code, 34))
5571 {
5572 YP.put_code(92);
5573 YP.put_code(Code);
5574 convertStringCodesPython(RestCodes);
5575 return;
5576 goto cutIf1;
5577 }
5578 if (YP.termEqual(Code, 92))
5579 {
5580 YP.put_code(92);
5581 YP.put_code(Code);
5582 convertStringCodesPython(RestCodes);
5583 return;
5584 goto cutIf1;
5585 }
5586 YP.put_code(Code);
5587 convertStringCodesPython(RestCodes);
5588 return;
5589 cutIf1:
5590 { }
5591 }
5592 }
5593 }
5594
5595 public static IEnumerable<bool> member(object X, object arg2)
5596 {
5597 {
5598 Variable x2 = new Variable();
5599 foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2)))
5600 {
5601 yield return false;
5602 }
5603 }
5604 {
5605 Variable x2 = new Variable();
5606 Variable Rest = new Variable();
5607 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest)))
5608 {
5609 foreach (bool l3 in member(X, Rest))
5610 {
5611 yield return false;
5612 }
5613 }
5614 }
5615 }
5616
5617 public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
5618 {
5619 {
5620 Variable List = new Variable();
5621 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5622 {
5623 foreach (bool l3 in YP.unify(arg2, List))
5624 {
5625 foreach (bool l4 in YP.unify(arg3, List))
5626 {
5627 yield return false;
5628 }
5629 }
5630 }
5631 }
5632 {
5633 object List2 = arg2;
5634 Variable X = new Variable();
5635 Variable List1 = new Variable();
5636 Variable List12 = new Variable();
5637 foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
5638 {
5639 foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
5640 {
5641 foreach (bool l4 in append(List1, List2, List12))
5642 {
5643 yield return false;
5644 }
5645 }
5646 }
5647 }
5648 }
5649
5650 }
5651}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs
index cf15b67..f9b160d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs
@@ -29,7 +29,7 @@ using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31 31
32namespace OpenSim.Region.ScriptEngine.XEngine.Script 32namespace OpenSim.Region.ScriptEngine.Shared
33{ 33{
34 [Serializable] 34 [Serializable]
35 public class AssemblyResolver 35 public class AssemblyResolver
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 68fb1dd..2edcee0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -34,8 +34,9 @@ using Microsoft.CSharp;
34using Microsoft.JScript; 34using Microsoft.JScript;
35using Microsoft.VisualBasic; 35using Microsoft.VisualBasic;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.ScriptEngine.Interfaces;
37 38
38namespace OpenSim.Region.ScriptEngine.XEngine 39namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
39{ 40{
40 public class Compiler 41 public class Compiler
41 { 42 {
@@ -78,8 +79,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
78 private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files 79 private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
79 private static UInt64 scriptCompileCounter = 0; // And a counter 80 private static UInt64 scriptCompileCounter = 0; // And a counter
80 81
81 public XEngine m_scriptEngine; 82 public IScriptEngine m_scriptEngine;
82 public Compiler(XEngine scriptEngine) 83 public Compiler(IScriptEngine scriptEngine)
83 { 84 {
84 m_scriptEngine = scriptEngine; 85 m_scriptEngine = scriptEngine;
85 ReadConfig(); 86 ReadConfig();
@@ -89,11 +90,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
89 { 90 {
90 91
91 // Get some config 92 // Get some config
92 WriteScriptSourceToDebugFile = m_scriptEngine.ScriptConfigSource.GetBoolean("WriteScriptSourceToDebugFile", true); 93 WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true);
93 CompileWithDebugInformation = m_scriptEngine.ScriptConfigSource.GetBoolean("CompileWithDebugInformation", true); 94 CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true);
94 95
95 // Get file prefix from scriptengine name and make it file system safe: 96 // Get file prefix from scriptengine name and make it file system safe:
96 FilePrefix = m_scriptEngine.ScriptEngineName; 97 FilePrefix = "CommonCompiler";
97 foreach (char c in Path.GetInvalidFileNameChars()) 98 foreach (char c in Path.GetInvalidFileNameChars())
98 { 99 {
99 FilePrefix = FilePrefix.Replace(c, '_'); 100 FilePrefix = FilePrefix.Replace(c, '_');
@@ -113,11 +114,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
113 LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); 114 LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js);
114 115
115 // Allowed compilers 116 // Allowed compilers
116 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js"); 117 string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js");
117 AllowedCompilers.Clear(); 118 AllowedCompilers.Clear();
118 119
119#if DEBUG 120#if DEBUG
120 m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Allowed languages: " + allowComp); 121 m_scriptEngine.Log.Debug("[Compiler]: Allowed languages: " + allowComp);
121#endif 122#endif
122 123
123 124
@@ -126,26 +127,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine
126 string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); 127 string strlan = strl.Trim(" \t".ToCharArray()).ToLower();
127 if (!LanguageMapping.ContainsKey(strlan)) 128 if (!LanguageMapping.ContainsKey(strlan))
128 { 129 {
129 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); 130 m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
130 } 131 }
131 else 132 else
132 { 133 {
133#if DEBUG 134#if DEBUG
134 //m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); 135 //m_scriptEngine.Log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
135#endif 136#endif
136 } 137 }
137 AllowedCompilers.Add(strlan, true); 138 AllowedCompilers.Add(strlan, true);
138 } 139 }
139 if (AllowedCompilers.Count == 0) 140 if (AllowedCompilers.Count == 0)
140 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!"); 141 m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!");
141 142
142 // Default language 143 // Default language
143 string defaultCompileLanguage = m_scriptEngine.ScriptConfigSource.GetString("DefaultCompileLanguage", "lsl").ToLower(); 144 string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower();
144 145
145 // Is this language recognized at all? 146 // Is this language recognized at all?
146 if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) 147 if (!LanguageMapping.ContainsKey(defaultCompileLanguage))
147 { 148 {
148 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: " + 149 m_scriptEngine.Log.Error("[Compiler]: " +
149 "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\"."); 150 "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\".");
150 defaultCompileLanguage = "lsl"; 151 defaultCompileLanguage = "lsl";
151 } 152 }
@@ -153,13 +154,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
153 // Is this language in allow-list? 154 // Is this language in allow-list?
154 if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) 155 if (!AllowedCompilers.ContainsKey(defaultCompileLanguage))
155 { 156 {
156 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: " + 157 m_scriptEngine.Log.Error("[Compiler]: " +
157 "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!"); 158 "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
158 } 159 }
159 else 160 else
160 { 161 {
161#if DEBUG 162#if DEBUG
162// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: " + 163// m_scriptEngine.Log.Debug("[Compiler]: " +
163// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); 164// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
164#endif 165#endif
165 // LANGUAGE IS IN ALLOW-LIST 166 // LANGUAGE IS IN ALLOW-LIST
@@ -185,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
185 } 186 }
186 catch (Exception ex) 187 catch (Exception ex)
187 { 188 {
188 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString()); 189 m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString());
189 } 190 }
190 } 191 }
191 192
@@ -199,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
199 } 200 }
200 catch (Exception ex) 201 catch (Exception ex)
201 { 202 {
202 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, 203 m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
203 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); 204 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString());
204 } 205 }
205 } 206 }
@@ -207,7 +208,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
207 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, 208 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
208 m_scriptEngine.World.RegionInfo.RegionID.ToString()))) 209 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
209 { 210 {
210 //m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: FILE FOUND: " + file); 211 //m_scriptEngine.Log.Error("[Compiler]: FILE FOUND: " + file);
211 212
212 if (file.ToLower().StartsWith(FilePrefix + "_compiled_") || 213 if (file.ToLower().StartsWith(FilePrefix + "_compiled_") ||
213 file.ToLower().StartsWith(FilePrefix + "_source_")) 214 file.ToLower().StartsWith(FilePrefix + "_source_"))
@@ -218,7 +219,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
218 } 219 }
219 catch (Exception ex) 220 catch (Exception ex)
220 { 221 {
221 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying delete old script file \"" + file + "\": " + ex.ToString()); 222 m_scriptEngine.Log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString());
222 } 223 }
223 224
224 } 225 }
@@ -233,10 +234,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
233 // { 234 // {
234 // case ".txt": 235 // case ".txt":
235 // case ".lsl": 236 // case ".lsl":
236 // Common.ScriptEngineBase.Common.SendToDebug("Source code is LSL, converting to CS"); 237 // Common.ScriptEngineBase.Shared.SendToDebug("Source code is LSL, converting to CS");
237 // return CompileFromLSLText(File.ReadAllText(LSOFileName)); 238 // return CompileFromLSLText(File.ReadAllText(LSOFileName));
238 // case ".cs": 239 // case ".cs":
239 // Common.ScriptEngineBase.Common.SendToDebug("Source code is CS"); 240 // Common.ScriptEngineBase.Shared.SendToDebug("Source code is CS");
240 // return CompileFromCSText(File.ReadAllText(LSOFileName)); 241 // return CompileFromCSText(File.ReadAllText(LSOFileName));
241 // default: 242 // default:
242 // throw new Exception("Unknown script type."); 243 // throw new Exception("Unknown script type.");
@@ -258,7 +259,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
258 259
259 if (File.Exists(OutFile)) 260 if (File.Exists(OutFile))
260 { 261 {
261 m_scriptEngine.Log.DebugFormat("[XEngine] Returning existing assembly for {0}", asset); 262 m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
262 return OutFile; 263 return OutFile;
263 } 264 }
264 265
@@ -359,9 +360,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
359 private static string CreateJSCompilerScript(string compileScript) 360 private static string CreateJSCompilerScript(string compileScript)
360 { 361 {
361 compileScript = String.Empty + 362 compileScript = String.Empty +
362 "import OpenSim.Region.ScriptEngine.XEngine.Script; import System.Collections.Generic;\r\n" + 363 "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" +
363 "package SecondLife {\r\n" + 364 "package SecondLife {\r\n" +
364 "class Script extends OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" + 365 "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
365 compileScript + 366 compileScript +
366 "} }\r\n"; 367 "} }\r\n";
367 return compileScript; 368 return compileScript;
@@ -370,9 +371,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
370 private static string CreateCSCompilerScript(string compileScript) 371 private static string CreateCSCompilerScript(string compileScript)
371 { 372 {
372 compileScript = String.Empty + 373 compileScript = String.Empty +
373 "using OpenSim.Region.ScriptEngine.XEngine.Script; using System.Collections.Generic;\r\n" + 374 "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
374 String.Empty + "namespace SecondLife { " + 375 String.Empty + "namespace SecondLife { " +
375 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" + 376 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
376 @"public Script() { } " + 377 @"public Script() { } " +
377 compileScript + 378 compileScript +
378 "} }\r\n"; 379 "} }\r\n";
@@ -382,9 +383,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
382 private static string CreateVBCompilerScript(string compileScript) 383 private static string CreateVBCompilerScript(string compileScript)
383 { 384 {
384 compileScript = String.Empty + 385 compileScript = String.Empty +
385 "Imports OpenSim.Region.ScriptEngine.XEngine.Script: Imports System.Collections.Generic: " + 386 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
386 String.Empty + "NameSpace SecondLife:" + 387 String.Empty + "NameSpace SecondLife:" +
387 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass: " + 388 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " +
388 "\r\nPublic Sub New()\r\nEnd Sub: " + 389 "\r\nPublic Sub New()\r\nEnd Sub: " +
389 compileScript + 390 compileScript +
390 ":End Class :End Namespace\r\n"; 391 ":End Class :End Namespace\r\n";
@@ -406,7 +407,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
406 m_scriptEngine.World.RegionInfo.RegionID.ToString(), 407 m_scriptEngine.World.RegionInfo.RegionID.ToString(),
407 FilePrefix + "_compiled_" + asset + ".dll")); 408 FilePrefix + "_compiled_" + asset + ".dll"));
408#if DEBUG 409#if DEBUG
409// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Starting compile of \"" + OutFile + "\"."); 410// m_scriptEngine.Log.Debug("[Compiler]: Starting compile of \"" + OutFile + "\".");
410#endif 411#endif
411 try 412 try
412 { 413 {
@@ -414,7 +415,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
414 } 415 }
415 catch (Exception e) // NOTLEGIT - Should be just catching FileIOException 416 catch (Exception e) // NOTLEGIT - Should be just catching FileIOException
416 { 417 {
417 //m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString()); 418 //m_scriptEngine.Log.Error("[Compiler]: Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString());
418 throw new Exception("Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString()); 419 throw new Exception("Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString());
419 } 420 }
420 //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll"); 421 //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll");
@@ -432,7 +433,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
432 } 433 }
433 catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException 434 catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException
434 { 435 {
435 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception while trying to write script source to file \"" + srcFileName + "\": " + ex.ToString()); 436 m_scriptEngine.Log.Error("[Compiler]: Exception while trying to write script source to file \"" + srcFileName + "\": " + ex.ToString());
436 } 437 }
437 } 438 }
438 439
@@ -451,10 +452,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
451 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); 452 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
452 string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location); 453 string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location);
453 //Console.WriteLine("Assembly location: " + rootPath); 454 //Console.WriteLine("Assembly location: " + rootPath);
454 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.XEngine.Script.dll")); 455 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll"));
455// parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.XEngine.dll")); 456 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
456 457
457 //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment");
458 parameters.GenerateExecutable = false; 458 parameters.GenerateExecutable = false;
459 parameters.OutputAssembly = OutFile; 459 parameters.OutputAssembly = OutFile;
460 parameters.IncludeDebugInformation = CompileWithDebugInformation; 460 parameters.IncludeDebugInformation = CompileWithDebugInformation;
@@ -508,7 +508,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
508 errtext += "No compile error. But not able to locate compiled file."; 508 errtext += "No compile error. But not able to locate compiled file.";
509 throw new Exception(errtext); 509 throw new Exception(errtext);
510 } 510 }
511 m_scriptEngine.Log.DebugFormat("[XEngine] Compiled new assembly for {0}", asset); 511 m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly for {0}", asset);
512 return OutFile; 512 return OutFile;
513 } 513 }
514 } 514 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs
index 2dc8547..380686e 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs
@@ -30,7 +30,7 @@ using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text.RegularExpressions; 31using System.Text.RegularExpressions;
32 32
33namespace OpenSim.Region.ScriptEngine.XEngine 33namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
34{ 34{
35 public class LSL2CSConverter 35 public class LSL2CSConverter
36 { 36 {
@@ -355,13 +355,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
355 355
356 //System.Console.WriteLine(Script); 356 //System.Console.WriteLine(Script);
357 Return = String.Empty;// + 357 Return = String.Empty;// +
358 //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; 358 //"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;";
359 359
360 //Return += String.Empty + 360 //Return += String.Empty +
361 // "namespace SecondLife { "; 361 // "namespace SecondLife { ";
362 //Return += String.Empty + 362 //Return += String.Empty +
363 // //"[Serializable] " + 363 // //"[Serializable] " +
364 // "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { "; 364 // "public class Script : OpenSim.Region.ScriptEngine.Shared.LSL_BaseClass { ";
365 //Return += @"public Script() { } "; 365 //Return += @"public Script() { } ";
366 Return += Script; 366 Return += Script;
367 //Return += "} }\r\n"; 367 //Return += "} }\r\n";
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
new file mode 100644
index 0000000..54b4861
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/YP2CSConverter.cs
@@ -0,0 +1,108 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.IO;
31using System.Collections.Generic;
32using System.Text;
33using System.Text.RegularExpressions;
34using OpenSim.Region.ScriptEngine.Shared.YieldProlog;
35
36namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
37{
38 public class YP2CSConverter
39 {
40 public YP2CSConverter()
41 {
42 }
43
44 public string Convert(string Script)
45 {
46 string CS_code = GenCode(Script);
47 return CS_code;
48 }
49
50 static string GenCode(string myCode)
51 {
52 Variable TermList = new Variable();
53 Variable FunctionCode = new Variable();
54
55 string CS_code = "";
56
57 int cs_pointer = myCode.IndexOf("\n//cs");
58 if (cs_pointer > 0)
59 {
60 CS_code = myCode.Substring(cs_pointer); // CS code comes after
61 myCode = myCode.Substring(0, cs_pointer);
62 }
63 myCode.Replace("//yp", "%YPCode");
64
65 StringWriter myCS_SW = new StringWriter();
66 StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n");
67
68 YP.see(myCode_SR);
69 YP.tell(myCS_SW);
70
71 //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n");
72 foreach (bool l1 in Parser.parseInput(TermList))
73 {
74 foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode))
75 {
76 ListPair VFC = new ListPair(FunctionCode, new Variable());
77 //Console.WriteLine("-------------------------")
78 //Console.WriteLine(FunctionCode.ToString())
79 //Console.WriteLine("-------------------------")
80 YPCompiler.convertFunctionCSharp(FunctionCode);
81 //YPCompiler.convertStringCodesCSharp(VFC);
82 }
83 }
84 YP.seen();
85 myCS_SW.Close();
86 YP.told();
87 StringBuilder bu = myCS_SW.GetStringBuilder();
88 string finalcode = "//YPEncoded\n" + bu.ToString();
89 // FIX script events (we're in the same script)
90 // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit('
91 finalcode = Regex.Replace(finalcode,
92 @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,",
93 @"this.$1(",
94 RegexOptions.Compiled | RegexOptions.Singleline);
95 finalcode = Regex.Replace(finalcode,
96 @" static ",
97 @" ",
98 RegexOptions.Compiled | RegexOptions.Singleline);
99
100 finalcode = CS_code+"\n\r"+ finalcode;
101 finalcode = Regex.Replace(finalcode,
102 @"PrologCallback",
103 @"public IEnumerable<bool> ",
104 RegexOptions.Compiled | RegexOptions.Singleline);
105 return finalcode;
106 }
107 }
108}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
new file mode 100644
index 0000000..8e312c5
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -0,0 +1,121 @@
1using System;
2using System.IO;
3using System.Threading;
4using System.Collections;
5using System.Collections.Generic;
6using libsecondlife;
7using OpenSim.Framework;
8using OpenSim.Region.Environment;
9using OpenSim.Region.Environment.Scenes;
10
11namespace OpenSim.Region.ScriptEngine.Shared
12{
13 public class DetectParams
14 {
15 public DetectParams()
16 {
17 Key = LLUUID.Zero;
18 OffsetPos = new LSL_Types.Vector3();
19 LinkNum = 0;
20 Group = LLUUID.Zero;
21 Name = String.Empty;
22 Owner = LLUUID.Zero;
23 Position = new LSL_Types.Vector3();
24 Rotation = new LSL_Types.Quaternion();
25 Type = 0;
26 Velocity = new LSL_Types.Vector3();
27 }
28
29 public LLUUID Key;
30 public LSL_Types.Vector3 OffsetPos;
31 public int LinkNum;
32 public LLUUID Group;
33 public string Name;
34 public LLUUID Owner;
35 public LSL_Types.Vector3 Position;
36 public LSL_Types.Quaternion Rotation;
37 public int Type;
38 public LSL_Types.Vector3 Velocity;
39
40 public void Populate(Scene scene)
41 {
42 SceneObjectPart part = scene.GetSceneObjectPart(Key);
43 if (part == null) // Avatar, maybe?
44 {
45 ScenePresence presence = scene.GetScenePresence(Key);
46 if (presence == null)
47 return;
48
49 Name = presence.Firstname + " " + presence.Lastname;
50 Owner = Key;
51 Position = new LSL_Types.Vector3(
52 presence.AbsolutePosition.X,
53 presence.AbsolutePosition.X,
54 presence.AbsolutePosition.Z);
55 Rotation = new LSL_Types.Quaternion(
56 presence.Rotation.x,
57 presence.Rotation.y,
58 presence.Rotation.z,
59 presence.Rotation.w);
60 Velocity = new LSL_Types.Vector3(
61 presence.Velocity.X,
62 presence.Velocity.X,
63 presence.Velocity.Z);
64
65 Type = 0x01; // Avatar
66 if (presence.Velocity != LLVector3.Zero)
67 Type |= 0x02; // Active
68
69 Group = presence.ControllingClient.ActiveGroupId;
70
71 return;
72 }
73
74 part=part.ParentGroup.RootPart; // We detect objects only
75
76 LinkNum = 0; // Not relevant
77
78 Group = part.GroupID;
79 Name = part.Name;
80 Owner = part.OwnerID;
81 if (part.Velocity == LLVector3.Zero)
82 Type = 0x04; // Passive
83 else
84 Type = 0x02; // Passive
85
86 foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
87 {
88 if (p.ContainsScripts())
89 {
90 Type |= 0x08; // Scripted
91 break;
92 }
93 }
94
95 Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
96 part.AbsolutePosition.Y,
97 part.AbsolutePosition.Z);
98
99 LLQuaternion wr = part.GetWorldRotation();
100 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
101
102 Velocity = new LSL_Types.Vector3(part.Velocity.X,
103 part.Velocity.Y,
104 part.Velocity.Z);
105 }
106 }
107
108 public class EventParams
109 {
110 public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams)
111 {
112 EventName=eventName;
113 Params=eventParams;
114 DetectParams=detectParams;
115 }
116
117 public string EventName;
118 public Object[] Params;
119 public DetectParams[] DetectParams;
120 }
121}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 8bd3d73..6b080a0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Text.RegularExpressions; 30using System.Text.RegularExpressions;
31 31
32namespace OpenSim.Region.ScriptEngine.XEngine.Script 32namespace OpenSim.Region.ScriptEngine.Shared
33{ 33{
34 [Serializable] 34 [Serializable]
35 public partial class LSL_Types 35 public partial class LSL_Types
@@ -1474,6 +1474,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1474 return f1.value != f2.value; 1474 return f1.value != f2.value;
1475 } 1475 }
1476 1476
1477 public override bool Equals(Object o)
1478 {
1479 if(!(o is LSLFloat))
1480 return false;
1481
1482 return value == ((LSLFloat)o).value;
1483 }
1484
1485 public override int GetHashCode()
1486 {
1487 return (int)value;
1488 }
1489
1477 static public LSLFloat operator ++(LSLFloat f) 1490 static public LSLFloat operator ++(LSLFloat f)
1478 { 1491 {
1479 f.value++; 1492 f.value++;
@@ -1491,12 +1504,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1491 return f.value; 1504 return f.value;
1492 } 1505 }
1493 1506
1494 static public explicit operator LSLString(LSLFloat f)
1495 {
1496 string v = String.Format("{0:0.000000}", f.value);
1497 return new LSLString(v);
1498 }
1499
1500 #endregion 1507 #endregion
1501 1508
1502 #region Overriders 1509 #region Overriders
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index c226a7e..8bfef79 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -33,7 +33,8 @@ using OpenSim.Framework;
33using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; 33using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.ScriptEngine.XEngine.Script; 36using OpenSim.Region.ScriptEngine.Shared;
37using OpenSim.Region.ScriptEngine.Interfaces;
37using Axiom.Math; 38using Axiom.Math;
38 39
39namespace OpenSim.Region.ScriptEngine.XEngine 40namespace OpenSim.Region.ScriptEngine.XEngine
@@ -83,8 +84,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
83 IClientAPI remoteClient) 84 IClientAPI remoteClient)
84 { 85 {
85 // Add to queue for all scripts in ObjectID object 86 // Add to queue for all scripts in ObjectID object
86 XDetectParams[] det = new XDetectParams[1]; 87 DetectParams[] det = new DetectParams[1];
87 det[0] = new XDetectParams(); 88 det[0] = new DetectParams();
88 det[0].Key = remoteClient.AgentId; 89 det[0].Key = remoteClient.AgentId;
89 det[0].Populate(myScriptEngine.World); 90 det[0].Populate(myScriptEngine.World);
90 91
@@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
97 if (part.ParentGroup.Children.Count > 0) 98 if (part.ParentGroup.Children.Count > 0)
98 det[0].LinkNum = part.LinkNum + 1; 99 det[0].LinkNum = part.LinkNum + 1;
99 100
100 myScriptEngine.PostObjectEvent(localID, new XEventParams( 101 myScriptEngine.PostObjectEvent(localID, new EventParams(
101 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, 102 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
102 det)); 103 det));
103 } 104 }
@@ -106,8 +107,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
106 IClientAPI remoteClient) 107 IClientAPI remoteClient)
107 { 108 {
108 // Add to queue for all scripts in ObjectID object 109 // Add to queue for all scripts in ObjectID object
109 XDetectParams[] det = new XDetectParams[1]; 110 DetectParams[] det = new DetectParams[1];
110 det[0] = new XDetectParams(); 111 det[0] = new DetectParams();
111 det[0].Key = remoteClient.AgentId; 112 det[0].Key = remoteClient.AgentId;
112 det[0].Populate(myScriptEngine.World); 113 det[0].Populate(myScriptEngine.World);
113 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, 114 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
@@ -123,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
123 if (part.ParentGroup.Children.Count > 0) 124 if (part.ParentGroup.Children.Count > 0)
124 det[0].LinkNum = part.LinkNum + 1; 125 det[0].LinkNum = part.LinkNum + 1;
125 126
126 myScriptEngine.PostObjectEvent(localID, new XEventParams( 127 myScriptEngine.PostObjectEvent(localID, new EventParams(
127 "touch", new Object[] { new LSL_Types.LSLInteger(1) }, 128 "touch", new Object[] { new LSL_Types.LSLInteger(1) },
128 det)); 129 det));
129 } 130 }
@@ -131,8 +132,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
131 public void touch_end(uint localID, IClientAPI remoteClient) 132 public void touch_end(uint localID, IClientAPI remoteClient)
132 { 133 {
133 // Add to queue for all scripts in ObjectID object 134 // Add to queue for all scripts in ObjectID object
134 XDetectParams[] det = new XDetectParams[1]; 135 DetectParams[] det = new DetectParams[1];
135 det[0] = new XDetectParams(); 136 det[0] = new DetectParams();
136 det[0].Key = remoteClient.AgentId; 137 det[0].Key = remoteClient.AgentId;
137 det[0].Populate(myScriptEngine.World); 138 det[0].Populate(myScriptEngine.World);
138 139
@@ -145,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
145 if (part.ParentGroup.Children.Count > 0) 146 if (part.ParentGroup.Children.Count > 0)
146 det[0].LinkNum = part.LinkNum + 1; 147 det[0].LinkNum = part.LinkNum + 1;
147 148
148 myScriptEngine.PostObjectEvent(localID, new XEventParams( 149 myScriptEngine.PostObjectEvent(localID, new EventParams(
149 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, 150 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
150 det)); 151 det));
151 } 152 }
@@ -153,9 +154,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
153 public void changed(uint localID, uint change) 154 public void changed(uint localID, uint change)
154 { 155 {
155 // Add to queue for all scripts in localID, Object pass change. 156 // Add to queue for all scripts in localID, Object pass change.
156 myScriptEngine.PostObjectEvent(localID, new XEventParams( 157 myScriptEngine.PostObjectEvent(localID, new EventParams(
157 "changed",new object[] { new LSL_Types.LSLInteger(change) }, 158 "changed",new object[] { new LSL_Types.LSLInteger(change) },
158 new XDetectParams[0])); 159 new DetectParams[0]));
159 } 160 }
160 161
161 // state_entry: not processed here 162 // state_entry: not processed here
@@ -163,27 +164,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
163 164
164 public void money(uint localID, LLUUID agentID, int amount) 165 public void money(uint localID, LLUUID agentID, int amount)
165 { 166 {
166 myScriptEngine.PostObjectEvent(localID, new XEventParams( 167 myScriptEngine.PostObjectEvent(localID, new EventParams(
167 "money", new object[] { 168 "money", new object[] {
168 new LSL_Types.LSLString(agentID.ToString()), 169 new LSL_Types.LSLString(agentID.ToString()),
169 new LSL_Types.LSLInteger(amount) }, 170 new LSL_Types.LSLInteger(amount) },
170 new XDetectParams[0])); 171 new DetectParams[0]));
171 } 172 }
172 173
173 public void collision_start(uint localID, ColliderArgs col) 174 public void collision_start(uint localID, ColliderArgs col)
174 { 175 {
175 // Add to queue for all scripts in ObjectID object 176 // Add to queue for all scripts in ObjectID object
176 List<XDetectParams> det = new List<XDetectParams>(); 177 List<DetectParams> det = new List<DetectParams>();
177 178
178 foreach (DetectedObject detobj in col.Colliders) 179 foreach (DetectedObject detobj in col.Colliders)
179 { 180 {
180 XDetectParams d = new XDetectParams(); 181 DetectParams d = new DetectParams();
181 d.Key =detobj.keyUUID; 182 d.Key =detobj.keyUUID;
182 d.Populate(myScriptEngine.World); 183 d.Populate(myScriptEngine.World);
183 det.Add(d); 184 det.Add(d);
184 } 185 }
185 186
186 myScriptEngine.PostObjectEvent(localID, new XEventParams( 187 myScriptEngine.PostObjectEvent(localID, new EventParams(
187 "collision_start", 188 "collision_start",
188 new Object[] { new LSL_Types.LSLInteger(1) }, 189 new Object[] { new LSL_Types.LSLInteger(1) },
189 det.ToArray())); 190 det.ToArray()));
@@ -192,17 +193,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
192 public void collision(uint localID, ColliderArgs col) 193 public void collision(uint localID, ColliderArgs col)
193 { 194 {
194 // Add to queue for all scripts in ObjectID object 195 // Add to queue for all scripts in ObjectID object
195 List<XDetectParams> det = new List<XDetectParams>(); 196 List<DetectParams> det = new List<DetectParams>();
196 197
197 foreach (DetectedObject detobj in col.Colliders) 198 foreach (DetectedObject detobj in col.Colliders)
198 { 199 {
199 XDetectParams d = new XDetectParams(); 200 DetectParams d = new DetectParams();
200 d.Key =detobj.keyUUID; 201 d.Key =detobj.keyUUID;
201 d.Populate(myScriptEngine.World); 202 d.Populate(myScriptEngine.World);
202 det.Add(d); 203 det.Add(d);
203 } 204 }
204 205
205 myScriptEngine.PostObjectEvent(localID, new XEventParams( 206 myScriptEngine.PostObjectEvent(localID, new EventParams(
206 "collision", new Object[] { new LSL_Types.LSLInteger(1) }, 207 "collision", new Object[] { new LSL_Types.LSLInteger(1) },
207 det.ToArray())); 208 det.ToArray()));
208 } 209 }
@@ -210,17 +211,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
210 public void collision_end(uint localID, ColliderArgs col) 211 public void collision_end(uint localID, ColliderArgs col)
211 { 212 {
212 // Add to queue for all scripts in ObjectID object 213 // Add to queue for all scripts in ObjectID object
213 List<XDetectParams> det = new List<XDetectParams>(); 214 List<DetectParams> det = new List<DetectParams>();
214 215
215 foreach (DetectedObject detobj in col.Colliders) 216 foreach (DetectedObject detobj in col.Colliders)
216 { 217 {
217 XDetectParams d = new XDetectParams(); 218 DetectParams d = new DetectParams();
218 d.Key =detobj.keyUUID; 219 d.Key =detobj.keyUUID;
219 d.Populate(myScriptEngine.World); 220 d.Populate(myScriptEngine.World);
220 det.Add(d); 221 det.Add(d);
221 } 222 }
222 223
223 myScriptEngine.PostObjectEvent(localID, new XEventParams( 224 myScriptEngine.PostObjectEvent(localID, new EventParams(
224 "collision_end", 225 "collision_end",
225 new Object[] { new LSL_Types.LSLInteger(1) }, 226 new Object[] { new LSL_Types.LSLInteger(1) },
226 det.ToArray())); 227 det.ToArray()));
@@ -228,26 +229,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine
228 229
229 public void land_collision_start(uint localID, LLUUID itemID) 230 public void land_collision_start(uint localID, LLUUID itemID)
230 { 231 {
231 myScriptEngine.PostObjectEvent(localID, new XEventParams( 232 myScriptEngine.PostObjectEvent(localID, new EventParams(
232 "land_collision_start", 233 "land_collision_start",
233 new object[0], 234 new object[0],
234 new XDetectParams[0])); 235 new DetectParams[0]));
235 } 236 }
236 237
237 public void land_collision(uint localID, LLUUID itemID) 238 public void land_collision(uint localID, LLUUID itemID)
238 { 239 {
239 myScriptEngine.PostObjectEvent(localID, new XEventParams( 240 myScriptEngine.PostObjectEvent(localID, new EventParams(
240 "land_collision", 241 "land_collision",
241 new object[0], 242 new object[0],
242 new XDetectParams[0])); 243 new DetectParams[0]));
243 } 244 }
244 245
245 public void land_collision_end(uint localID, LLUUID itemID) 246 public void land_collision_end(uint localID, LLUUID itemID)
246 { 247 {
247 myScriptEngine.PostObjectEvent(localID, new XEventParams( 248 myScriptEngine.PostObjectEvent(localID, new EventParams(
248 "land_collision_end", 249 "land_collision_end",
249 new object[0], 250 new object[0],
250 new XDetectParams[0])); 251 new DetectParams[0]));
251 } 252 }
252 253
253 // timer: not handled here 254 // timer: not handled here
@@ -255,75 +256,75 @@ namespace OpenSim.Region.ScriptEngine.XEngine
255 256
256 public void on_rez(uint localID, LLUUID itemID, int startParam) 257 public void on_rez(uint localID, LLUUID itemID, int startParam)
257 { 258 {
258 myScriptEngine.PostObjectEvent(localID, new XEventParams( 259 myScriptEngine.PostObjectEvent(localID, new EventParams(
259 "on_rez",new object[] { 260 "on_rez",new object[] {
260 new LSL_Types.LSLInteger(startParam)}, 261 new LSL_Types.LSLInteger(startParam)},
261 new XDetectParams[0])); 262 new DetectParams[0]));
262 } 263 }
263 264
264 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) 265 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change)
265 { 266 {
266 myScriptEngine.PostObjectEvent(localID, new XEventParams( 267 myScriptEngine.PostObjectEvent(localID, new EventParams(
267 "control",new object[] { 268 "control",new object[] {
268 new LSL_Types.LSLString(agentID.ToString()), 269 new LSL_Types.LSLString(agentID.ToString()),
269 new LSL_Types.LSLInteger(held), 270 new LSL_Types.LSLInteger(held),
270 new LSL_Types.LSLInteger(change)}, 271 new LSL_Types.LSLInteger(change)},
271 new XDetectParams[0])); 272 new DetectParams[0]));
272 } 273 }
273 274
274 public void email(uint localID, LLUUID itemID, string timeSent, 275 public void email(uint localID, LLUUID itemID, string timeSent,
275 string address, string subject, string message, int numLeft) 276 string address, string subject, string message, int numLeft)
276 { 277 {
277 myScriptEngine.PostObjectEvent(localID, new XEventParams( 278 myScriptEngine.PostObjectEvent(localID, new EventParams(
278 "email",new object[] { 279 "email",new object[] {
279 new LSL_Types.LSLString(timeSent), 280 new LSL_Types.LSLString(timeSent),
280 new LSL_Types.LSLString(address), 281 new LSL_Types.LSLString(address),
281 new LSL_Types.LSLString(subject), 282 new LSL_Types.LSLString(subject),
282 new LSL_Types.LSLString(message), 283 new LSL_Types.LSLString(message),
283 new LSL_Types.LSLInteger(numLeft)}, 284 new LSL_Types.LSLInteger(numLeft)},
284 new XDetectParams[0])); 285 new DetectParams[0]));
285 } 286 }
286 287
287 public void at_target(uint localID, uint handle, LLVector3 targetpos, 288 public void at_target(uint localID, uint handle, LLVector3 targetpos,
288 LLVector3 atpos) 289 LLVector3 atpos)
289 { 290 {
290 myScriptEngine.PostObjectEvent(localID, new XEventParams( 291 myScriptEngine.PostObjectEvent(localID, new EventParams(
291 "at_target", new object[] { 292 "at_target", new object[] {
292 new LSL_Types.LSLInteger(handle), 293 new LSL_Types.LSLInteger(handle),
293 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), 294 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
294 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, 295 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
295 new XDetectParams[0])); 296 new DetectParams[0]));
296 } 297 }
297 298
298 public void not_at_target(uint localID) 299 public void not_at_target(uint localID)
299 { 300 {
300 myScriptEngine.PostObjectEvent(localID, new XEventParams( 301 myScriptEngine.PostObjectEvent(localID, new EventParams(
301 "not_at_target",new object[0], 302 "not_at_target",new object[0],
302 new XDetectParams[0])); 303 new DetectParams[0]));
303 } 304 }
304 305
305 public void at_rot_target(uint localID, LLUUID itemID) 306 public void at_rot_target(uint localID, LLUUID itemID)
306 { 307 {
307 myScriptEngine.PostObjectEvent(localID, new XEventParams( 308 myScriptEngine.PostObjectEvent(localID, new EventParams(
308 "at_rot_target",new object[0], 309 "at_rot_target",new object[0],
309 new XDetectParams[0])); 310 new DetectParams[0]));
310 } 311 }
311 312
312 public void not_at_rot_target(uint localID, LLUUID itemID) 313 public void not_at_rot_target(uint localID, LLUUID itemID)
313 { 314 {
314 myScriptEngine.PostObjectEvent(localID, new XEventParams( 315 myScriptEngine.PostObjectEvent(localID, new EventParams(
315 "not_at_rot_target",new object[0], 316 "not_at_rot_target",new object[0],
316 new XDetectParams[0])); 317 new DetectParams[0]));
317 } 318 }
318 319
319 // run_time_permissions: not handled here 320 // run_time_permissions: not handled here
320 321
321 public void attach(uint localID, LLUUID itemID, LLUUID avatar) 322 public void attach(uint localID, LLUUID itemID, LLUUID avatar)
322 { 323 {
323 myScriptEngine.PostObjectEvent(localID, new XEventParams( 324 myScriptEngine.PostObjectEvent(localID, new EventParams(
324 "attach",new object[] { 325 "attach",new object[] {
325 new LSL_Types.LSLString(avatar.ToString()) }, 326 new LSL_Types.LSLString(avatar.ToString()) },
326 new XDetectParams[0])); 327 new DetectParams[0]));
327 } 328 }
328 329
329 // dataserver: not handled here 330 // dataserver: not handled here
@@ -331,16 +332,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
331 332
332 public void moving_start(uint localID, LLUUID itemID) 333 public void moving_start(uint localID, LLUUID itemID)
333 { 334 {
334 myScriptEngine.PostObjectEvent(localID, new XEventParams( 335 myScriptEngine.PostObjectEvent(localID, new EventParams(
335 "moving_start",new object[0], 336 "moving_start",new object[0],
336 new XDetectParams[0])); 337 new DetectParams[0]));
337 } 338 }
338 339
339 public void moving_end(uint localID, LLUUID itemID) 340 public void moving_end(uint localID, LLUUID itemID)
340 { 341 {
341 myScriptEngine.PostObjectEvent(localID, new XEventParams( 342 myScriptEngine.PostObjectEvent(localID, new EventParams(
342 "moving_end",new object[0], 343 "moving_end",new object[0],
343 new XDetectParams[0])); 344 new DetectParams[0]));
344 } 345 }
345 346
346 // object_rez: not handled here 347 // object_rez: not handled here
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
index 29336ac..e12f2bf 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
@@ -28,7 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
32 33
33namespace OpenSim.Region.ScriptEngine.XEngine 34namespace OpenSim.Region.ScriptEngine.XEngine
34{ 35{
@@ -44,15 +45,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
44 } 45 }
45 46
46 47
47 protected override scriptEvents DoGetStateEventFlags() 48 protected override scriptEvents DoGetStateEventFlags(string state)
48 { 49 {
49 //Console.WriteLine("Get event flags for " + m_Script.State); 50 //Console.WriteLine("Get event flags for " + state);
50 51
51 // Check to see if we've already computed the flags for this state 52 // Check to see if we've already computed the flags for this state
52 scriptEvents eventFlags = scriptEvents.None; 53 scriptEvents eventFlags = scriptEvents.None;
53 if (m_stateEvents.ContainsKey(m_Script.State)) 54 if (m_stateEvents.ContainsKey(state))
54 { 55 {
55 m_stateEvents.TryGetValue(m_Script.State, out eventFlags); 56 m_stateEvents.TryGetValue(state, out eventFlags);
56 return eventFlags; 57 return eventFlags;
57 } 58 }
58 59
@@ -61,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
61 // Fill in the events for this state, cache the results in the map 62 // Fill in the events for this state, cache the results in the map
62 foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap) 63 foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap)
63 { 64 {
64 string evname = m_Script.State + "_event_" + kvp.Key; 65 string evname = state + "_event_" + kvp.Key;
65 //Console.WriteLine("Trying event "+evname); 66 //Console.WriteLine("Trying event "+evname);
66 try 67 try
67 { 68 {
@@ -80,18 +81,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
80 81
81 // Save the flags we just computed and return the result 82 // Save the flags we just computed and return the result
82 if (eventFlags != 0) 83 if (eventFlags != 0)
83 m_stateEvents.Add(m_Script.State, eventFlags); 84 m_stateEvents.Add(state, eventFlags);
84 85
85 //Console.WriteLine("Returning {0:x}", eventFlags); 86 //Console.WriteLine("Returning {0:x}", eventFlags);
86 return (eventFlags); 87 return (eventFlags);
87 } 88 }
88 89
89 protected override void DoExecuteEvent(string FunctionName, object[] args) 90 protected override void DoExecuteEvent(string state, string FunctionName, object[] args)
90 { 91 {
91 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 92 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
92 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! 93 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
93 94
94 string EventName = m_Script.State + "_event_" + FunctionName; 95 string EventName = state + "_event_" + FunctionName;
95 96
96//#if DEBUG 97//#if DEBUG
97// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); 98// Console.WriteLine("ScriptEngine: Script event function name: " + EventName);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
index 3775372..799005c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
@@ -28,7 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
33using OpenSim.Region.ScriptEngine.Interfaces;
32 34
33namespace OpenSim.Region.ScriptEngine.XEngine 35namespace OpenSim.Region.ScriptEngine.XEngine
34{ 36{
@@ -117,23 +119,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
117 /// </summary> 119 /// </summary>
118 /// <param name="FunctionName">Name of function to execute</param> 120 /// <param name="FunctionName">Name of function to execute</param>
119 /// <param name="args">Arguments to pass to function</param> 121 /// <param name="args">Arguments to pass to function</param>
120 public void ExecuteEvent(string FunctionName, object[] args) 122 public void ExecuteEvent(string state, string FunctionName, object[] args)
121 { 123 {
122 DoExecuteEvent(FunctionName, args); 124 DoExecuteEvent(state, FunctionName, args);
123 } 125 }
124 126
125 protected abstract void DoExecuteEvent(string FunctionName, object[] args); 127 protected abstract void DoExecuteEvent(string state, string FunctionName, object[] args);
126 128
127 /// <summary> 129 /// <summary>
128 /// Compute the events handled by the current state of the script 130 /// Compute the events handled by the current state of the script
129 /// </summary> 131 /// </summary>
130 /// <returns>state mask</returns> 132 /// <returns>state mask</returns>
131 public scriptEvents GetStateEventFlags() 133 public scriptEvents GetStateEventFlags(string state)
132 { 134 {
133 return DoGetStateEventFlags(); 135 return DoGetStateEventFlags(state);
134 } 136 }
135 137
136 protected abstract scriptEvents DoGetStateEventFlags(); 138 protected abstract scriptEvents DoGetStateEventFlags(string state);
137 139
138 protected void initEventFlags() 140 protected void initEventFlags()
139 { 141 {
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 0b0ff3d..709e3ee 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -14,11 +14,15 @@ using OpenSim.Framework;
14using OpenSim.Region.Environment; 14using OpenSim.Region.Environment;
15using OpenSim.Region.Environment.Scenes; 15using OpenSim.Region.Environment.Scenes;
16using OpenSim.Region.Environment.Interfaces; 16using OpenSim.Region.Environment.Interfaces;
17using OpenSim.Region.ScriptEngine.XEngine.Script; 17using OpenSim.Region.ScriptEngine.Shared;
18using OpenSim.Region.ScriptEngine.Shared.Api;
19using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
20using OpenSim.Region.ScriptEngine.Shared.CodeTools;
21using OpenSim.Region.ScriptEngine.Interfaces;
18 22
19namespace OpenSim.Region.ScriptEngine.XEngine 23namespace OpenSim.Region.ScriptEngine.XEngine
20{ 24{
21 public class XEngine : IRegionModule 25 public class XEngine : IRegionModule, IScriptEngine
22 { 26 {
23 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 27 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
24 28
@@ -30,10 +34,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
30 private EventManager m_EventManager; 34 private EventManager m_EventManager;
31 private int m_EventLimit; 35 private int m_EventLimit;
32 private bool m_KillTimedOutScripts; 36 private bool m_KillTimedOutScripts;
37 public AsyncCommandManager m_AsyncCommands;
33 38
34 private static List<XEngine> m_ScriptEngines = 39 private static List<XEngine> m_ScriptEngines =
35 new List<XEngine>(); 40 new List<XEngine>();
36 public AsyncCommandManager m_ASYNCLSLCommandManager;
37 41
38 // Maps the local id to the script inventory items in it 42 // Maps the local id to the script inventory items in it
39 43
@@ -87,11 +91,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
87 string Script; 91 string Script;
88 } 92 }
89 93
90 public IConfig ScriptConfigSource 94 public IConfig Config
91 { 95 {
92 get { return m_ScriptConfig; } 96 get { return m_ScriptConfig; }
93 } 97 }
94 98
99 public Object AsyncCommands
100 {
101 get { return (Object)m_AsyncCommands; }
102 }
103
95 // 104 //
96 // IRegionModule functions 105 // IRegionModule functions
97 // 106 //
@@ -155,7 +164,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
155 } 164 }
156 165
157 m_EventManager = new EventManager(this); 166 m_EventManager = new EventManager(this);
158 m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
159 167
160 StartEngine(minThreads, maxThreads, idleTimeout, prio, 168 StartEngine(minThreads, maxThreads, idleTimeout, prio,
161 maxScriptQueue, stackSize); 169 maxScriptQueue, stackSize);
@@ -166,6 +174,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
166 m_Scene.EventManager.OnRemoveScript += OnRemoveScript; 174 m_Scene.EventManager.OnRemoveScript += OnRemoveScript;
167 m_Scene.EventManager.OnScriptReset += OnScriptReset; 175 m_Scene.EventManager.OnScriptReset += OnScriptReset;
168 176
177 m_AsyncCommands = new AsyncCommandManager(this);
178
169 if (sleepTime > 0) 179 if (sleepTime > 0)
170 { 180 {
171 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 181 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
@@ -418,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
418 if (!m_Scripts.ContainsKey(itemID)) 428 if (!m_Scripts.ContainsKey(itemID))
419 return; 429 return;
420 430
421 m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); 431 m_AsyncCommands.RemoveScript(localID, itemID);
422 432
423 XScriptInstance instance=m_Scripts[itemID]; 433 XScriptInstance instance=m_Scripts[itemID];
424 m_Scripts.Remove(itemID); 434 m_Scripts.Remove(itemID);
@@ -552,7 +562,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
552 // 562 //
553 // Post event to an entire prim 563 // Post event to an entire prim
554 // 564 //
555 public bool PostObjectEvent(uint localID, XEventParams p) 565 public bool PostObjectEvent(uint localID, EventParams p)
556 { 566 {
557 bool result = false; 567 bool result = false;
558 568
@@ -577,7 +587,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
577 // 587 //
578 // Post an event to a single script 588 // Post an event to a single script
579 // 589 //
580 public bool PostScriptEvent(LLUUID itemID, XEventParams p) 590 public bool PostScriptEvent(LLUUID itemID, EventParams p)
581 { 591 {
582 if (m_Scripts.ContainsKey(itemID)) 592 if (m_Scripts.ContainsKey(itemID))
583 { 593 {
@@ -654,7 +664,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
654 instance.ResetScript(); 664 instance.ResetScript();
655 } 665 }
656 666
657 public XDetectParams GetDetectParams(LLUUID itemID, int idx) 667 public DetectParams GetDetectParams(LLUUID itemID, int idx)
658 { 668 {
659 XScriptInstance instance = GetInstance(itemID); 669 XScriptInstance instance = GetInstance(itemID);
660 if (instance != null) 670 if (instance != null)
@@ -669,115 +679,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
669 return instance.GetDetectID(idx); 679 return instance.GetDetectID(idx);
670 return LLUUID.Zero; 680 return LLUUID.Zero;
671 } 681 }
672 }
673
674 public class XDetectParams
675 {
676 public XDetectParams()
677 {
678 Key = LLUUID.Zero;
679 OffsetPos = new LSL_Types.Vector3();
680 LinkNum = 0;
681 Group = LLUUID.Zero;
682 Name = String.Empty;
683 Owner = LLUUID.Zero;
684 Position = new LSL_Types.Vector3();
685 Rotation = new LSL_Types.Quaternion();
686 Type = 0;
687 Velocity = new LSL_Types.Vector3();
688 }
689
690 public LLUUID Key;
691 public LSL_Types.Vector3 OffsetPos;
692 public int LinkNum;
693 public LLUUID Group;
694 public string Name;
695 public LLUUID Owner;
696 public LSL_Types.Vector3 Position;
697 public LSL_Types.Quaternion Rotation;
698 public int Type;
699 public LSL_Types.Vector3 Velocity;
700
701 public void Populate(Scene scene)
702 {
703 SceneObjectPart part = scene.GetSceneObjectPart(Key);
704 if (part == null) // Avatar, maybe?
705 {
706 ScenePresence presence = scene.GetScenePresence(Key);
707 if (presence == null)
708 return;
709
710 Name = presence.Firstname + " " + presence.Lastname;
711 Owner = Key;
712 Position = new LSL_Types.Vector3(
713 presence.AbsolutePosition.X,
714 presence.AbsolutePosition.X,
715 presence.AbsolutePosition.Z);
716 Rotation = new LSL_Types.Quaternion(
717 presence.Rotation.x,
718 presence.Rotation.y,
719 presence.Rotation.z,
720 presence.Rotation.w);
721 Velocity = new LSL_Types.Vector3(
722 presence.Velocity.X,
723 presence.Velocity.X,
724 presence.Velocity.Z);
725
726 Type = 0x01; // Avatar
727 if (presence.Velocity != LLVector3.Zero)
728 Type |= 0x02; // Active
729
730 Group = presence.ControllingClient.ActiveGroupId;
731 682
683 public void SetState(LLUUID itemID, string newState)
684 {
685 XScriptInstance instance = GetInstance(itemID);
686 if (instance == null)
732 return; 687 return;
733 } 688 instance.SetState(newState);
734
735 part=part.ParentGroup.RootPart; // We detect objects only
736
737 LinkNum = 0; // Not relevant
738
739 Group = part.GroupID;
740 Name = part.Name;
741 Owner = part.OwnerID;
742 if (part.Velocity == LLVector3.Zero)
743 Type = 0x04; // Passive
744 else
745 Type = 0x02; // Passive
746
747 foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
748 {
749 if (part.ContainsScripts())
750 {
751 Type |= 0x08; // Scripted
752 break;
753 }
754 }
755
756 Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
757 part.AbsolutePosition.Y,
758 part.AbsolutePosition.Z);
759
760 LLQuaternion wr = part.GetWorldRotation();
761 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
762
763 Velocity = new LSL_Types.Vector3(part.Velocity.X,
764 part.Velocity.Y,
765 part.Velocity.Z);
766 } 689 }
767 } 690 public string GetState(LLUUID itemID)
768
769 public class XEventParams
770 {
771 public XEventParams(string eventName, Object[] eventParams, XDetectParams[] detectParams)
772 { 691 {
773 EventName=eventName; 692 XScriptInstance instance = GetInstance(itemID);
774 Params=eventParams; 693 if (instance == null)
775 DetectParams=detectParams; 694 return "default";
695 return instance.State;
776 } 696 }
777
778 public string EventName;
779 public Object[] Params;
780 public XDetectParams[] DetectParams;
781 } 697 }
782 698
783 public class XScriptInstance 699 public class XScriptInstance
@@ -791,17 +707,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
791 private LLUUID m_ObjectID; 707 private LLUUID m_ObjectID;
792 private LLUUID m_AssetID; 708 private LLUUID m_AssetID;
793 private IScript m_Script; 709 private IScript m_Script;
794 private LSL_ScriptCommands m_LSLCommands;
795 private OSSL_ScriptCommands m_OSSLCommands;
796 private Executor m_Executor; 710 private Executor m_Executor;
797 private LLUUID m_AppDomain; 711 private LLUUID m_AppDomain;
798 private XDetectParams[] m_DetectParams; 712 private DetectParams[] m_DetectParams;
799 private bool m_TimerQueued; 713 private bool m_TimerQueued;
800 private DateTime m_EventStart; 714 private DateTime m_EventStart;
801 private bool m_InEvent; 715 private bool m_InEvent;
802 private string m_PrimName; 716 private string m_PrimName;
803 private string m_ScriptName; 717 private string m_ScriptName;
804 private string m_Assembly; 718 private string m_Assembly;
719 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
805 720
806 public enum StateSource 721 public enum StateSource
807 { 722 {
@@ -893,6 +808,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
893 m_ScriptName = scriptName; 808 m_ScriptName = scriptName;
894 m_Assembly = assembly; 809 m_Assembly = assembly;
895 810
811 ApiManager am = new ApiManager();
812
896 SceneObjectPart part=engine.World.GetSceneObjectPart(localID); 813 SceneObjectPart part=engine.World.GetSceneObjectPart(localID);
897 if (part == null) 814 if (part == null)
898 { 815 {
@@ -900,10 +817,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
900 return; 817 return;
901 } 818 }
902 819
903 m_LSLCommands = new LSL_ScriptCommands(engine, this, part, localID, 820 foreach (string api in am.GetApis())
904 itemID); 821 {
905 m_OSSLCommands = new OSSL_ScriptCommands(engine, this, part, 822 m_Apis[api] = am.CreateApi(api);
906 localID, itemID); 823 m_Apis[api].Initialize(engine, part, localID, itemID);
824 }
907 825
908 try 826 try
909 { 827 {
@@ -918,14 +836,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
918 836
919 try 837 try
920 { 838 {
921 m_Script.Start(m_LSLCommands, m_OSSLCommands); 839 foreach (KeyValuePair<string,IScriptApi> kv in m_Apis)
840 {
841 m_Script.InitApi(kv.Key, kv.Value);
842 }
922 843
923 m_Executor = new Executor(m_Script); 844 m_Executor = new Executor(m_Script);
924 845
925// m_Engine.Log.Debug("[XEngine] Script instance created"); 846// m_Engine.Log.Debug("[XEngine] Script instance created");
926 847
927 part.SetScriptEvents(m_ItemID, 848 part.SetScriptEvents(m_ItemID,
928 (int)m_Executor.GetStateEventFlags()); 849 (int)m_Executor.GetStateEventFlags(State));
929 } 850 }
930 catch (Exception e) 851 catch (Exception e)
931 { 852 {
@@ -958,7 +879,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
958 879
959 ScriptSerializer.Deserialize(xml, this); 880 ScriptSerializer.Deserialize(xml, this);
960 881
961 m_Engine.m_ASYNCLSLCommandManager.CreateFromData( 882 m_Engine.m_AsyncCommands.CreateFromData(
962 m_LocalID, m_ItemID, m_ObjectID, 883 m_LocalID, m_ItemID, m_ObjectID,
963 PluginData); 884 PluginData);
964 885
@@ -976,32 +897,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine
976 if (stateSource == StateSource.NewRez) 897 if (stateSource == StateSource.NewRez)
977 { 898 {
978// m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script"); 899// m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script");
979 PostEvent(new XEventParams("changed", 900 PostEvent(new EventParams("changed",
980 new Object[] {new LSL_Types.LSLInteger(256)}, new XDetectParams[0])); 901 new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0]));
981 } 902 }
982 } 903 }
983 } 904 }
984 else 905 else
985 { 906 {
986 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); 907 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded");
987 PostEvent(new XEventParams("state_entry", 908 PostEvent(new EventParams("state_entry",
988 new Object[0], new XDetectParams[0])); 909 new Object[0], new DetectParams[0]));
989 Start(); 910 Start();
990 } 911 }
991 } 912 }
992 catch (Exception e) 913 catch (Exception e)
993 { 914 {
994 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); 915 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml);
995 PostEvent(new XEventParams("state_entry", 916 PostEvent(new EventParams("state_entry",
996 new Object[0], new XDetectParams[0])); 917 new Object[0], new DetectParams[0]));
997 Start(); 918 Start();
998 } 919 }
999 } 920 }
1000 else 921 else
1001 { 922 {
1002 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); 923 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found");
1003 PostEvent(new XEventParams("state_entry", 924 PostEvent(new EventParams("state_entry",
1004 new Object[0], new XDetectParams[0])); 925 new Object[0], new DetectParams[0]));
1005 Start(); 926 Start();
1006 } 927 }
1007 } 928 }
@@ -1100,15 +1021,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1100 1021
1101 public void SetState(string state) 1022 public void SetState(string state)
1102 { 1023 {
1103 PostEvent(new XEventParams("state_exit", new Object[0], 1024 PostEvent(new EventParams("state_exit", new Object[0],
1104 new XDetectParams[0])); 1025 new DetectParams[0]));
1105 PostEvent(new XEventParams("state", new Object[] { state }, 1026 PostEvent(new EventParams("state", new Object[] { state },
1106 new XDetectParams[0])); 1027 new DetectParams[0]));
1107 PostEvent(new XEventParams("state_entry", new Object[0], 1028 PostEvent(new EventParams("state_entry", new Object[0],
1108 new XDetectParams[0])); 1029 new DetectParams[0]));
1109 } 1030 }
1110 1031
1111 public void PostEvent(XEventParams data) 1032 public void PostEvent(EventParams data)
1112 { 1033 {
1113// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", 1034// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}",
1114// m_PrimName, m_ScriptName, data.EventName, m_State); 1035// m_PrimName, m_ScriptName, data.EventName, m_State);
@@ -1137,11 +1058,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1137 1058
1138 public object EventProcessor() 1059 public object EventProcessor()
1139 { 1060 {
1140 XEventParams data = null; 1061 EventParams data = null;
1141 1062
1142 lock (m_EventQueue) 1063 lock (m_EventQueue)
1143 { 1064 {
1144 data = (XEventParams) m_EventQueue.Dequeue(); 1065 data = (EventParams) m_EventQueue.Dequeue();
1145 if (data == null) // Shouldn't happen 1066 if (data == null) // Shouldn't happen
1146 { 1067 {
1147 m_CurrentResult = null; 1068 m_CurrentResult = null;
@@ -1158,7 +1079,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1158// m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}", 1079// m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}",
1159// m_PrimName, m_ScriptName, data.Params[0].ToString()); 1080// m_PrimName, m_ScriptName, data.Params[0].ToString());
1160 m_State=data.Params[0].ToString(); 1081 m_State=data.Params[0].ToString();
1161 m_Engine.m_ASYNCLSLCommandManager.RemoveScript( 1082 m_Engine.m_AsyncCommands.RemoveScript(
1162 m_LocalID, m_ItemID); 1083 m_LocalID, m_ItemID);
1163 1084
1164 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 1085 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
@@ -1166,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1166 if (part != null) 1087 if (part != null)
1167 { 1088 {
1168 part.SetScriptEvents(m_ItemID, 1089 part.SetScriptEvents(m_ItemID,
1169 (int)m_Executor.GetStateEventFlags()); 1090 (int)m_Executor.GetStateEventFlags(State));
1170 } 1091 }
1171 } 1092 }
1172 else 1093 else
@@ -1181,7 +1102,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1181 { 1102 {
1182 m_EventStart = DateTime.Now; 1103 m_EventStart = DateTime.Now;
1183 m_InEvent = true; 1104 m_InEvent = true;
1184 m_Executor.ExecuteEvent(data.EventName, data.Params); 1105 m_Executor.ExecuteEvent(State, data.EventName, data.Params);
1185 m_InEvent = false; 1106 m_InEvent = false;
1186 } 1107 }
1187 catch (Exception e) 1108 catch (Exception e)
@@ -1259,14 +1180,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1259 bool running = Running; 1180 bool running = Running;
1260 1181
1261 Stop(0); 1182 Stop(0);
1262 m_Engine.m_ASYNCLSLCommandManager.RemoveScript(m_LocalID, m_ItemID); 1183 m_Engine.m_AsyncCommands.RemoveScript(m_LocalID, m_ItemID);
1263 m_EventQueue.Clear(); 1184 m_EventQueue.Clear();
1264 m_Script.ResetVars(); 1185 m_Script.ResetVars();
1265 m_State = "default"; 1186 m_State = "default";
1266 if (running) 1187 if (running)
1267 Start(); 1188 Start();
1268 PostEvent(new XEventParams("state_entry", 1189 PostEvent(new EventParams("state_entry",
1269 new Object[0], new XDetectParams[0])); 1190 new Object[0], new DetectParams[0]));
1270 } 1191 }
1271 1192
1272 public Dictionary<string, object> GetVars() 1193 public Dictionary<string, object> GetVars()
@@ -1279,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1279 m_Script.SetVars(vars); 1200 m_Script.SetVars(vars);
1280 } 1201 }
1281 1202
1282 public XDetectParams GetDetectParams(int idx) 1203 public DetectParams GetDetectParams(int idx)
1283 { 1204 {
1284 if (idx < 0 || idx >= m_DetectParams.Length) 1205 if (idx < 0 || idx >= m_DetectParams.Length)
1285 return null; 1206 return null;
@@ -1298,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1298 public void SaveState(string assembly) 1219 public void SaveState(string assembly)
1299 { 1220 {
1300 PluginData = 1221 PluginData =
1301 m_Engine.m_ASYNCLSLCommandManager.GetSerializationData( 1222 m_Engine.m_AsyncCommands.GetSerializationData(
1302 m_ItemID); 1223 m_ItemID);
1303 1224
1304 string xml = ScriptSerializer.Serialize(this); 1225 string xml = ScriptSerializer.Serialize(this);
@@ -1368,7 +1289,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1368 1289
1369 while (count > 0) 1290 while (count > 0)
1370 { 1291 {
1371 XEventParams ep = (XEventParams)instance.EventQueue.Dequeue(); 1292 EventParams ep = (EventParams)instance.EventQueue.Dequeue();
1372 instance.EventQueue.Enqueue(ep); 1293 instance.EventQueue.Enqueue(ep);
1373 count--; 1294 count--;
1374 1295
@@ -1387,7 +1308,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1387 1308
1388 XmlElement detect = xmldoc.CreateElement("", "Detected", ""); 1309 XmlElement detect = xmldoc.CreateElement("", "Detected", "");
1389 1310
1390 foreach (XDetectParams det in ep.DetectParams) 1311 foreach (DetectParams det in ep.DetectParams)
1391 { 1312 {
1392 XmlElement objectElem = xmldoc.CreateElement("", "Object", 1313 XmlElement objectElem = xmldoc.CreateElement("", "Object",
1393 ""); 1314 "");
@@ -1449,9 +1370,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1449 rootElement.AppendChild(queue); 1370 rootElement.AppendChild(queue);
1450 1371
1451 XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); 1372 XmlNode plugins = xmldoc.CreateElement("", "Plugins", "");
1452 if (instance.PluginData.Length > 0) 1373 DumpList(xmldoc, plugins,
1453 DumpList(xmldoc, plugins, 1374 new LSL_Types.list(instance.PluginData));
1454 new LSL_Types.list(instance.PluginData));
1455 1375
1456 rootElement.AppendChild(plugins); 1376 rootElement.AppendChild(plugins);
1457 1377
@@ -1510,8 +1430,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1510 foreach (XmlNode item in itemL) 1430 foreach (XmlNode item in itemL)
1511 { 1431 {
1512 List<Object> parms = new List<Object>(); 1432 List<Object> parms = new List<Object>();
1513 List<XDetectParams> detected = 1433 List<DetectParams> detected =
1514 new List<XDetectParams>(); 1434 new List<DetectParams>();
1515 1435
1516 string eventName = 1436 string eventName =
1517 item.Attributes.GetNamedItem("event").Value; 1437 item.Attributes.GetNamedItem("event").Value;
@@ -1595,7 +1515,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1595 LLUUID.TryParse(det.InnerText, 1515 LLUUID.TryParse(det.InnerText,
1596 out uuid); 1516 out uuid);
1597 1517
1598 XDetectParams d = new XDetectParams(); 1518 DetectParams d = new DetectParams();
1599 d.Key = uuid; 1519 d.Key = uuid;
1600 d.OffsetPos = v; 1520 d.OffsetPos = v;
1601 d.LinkNum = d_linkNum; 1521 d.LinkNum = d_linkNum;
@@ -1612,7 +1532,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1612 break; 1532 break;
1613 } 1533 }
1614 } 1534 }
1615 XEventParams ep = new XEventParams( 1535 EventParams ep = new EventParams(
1616 eventName, parms.ToArray(), 1536 eventName, parms.ToArray(),
1617 detected.ToArray()); 1537 detected.ToArray());
1618 instance.EventQueue.Enqueue(ep); 1538 instance.EventQueue.Enqueue(ep);