diff options
author | lbsa71 | 2008-06-24 21:09:49 +0000 |
---|---|---|
committer | lbsa71 | 2008-06-24 21:09:49 +0000 |
commit | 6b7930104bdb845d3b9c085dc04f52b6446f23b1 (patch) | |
tree | 05ee45781a455817fa400bb99f30f4d19d4eb1f8 /OpenSim/Region/ScriptEngine/Shared | |
parent | based on positive feedback on performance of making keys fixed length (diff) | |
download | opensim-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 'OpenSim/Region/ScriptEngine/Shared')
41 files changed, 28341 insertions, 0 deletions
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
33 | |||
34 | namespace 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/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs new file mode 100644 index 0000000..8c967a2 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -0,0 +1,308 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Threading; | ||
32 | using libsecondlife; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Shared; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
38 | using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | ||
39 | |||
40 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. | ||
44 | /// </summary> | ||
45 | public class AsyncCommandManager | ||
46 | { | ||
47 | private static Thread cmdHandlerThread; | ||
48 | private static int cmdHandlerThreadCycleSleepms; | ||
49 | |||
50 | private static List<AsyncCommandManager> m_Managers = new List<AsyncCommandManager>(); | ||
51 | public IScriptEngine m_ScriptEngine; | ||
52 | |||
53 | private Dataserver m_Dataserver; | ||
54 | private Timer m_Timer; | ||
55 | private HttpRequest m_HttpRequest; | ||
56 | private Listener m_Listener; | ||
57 | private SensorRepeat m_SensorRepeat; | ||
58 | private XmlRequest m_XmlRequest; | ||
59 | |||
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) | ||
96 | { | ||
97 | m_ScriptEngine = _ScriptEngine; | ||
98 | if(!m_Managers.Contains(this)) | ||
99 | m_Managers.Add(this); | ||
100 | |||
101 | ReadConfig(); | ||
102 | |||
103 | // Create instances of all plugins | ||
104 | m_Dataserver = new Dataserver(this); | ||
105 | m_Timer = new Timer(this); | ||
106 | m_HttpRequest = new HttpRequest(this); | ||
107 | m_Listener = new Listener(this); | ||
108 | m_SensorRepeat = new SensorRepeat(this); | ||
109 | m_XmlRequest = new XmlRequest(this); | ||
110 | |||
111 | StartThread(); | ||
112 | } | ||
113 | |||
114 | private static void StartThread() | ||
115 | { | ||
116 | if (cmdHandlerThread == null) | ||
117 | { | ||
118 | // Start the thread that will be doing the work | ||
119 | cmdHandlerThread = new Thread(CmdHandlerThreadLoop); | ||
120 | cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread"; | ||
121 | cmdHandlerThread.Priority = ThreadPriority.BelowNormal; | ||
122 | cmdHandlerThread.IsBackground = true; | ||
123 | cmdHandlerThread.Start(); | ||
124 | ThreadTracker.Add(cmdHandlerThread); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | public void ReadConfig() | ||
129 | { | ||
130 | cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); | ||
131 | } | ||
132 | |||
133 | ~AsyncCommandManager() | ||
134 | { | ||
135 | // Shut down thread | ||
136 | try | ||
137 | { | ||
138 | if (cmdHandlerThread != null) | ||
139 | { | ||
140 | if (cmdHandlerThread.IsAlive == true) | ||
141 | { | ||
142 | cmdHandlerThread.Abort(); | ||
143 | //cmdHandlerThread.Join(); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | catch | ||
148 | { | ||
149 | } | ||
150 | } | ||
151 | |||
152 | private static void CmdHandlerThreadLoop() | ||
153 | { | ||
154 | while (true) | ||
155 | { | ||
156 | try | ||
157 | { | ||
158 | while (true) | ||
159 | { | ||
160 | Thread.Sleep(cmdHandlerThreadCycleSleepms); | ||
161 | |||
162 | foreach (AsyncCommandManager m in m_Managers) | ||
163 | { | ||
164 | m.DoOneCmdHandlerPass(); | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | catch | ||
169 | { | ||
170 | } | ||
171 | } | ||
172 | } | ||
173 | |||
174 | public void DoOneCmdHandlerPass() | ||
175 | { | ||
176 | // Check timers | ||
177 | m_Timer.CheckTimerEvents(); | ||
178 | // Check HttpRequests | ||
179 | m_HttpRequest.CheckHttpRequests(); | ||
180 | // Check XMLRPCRequests | ||
181 | m_XmlRequest.CheckXMLRPCRequests(); | ||
182 | // Check Listeners | ||
183 | m_Listener.CheckListeners(); | ||
184 | // Check Sensors | ||
185 | m_SensorRepeat.CheckSenseRepeaterEvents(); | ||
186 | // Check dataserver | ||
187 | m_Dataserver.ExpireRequests(); | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Remove a specific script (and all its pending commands) | ||
192 | /// </summary> | ||
193 | /// <param name="localID"></param> | ||
194 | /// <param name="itemID"></param> | ||
195 | public void RemoveScript(uint localID, LLUUID itemID) | ||
196 | { | ||
197 | // Remove a specific script | ||
198 | |||
199 | // Remove dataserver events | ||
200 | m_Dataserver.RemoveEvents(localID, itemID); | ||
201 | |||
202 | // Remove from: Timers | ||
203 | m_Timer.UnSetTimerEvents(localID, itemID); | ||
204 | |||
205 | // Remove from: HttpRequest | ||
206 | IHttpRequests iHttpReq = | ||
207 | m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | ||
208 | iHttpReq.StopHttpRequest(localID, itemID); | ||
209 | |||
210 | IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
211 | comms.DeleteListener(itemID); | ||
212 | |||
213 | IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
214 | xmlrpc.DeleteChannels(itemID); | ||
215 | xmlrpc.CancelSRDRequests(itemID); | ||
216 | |||
217 | // Remove Sensors | ||
218 | m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID); | ||
219 | |||
220 | } | ||
221 | |||
222 | public Object[] GetSerializationData(LLUUID itemID) | ||
223 | { | ||
224 | List<Object> data = new List<Object>(); | ||
225 | |||
226 | Object[] listeners=m_Listener.GetSerializationData(itemID); | ||
227 | if (listeners.Length > 0) | ||
228 | { | ||
229 | data.Add("listener"); | ||
230 | data.Add(listeners.Length); | ||
231 | data.AddRange(listeners); | ||
232 | } | ||
233 | |||
234 | Object[] timers=m_Timer.GetSerializationData(itemID); | ||
235 | if (timers.Length > 0) | ||
236 | { | ||
237 | data.Add("timer"); | ||
238 | data.Add(timers.Length); | ||
239 | data.AddRange(timers); | ||
240 | } | ||
241 | |||
242 | Object[] sensors=m_SensorRepeat.GetSerializationData(itemID); | ||
243 | if (sensors.Length > 0) | ||
244 | { | ||
245 | data.Add("sensor"); | ||
246 | data.Add(sensors.Length); | ||
247 | data.AddRange(sensors); | ||
248 | } | ||
249 | |||
250 | return data.ToArray(); | ||
251 | } | ||
252 | |||
253 | public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, | ||
254 | Object[] data) | ||
255 | { | ||
256 | int idx = 0; | ||
257 | int len; | ||
258 | |||
259 | while (idx < data.Length) | ||
260 | { | ||
261 | string type = data[idx].ToString(); | ||
262 | len = (int)data[idx+1]; | ||
263 | idx+=2; | ||
264 | |||
265 | if (len > 0) | ||
266 | { | ||
267 | Object[] item = new Object[len]; | ||
268 | Array.Copy(data, idx, item, 0, len); | ||
269 | |||
270 | idx+=len; | ||
271 | |||
272 | switch (type) | ||
273 | { | ||
274 | case "listener": | ||
275 | m_Listener.CreateFromData(localID, itemID, hostID, | ||
276 | item); | ||
277 | break; | ||
278 | case "timer": | ||
279 | m_Timer.CreateFromData(localID, itemID, hostID, item); | ||
280 | break; | ||
281 | case "sensor": | ||
282 | m_SensorRepeat.CreateFromData(localID, itemID, hostID, | ||
283 | item); | ||
284 | break; | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | |||
290 | #region Check llRemoteData channels | ||
291 | |||
292 | #endregion | ||
293 | |||
294 | #region Check llListeners | ||
295 | |||
296 | #endregion | ||
297 | |||
298 | /// <summary> | ||
299 | /// If set to true then threads and stuff should try to make a graceful exit | ||
300 | /// </summary> | ||
301 | public bool PleaseShutdown | ||
302 | { | ||
303 | get { return _PleaseShutdown; } | ||
304 | set { _PleaseShutdown = value; } | ||
305 | } | ||
306 | private bool _PleaseShutdown = false; | ||
307 | } | ||
308 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs new file mode 100644 index 0000000..7832633 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -0,0 +1,6583 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Runtime.Remoting.Lifetime; | ||
32 | using System.Text; | ||
33 | using System.Threading; | ||
34 | using Nini.Config; | ||
35 | using Axiom.Math; | ||
36 | using libsecondlife; | ||
37 | using OpenSim; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.Environment; | ||
40 | using OpenSim.Region.Environment.Interfaces; | ||
41 | using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; | ||
42 | using OpenSim.Region.Environment.Modules.World.Land; | ||
43 | using OpenSim.Region.Environment.Scenes; | ||
44 | using OpenSim.Region.ScriptEngine.Shared; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
46 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
47 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
48 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
49 | |||
50 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
51 | { | ||
52 | /// <summary> | ||
53 | /// Contains all LSL ll-functions. This class will be in Default AppDomain. | ||
54 | /// </summary> | ||
55 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | ||
56 | { | ||
57 | // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
58 | |||
59 | internal IScriptEngine m_ScriptEngine; | ||
60 | internal SceneObjectPart m_host; | ||
61 | internal uint m_localID; | ||
62 | internal LLUUID m_itemID; | ||
63 | internal bool throwErrorOnNotImplemented = true; | ||
64 | internal static AsyncCommandManager AsyncCommands = null; | ||
65 | |||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) | ||
67 | { | ||
68 | m_ScriptEngine = ScriptEngine; | ||
69 | m_host = host; | ||
70 | m_localID = localID; | ||
71 | m_itemID = itemID; | ||
72 | |||
73 | AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; | ||
74 | } | ||
75 | |||
76 | private DateTime m_timer = DateTime.Now; | ||
77 | private bool m_waitingForScriptAnswer=false; | ||
78 | |||
79 | |||
80 | // Object never expires | ||
81 | public override Object InitializeLifetimeService() | ||
82 | { | ||
83 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
84 | |||
85 | if (lease.CurrentState == LeaseState.Initial) | ||
86 | { | ||
87 | lease.InitialLeaseTime = TimeSpan.Zero; | ||
88 | } | ||
89 | return lease; | ||
90 | } | ||
91 | |||
92 | public Scene World | ||
93 | { | ||
94 | get { return m_ScriptEngine.World; } | ||
95 | } | ||
96 | |||
97 | public void state(string newState) | ||
98 | { | ||
99 | m_ScriptEngine.SetState(m_itemID, newState); | ||
100 | } | ||
101 | |||
102 | public void llSay(int channelID, string text) | ||
103 | { | ||
104 | m_host.AddScriptLPS(1); | ||
105 | |||
106 | if (text.Length > 1023) | ||
107 | text = text.Substring(0, 1023); | ||
108 | |||
109 | World.SimChat(Helpers.StringToField(text), | ||
110 | ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); | ||
111 | |||
112 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
113 | wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text); | ||
114 | } | ||
115 | |||
116 | // Extension commands use this: | ||
117 | public ICommander GetCommander(string name) | ||
118 | { | ||
119 | return World.GetCommander(name); | ||
120 | } | ||
121 | |||
122 | private LLUUID InventorySelf() | ||
123 | { | ||
124 | LLUUID invItemID = new LLUUID(); | ||
125 | |||
126 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
127 | { | ||
128 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
129 | { | ||
130 | invItemID = inv.Key; | ||
131 | break; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | return invItemID; | ||
136 | } | ||
137 | |||
138 | private LLUUID InventoryKey(string name, int type) | ||
139 | { | ||
140 | m_host.AddScriptLPS(1); | ||
141 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
142 | { | ||
143 | if (inv.Value.Name == name) | ||
144 | { | ||
145 | if (inv.Value.Type != type) | ||
146 | return LLUUID.Zero; | ||
147 | |||
148 | return inv.Value.AssetID.ToString(); | ||
149 | } | ||
150 | } | ||
151 | return LLUUID.Zero; | ||
152 | } | ||
153 | |||
154 | private LLUUID InventoryKey(string name) | ||
155 | { | ||
156 | m_host.AddScriptLPS(1); | ||
157 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
158 | { | ||
159 | if (inv.Value.Name == name) | ||
160 | { | ||
161 | return inv.Value.AssetID.ToString(); | ||
162 | } | ||
163 | } | ||
164 | return LLUUID.Zero; | ||
165 | } | ||
166 | |||
167 | |||
168 | /// <summary> | ||
169 | /// accepts a valid LLUUID, -or- a name of an inventory item. | ||
170 | /// Returns a valid LLUUID or LLUUID.Zero if key invalid and item not found | ||
171 | /// in prim inventory. | ||
172 | /// </summary> | ||
173 | /// <param name="k"></param> | ||
174 | /// <returns></returns> | ||
175 | private LLUUID KeyOrName(string k) | ||
176 | { | ||
177 | LLUUID key = LLUUID.Zero; | ||
178 | |||
179 | // if we can parse the string as a key, use it. | ||
180 | if (LLUUID.TryParse(k, out key)) | ||
181 | { | ||
182 | return key; | ||
183 | } | ||
184 | // else try to locate the name in inventory of object. found returns key, | ||
185 | // not found returns LLUUID.Zero which will translate to the default particle texture | ||
186 | else | ||
187 | { | ||
188 | return InventoryKey(k); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | public void osSetRegionWaterHeight(double height) | ||
193 | { | ||
194 | m_host.AddScriptLPS(1); | ||
195 | //Check to make sure that the script's owner is the estate manager/master | ||
196 | //World.Permissions.GenericEstatePermission( | ||
197 | if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID)) | ||
198 | { | ||
199 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | //These are the implementations of the various ll-functions used by the LSL scripts. | ||
204 | //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 | ||
205 | public double llSin(double f) | ||
206 | { | ||
207 | m_host.AddScriptLPS(1); | ||
208 | return (double)Math.Sin(f); | ||
209 | } | ||
210 | |||
211 | public double llCos(double f) | ||
212 | { | ||
213 | m_host.AddScriptLPS(1); | ||
214 | return (double)Math.Cos(f); | ||
215 | } | ||
216 | |||
217 | public double llTan(double f) | ||
218 | { | ||
219 | m_host.AddScriptLPS(1); | ||
220 | return (double)Math.Tan(f); | ||
221 | } | ||
222 | |||
223 | public double llAtan2(double x, double y) | ||
224 | { | ||
225 | m_host.AddScriptLPS(1); | ||
226 | return (double)Math.Atan2(y, x); | ||
227 | } | ||
228 | |||
229 | public double llSqrt(double f) | ||
230 | { | ||
231 | m_host.AddScriptLPS(1); | ||
232 | return (double)Math.Sqrt(f); | ||
233 | } | ||
234 | |||
235 | public double llPow(double fbase, double fexponent) | ||
236 | { | ||
237 | m_host.AddScriptLPS(1); | ||
238 | return (double)Math.Pow(fbase, fexponent); | ||
239 | } | ||
240 | |||
241 | public LSL_Types.LSLInteger llAbs(int i) | ||
242 | { | ||
243 | m_host.AddScriptLPS(1); | ||
244 | return (int)Math.Abs(i); | ||
245 | } | ||
246 | |||
247 | public double llFabs(double f) | ||
248 | { | ||
249 | m_host.AddScriptLPS(1); | ||
250 | return (double)Math.Abs(f); | ||
251 | } | ||
252 | |||
253 | public double llFrand(double mag) | ||
254 | { | ||
255 | m_host.AddScriptLPS(1); | ||
256 | lock (Util.RandomClass) | ||
257 | { | ||
258 | return Util.RandomClass.NextDouble() * mag; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | public LSL_Types.LSLInteger llFloor(double f) | ||
263 | { | ||
264 | m_host.AddScriptLPS(1); | ||
265 | return (int)Math.Floor(f); | ||
266 | } | ||
267 | |||
268 | public LSL_Types.LSLInteger llCeil(double f) | ||
269 | { | ||
270 | m_host.AddScriptLPS(1); | ||
271 | return (int)Math.Ceiling(f); | ||
272 | } | ||
273 | |||
274 | // Xantor 01/May/2008 fixed midpointrounding (2.5 becomes 3.0 instead of 2.0, default = ToEven) | ||
275 | public LSL_Types.LSLInteger llRound(double f) | ||
276 | { | ||
277 | m_host.AddScriptLPS(1); | ||
278 | return (int)Math.Round(f, MidpointRounding.AwayFromZero); | ||
279 | } | ||
280 | |||
281 | //This next group are vector operations involving squaring and square root. ckrinke | ||
282 | public double llVecMag(LSL_Types.Vector3 v) | ||
283 | { | ||
284 | m_host.AddScriptLPS(1); | ||
285 | return LSL_Types.Vector3.Mag(v); | ||
286 | } | ||
287 | |||
288 | public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) | ||
289 | { | ||
290 | m_host.AddScriptLPS(1); | ||
291 | double mag = LSL_Types.Vector3.Mag(v); | ||
292 | LSL_Types.Vector3 nor = new LSL_Types.Vector3(); | ||
293 | nor.x = v.x / mag; | ||
294 | nor.y = v.y / mag; | ||
295 | nor.z = v.z / mag; | ||
296 | return nor; | ||
297 | } | ||
298 | |||
299 | public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) | ||
300 | { | ||
301 | m_host.AddScriptLPS(1); | ||
302 | double dx = a.x - b.x; | ||
303 | double dy = a.y - b.y; | ||
304 | double dz = a.z - b.z; | ||
305 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); | ||
306 | } | ||
307 | |||
308 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | ||
309 | |||
310 | // Utility function for llRot2Euler | ||
311 | |||
312 | // normalize an angle between 0 - 2*PI (0 and 360 degrees) | ||
313 | private double NormalizeAngle(double angle) | ||
314 | { | ||
315 | angle = angle % (Math.PI * 2); | ||
316 | if (angle < 0) angle = angle + Math.PI * 2; | ||
317 | return angle; | ||
318 | } | ||
319 | |||
320 | // Old implementation of llRot2Euler, now normalized | ||
321 | |||
322 | public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) | ||
323 | { | ||
324 | m_host.AddScriptLPS(1); | ||
325 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | ||
326 | LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | ||
327 | double m = (t.x + t.y + t.z + t.s); | ||
328 | if (m == 0) return new LSL_Types.Vector3(); | ||
329 | double n = 2 * (r.y * r.s + r.x * r.z); | ||
330 | double p = m * m - n * n; | ||
331 | if (p > 0) | ||
332 | return new LSL_Types.Vector3(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), | ||
333 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | ||
334 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | ||
335 | else if (n > 0) | ||
336 | return new LSL_Types.Vector3(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | ||
337 | else | ||
338 | return new LSL_Types.Vector3(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | ||
339 | } | ||
340 | |||
341 | // Xantor's newer llEuler2Rot() *try the second* inverted quaternions (-x,-y,-z,w) as LL seems to like | ||
342 | // New and improved, now actually works as described. Prim rotates as expected as does llRot2Euler. | ||
343 | |||
344 | /* From wiki: | ||
345 | The Euler angle vector (in radians) is converted to a rotation by doing the rotations around the 3 axes | ||
346 | in Z, Y, X order. So llEuler2Rot(<1.0, 2.0, 3.0> * DEG_TO_RAD) generates a rotation by taking the zero rotation, | ||
347 | a vector pointing along the X axis, first rotating it 3 degrees around the global Z axis, then rotating the resulting | ||
348 | vector 2 degrees around the global Y axis, and finally rotating that 1 degree around the global X axis. | ||
349 | */ | ||
350 | |||
351 | public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) | ||
352 | { | ||
353 | m_host.AddScriptLPS(1); | ||
354 | |||
355 | double x,y,z,s,s_i; | ||
356 | |||
357 | double cosX = Math.Cos(v.x); | ||
358 | double cosY = Math.Cos(v.y); | ||
359 | double cosZ = Math.Cos(v.z); | ||
360 | double sinX = Math.Sin(v.x); | ||
361 | double sinY = Math.Sin(v.y); | ||
362 | double sinZ = Math.Sin(v.z); | ||
363 | |||
364 | s = Math.Sqrt(cosY * cosZ - sinX * sinY * sinZ + cosX * cosZ + cosX * cosY + 1.0f) * 0.5f; | ||
365 | if (Math.Abs(s) < 0.00001) // null rotation | ||
366 | { | ||
367 | x = 0.0f; | ||
368 | y = 1.0f; | ||
369 | z = 0.0f; | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | s_i = 1.0f / (4.0f * s); | ||
374 | x = - (-sinX * cosY - cosX * sinY * sinZ - sinX * cosZ) * s_i; | ||
375 | y = - (-cosX * sinY * cosZ + sinX * sinZ - sinY) * s_i; | ||
376 | z = - (-cosY * sinZ - sinX * sinY * cosZ - cosX * sinZ) * s_i; | ||
377 | } | ||
378 | return new LSL_Types.Quaternion(x, y, z, s); | ||
379 | } | ||
380 | |||
381 | public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) | ||
382 | { | ||
383 | m_host.AddScriptLPS(1); | ||
384 | NotImplemented("llAxes2Rot"); | ||
385 | return new LSL_Types.Quaternion(); | ||
386 | } | ||
387 | |||
388 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) | ||
389 | { | ||
390 | m_host.AddScriptLPS(1); | ||
391 | return (new LSL_Types.Vector3(1,0,0) * r); | ||
392 | } | ||
393 | |||
394 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) | ||
395 | { | ||
396 | m_host.AddScriptLPS(1); | ||
397 | return (new LSL_Types.Vector3(0, 1, 0) * r); | ||
398 | } | ||
399 | |||
400 | public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) | ||
401 | { | ||
402 | m_host.AddScriptLPS(1); | ||
403 | return (new LSL_Types.Vector3(0, 0, 1) * r); | ||
404 | } | ||
405 | |||
406 | public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b) | ||
407 | { | ||
408 | //A and B should both be normalized | ||
409 | m_host.AddScriptLPS(1); | ||
410 | double dotProduct = LSL_Types.Vector3.Dot(a, b); | ||
411 | LSL_Types.Vector3 crossProduct = LSL_Types.Vector3.Cross(a, b); | ||
412 | double magProduct = LSL_Types.Vector3.Mag(a) * LSL_Types.Vector3.Mag(b); | ||
413 | double angle = Math.Acos(dotProduct / magProduct); | ||
414 | LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct); | ||
415 | double s = Math.Sin(angle / 2); | ||
416 | |||
417 | return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2)); | ||
418 | } | ||
419 | |||
420 | public void llWhisper(int channelID, string text) | ||
421 | { | ||
422 | m_host.AddScriptLPS(1); | ||
423 | |||
424 | if (text.Length > 1023) | ||
425 | text = text.Substring(0, 1023); | ||
426 | |||
427 | World.SimChat(Helpers.StringToField(text), | ||
428 | ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); | ||
429 | |||
430 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
431 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | ||
432 | } | ||
433 | |||
434 | public void llShout(int channelID, string text) | ||
435 | { | ||
436 | m_host.AddScriptLPS(1); | ||
437 | |||
438 | if (text.Length > 1023) | ||
439 | text = text.Substring(0, 1023); | ||
440 | |||
441 | World.SimChat(Helpers.StringToField(text), | ||
442 | ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
443 | |||
444 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
445 | wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text); | ||
446 | } | ||
447 | |||
448 | public void llRegionSay(int channelID, string text) | ||
449 | { | ||
450 | if (channelID == 0) | ||
451 | { | ||
452 | LSLError("Cannot use llRegionSay() on channel 0"); | ||
453 | return; | ||
454 | } | ||
455 | |||
456 | if (text.Length > 1023) | ||
457 | text = text.Substring(0, 1023); | ||
458 | |||
459 | m_host.AddScriptLPS(1); | ||
460 | |||
461 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
462 | wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); | ||
463 | } | ||
464 | |||
465 | public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg) | ||
466 | { | ||
467 | m_host.AddScriptLPS(1); | ||
468 | LLUUID keyID; | ||
469 | LLUUID.TryParse(ID, out keyID); | ||
470 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
471 | return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); | ||
472 | } | ||
473 | |||
474 | public void llListenControl(int number, int active) | ||
475 | { | ||
476 | m_host.AddScriptLPS(1); | ||
477 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
478 | wComm.ListenControl(m_itemID, number, active); | ||
479 | } | ||
480 | |||
481 | public void llListenRemove(int number) | ||
482 | { | ||
483 | m_host.AddScriptLPS(1); | ||
484 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
485 | wComm.ListenRemove(m_itemID, number); | ||
486 | } | ||
487 | |||
488 | public void llSensor(string name, string id, int type, double range, double arc) | ||
489 | { | ||
490 | m_host.AddScriptLPS(1); | ||
491 | LLUUID keyID = LLUUID.Zero; | ||
492 | LLUUID.TryParse(id, out keyID); | ||
493 | |||
494 | AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); | ||
495 | } | ||
496 | |||
497 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) | ||
498 | { | ||
499 | m_host.AddScriptLPS(1); | ||
500 | LLUUID keyID = LLUUID.Zero; | ||
501 | LLUUID.TryParse(id, out keyID); | ||
502 | |||
503 | AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); | ||
504 | } | ||
505 | |||
506 | public void llSensorRemove() | ||
507 | { | ||
508 | m_host.AddScriptLPS(1); | ||
509 | AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); | ||
510 | } | ||
511 | |||
512 | public string resolveName(LLUUID objecUUID) | ||
513 | { | ||
514 | // try avatar username surname | ||
515 | UserProfileData profile = World.CommsManager.UserService.GetUserProfile(objecUUID); | ||
516 | if (profile != null) | ||
517 | { | ||
518 | string avatarname = profile.FirstName + " " + profile.SurName; | ||
519 | return avatarname; | ||
520 | } | ||
521 | // try an scene object | ||
522 | SceneObjectPart SOP = World.GetSceneObjectPart(objecUUID); | ||
523 | if (SOP != null) | ||
524 | { | ||
525 | string objectname = SOP.Name; | ||
526 | return objectname; | ||
527 | } | ||
528 | |||
529 | EntityBase SensedObject; | ||
530 | lock (World.Entities) | ||
531 | { | ||
532 | World.Entities.TryGetValue(objecUUID, out SensedObject); | ||
533 | } | ||
534 | |||
535 | if (SensedObject == null) | ||
536 | return String.Empty; | ||
537 | return SensedObject.Name; | ||
538 | } | ||
539 | |||
540 | public string llDetectedName(int number) | ||
541 | { | ||
542 | m_host.AddScriptLPS(1); | ||
543 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
544 | if (d == null) | ||
545 | return String.Empty; | ||
546 | return d.Name; | ||
547 | } | ||
548 | |||
549 | public string llDetectedKey(int number) | ||
550 | { | ||
551 | m_host.AddScriptLPS(1); | ||
552 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
553 | if (d == null) | ||
554 | return String.Empty; | ||
555 | return d.Key.ToString(); | ||
556 | } | ||
557 | |||
558 | public string llDetectedOwner(int number) | ||
559 | { | ||
560 | m_host.AddScriptLPS(1); | ||
561 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
562 | if (d == null) | ||
563 | return String.Empty; | ||
564 | return d.Owner.ToString(); | ||
565 | } | ||
566 | |||
567 | public LSL_Types.LSLInteger llDetectedType(int number) | ||
568 | { | ||
569 | m_host.AddScriptLPS(1); | ||
570 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
571 | if (d == null) | ||
572 | return 0; | ||
573 | return new LSL_Types.LSLInteger(d.Type); | ||
574 | } | ||
575 | |||
576 | public LSL_Types.Vector3 llDetectedPos(int number) | ||
577 | { | ||
578 | m_host.AddScriptLPS(1); | ||
579 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
580 | if (d == null) | ||
581 | return new LSL_Types.Vector3(); | ||
582 | return d.Position; | ||
583 | } | ||
584 | |||
585 | public LSL_Types.Vector3 llDetectedVel(int number) | ||
586 | { | ||
587 | m_host.AddScriptLPS(1); | ||
588 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
589 | if (d == null) | ||
590 | return new LSL_Types.Vector3(); | ||
591 | return d.Velocity; | ||
592 | } | ||
593 | |||
594 | public LSL_Types.Vector3 llDetectedGrab(int number) | ||
595 | { | ||
596 | m_host.AddScriptLPS(1); | ||
597 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
598 | if (parms == null) | ||
599 | return new LSL_Types.Vector3(0, 0, 0); | ||
600 | |||
601 | return parms.OffsetPos; | ||
602 | } | ||
603 | |||
604 | public LSL_Types.Quaternion llDetectedRot(int number) | ||
605 | { | ||
606 | m_host.AddScriptLPS(1); | ||
607 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
608 | if (d == null) | ||
609 | return new LSL_Types.Quaternion(); | ||
610 | return d.Rotation; | ||
611 | } | ||
612 | |||
613 | public LSL_Types.LSLInteger llDetectedGroup(int number) | ||
614 | { | ||
615 | m_host.AddScriptLPS(1); | ||
616 | DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
617 | if (d == null) | ||
618 | return new LSL_Types.LSLInteger(0); | ||
619 | if (m_host.GroupID == d.Group) | ||
620 | return new LSL_Types.LSLInteger(1); | ||
621 | return new LSL_Types.LSLInteger(0); | ||
622 | } | ||
623 | |||
624 | public LSL_Types.LSLInteger llDetectedLinkNumber(int number) | ||
625 | { | ||
626 | m_host.AddScriptLPS(1); | ||
627 | DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); | ||
628 | if (parms == null) | ||
629 | return new LSL_Types.LSLInteger(0); | ||
630 | |||
631 | return new LSL_Types.LSLInteger(parms.LinkNum); | ||
632 | } | ||
633 | |||
634 | public void llDie() | ||
635 | { | ||
636 | m_host.AddScriptLPS(1); | ||
637 | World.DeleteSceneObject(m_host.ParentGroup); | ||
638 | } | ||
639 | |||
640 | public double llGround(LSL_Types.Vector3 offset) | ||
641 | { | ||
642 | m_host.AddScriptLPS(1); | ||
643 | int x = (int)(m_host.AbsolutePosition.X + offset.x); | ||
644 | int y = (int)(m_host.AbsolutePosition.Y + offset.y); | ||
645 | return World.GetLandHeight(x, y); | ||
646 | } | ||
647 | |||
648 | public double llCloud(LSL_Types.Vector3 offset) | ||
649 | { | ||
650 | m_host.AddScriptLPS(1); | ||
651 | NotImplemented("llCloud"); | ||
652 | return 0; | ||
653 | } | ||
654 | |||
655 | public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) | ||
656 | { | ||
657 | m_host.AddScriptLPS(1); | ||
658 | NotImplemented("llWind"); | ||
659 | return new LSL_Types.Vector3(); | ||
660 | } | ||
661 | |||
662 | public void llSetStatus(int status, int value) | ||
663 | { | ||
664 | m_host.AddScriptLPS(1); | ||
665 | |||
666 | int statusrotationaxis = 0; | ||
667 | |||
668 | if ((status & ScriptBaseClass.STATUS_PHYSICS) == ScriptBaseClass.STATUS_PHYSICS) | ||
669 | { | ||
670 | if (value == 1) | ||
671 | m_host.ScriptSetPhysicsStatus(true); | ||
672 | else | ||
673 | m_host.ScriptSetPhysicsStatus(false); | ||
674 | } | ||
675 | |||
676 | if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) | ||
677 | { | ||
678 | if (value == 1) | ||
679 | m_host.ScriptSetPhantomStatus(true); | ||
680 | else | ||
681 | m_host.ScriptSetPhantomStatus(false); | ||
682 | } | ||
683 | |||
684 | if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) | ||
685 | { | ||
686 | m_host.AddFlag(LLObject.ObjectFlags.CastShadows); | ||
687 | } | ||
688 | |||
689 | if ((status & ScriptBaseClass.STATUS_ROTATE_X) == ScriptBaseClass.STATUS_ROTATE_X) | ||
690 | { | ||
691 | statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_X; | ||
692 | } | ||
693 | |||
694 | if ((status & ScriptBaseClass.STATUS_ROTATE_Y) == ScriptBaseClass.STATUS_ROTATE_Y) | ||
695 | { | ||
696 | statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_Y; | ||
697 | } | ||
698 | |||
699 | if ((status & ScriptBaseClass.STATUS_ROTATE_Z) == ScriptBaseClass.STATUS_ROTATE_Z) | ||
700 | { | ||
701 | statusrotationaxis |= ScriptBaseClass.STATUS_ROTATE_Z; | ||
702 | } | ||
703 | |||
704 | if ((status & ScriptBaseClass.STATUS_BLOCK_GRAB) == ScriptBaseClass.STATUS_BLOCK_GRAB) | ||
705 | { | ||
706 | NotImplemented("llSetStatus - STATUS_BLOCK_GRAB"); | ||
707 | } | ||
708 | |||
709 | if ((status & ScriptBaseClass.STATUS_DIE_AT_EDGE) == ScriptBaseClass.STATUS_DIE_AT_EDGE) | ||
710 | { | ||
711 | if (value == 1) | ||
712 | m_host.SetDieAtEdge(true); | ||
713 | else | ||
714 | m_host.SetDieAtEdge(false); | ||
715 | } | ||
716 | |||
717 | if ((status & ScriptBaseClass.STATUS_RETURN_AT_EDGE) == ScriptBaseClass.STATUS_RETURN_AT_EDGE) | ||
718 | { | ||
719 | NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE"); | ||
720 | } | ||
721 | |||
722 | if ((status & ScriptBaseClass.STATUS_SANDBOX) == ScriptBaseClass.STATUS_SANDBOX) | ||
723 | { | ||
724 | NotImplemented("llSetStatus - STATUS_SANDBOX"); | ||
725 | } | ||
726 | |||
727 | if (statusrotationaxis != 0) | ||
728 | { | ||
729 | m_host.SetAxisRotation(statusrotationaxis, value); | ||
730 | } | ||
731 | } | ||
732 | |||
733 | public LSL_Types.LSLInteger llGetStatus(int status) | ||
734 | { | ||
735 | m_host.AddScriptLPS(1); | ||
736 | // Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString()); | ||
737 | switch (status) | ||
738 | { | ||
739 | case ScriptBaseClass.STATUS_PHYSICS: | ||
740 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics) | ||
741 | { | ||
742 | return 1; | ||
743 | } | ||
744 | return 0; | ||
745 | |||
746 | case ScriptBaseClass.STATUS_PHANTOM: | ||
747 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom) | ||
748 | { | ||
749 | return 1; | ||
750 | } | ||
751 | return 0; | ||
752 | |||
753 | case ScriptBaseClass.STATUS_CAST_SHADOWS: | ||
754 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows) | ||
755 | { | ||
756 | return 1; | ||
757 | } | ||
758 | return 0; | ||
759 | |||
760 | case ScriptBaseClass.STATUS_BLOCK_GRAB: | ||
761 | NotImplemented("llGetStatus - STATUS_BLOCK_GRAB"); | ||
762 | return 0; | ||
763 | |||
764 | case ScriptBaseClass.STATUS_DIE_AT_EDGE: | ||
765 | if (m_host.GetDieAtEdge()) | ||
766 | return 1; | ||
767 | else | ||
768 | return 0; | ||
769 | |||
770 | case ScriptBaseClass.STATUS_RETURN_AT_EDGE: | ||
771 | NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE"); | ||
772 | return 0; | ||
773 | |||
774 | case ScriptBaseClass.STATUS_ROTATE_X: | ||
775 | NotImplemented("llGetStatus - STATUS_ROTATE_X"); | ||
776 | return 0; | ||
777 | |||
778 | case ScriptBaseClass.STATUS_ROTATE_Y: | ||
779 | NotImplemented("llGetStatus - STATUS_ROTATE_Y"); | ||
780 | return 0; | ||
781 | |||
782 | case ScriptBaseClass.STATUS_ROTATE_Z: | ||
783 | NotImplemented("llGetStatus - STATUS_ROTATE_Z"); | ||
784 | return 0; | ||
785 | |||
786 | case ScriptBaseClass.STATUS_SANDBOX: | ||
787 | NotImplemented("llGetStatus - STATUS_SANDBOX"); | ||
788 | return 0; | ||
789 | } | ||
790 | return 0; | ||
791 | } | ||
792 | |||
793 | public void llSetScale(LSL_Types.Vector3 scale) | ||
794 | { | ||
795 | m_host.AddScriptLPS(1); | ||
796 | SetScale(m_host, scale); | ||
797 | } | ||
798 | |||
799 | private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale) | ||
800 | { | ||
801 | // TODO: this needs to trigger a persistance save as well | ||
802 | LLVector3 tmp = part.Scale; | ||
803 | tmp.X = (float)scale.x; | ||
804 | tmp.Y = (float)scale.y; | ||
805 | tmp.Z = (float)scale.z; | ||
806 | part.Scale = tmp; | ||
807 | part.SendFullUpdateToAllClients(); | ||
808 | } | ||
809 | |||
810 | public LSL_Types.Vector3 llGetScale() | ||
811 | { | ||
812 | m_host.AddScriptLPS(1); | ||
813 | return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); | ||
814 | } | ||
815 | |||
816 | public void llSetColor(LSL_Types.Vector3 color, int face) | ||
817 | { | ||
818 | m_host.AddScriptLPS(1); | ||
819 | |||
820 | SetColor(m_host, color, face); | ||
821 | } | ||
822 | |||
823 | private void SetColor(SceneObjectPart part, LSL_Types.Vector3 color, int face) | ||
824 | { | ||
825 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
826 | LLColor texcolor; | ||
827 | if (face > -1) | ||
828 | { | ||
829 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
830 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
831 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
832 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
833 | tex.FaceTextures[face].RGBA = texcolor; | ||
834 | part.UpdateTexture(tex); | ||
835 | return; | ||
836 | } | ||
837 | else if (face == -1) | ||
838 | { | ||
839 | for (uint i = 0; i < 32; i++) | ||
840 | { | ||
841 | if (tex.FaceTextures[i] != null) | ||
842 | { | ||
843 | texcolor = tex.FaceTextures[i].RGBA; | ||
844 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
845 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
846 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
847 | tex.FaceTextures[i].RGBA = texcolor; | ||
848 | } | ||
849 | texcolor = tex.DefaultTexture.RGBA; | ||
850 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
851 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
852 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
853 | tex.DefaultTexture.RGBA = texcolor; | ||
854 | } | ||
855 | part.UpdateTexture(tex); | ||
856 | return; | ||
857 | } | ||
858 | } | ||
859 | |||
860 | public double llGetAlpha(int face) | ||
861 | { | ||
862 | m_host.AddScriptLPS(1); | ||
863 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
864 | if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color | ||
865 | { | ||
866 | return (double)((tex.DefaultTexture.RGBA.A * 255) / 255); | ||
867 | } | ||
868 | if (face > -1) | ||
869 | { | ||
870 | return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255); | ||
871 | } | ||
872 | return 0; | ||
873 | } | ||
874 | |||
875 | public void llSetAlpha(double alpha, int face) | ||
876 | { | ||
877 | m_host.AddScriptLPS(1); | ||
878 | |||
879 | SetAlpha(m_host, alpha, face); | ||
880 | } | ||
881 | |||
882 | private void SetAlpha(SceneObjectPart part, double alpha, int face) | ||
883 | { | ||
884 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
885 | LLColor texcolor; | ||
886 | if (face > -1) | ||
887 | { | ||
888 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
889 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
890 | tex.FaceTextures[face].RGBA = texcolor; | ||
891 | part.UpdateTexture(tex); | ||
892 | return; | ||
893 | } | ||
894 | else if (face == -1) | ||
895 | { | ||
896 | for (int i = 0; i < 32; i++) | ||
897 | { | ||
898 | if (tex.FaceTextures[i] != null) | ||
899 | { | ||
900 | texcolor = tex.FaceTextures[i].RGBA; | ||
901 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
902 | tex.FaceTextures[i].RGBA = texcolor; | ||
903 | } | ||
904 | } | ||
905 | texcolor = tex.DefaultTexture.RGBA; | ||
906 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
907 | tex.DefaultTexture.RGBA = texcolor; | ||
908 | part.UpdateTexture(tex); | ||
909 | return; | ||
910 | } | ||
911 | } | ||
912 | |||
913 | private void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | ||
914 | float wind, float tension, LSL_Types.Vector3 Force) | ||
915 | { | ||
916 | if (part == null) | ||
917 | return; | ||
918 | |||
919 | bool needs_fakedelete = false; | ||
920 | if (flexi) | ||
921 | { | ||
922 | if (!part.Shape.FlexiEntry) | ||
923 | { | ||
924 | needs_fakedelete = true; | ||
925 | } | ||
926 | part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do | ||
927 | // work once the prim is already flexi | ||
928 | part.Shape.FlexiSoftness = softness; | ||
929 | part.Shape.FlexiGravity = gravity; | ||
930 | part.Shape.FlexiDrag = friction; | ||
931 | part.Shape.FlexiWind = wind; | ||
932 | part.Shape.FlexiTension = tension; | ||
933 | part.Shape.FlexiForceX = (float)Force.x; | ||
934 | part.Shape.FlexiForceY = (float)Force.y; | ||
935 | part.Shape.FlexiForceZ = (float)Force.z; | ||
936 | part.Shape.PathCurve = 0x80; | ||
937 | |||
938 | } | ||
939 | else | ||
940 | { | ||
941 | if (part.Shape.FlexiEntry) | ||
942 | { | ||
943 | needs_fakedelete = true; | ||
944 | } | ||
945 | part.Shape.FlexiEntry = false; | ||
946 | } | ||
947 | |||
948 | needs_fakedelete = false; | ||
949 | if (needs_fakedelete) | ||
950 | { | ||
951 | if (part.ParentGroup != null) | ||
952 | { | ||
953 | part.ParentGroup.FakeDeleteGroup(); | ||
954 | } | ||
955 | } | ||
956 | |||
957 | part.ScheduleFullUpdate(); | ||
958 | } | ||
959 | |||
960 | private void SetPointLight(SceneObjectPart part, bool light, LSL_Types.Vector3 color, float intensity, float radius, float falloff) | ||
961 | { | ||
962 | if (part == null) | ||
963 | return; | ||
964 | |||
965 | if (light) | ||
966 | { | ||
967 | part.Shape.LightEntry = true; | ||
968 | part.Shape.LightColorR = (float)color.x; | ||
969 | part.Shape.LightColorG = (float)color.y; | ||
970 | part.Shape.LightColorB = (float)color.z; | ||
971 | part.Shape.LightIntensity = intensity; | ||
972 | part.Shape.LightRadius = radius; | ||
973 | part.Shape.LightFalloff = falloff; | ||
974 | } | ||
975 | else | ||
976 | { | ||
977 | part.Shape.LightEntry = false; | ||
978 | } | ||
979 | |||
980 | part.ScheduleFullUpdate(); | ||
981 | } | ||
982 | |||
983 | |||
984 | |||
985 | public LSL_Types.Vector3 llGetColor(int face) | ||
986 | { | ||
987 | m_host.AddScriptLPS(1); | ||
988 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
989 | LLColor texcolor; | ||
990 | LSL_Types.Vector3 rgb; | ||
991 | if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color | ||
992 | { | ||
993 | texcolor = tex.DefaultTexture.RGBA; | ||
994 | rgb.x = (255 - (texcolor.R * 255)) / 255; | ||
995 | rgb.y = (255 - (texcolor.G * 255)) / 255; | ||
996 | rgb.z = (255 - (texcolor.B * 255)) / 255; | ||
997 | return rgb; | ||
998 | } | ||
999 | if (face > -1) | ||
1000 | { | ||
1001 | texcolor = tex.GetFace((uint)face).RGBA; | ||
1002 | rgb.x = (255 - (texcolor.R * 255)) / 255; | ||
1003 | rgb.y = (255 - (texcolor.G * 255)) / 255; | ||
1004 | rgb.z = (255 - (texcolor.B * 255)) / 255; | ||
1005 | return rgb; | ||
1006 | } | ||
1007 | else | ||
1008 | { | ||
1009 | return new LSL_Types.Vector3(); | ||
1010 | } | ||
1011 | } | ||
1012 | |||
1013 | public void llSetTexture(string texture, int face) | ||
1014 | { | ||
1015 | m_host.AddScriptLPS(1); | ||
1016 | SetTexture(m_host, texture, face); | ||
1017 | } | ||
1018 | |||
1019 | private void SetTexture(SceneObjectPart part, string texture, int face) | ||
1020 | { | ||
1021 | LLUUID textureID=new LLUUID(); | ||
1022 | |||
1023 | if (!LLUUID.TryParse(texture, out textureID)) | ||
1024 | { | ||
1025 | textureID=InventoryKey(texture, (int)AssetType.Texture); | ||
1026 | } | ||
1027 | |||
1028 | if (textureID == LLUUID.Zero) | ||
1029 | return; | ||
1030 | |||
1031 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
1032 | |||
1033 | if (face > -1) | ||
1034 | { | ||
1035 | LLObject.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
1036 | texface.TextureID = textureID; | ||
1037 | tex.FaceTextures[face] = texface; | ||
1038 | part.UpdateTexture(tex); | ||
1039 | return; | ||
1040 | } | ||
1041 | else if (face == -1) | ||
1042 | { | ||
1043 | for (uint i = 0; i < 32; i++) | ||
1044 | { | ||
1045 | if (tex.FaceTextures[i] != null) | ||
1046 | { | ||
1047 | tex.FaceTextures[i].TextureID = textureID; | ||
1048 | } | ||
1049 | } | ||
1050 | tex.DefaultTexture.TextureID = textureID; | ||
1051 | part.UpdateTexture(tex); | ||
1052 | return; | ||
1053 | } | ||
1054 | } | ||
1055 | |||
1056 | public void llScaleTexture(double u, double v, int face) | ||
1057 | { | ||
1058 | m_host.AddScriptLPS(1); | ||
1059 | |||
1060 | ScaleTexture(m_host, u, v, face); | ||
1061 | } | ||
1062 | |||
1063 | private void ScaleTexture(SceneObjectPart part, double u, double v, int face) | ||
1064 | { | ||
1065 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
1066 | if (face > -1) | ||
1067 | { | ||
1068 | LLObject.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
1069 | texface.RepeatU = (float)u; | ||
1070 | texface.RepeatV = (float)v; | ||
1071 | tex.FaceTextures[face] = texface; | ||
1072 | part.UpdateTexture(tex); | ||
1073 | return; | ||
1074 | } | ||
1075 | if (face == -1) | ||
1076 | { | ||
1077 | for (int i = 0; i < 32; i++) | ||
1078 | { | ||
1079 | if (tex.FaceTextures[i] != null) | ||
1080 | { | ||
1081 | tex.FaceTextures[i].RepeatU = (float)u; | ||
1082 | tex.FaceTextures[i].RepeatV = (float)v; | ||
1083 | } | ||
1084 | } | ||
1085 | tex.DefaultTexture.RepeatU = (float)u; | ||
1086 | tex.DefaultTexture.RepeatV = (float)v; | ||
1087 | part.UpdateTexture(tex); | ||
1088 | return; | ||
1089 | } | ||
1090 | } | ||
1091 | |||
1092 | public void llOffsetTexture(double u, double v, int face) | ||
1093 | { | ||
1094 | m_host.AddScriptLPS(1); | ||
1095 | OffsetTexture(m_host, u, v, face); | ||
1096 | } | ||
1097 | |||
1098 | private void OffsetTexture(SceneObjectPart part, double u, double v, int face) | ||
1099 | { | ||
1100 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
1101 | if (face > -1) | ||
1102 | { | ||
1103 | LLObject.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
1104 | texface.OffsetU = (float)u; | ||
1105 | texface.OffsetV = (float)v; | ||
1106 | tex.FaceTextures[face] = texface; | ||
1107 | part.UpdateTexture(tex); | ||
1108 | return; | ||
1109 | } | ||
1110 | if (face == -1) | ||
1111 | { | ||
1112 | for (int i = 0; i < 32; i++) | ||
1113 | { | ||
1114 | if (tex.FaceTextures[i] != null) | ||
1115 | { | ||
1116 | tex.FaceTextures[i].OffsetU = (float)u; | ||
1117 | tex.FaceTextures[i].OffsetV = (float)v; | ||
1118 | } | ||
1119 | } | ||
1120 | tex.DefaultTexture.OffsetU = (float)u; | ||
1121 | tex.DefaultTexture.OffsetV = (float)v; | ||
1122 | part.UpdateTexture(tex); | ||
1123 | return; | ||
1124 | } | ||
1125 | } | ||
1126 | |||
1127 | public void llRotateTexture(double rotation, int face) | ||
1128 | { | ||
1129 | m_host.AddScriptLPS(1); | ||
1130 | RotateTexture(m_host, rotation, face); | ||
1131 | } | ||
1132 | |||
1133 | private void RotateTexture(SceneObjectPart part, double rotation, int face) | ||
1134 | { | ||
1135 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
1136 | if (face > -1) | ||
1137 | { | ||
1138 | LLObject.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
1139 | texface.Rotation = (float)rotation; | ||
1140 | tex.FaceTextures[face] = texface; | ||
1141 | part.UpdateTexture(tex); | ||
1142 | return; | ||
1143 | } | ||
1144 | if (face == -1) | ||
1145 | { | ||
1146 | for (int i = 0; i < 32; i++) | ||
1147 | { | ||
1148 | if (tex.FaceTextures[i] != null) | ||
1149 | { | ||
1150 | tex.FaceTextures[i].Rotation = (float)rotation; | ||
1151 | } | ||
1152 | } | ||
1153 | tex.DefaultTexture.Rotation = (float)rotation; | ||
1154 | part.UpdateTexture(tex); | ||
1155 | return; | ||
1156 | } | ||
1157 | } | ||
1158 | |||
1159 | public string llGetTexture(int face) | ||
1160 | { | ||
1161 | m_host.AddScriptLPS(1); | ||
1162 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
1163 | if (face == -1) | ||
1164 | { | ||
1165 | face = 0; | ||
1166 | } | ||
1167 | if (face > -1) | ||
1168 | { | ||
1169 | LLObject.TextureEntryFace texface; | ||
1170 | texface = tex.GetFace((uint)face); | ||
1171 | return texface.TextureID.ToString(); | ||
1172 | } | ||
1173 | else | ||
1174 | { | ||
1175 | return String.Empty; | ||
1176 | } | ||
1177 | } | ||
1178 | |||
1179 | public void llSetPos(LSL_Types.Vector3 pos) | ||
1180 | { | ||
1181 | m_host.AddScriptLPS(1); | ||
1182 | |||
1183 | SetPos(m_host, pos); | ||
1184 | } | ||
1185 | |||
1186 | private void SetPos(SceneObjectPart part, LSL_Types.Vector3 pos) | ||
1187 | { | ||
1188 | if (part.ParentID != 0) | ||
1189 | { | ||
1190 | part.UpdateOffSet(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z)); | ||
1191 | } | ||
1192 | else | ||
1193 | { | ||
1194 | part.UpdateGroupPosition(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z)); | ||
1195 | } | ||
1196 | } | ||
1197 | |||
1198 | public LSL_Types.Vector3 llGetPos() | ||
1199 | { | ||
1200 | m_host.AddScriptLPS(1); | ||
1201 | return new LSL_Types.Vector3(m_host.AbsolutePosition.X, | ||
1202 | m_host.AbsolutePosition.Y, | ||
1203 | m_host.AbsolutePosition.Z); | ||
1204 | } | ||
1205 | |||
1206 | public LSL_Types.Vector3 llGetLocalPos() | ||
1207 | { | ||
1208 | m_host.AddScriptLPS(1); | ||
1209 | if (m_host.ParentID != 0) | ||
1210 | { | ||
1211 | return new LSL_Types.Vector3(m_host.OffsetPosition.X, | ||
1212 | m_host.OffsetPosition.Y, | ||
1213 | m_host.OffsetPosition.Z); | ||
1214 | } | ||
1215 | else | ||
1216 | { | ||
1217 | return new LSL_Types.Vector3(m_host.AbsolutePosition.X, | ||
1218 | m_host.AbsolutePosition.Y, | ||
1219 | m_host.AbsolutePosition.Z); | ||
1220 | } | ||
1221 | } | ||
1222 | |||
1223 | public void llSetRot(LSL_Types.Quaternion rot) | ||
1224 | { | ||
1225 | m_host.AddScriptLPS(1); | ||
1226 | |||
1227 | SetRot(m_host, rot); | ||
1228 | } | ||
1229 | |||
1230 | private void SetRot(SceneObjectPart part, LSL_Types.Quaternion rot) | ||
1231 | { | ||
1232 | part.UpdateRotation(new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s)); | ||
1233 | // Update rotation does not move the object in the physics scene if it's a linkset. | ||
1234 | part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | ||
1235 | } | ||
1236 | |||
1237 | public LSL_Types.Quaternion llGetRot() | ||
1238 | { | ||
1239 | m_host.AddScriptLPS(1); | ||
1240 | LLQuaternion q = m_host.RotationOffset; | ||
1241 | return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | ||
1242 | } | ||
1243 | |||
1244 | public LSL_Types.Quaternion llGetLocalRot() | ||
1245 | { | ||
1246 | m_host.AddScriptLPS(1); | ||
1247 | return new LSL_Types.Quaternion(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); | ||
1248 | } | ||
1249 | |||
1250 | public void llSetForce(LSL_Types.Vector3 force, int local) | ||
1251 | { | ||
1252 | m_host.AddScriptLPS(1); | ||
1253 | NotImplemented("llSetForce"); | ||
1254 | } | ||
1255 | |||
1256 | public LSL_Types.Vector3 llGetForce() | ||
1257 | { | ||
1258 | m_host.AddScriptLPS(1); | ||
1259 | NotImplemented("llGetForce"); | ||
1260 | return new LSL_Types.Vector3(); | ||
1261 | } | ||
1262 | |||
1263 | public LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range) | ||
1264 | { | ||
1265 | m_host.AddScriptLPS(1); | ||
1266 | return m_host.registerTargetWaypoint(new LLVector3((float)position.x, (float)position.y, (float)position.z), (float)range); | ||
1267 | |||
1268 | } | ||
1269 | |||
1270 | public void llTargetRemove(int number) | ||
1271 | { | ||
1272 | m_host.AddScriptLPS(1); | ||
1273 | m_host.unregisterTargetWaypoint(number); | ||
1274 | } | ||
1275 | |||
1276 | public LSL_Types.LSLInteger llRotTarget(LSL_Types.Quaternion rot, double error) | ||
1277 | { | ||
1278 | m_host.AddScriptLPS(1); | ||
1279 | NotImplemented("llRotTarget"); | ||
1280 | return 0; | ||
1281 | } | ||
1282 | |||
1283 | public void llRotTargetRemove(int number) | ||
1284 | { | ||
1285 | m_host.AddScriptLPS(1); | ||
1286 | NotImplemented("llRotTargetRemove"); | ||
1287 | } | ||
1288 | |||
1289 | public void llMoveToTarget(LSL_Types.Vector3 target, double tau) | ||
1290 | { | ||
1291 | m_host.AddScriptLPS(1); | ||
1292 | m_host.MoveToTarget(new LLVector3((float)target.x, (float)target.y, (float)target.z), (float)tau); | ||
1293 | } | ||
1294 | |||
1295 | public void llStopMoveToTarget() | ||
1296 | { | ||
1297 | m_host.AddScriptLPS(1); | ||
1298 | m_host.StopMoveToTarget(); | ||
1299 | } | ||
1300 | |||
1301 | public void llApplyImpulse(LSL_Types.Vector3 force, int local) | ||
1302 | { | ||
1303 | m_host.AddScriptLPS(1); | ||
1304 | //No energy force yet | ||
1305 | |||
1306 | if (force.x > 20000) | ||
1307 | force.x = 20000; | ||
1308 | if (force.y > 20000) | ||
1309 | force.y = 20000; | ||
1310 | if (force.z > 20000) | ||
1311 | force.z = 20000; | ||
1312 | |||
1313 | if (local == 1) | ||
1314 | { | ||
1315 | m_host.ApplyImpulse(new LLVector3((float)force.x, (float)force.y, (float)force.z), true); | ||
1316 | } | ||
1317 | else | ||
1318 | { | ||
1319 | |||
1320 | m_host.ApplyImpulse(new LLVector3((float)force.x,(float)force.y,(float)force.z), false); | ||
1321 | } | ||
1322 | } | ||
1323 | |||
1324 | public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) | ||
1325 | { | ||
1326 | m_host.AddScriptLPS(1); | ||
1327 | NotImplemented("llApplyRotationalImpulse"); | ||
1328 | } | ||
1329 | |||
1330 | public void llSetTorque(LSL_Types.Vector3 torque, int local) | ||
1331 | { | ||
1332 | m_host.AddScriptLPS(1); | ||
1333 | NotImplemented("llSetTorque"); | ||
1334 | } | ||
1335 | |||
1336 | public LSL_Types.Vector3 llGetTorque() | ||
1337 | { | ||
1338 | m_host.AddScriptLPS(1); | ||
1339 | NotImplemented("llGetTorque"); | ||
1340 | return new LSL_Types.Vector3(); | ||
1341 | } | ||
1342 | |||
1343 | public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) | ||
1344 | { | ||
1345 | m_host.AddScriptLPS(1); | ||
1346 | NotImplemented("llSetForceAndTorque"); | ||
1347 | } | ||
1348 | |||
1349 | public LSL_Types.Vector3 llGetVel() | ||
1350 | { | ||
1351 | m_host.AddScriptLPS(1); | ||
1352 | return new LSL_Types.Vector3(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z); | ||
1353 | } | ||
1354 | |||
1355 | public LSL_Types.Vector3 llGetAccel() | ||
1356 | { | ||
1357 | m_host.AddScriptLPS(1); | ||
1358 | return new LSL_Types.Vector3(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); | ||
1359 | } | ||
1360 | |||
1361 | public LSL_Types.Vector3 llGetOmega() | ||
1362 | { | ||
1363 | m_host.AddScriptLPS(1); | ||
1364 | return new LSL_Types.Vector3(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z); | ||
1365 | } | ||
1366 | |||
1367 | public double llGetTimeOfDay() | ||
1368 | { | ||
1369 | m_host.AddScriptLPS(1); | ||
1370 | NotImplemented("llGetTimeOfDay"); | ||
1371 | return 0; | ||
1372 | } | ||
1373 | |||
1374 | public double llGetWallclock() | ||
1375 | { | ||
1376 | m_host.AddScriptLPS(1); | ||
1377 | return DateTime.Now.TimeOfDay.TotalSeconds; | ||
1378 | } | ||
1379 | |||
1380 | public double llGetTime() | ||
1381 | { | ||
1382 | m_host.AddScriptLPS(1); | ||
1383 | TimeSpan ScriptTime = DateTime.Now - m_timer; | ||
1384 | return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation); | ||
1385 | } | ||
1386 | |||
1387 | public void llResetTime() | ||
1388 | { | ||
1389 | m_host.AddScriptLPS(1); | ||
1390 | m_timer = DateTime.Now; | ||
1391 | } | ||
1392 | |||
1393 | public double llGetAndResetTime() | ||
1394 | { | ||
1395 | m_host.AddScriptLPS(1); | ||
1396 | TimeSpan ScriptTime = DateTime.Now - m_timer; | ||
1397 | m_timer = DateTime.Now; | ||
1398 | return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation); | ||
1399 | } | ||
1400 | |||
1401 | public void llSound() | ||
1402 | { | ||
1403 | m_host.AddScriptLPS(1); | ||
1404 | // This function has been deprecated | ||
1405 | // see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSound | ||
1406 | Deprecated("llSound"); | ||
1407 | } | ||
1408 | |||
1409 | // Xantor 20080528 PlaySound updated so it accepts an objectinventory name -or- a key to a sound | ||
1410 | // 20080530 Updated to remove code duplication | ||
1411 | public void llPlaySound(string sound, double volume) | ||
1412 | { | ||
1413 | m_host.AddScriptLPS(1); | ||
1414 | |||
1415 | // send the sound, once, to all clients in range | ||
1416 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0); | ||
1417 | } | ||
1418 | |||
1419 | // Xantor 20080528 we should do this differently. | ||
1420 | // 1) apply the sound to the object | ||
1421 | // 2) schedule full update | ||
1422 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
1423 | // or when the prim gets moved, changed, sat on, whatever | ||
1424 | // see large number of mantises (mantes?) | ||
1425 | // 20080530 Updated to remove code duplication | ||
1426 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
1427 | public void llLoopSound(string sound, double volume) | ||
1428 | { | ||
1429 | m_host.AddScriptLPS(1); | ||
1430 | |||
1431 | if (m_host.Sound != LLUUID.Zero) | ||
1432 | llStopSound(); | ||
1433 | |||
1434 | m_host.Sound = KeyOrName(sound); | ||
1435 | m_host.SoundGain = volume; | ||
1436 | m_host.SoundFlags = 1; // looping | ||
1437 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
1438 | |||
1439 | m_host.ScheduleFullUpdate(); | ||
1440 | m_host.SendFullUpdateToAllClients(); | ||
1441 | } | ||
1442 | |||
1443 | public void llLoopSoundMaster(string sound, double volume) | ||
1444 | { | ||
1445 | m_host.AddScriptLPS(1); | ||
1446 | NotImplemented("llLoopSoundMaster"); | ||
1447 | } | ||
1448 | |||
1449 | public void llLoopSoundSlave(string sound, double volume) | ||
1450 | { | ||
1451 | m_host.AddScriptLPS(1); | ||
1452 | NotImplemented("llLoopSoundSlave"); | ||
1453 | } | ||
1454 | |||
1455 | public void llPlaySoundSlave(string sound, double volume) | ||
1456 | { | ||
1457 | m_host.AddScriptLPS(1); | ||
1458 | NotImplemented("llPlaySoundSlave"); | ||
1459 | } | ||
1460 | |||
1461 | public void llTriggerSound(string sound, double volume) | ||
1462 | { | ||
1463 | m_host.AddScriptLPS(1); | ||
1464 | m_host.SendSound(sound, volume, true, 0); | ||
1465 | } | ||
1466 | |||
1467 | // Xantor 20080528: Clear prim data of sound instead | ||
1468 | public void llStopSound() | ||
1469 | { | ||
1470 | m_host.AddScriptLPS(1); | ||
1471 | |||
1472 | m_host.Sound = LLUUID.Zero; | ||
1473 | m_host.SoundGain = 0; | ||
1474 | m_host.SoundFlags = 0; | ||
1475 | m_host.SoundRadius = 0; | ||
1476 | |||
1477 | m_host.ScheduleFullUpdate(); | ||
1478 | m_host.SendFullUpdateToAllClients(); | ||
1479 | |||
1480 | // m_host.SendSound(LLUUID.Zero.ToString(), 1.0, false, 2); | ||
1481 | } | ||
1482 | |||
1483 | public void llPreloadSound(string sound) | ||
1484 | { | ||
1485 | m_host.AddScriptLPS(1); | ||
1486 | m_host.PreloadSound(sound); | ||
1487 | } | ||
1488 | |||
1489 | /// <summary> | ||
1490 | /// Return a portion of the designated string bounded by | ||
1491 | /// inclusive indices (start and end). As usual, the negative | ||
1492 | /// indices, and the tolerance for out-of-bound values, makes | ||
1493 | /// this more complicated than it might otherwise seem. | ||
1494 | /// </summary> | ||
1495 | |||
1496 | public string llGetSubString(string src, int start, int end) | ||
1497 | { | ||
1498 | |||
1499 | m_host.AddScriptLPS(1); | ||
1500 | |||
1501 | // Normalize indices (if negative). | ||
1502 | // After normlaization they may still be | ||
1503 | // negative, but that is now relative to | ||
1504 | // the start, rather than the end, of the | ||
1505 | // sequence. | ||
1506 | |||
1507 | if (start < 0) | ||
1508 | { | ||
1509 | start = src.Length+start; | ||
1510 | } | ||
1511 | if (end < 0) | ||
1512 | { | ||
1513 | end = src.Length+end; | ||
1514 | } | ||
1515 | |||
1516 | // Conventional substring | ||
1517 | if (start <= end) | ||
1518 | { | ||
1519 | // Implies both bounds are out-of-range. | ||
1520 | if (end < 0 || start >= src.Length) | ||
1521 | { | ||
1522 | return String.Empty; | ||
1523 | } | ||
1524 | // If end is positive, then it directly | ||
1525 | // corresponds to the lengt of the substring | ||
1526 | // needed (plus one of course). BUT, it | ||
1527 | // must be within bounds. | ||
1528 | if (end >= src.Length) | ||
1529 | { | ||
1530 | end = src.Length-1; | ||
1531 | } | ||
1532 | |||
1533 | if (start < 0) | ||
1534 | { | ||
1535 | return src.Substring(0,end+1); | ||
1536 | } | ||
1537 | // Both indices are positive | ||
1538 | return src.Substring(start, (end+1) - start); | ||
1539 | } | ||
1540 | |||
1541 | // Inverted substring (end < start) | ||
1542 | else | ||
1543 | { | ||
1544 | // Implies both indices are below the | ||
1545 | // lower bound. In the inverted case, that | ||
1546 | // means the entire string will be returned | ||
1547 | // unchanged. | ||
1548 | if (start < 0) | ||
1549 | { | ||
1550 | return src; | ||
1551 | } | ||
1552 | // If both indices are greater than the upper | ||
1553 | // bound the result may seem initially counter | ||
1554 | // intuitive. | ||
1555 | if (end >= src.Length) | ||
1556 | { | ||
1557 | return src; | ||
1558 | } | ||
1559 | |||
1560 | if (end < 0) | ||
1561 | { | ||
1562 | if (start < src.Length) | ||
1563 | { | ||
1564 | return src.Substring(start); | ||
1565 | } | ||
1566 | else | ||
1567 | { | ||
1568 | return String.Empty; | ||
1569 | } | ||
1570 | } | ||
1571 | else | ||
1572 | { | ||
1573 | if (start < src.Length) | ||
1574 | { | ||
1575 | return src.Substring(0,end+1) + src.Substring(start); | ||
1576 | } | ||
1577 | else | ||
1578 | { | ||
1579 | return src.Substring(0,end+1); | ||
1580 | } | ||
1581 | } | ||
1582 | } | ||
1583 | } | ||
1584 | |||
1585 | /// <summary> | ||
1586 | /// Delete substring removes the specified substring bounded | ||
1587 | /// by the inclusive indices start and end. Indices may be | ||
1588 | /// negative (indicating end-relative) and may be inverted, | ||
1589 | /// i.e. end < start. | ||
1590 | /// </summary> | ||
1591 | |||
1592 | public string llDeleteSubString(string src, int start, int end) | ||
1593 | { | ||
1594 | |||
1595 | m_host.AddScriptLPS(1); | ||
1596 | |||
1597 | // Normalize indices (if negative). | ||
1598 | // After normlaization they may still be | ||
1599 | // negative, but that is now relative to | ||
1600 | // the start, rather than the end, of the | ||
1601 | // sequence. | ||
1602 | if (start < 0) | ||
1603 | { | ||
1604 | start = src.Length+start; | ||
1605 | } | ||
1606 | if (end < 0) | ||
1607 | { | ||
1608 | end = src.Length+end; | ||
1609 | } | ||
1610 | // Conventionally delimited substring | ||
1611 | if (start <= end) | ||
1612 | { | ||
1613 | // If both bounds are outside of the existing | ||
1614 | // string, then return unchanges. | ||
1615 | if (end < 0 || start >= src.Length) | ||
1616 | { | ||
1617 | return src; | ||
1618 | } | ||
1619 | // At least one bound is in-range, so we | ||
1620 | // need to clip the out-of-bound argument. | ||
1621 | if (start < 0) | ||
1622 | { | ||
1623 | start = 0; | ||
1624 | } | ||
1625 | |||
1626 | if (end >= src.Length) | ||
1627 | { | ||
1628 | end = src.Length-1; | ||
1629 | } | ||
1630 | |||
1631 | return src.Remove(start,end-start+1); | ||
1632 | } | ||
1633 | // Inverted substring | ||
1634 | else | ||
1635 | { | ||
1636 | // In this case, out of bounds means that | ||
1637 | // the existing string is part of the cut. | ||
1638 | if (start < 0 || end >= src.Length) | ||
1639 | { | ||
1640 | return String.Empty; | ||
1641 | } | ||
1642 | |||
1643 | if (end > 0) | ||
1644 | { | ||
1645 | if (start < src.Length) | ||
1646 | { | ||
1647 | return src.Remove(start).Remove(0,end+1); | ||
1648 | } | ||
1649 | else | ||
1650 | { | ||
1651 | return src.Remove(0,end+1); | ||
1652 | } | ||
1653 | } | ||
1654 | else | ||
1655 | { | ||
1656 | if (start < src.Length) | ||
1657 | { | ||
1658 | return src.Remove(start); | ||
1659 | } | ||
1660 | else | ||
1661 | { | ||
1662 | return src; | ||
1663 | } | ||
1664 | } | ||
1665 | } | ||
1666 | } | ||
1667 | |||
1668 | /// <summary> | ||
1669 | /// Insert string inserts the specified string identified by src | ||
1670 | /// at the index indicated by index. Index may be negative, in | ||
1671 | /// which case it is end-relative. The index may exceed either | ||
1672 | /// string bound, with the result being a concatenation. | ||
1673 | /// </summary> | ||
1674 | |||
1675 | public string llInsertString(string dest, int index, string src) | ||
1676 | { | ||
1677 | |||
1678 | m_host.AddScriptLPS(1); | ||
1679 | |||
1680 | // Normalize indices (if negative). | ||
1681 | // After normlaization they may still be | ||
1682 | // negative, but that is now relative to | ||
1683 | // the start, rather than the end, of the | ||
1684 | // sequence. | ||
1685 | if (index < 0) | ||
1686 | { | ||
1687 | index = dest.Length+index; | ||
1688 | |||
1689 | // Negative now means it is less than the lower | ||
1690 | // bound of the string. | ||
1691 | |||
1692 | if (index < 0) | ||
1693 | { | ||
1694 | return src+dest; | ||
1695 | } | ||
1696 | |||
1697 | } | ||
1698 | |||
1699 | if (index >= dest.Length) | ||
1700 | { | ||
1701 | return dest+src; | ||
1702 | } | ||
1703 | |||
1704 | // The index is in bounds. | ||
1705 | // In this case the index refers to the index that will | ||
1706 | // be assigned to the first character of the inserted string. | ||
1707 | // So unlike the other string operations, we do not add one | ||
1708 | // to get the correct string length. | ||
1709 | return dest.Substring(0,index)+src+dest.Substring(index); | ||
1710 | |||
1711 | } | ||
1712 | |||
1713 | public string llToUpper(string src) | ||
1714 | { | ||
1715 | m_host.AddScriptLPS(1); | ||
1716 | return src.ToUpper(); | ||
1717 | } | ||
1718 | |||
1719 | public string llToLower(string src) | ||
1720 | { | ||
1721 | m_host.AddScriptLPS(1); | ||
1722 | return src.ToLower(); | ||
1723 | } | ||
1724 | |||
1725 | public LSL_Types.LSLInteger llGiveMoney(string destination, int amount) | ||
1726 | { | ||
1727 | LLUUID invItemID=InventorySelf(); | ||
1728 | if (invItemID == LLUUID.Zero) | ||
1729 | return 0; | ||
1730 | |||
1731 | m_host.AddScriptLPS(1); | ||
1732 | |||
1733 | if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) | ||
1734 | return 0; | ||
1735 | |||
1736 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) | ||
1737 | { | ||
1738 | LSLError("No permissions to give money"); | ||
1739 | return 0; | ||
1740 | } | ||
1741 | |||
1742 | LLUUID toID=new LLUUID(); | ||
1743 | |||
1744 | if (!LLUUID.TryParse(destination, out toID)) | ||
1745 | { | ||
1746 | LSLError("Bad key in llGiveMoney"); | ||
1747 | return 0; | ||
1748 | } | ||
1749 | |||
1750 | IMoneyModule money=World.RequestModuleInterface<IMoneyModule>(); | ||
1751 | |||
1752 | if (money == null) | ||
1753 | { | ||
1754 | NotImplemented("llGiveMoney"); | ||
1755 | return 0; | ||
1756 | } | ||
1757 | |||
1758 | bool result=money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | ||
1759 | |||
1760 | if (result) | ||
1761 | return 1; | ||
1762 | |||
1763 | return 0; | ||
1764 | } | ||
1765 | |||
1766 | public void llMakeExplosion() | ||
1767 | { | ||
1768 | m_host.AddScriptLPS(1); | ||
1769 | NotImplemented("llMakeExplosion"); | ||
1770 | } | ||
1771 | |||
1772 | public void llMakeFountain() | ||
1773 | { | ||
1774 | m_host.AddScriptLPS(1); | ||
1775 | NotImplemented("llMakeFountain"); | ||
1776 | } | ||
1777 | |||
1778 | public void llMakeSmoke() | ||
1779 | { | ||
1780 | m_host.AddScriptLPS(1); | ||
1781 | NotImplemented("llMakeSmoke"); | ||
1782 | } | ||
1783 | |||
1784 | public void llMakeFire() | ||
1785 | { | ||
1786 | m_host.AddScriptLPS(1); | ||
1787 | NotImplemented("llMakeFire"); | ||
1788 | } | ||
1789 | |||
1790 | public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Vector3 vel, LSL_Types.Quaternion rot, int param) | ||
1791 | { | ||
1792 | m_host.AddScriptLPS(1); | ||
1793 | //NotImplemented("llRezObject"); | ||
1794 | bool found = false; | ||
1795 | |||
1796 | // Instead of using return;, I'm using continue; because in our TaskInventory implementation | ||
1797 | // it's possible to have two items with the same task inventory name. | ||
1798 | // this is an easter egg of sorts. | ||
1799 | |||
1800 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
1801 | { | ||
1802 | if (inv.Value.Name == inventory) | ||
1803 | { | ||
1804 | // make sure we're an object. | ||
1805 | if (inv.Value.InvType != (int)InventoryType.Object) | ||
1806 | { | ||
1807 | llSay(0, "Unable to create requested object. Object is missing from database."); | ||
1808 | continue; | ||
1809 | } | ||
1810 | |||
1811 | LLVector3 llpos = new LLVector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
1812 | |||
1813 | // test if we're further away then 10m | ||
1814 | if (Util.GetDistanceTo(llpos, m_host.AbsolutePosition) > 10) | ||
1815 | return; // wiki says, if it's further away then 10m, silently fail. | ||
1816 | |||
1817 | LLVector3 llvel = new LLVector3((float)vel.x, (float)vel.y, (float)vel.z); | ||
1818 | |||
1819 | // need the magnitude later | ||
1820 | float velmag = (float)Util.GetMagnitude(llvel); | ||
1821 | |||
1822 | SceneObjectGroup new_group = World.RezObject(inv.Value, llpos, new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), llvel, param); | ||
1823 | |||
1824 | // If either of these are null, then there was an unknown error. | ||
1825 | if (new_group == null) | ||
1826 | continue; | ||
1827 | if (new_group.RootPart == null) | ||
1828 | continue; | ||
1829 | |||
1830 | // objects rezzed with this method are die_at_edge by default. | ||
1831 | new_group.RootPart.SetDieAtEdge(true); | ||
1832 | |||
1833 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
1834 | "object_rez", new Object[] { | ||
1835 | new LSL_Types.LSLString( | ||
1836 | new_group.RootPart.UUID.ToString()) }, | ||
1837 | new DetectParams[0])); | ||
1838 | |||
1839 | float groupmass = new_group.GetMass(); | ||
1840 | |||
1841 | //Recoil. | ||
1842 | llApplyImpulse(new LSL_Types.Vector3(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); | ||
1843 | found = true; | ||
1844 | //script delay | ||
1845 | System.Threading.Thread.Sleep((int)((groupmass * velmag) / 10)); | ||
1846 | break; | ||
1847 | } | ||
1848 | } | ||
1849 | if (!found) | ||
1850 | llSay(0, "Could not find object " + inventory); | ||
1851 | } | ||
1852 | |||
1853 | public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) | ||
1854 | { | ||
1855 | m_host.AddScriptLPS(1); | ||
1856 | NotImplemented("llLookAt"); | ||
1857 | } | ||
1858 | |||
1859 | public void llStopLookAt() | ||
1860 | { | ||
1861 | m_host.AddScriptLPS(1); | ||
1862 | NotImplemented("llStopLookAt"); | ||
1863 | } | ||
1864 | |||
1865 | public void llSetTimerEvent(double sec) | ||
1866 | { | ||
1867 | m_host.AddScriptLPS(1); | ||
1868 | // Setting timer repeat | ||
1869 | AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); | ||
1870 | } | ||
1871 | |||
1872 | public void llSleep(double sec) | ||
1873 | { | ||
1874 | m_host.AddScriptLPS(1); | ||
1875 | Thread.Sleep((int)(sec * 1000)); | ||
1876 | } | ||
1877 | |||
1878 | public double llGetMass() | ||
1879 | { | ||
1880 | m_host.AddScriptLPS(1); | ||
1881 | return m_host.GetMass(); | ||
1882 | } | ||
1883 | |||
1884 | public void llCollisionFilter(string name, string id, int accept) | ||
1885 | { | ||
1886 | m_host.AddScriptLPS(1); | ||
1887 | NotImplemented("llCollisionFilter"); | ||
1888 | } | ||
1889 | |||
1890 | public void llTakeControls(int controls, int accept, int pass_on) | ||
1891 | { | ||
1892 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
1893 | { | ||
1894 | return; | ||
1895 | } | ||
1896 | |||
1897 | if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero) | ||
1898 | { | ||
1899 | ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter); | ||
1900 | |||
1901 | if (presence != null) | ||
1902 | { | ||
1903 | if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | ||
1904 | { | ||
1905 | presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); | ||
1906 | |||
1907 | } | ||
1908 | } | ||
1909 | } | ||
1910 | |||
1911 | m_host.AddScriptLPS(1); | ||
1912 | //NotImplemented("llTakeControls"); | ||
1913 | } | ||
1914 | |||
1915 | public void llReleaseControls() | ||
1916 | { | ||
1917 | m_host.AddScriptLPS(1); | ||
1918 | |||
1919 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
1920 | { | ||
1921 | return; | ||
1922 | } | ||
1923 | |||
1924 | if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero) | ||
1925 | { | ||
1926 | ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter); | ||
1927 | |||
1928 | if (presence != null) | ||
1929 | { | ||
1930 | if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | ||
1931 | { | ||
1932 | // Unregister controls from Presence | ||
1933 | presence.UnRegisterControlEventsToScript(m_localID, m_itemID); | ||
1934 | // Remove Take Control permission. | ||
1935 | m_host.TaskInventory[InventorySelf()].PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | ||
1936 | } | ||
1937 | } | ||
1938 | } | ||
1939 | } | ||
1940 | |||
1941 | public void llAttachToAvatar(int attachment) | ||
1942 | { | ||
1943 | m_host.AddScriptLPS(1); | ||
1944 | NotImplemented("llAttachToAvatar"); | ||
1945 | } | ||
1946 | |||
1947 | public void llDetachFromAvatar() | ||
1948 | { | ||
1949 | m_host.AddScriptLPS(1); | ||
1950 | NotImplemented("llDetachFromAvatar"); | ||
1951 | } | ||
1952 | |||
1953 | public void llTakeCamera() | ||
1954 | { | ||
1955 | m_host.AddScriptLPS(1); | ||
1956 | NotImplemented("llTakeCamera"); | ||
1957 | } | ||
1958 | |||
1959 | public void llReleaseCamera() | ||
1960 | { | ||
1961 | m_host.AddScriptLPS(1); | ||
1962 | NotImplemented("llReleaseCamera"); | ||
1963 | } | ||
1964 | |||
1965 | public string llGetOwner() | ||
1966 | { | ||
1967 | m_host.AddScriptLPS(1); | ||
1968 | |||
1969 | return m_host.ObjectOwner.ToString(); | ||
1970 | } | ||
1971 | |||
1972 | public void llInstantMessage(string user, string message) | ||
1973 | { | ||
1974 | m_host.AddScriptLPS(1); | ||
1975 | |||
1976 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | ||
1977 | // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent, | ||
1978 | // but I don't think we have a list of scenes available from here. | ||
1979 | // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.) | ||
1980 | |||
1981 | // user is a UUID | ||
1982 | |||
1983 | // TODO: figure out values for client, fromSession, and imSessionID | ||
1984 | // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); | ||
1985 | LLUUID friendTransactionID = LLUUID.Random(); | ||
1986 | |||
1987 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | ||
1988 | |||
1989 | GridInstantMessage msg = new GridInstantMessage(); | ||
1990 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.UUID; | ||
1991 | msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID; | ||
1992 | msg.toAgentID = new Guid(user); // toAgentID.UUID; | ||
1993 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | ||
1994 | // Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | ||
1995 | // Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | ||
1996 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | ||
1997 | //if (client != null) | ||
1998 | //{ | ||
1999 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | ||
2000 | //} | ||
2001 | //else | ||
2002 | //{ | ||
2003 | // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it | ||
2004 | //} | ||
2005 | msg.message = message; | ||
2006 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | ||
2007 | msg.fromGroup = false;// fromGroup; | ||
2008 | msg.offline = (byte)0; //offline; | ||
2009 | msg.ParentEstateID = 0; //ParentEstateID; | ||
2010 | msg.Position = new sLLVector3();// new sLLVector3(m_host.AbsolutePosition); | ||
2011 | msg.RegionID = World.RegionInfo.RegionID.UUID;//RegionID.UUID; | ||
2012 | msg.binaryBucket = new byte[0];// binaryBucket; | ||
2013 | World.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); | ||
2014 | // NotImplemented("llInstantMessage"); | ||
2015 | } | ||
2016 | |||
2017 | public void llEmail(string address, string subject, string message) | ||
2018 | { | ||
2019 | m_host.AddScriptLPS(1); | ||
2020 | NotImplemented("llEmail"); | ||
2021 | } | ||
2022 | |||
2023 | public void llGetNextEmail(string address, string subject) | ||
2024 | { | ||
2025 | m_host.AddScriptLPS(1); | ||
2026 | NotImplemented("llGetNextEmail"); | ||
2027 | } | ||
2028 | |||
2029 | public string llGetKey() | ||
2030 | { | ||
2031 | m_host.AddScriptLPS(1); | ||
2032 | return m_host.UUID.ToString(); | ||
2033 | } | ||
2034 | |||
2035 | public void llSetBuoyancy(double buoyancy) | ||
2036 | { | ||
2037 | m_host.AddScriptLPS(1); | ||
2038 | if (m_host.ParentGroup != null) | ||
2039 | { | ||
2040 | if (m_host.ParentGroup.RootPart != null) | ||
2041 | { | ||
2042 | m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); | ||
2043 | } | ||
2044 | } | ||
2045 | } | ||
2046 | |||
2047 | |||
2048 | |||
2049 | public void llSetHoverHeight(double height, int water, double tau) | ||
2050 | { | ||
2051 | m_host.AddScriptLPS(1); | ||
2052 | NotImplemented("llSetHoverHeight"); | ||
2053 | } | ||
2054 | |||
2055 | public void llStopHover() | ||
2056 | { | ||
2057 | m_host.AddScriptLPS(1); | ||
2058 | NotImplemented("llStopHover"); | ||
2059 | } | ||
2060 | |||
2061 | public void llMinEventDelay(double delay) | ||
2062 | { | ||
2063 | m_host.AddScriptLPS(1); | ||
2064 | NotImplemented("llMinEventDelay"); | ||
2065 | } | ||
2066 | |||
2067 | public void llSoundPreload() | ||
2068 | { | ||
2069 | m_host.AddScriptLPS(1); | ||
2070 | NotImplemented("llSoundPreload"); | ||
2071 | } | ||
2072 | |||
2073 | public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) | ||
2074 | { | ||
2075 | m_host.AddScriptLPS(1); | ||
2076 | NotImplemented("llRotLookAt"); | ||
2077 | } | ||
2078 | |||
2079 | public LSL_Types.LSLInteger llStringLength(string str) | ||
2080 | { | ||
2081 | m_host.AddScriptLPS(1); | ||
2082 | if (str.Length > 0) | ||
2083 | { | ||
2084 | return str.Length; | ||
2085 | } | ||
2086 | else | ||
2087 | { | ||
2088 | return 0; | ||
2089 | } | ||
2090 | } | ||
2091 | |||
2092 | public void llStartAnimation(string anim) | ||
2093 | { | ||
2094 | m_host.AddScriptLPS(1); | ||
2095 | |||
2096 | LLUUID invItemID=InventorySelf(); | ||
2097 | if (invItemID == LLUUID.Zero) | ||
2098 | return; | ||
2099 | |||
2100 | if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) | ||
2101 | return; | ||
2102 | |||
2103 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | ||
2104 | { | ||
2105 | ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter); | ||
2106 | |||
2107 | if (presence != null) | ||
2108 | { | ||
2109 | // Do NOT try to parse LLUUID, animations cannot be triggered by ID | ||
2110 | LLUUID animID=InventoryKey(anim, (int)AssetType.Animation); | ||
2111 | if (animID == LLUUID.Zero) | ||
2112 | presence.AddAnimation(anim); | ||
2113 | else | ||
2114 | presence.AddAnimation(animID); | ||
2115 | } | ||
2116 | } | ||
2117 | } | ||
2118 | |||
2119 | public void llStopAnimation(string anim) | ||
2120 | { | ||
2121 | m_host.AddScriptLPS(1); | ||
2122 | |||
2123 | LLUUID invItemID=InventorySelf(); | ||
2124 | if (invItemID == LLUUID.Zero) | ||
2125 | return; | ||
2126 | |||
2127 | if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero) | ||
2128 | return; | ||
2129 | |||
2130 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | ||
2131 | { | ||
2132 | LLUUID animID = new LLUUID(); | ||
2133 | |||
2134 | if (!LLUUID.TryParse(anim, out animID)) | ||
2135 | { | ||
2136 | animID=InventoryKey(anim); | ||
2137 | } | ||
2138 | |||
2139 | if (animID == LLUUID.Zero) | ||
2140 | return; | ||
2141 | |||
2142 | ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter); | ||
2143 | |||
2144 | if (presence != null) | ||
2145 | { | ||
2146 | if (animID == LLUUID.Zero) | ||
2147 | presence.RemoveAnimation(anim); | ||
2148 | else | ||
2149 | presence.RemoveAnimation(animID); | ||
2150 | } | ||
2151 | } | ||
2152 | } | ||
2153 | |||
2154 | public void llPointAt() | ||
2155 | { | ||
2156 | m_host.AddScriptLPS(1); | ||
2157 | NotImplemented("llPointAt"); | ||
2158 | } | ||
2159 | |||
2160 | public void llStopPointAt() | ||
2161 | { | ||
2162 | m_host.AddScriptLPS(1); | ||
2163 | NotImplemented("llStopPointAt"); | ||
2164 | } | ||
2165 | |||
2166 | public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) | ||
2167 | { | ||
2168 | m_host.AddScriptLPS(1); | ||
2169 | m_host.RotationalVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); | ||
2170 | m_host.AngularVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); | ||
2171 | m_host.ScheduleTerseUpdate(); | ||
2172 | m_host.SendTerseUpdateToAllClients(); | ||
2173 | } | ||
2174 | |||
2175 | public LSL_Types.LSLInteger llGetStartParameter() | ||
2176 | { | ||
2177 | m_host.AddScriptLPS(1); | ||
2178 | // NotImplemented("llGetStartParameter"); | ||
2179 | return m_host.ParentGroup.StartParameter; | ||
2180 | } | ||
2181 | |||
2182 | public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) | ||
2183 | { | ||
2184 | m_host.AddScriptLPS(1); | ||
2185 | NotImplemented("llGodLikeRezObject"); | ||
2186 | } | ||
2187 | |||
2188 | public void llRequestPermissions(string agent, int perm) | ||
2189 | { | ||
2190 | LLUUID agentID=new LLUUID(); | ||
2191 | |||
2192 | if (!LLUUID.TryParse(agent, out agentID)) | ||
2193 | return; | ||
2194 | |||
2195 | LLUUID invItemID=InventorySelf(); | ||
2196 | |||
2197 | if (invItemID == LLUUID.Zero) | ||
2198 | return; // Not in a prim? How?? | ||
2199 | |||
2200 | if (agentID == LLUUID.Zero || perm == 0) // Releasing permissions | ||
2201 | { | ||
2202 | m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero; | ||
2203 | m_host.TaskInventory[invItemID].PermsMask=0; | ||
2204 | |||
2205 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
2206 | "run_time_permissions", new Object[] { | ||
2207 | new LSL_Types.LSLInteger(0) }, | ||
2208 | new DetectParams[0])); | ||
2209 | |||
2210 | return; | ||
2211 | } | ||
2212 | |||
2213 | m_host.AddScriptLPS(1); | ||
2214 | |||
2215 | if (m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar) | ||
2216 | { | ||
2217 | // When attached, certain permissions are implicit if requested from owner | ||
2218 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | ||
2219 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | ||
2220 | ScriptBaseClass.PERMISSION_ATTACH; | ||
2221 | |||
2222 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | ||
2223 | { | ||
2224 | m_host.TaskInventory[invItemID].PermsGranter=agentID; | ||
2225 | m_host.TaskInventory[invItemID].PermsMask=perm; | ||
2226 | |||
2227 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
2228 | "run_time_permissions", new Object[] { | ||
2229 | new LSL_Types.LSLInteger(perm) }, | ||
2230 | new DetectParams[0])); | ||
2231 | |||
2232 | return; | ||
2233 | } | ||
2234 | } | ||
2235 | else if (m_host.m_sitTargetAvatar == agentID) // Sitting avatar | ||
2236 | { | ||
2237 | // When agent is sitting, certain permissions are implicit if requested from sitting agent | ||
2238 | int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | ||
2239 | ScriptBaseClass.PERMISSION_TRACK_CAMERA; | ||
2240 | |||
2241 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | ||
2242 | { | ||
2243 | m_host.TaskInventory[invItemID].PermsGranter=agentID; | ||
2244 | m_host.TaskInventory[invItemID].PermsMask=perm; | ||
2245 | |||
2246 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
2247 | "run_time_permissions", new Object[] { | ||
2248 | new LSL_Types.LSLInteger(perm) }, | ||
2249 | new DetectParams[0])); | ||
2250 | |||
2251 | return; | ||
2252 | } | ||
2253 | } | ||
2254 | |||
2255 | ScenePresence presence = World.GetScenePresence(agentID); | ||
2256 | |||
2257 | if (presence != null) | ||
2258 | { | ||
2259 | string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID); | ||
2260 | if (ownerName == String.Empty) | ||
2261 | ownerName="(hippos)"; | ||
2262 | |||
2263 | if (!m_waitingForScriptAnswer) | ||
2264 | { | ||
2265 | m_host.TaskInventory[invItemID].PermsGranter=agentID; | ||
2266 | m_host.TaskInventory[invItemID].PermsMask=0; | ||
2267 | presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer; | ||
2268 | m_waitingForScriptAnswer=true; | ||
2269 | } | ||
2270 | |||
2271 | presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); | ||
2272 | return; | ||
2273 | } | ||
2274 | |||
2275 | // Requested agent is not in range, refuse perms | ||
2276 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
2277 | "run_time_permissions", new Object[] { | ||
2278 | new LSL_Types.LSLInteger(0) }, | ||
2279 | new DetectParams[0])); | ||
2280 | } | ||
2281 | |||
2282 | void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer) | ||
2283 | { | ||
2284 | if (taskID != m_host.UUID) | ||
2285 | return; | ||
2286 | |||
2287 | LLUUID invItemID=InventorySelf(); | ||
2288 | |||
2289 | if (invItemID == LLUUID.Zero) | ||
2290 | return; | ||
2291 | |||
2292 | client.OnScriptAnswer-=handleScriptAnswer; | ||
2293 | m_waitingForScriptAnswer=false; | ||
2294 | |||
2295 | m_host.TaskInventory[invItemID].PermsMask=answer; | ||
2296 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
2297 | "run_time_permissions", new Object[] { | ||
2298 | new LSL_Types.LSLInteger(answer) }, | ||
2299 | new DetectParams[0])); | ||
2300 | } | ||
2301 | |||
2302 | public string llGetPermissionsKey() | ||
2303 | { | ||
2304 | m_host.AddScriptLPS(1); | ||
2305 | |||
2306 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
2307 | { | ||
2308 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
2309 | { | ||
2310 | return item.PermsGranter.ToString(); | ||
2311 | } | ||
2312 | } | ||
2313 | |||
2314 | return LLUUID.Zero.ToString(); | ||
2315 | } | ||
2316 | |||
2317 | public LSL_Types.LSLInteger llGetPermissions() | ||
2318 | { | ||
2319 | m_host.AddScriptLPS(1); | ||
2320 | |||
2321 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
2322 | { | ||
2323 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
2324 | { | ||
2325 | return item.PermsMask; | ||
2326 | } | ||
2327 | } | ||
2328 | |||
2329 | return 0; | ||
2330 | } | ||
2331 | |||
2332 | public LSL_Types.LSLInteger llGetLinkNumber() | ||
2333 | { | ||
2334 | m_host.AddScriptLPS(1); | ||
2335 | |||
2336 | if (m_host.ParentGroup.Children.Count > 0) | ||
2337 | { | ||
2338 | return m_host.LinkNum + 1; | ||
2339 | } | ||
2340 | else | ||
2341 | { | ||
2342 | return 0; | ||
2343 | } | ||
2344 | } | ||
2345 | |||
2346 | public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) | ||
2347 | { | ||
2348 | m_host.AddScriptLPS(1); | ||
2349 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber); | ||
2350 | if (linknumber > -1) | ||
2351 | { | ||
2352 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
2353 | LLColor texcolor; | ||
2354 | if (face > -1) | ||
2355 | { | ||
2356 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
2357 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2358 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2359 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2360 | tex.FaceTextures[face].RGBA = texcolor; | ||
2361 | part.UpdateTexture(tex); | ||
2362 | return; | ||
2363 | } | ||
2364 | else if (face == -1) | ||
2365 | { | ||
2366 | texcolor = tex.DefaultTexture.RGBA; | ||
2367 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2368 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2369 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2370 | tex.DefaultTexture.RGBA = texcolor; | ||
2371 | for (uint i = 0; i < 32; i++) | ||
2372 | { | ||
2373 | if (tex.FaceTextures[i] != null) | ||
2374 | { | ||
2375 | texcolor = tex.FaceTextures[i].RGBA; | ||
2376 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2377 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2378 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2379 | tex.FaceTextures[i].RGBA = texcolor; | ||
2380 | } | ||
2381 | } | ||
2382 | texcolor = tex.DefaultTexture.RGBA; | ||
2383 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2384 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2385 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2386 | tex.DefaultTexture.RGBA = texcolor; | ||
2387 | part.UpdateTexture(tex); | ||
2388 | return; | ||
2389 | } | ||
2390 | return; | ||
2391 | } | ||
2392 | else if (linknumber == -1) | ||
2393 | { | ||
2394 | int num = m_host.ParentGroup.PrimCount; | ||
2395 | for (int w = 0; w < num; w++) | ||
2396 | { | ||
2397 | linknumber = w; | ||
2398 | part = m_host.ParentGroup.GetLinkNumPart(linknumber); | ||
2399 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
2400 | LLColor texcolor; | ||
2401 | if (face > -1) | ||
2402 | { | ||
2403 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
2404 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2405 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2406 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2407 | tex.FaceTextures[face].RGBA = texcolor; | ||
2408 | part.UpdateTexture(tex); | ||
2409 | } | ||
2410 | else if (face == -1) | ||
2411 | { | ||
2412 | texcolor = tex.DefaultTexture.RGBA; | ||
2413 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2414 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2415 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2416 | tex.DefaultTexture.RGBA = texcolor; | ||
2417 | for (uint i = 0; i < 32; i++) | ||
2418 | { | ||
2419 | if (tex.FaceTextures[i] != null) | ||
2420 | { | ||
2421 | texcolor = tex.FaceTextures[i].RGBA; | ||
2422 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2423 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2424 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2425 | tex.FaceTextures[i].RGBA = texcolor; | ||
2426 | } | ||
2427 | } | ||
2428 | texcolor = tex.DefaultTexture.RGBA; | ||
2429 | texcolor.R = (float)Math.Abs(color.x - 1); | ||
2430 | texcolor.G = (float)Math.Abs(color.y - 1); | ||
2431 | texcolor.B = (float)Math.Abs(color.z - 1); | ||
2432 | tex.DefaultTexture.RGBA = texcolor; | ||
2433 | part.UpdateTexture(tex); | ||
2434 | } | ||
2435 | } | ||
2436 | return; | ||
2437 | } | ||
2438 | } | ||
2439 | |||
2440 | public void llCreateLink(string target, int parent) | ||
2441 | { | ||
2442 | m_host.AddScriptLPS(1); | ||
2443 | NotImplemented("llCreateLink"); | ||
2444 | } | ||
2445 | |||
2446 | public void llBreakLink(int linknum) | ||
2447 | { | ||
2448 | m_host.AddScriptLPS(1); | ||
2449 | NotImplemented("llBreakLink"); | ||
2450 | } | ||
2451 | |||
2452 | public void llBreakAllLinks() | ||
2453 | { | ||
2454 | m_host.AddScriptLPS(1); | ||
2455 | NotImplemented("llBreakAllLinks"); | ||
2456 | } | ||
2457 | |||
2458 | public string llGetLinkKey(int linknum) | ||
2459 | { | ||
2460 | m_host.AddScriptLPS(1); | ||
2461 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | ||
2462 | if (part != null) | ||
2463 | { | ||
2464 | return part.UUID.ToString(); | ||
2465 | } | ||
2466 | else | ||
2467 | { | ||
2468 | return LLUUID.Zero.ToString(); | ||
2469 | } | ||
2470 | } | ||
2471 | |||
2472 | public string llGetLinkName(int linknum) | ||
2473 | { | ||
2474 | m_host.AddScriptLPS(1); | ||
2475 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | ||
2476 | if (part != null) | ||
2477 | { | ||
2478 | return part.Name; | ||
2479 | } | ||
2480 | else | ||
2481 | { | ||
2482 | return LLUUID.Zero.ToString(); | ||
2483 | } | ||
2484 | } | ||
2485 | |||
2486 | public LSL_Types.LSLInteger llGetInventoryNumber(int type) | ||
2487 | { | ||
2488 | m_host.AddScriptLPS(1); | ||
2489 | int count = 0; | ||
2490 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
2491 | { | ||
2492 | if (inv.Value.Type == type || type == -1) | ||
2493 | { | ||
2494 | count = count + 1; | ||
2495 | } | ||
2496 | } | ||
2497 | return count; | ||
2498 | } | ||
2499 | |||
2500 | public string llGetInventoryName(int type, int number) | ||
2501 | { | ||
2502 | m_host.AddScriptLPS(1); | ||
2503 | ArrayList keys = new ArrayList(); | ||
2504 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
2505 | { | ||
2506 | if (inv.Value.Type == type || type == -1) | ||
2507 | { | ||
2508 | keys.Add(inv.Value.Name); | ||
2509 | } | ||
2510 | } | ||
2511 | if (keys.Count == 0) | ||
2512 | { | ||
2513 | return String.Empty; | ||
2514 | } | ||
2515 | keys.Sort(); | ||
2516 | if (keys.Count > number) | ||
2517 | { | ||
2518 | return (string)keys[number]; | ||
2519 | } | ||
2520 | return String.Empty; | ||
2521 | } | ||
2522 | |||
2523 | public void llSetScriptState(string name, int run) | ||
2524 | { | ||
2525 | LLUUID item; | ||
2526 | |||
2527 | m_host.AddScriptLPS(1); | ||
2528 | |||
2529 | // These functions are supposed to be robust, | ||
2530 | // so get the state one step at a time. | ||
2531 | |||
2532 | if ((item = ScriptByName(name)) != LLUUID.Zero) | ||
2533 | { | ||
2534 | m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); | ||
2535 | } | ||
2536 | else | ||
2537 | { | ||
2538 | ShoutError("llSetScriptState: script "+name+" not found"); | ||
2539 | } | ||
2540 | } | ||
2541 | |||
2542 | public double llGetEnergy() | ||
2543 | { | ||
2544 | m_host.AddScriptLPS(1); | ||
2545 | // TODO: figure out real energy value | ||
2546 | return 1.0f; | ||
2547 | } | ||
2548 | |||
2549 | public void llGiveInventory(string destination, string inventory) | ||
2550 | { | ||
2551 | m_host.AddScriptLPS(1); | ||
2552 | NotImplemented("llGiveInventory"); | ||
2553 | } | ||
2554 | |||
2555 | public void llRemoveInventory(string item) | ||
2556 | { | ||
2557 | m_host.AddScriptLPS(1); | ||
2558 | NotImplemented("llRemoveInventory"); | ||
2559 | } | ||
2560 | |||
2561 | public void llSetText(string text, LSL_Types.Vector3 color, double alpha) | ||
2562 | { | ||
2563 | m_host.AddScriptLPS(1); | ||
2564 | Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z); | ||
2565 | m_host.SetText(text, av3, alpha); | ||
2566 | } | ||
2567 | |||
2568 | public double llWater(LSL_Types.Vector3 offset) | ||
2569 | { | ||
2570 | m_host.AddScriptLPS(1); | ||
2571 | return World.RegionInfo.EstateSettings.waterHeight; | ||
2572 | } | ||
2573 | |||
2574 | public void llPassTouches(int pass) | ||
2575 | { | ||
2576 | m_host.AddScriptLPS(1); | ||
2577 | NotImplemented("llPassTouches"); | ||
2578 | } | ||
2579 | |||
2580 | public string llRequestAgentData(string id, int data) | ||
2581 | { | ||
2582 | m_host.AddScriptLPS(1); | ||
2583 | |||
2584 | UserProfileData userProfile = | ||
2585 | World.CommsManager.UserService.GetUserProfile(id); | ||
2586 | |||
2587 | UserAgentData userAgent = | ||
2588 | World.CommsManager.UserService.GetAgentByUUID(id); | ||
2589 | |||
2590 | if (userProfile == null || userAgent == null) | ||
2591 | return LLUUID.Zero.ToString(); | ||
2592 | |||
2593 | string reply = String.Empty; | ||
2594 | |||
2595 | switch (data) | ||
2596 | { | ||
2597 | case 1: // DATA_ONLINE (0|1) | ||
2598 | // TODO: implement fetching of this information | ||
2599 | if (userProfile.CurrentAgent.AgentOnline) | ||
2600 | reply = "1"; | ||
2601 | else | ||
2602 | reply = "0"; | ||
2603 | break; | ||
2604 | case 2: // DATA_NAME (First Last) | ||
2605 | reply = userProfile.FirstName + " " + userProfile.SurName; | ||
2606 | break; | ||
2607 | case 3: // DATA_BORN (YYYY-MM-DD) | ||
2608 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | ||
2609 | born = born.AddSeconds(userProfile.Created); | ||
2610 | reply = born.ToString("yyyy-MM-dd"); | ||
2611 | break; | ||
2612 | case 4: // DATA_RATING (0,0,0,0,0,0) | ||
2613 | reply = "0,0,0,0,0,0"; | ||
2614 | break; | ||
2615 | case 8: // DATA_PAYINFO (0|1|2|3) | ||
2616 | reply = "0"; | ||
2617 | break; | ||
2618 | default: | ||
2619 | return LLUUID.Zero.ToString(); // Raise no event | ||
2620 | } | ||
2621 | |||
2622 | LLUUID rq = LLUUID.Random(); | ||
2623 | |||
2624 | LLUUID tid = AsyncCommands. | ||
2625 | DataserverPlugin.RegisterRequest(m_localID, | ||
2626 | m_itemID, rq.ToString()); | ||
2627 | |||
2628 | AsyncCommands. | ||
2629 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | ||
2630 | |||
2631 | return tid.ToString(); | ||
2632 | } | ||
2633 | |||
2634 | public string llRequestInventoryData(string name) | ||
2635 | { | ||
2636 | m_host.AddScriptLPS(1); | ||
2637 | |||
2638 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
2639 | { | ||
2640 | if (item.Type == 3 && item.Name == name) | ||
2641 | { | ||
2642 | LLUUID tid = AsyncCommands. | ||
2643 | DataserverPlugin.RegisterRequest(m_localID, | ||
2644 | m_itemID, item.AssetID.ToString()); | ||
2645 | |||
2646 | LLVector3 region = new LLVector3( | ||
2647 | World.RegionInfo.RegionLocX * Constants.RegionSize, | ||
2648 | World.RegionInfo.RegionLocY * Constants.RegionSize, | ||
2649 | 0); | ||
2650 | |||
2651 | World.AssetCache.GetAsset(item.AssetID, | ||
2652 | delegate(LLUUID i, AssetBase a) | ||
2653 | { | ||
2654 | AssetLandmark lm = new AssetLandmark(a); | ||
2655 | |||
2656 | region += lm.Position; | ||
2657 | |||
2658 | string reply = region.ToString(); | ||
2659 | |||
2660 | AsyncCommands. | ||
2661 | DataserverPlugin.DataserverReply(i.ToString(), | ||
2662 | reply); | ||
2663 | }, false); | ||
2664 | |||
2665 | return tid.ToString(); | ||
2666 | } | ||
2667 | } | ||
2668 | |||
2669 | return String.Empty; | ||
2670 | } | ||
2671 | |||
2672 | public void llSetDamage(double damage) | ||
2673 | { | ||
2674 | m_host.AddScriptLPS(1); | ||
2675 | NotImplemented("llSetDamage"); | ||
2676 | } | ||
2677 | |||
2678 | public void llTeleportAgentHome(string agent) | ||
2679 | { | ||
2680 | m_host.AddScriptLPS(1); | ||
2681 | NotImplemented("llTeleportAgentHome"); | ||
2682 | } | ||
2683 | |||
2684 | public void llModifyLand(int action, int brush) | ||
2685 | { | ||
2686 | m_host.AddScriptLPS(1); | ||
2687 | World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0)); | ||
2688 | } | ||
2689 | |||
2690 | public void llCollisionSound(string impact_sound, double impact_volume) | ||
2691 | { | ||
2692 | m_host.AddScriptLPS(1); | ||
2693 | NotImplemented("llCollisionSound"); | ||
2694 | } | ||
2695 | |||
2696 | public void llCollisionSprite(string impact_sprite) | ||
2697 | { | ||
2698 | m_host.AddScriptLPS(1); | ||
2699 | NotImplemented("llCollisionSprite"); | ||
2700 | } | ||
2701 | |||
2702 | public string llGetAnimation(string id) | ||
2703 | { | ||
2704 | m_host.AddScriptLPS(1); | ||
2705 | NotImplemented("llGetAnimation"); | ||
2706 | return String.Empty; | ||
2707 | } | ||
2708 | |||
2709 | public void llResetScript() | ||
2710 | { | ||
2711 | m_host.AddScriptLPS(1); | ||
2712 | m_ScriptEngine.ResetScript(m_itemID); | ||
2713 | } | ||
2714 | |||
2715 | public void llMessageLinked(int linknum, int num, string msg, string id) | ||
2716 | { | ||
2717 | |||
2718 | m_host.AddScriptLPS(1); | ||
2719 | |||
2720 | uint partLocalID; | ||
2721 | LLUUID partItemID; | ||
2722 | |||
2723 | switch ((int)linknum) | ||
2724 | { | ||
2725 | |||
2726 | case (int)ScriptBaseClass.LINK_ROOT: | ||
2727 | |||
2728 | SceneObjectPart part = m_host.ParentGroup.RootPart; | ||
2729 | |||
2730 | foreach (TaskInventoryItem item in part.TaskInventory.Values) | ||
2731 | { | ||
2732 | if (item.Type == 10) | ||
2733 | { | ||
2734 | partLocalID = part.LocalId; | ||
2735 | partItemID = item.ItemID; | ||
2736 | |||
2737 | object[] resobj = new object[] | ||
2738 | { | ||
2739 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2740 | }; | ||
2741 | |||
2742 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2743 | new EventParams("link_message", | ||
2744 | resobj, new DetectParams[0])); | ||
2745 | } | ||
2746 | } | ||
2747 | |||
2748 | break; | ||
2749 | |||
2750 | case (int)ScriptBaseClass.LINK_SET: | ||
2751 | |||
2752 | foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) | ||
2753 | { | ||
2754 | |||
2755 | foreach (TaskInventoryItem item in partInst.TaskInventory.Values) | ||
2756 | { | ||
2757 | if (item.Type == 10) | ||
2758 | { | ||
2759 | partLocalID = partInst.LocalId; | ||
2760 | partItemID = item.ItemID; | ||
2761 | Object[] resobj = new object[] | ||
2762 | { | ||
2763 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2764 | }; | ||
2765 | |||
2766 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2767 | new EventParams("link_message", | ||
2768 | resobj, new DetectParams[0])); | ||
2769 | } | ||
2770 | } | ||
2771 | } | ||
2772 | |||
2773 | break; | ||
2774 | |||
2775 | case (int)ScriptBaseClass.LINK_ALL_OTHERS: | ||
2776 | |||
2777 | foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) | ||
2778 | { | ||
2779 | |||
2780 | if (partInst.LocalId != m_host.LocalId) | ||
2781 | { | ||
2782 | |||
2783 | foreach (TaskInventoryItem item in partInst.TaskInventory.Values) | ||
2784 | { | ||
2785 | if (item.Type == 10) | ||
2786 | { | ||
2787 | partLocalID = partInst.LocalId; | ||
2788 | partItemID = item.ItemID; | ||
2789 | Object[] resobj = new object[] | ||
2790 | { | ||
2791 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2792 | }; | ||
2793 | |||
2794 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2795 | new EventParams("link_message", | ||
2796 | resobj, new DetectParams[0])); | ||
2797 | } | ||
2798 | } | ||
2799 | |||
2800 | } | ||
2801 | } | ||
2802 | |||
2803 | break; | ||
2804 | |||
2805 | case (int)ScriptBaseClass.LINK_ALL_CHILDREN: | ||
2806 | |||
2807 | foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) | ||
2808 | { | ||
2809 | |||
2810 | if (partInst.LocalId != m_host.ParentGroup.RootPart.LocalId) | ||
2811 | { | ||
2812 | |||
2813 | foreach (TaskInventoryItem item in partInst.TaskInventory.Values) | ||
2814 | { | ||
2815 | if (item.Type == 10) | ||
2816 | { | ||
2817 | partLocalID = partInst.LocalId; | ||
2818 | partItemID = item.ItemID; | ||
2819 | Object[] resobj = new object[] | ||
2820 | { | ||
2821 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2822 | }; | ||
2823 | |||
2824 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2825 | new EventParams("link_message", | ||
2826 | resobj, new DetectParams[0])); | ||
2827 | } | ||
2828 | } | ||
2829 | |||
2830 | } | ||
2831 | } | ||
2832 | |||
2833 | break; | ||
2834 | |||
2835 | case (int)ScriptBaseClass.LINK_THIS: | ||
2836 | |||
2837 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
2838 | { | ||
2839 | if (item.Type == 10) | ||
2840 | { | ||
2841 | partItemID = item.ItemID; | ||
2842 | |||
2843 | object[] resobj = new object[] | ||
2844 | { | ||
2845 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2846 | }; | ||
2847 | |||
2848 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2849 | new EventParams("link_message", | ||
2850 | resobj, new DetectParams[0])); | ||
2851 | } | ||
2852 | } | ||
2853 | |||
2854 | break; | ||
2855 | |||
2856 | default: | ||
2857 | |||
2858 | foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) | ||
2859 | { | ||
2860 | |||
2861 | if ((partInst.LinkNum + 1) == linknum) | ||
2862 | { | ||
2863 | |||
2864 | foreach (TaskInventoryItem item in partInst.TaskInventory.Values) | ||
2865 | { | ||
2866 | if (item.Type == 10) | ||
2867 | { | ||
2868 | partLocalID = partInst.LocalId; | ||
2869 | partItemID = item.ItemID; | ||
2870 | Object[] resObjDef = new object[] | ||
2871 | { | ||
2872 | new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id) | ||
2873 | }; | ||
2874 | |||
2875 | m_ScriptEngine.PostScriptEvent(partItemID, | ||
2876 | new EventParams("link_message", | ||
2877 | resObjDef, new DetectParams[0])); | ||
2878 | } | ||
2879 | } | ||
2880 | |||
2881 | } | ||
2882 | } | ||
2883 | |||
2884 | break; | ||
2885 | |||
2886 | } | ||
2887 | |||
2888 | } | ||
2889 | |||
2890 | public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) | ||
2891 | { | ||
2892 | m_host.AddScriptLPS(1); | ||
2893 | NotImplemented("llPushObject"); | ||
2894 | } | ||
2895 | |||
2896 | public void llPassCollisions(int pass) | ||
2897 | { | ||
2898 | m_host.AddScriptLPS(1); | ||
2899 | NotImplemented("llPassCollisions"); | ||
2900 | } | ||
2901 | |||
2902 | public string llGetScriptName() | ||
2903 | { | ||
2904 | |||
2905 | string result = String.Empty; | ||
2906 | |||
2907 | m_host.AddScriptLPS(1); | ||
2908 | |||
2909 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
2910 | { | ||
2911 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
2912 | { | ||
2913 | result = item.Name!=null?item.Name:String.Empty; | ||
2914 | break; | ||
2915 | } | ||
2916 | } | ||
2917 | |||
2918 | return result; | ||
2919 | |||
2920 | } | ||
2921 | |||
2922 | public LSL_Types.LSLInteger llGetNumberOfSides() | ||
2923 | { | ||
2924 | m_host.AddScriptLPS(1); | ||
2925 | NotImplemented("llGetNumberOfSides"); | ||
2926 | return 0; | ||
2927 | } | ||
2928 | |||
2929 | |||
2930 | /* The new / changed functions were tested with the following LSL script: | ||
2931 | |||
2932 | default | ||
2933 | { | ||
2934 | state_entry() | ||
2935 | { | ||
2936 | rotation rot = llEuler2Rot(<0,70,0> * DEG_TO_RAD); | ||
2937 | |||
2938 | llOwnerSay("to get here, we rotate over: "+ (string) llRot2Axis(rot)); | ||
2939 | llOwnerSay("and we rotate for: "+ (llRot2Angle(rot) * RAD_TO_DEG)); | ||
2940 | |||
2941 | // convert back and forth between quaternion <-> vector and angle | ||
2942 | |||
2943 | rotation newrot = llAxisAngle2Rot(llRot2Axis(rot),llRot2Angle(rot)); | ||
2944 | |||
2945 | llOwnerSay("Old rotation was: "+(string) rot); | ||
2946 | llOwnerSay("re-converted rotation is: "+(string) newrot); | ||
2947 | |||
2948 | llSetRot(rot); // to check the parameters in the prim | ||
2949 | } | ||
2950 | } | ||
2951 | */ | ||
2952 | |||
2953 | |||
2954 | |||
2955 | // Xantor 29/apr/2008 | ||
2956 | // Returns rotation described by rotating angle radians about axis. | ||
2957 | // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) | ||
2958 | public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) | ||
2959 | { | ||
2960 | m_host.AddScriptLPS(1); | ||
2961 | |||
2962 | double x, y, z, s, t; | ||
2963 | |||
2964 | s = Math.Cos(angle / 2); | ||
2965 | t = Math.Sin(angle / 2); // temp value to avoid 2 more sin() calcs | ||
2966 | x = axis.x * t; | ||
2967 | y = axis.y * t; | ||
2968 | z = axis.z * t; | ||
2969 | |||
2970 | return new LSL_Types.Quaternion(x,y,z,s); | ||
2971 | } | ||
2972 | |||
2973 | |||
2974 | // Xantor 29/apr/2008 | ||
2975 | // converts a Quaternion to X,Y,Z axis rotations | ||
2976 | public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) | ||
2977 | { | ||
2978 | m_host.AddScriptLPS(1); | ||
2979 | double x,y,z; | ||
2980 | |||
2981 | if (rot.s > 1) // normalization needed | ||
2982 | { | ||
2983 | double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y + | ||
2984 | rot.z * rot.z + rot.s * rot.s); | ||
2985 | |||
2986 | rot.x /= length; | ||
2987 | rot.y /= length; | ||
2988 | rot.z /= length; | ||
2989 | rot.s /= length; | ||
2990 | |||
2991 | } | ||
2992 | |||
2993 | double angle = 2 * Math.Acos(rot.s); | ||
2994 | double s = Math.Sqrt(1 - rot.s * rot.s); | ||
2995 | if (s < 0.001) | ||
2996 | { | ||
2997 | x = 1; | ||
2998 | y = z = 0; | ||
2999 | } | ||
3000 | else | ||
3001 | { | ||
3002 | x = rot.x / s; // normalise axis | ||
3003 | y = rot.y / s; | ||
3004 | z = rot.z / s; | ||
3005 | } | ||
3006 | |||
3007 | |||
3008 | return new LSL_Types.Vector3(x,y,z); | ||
3009 | |||
3010 | |||
3011 | // NotImplemented("llRot2Axis"); | ||
3012 | } | ||
3013 | |||
3014 | |||
3015 | // Returns the angle of a quaternion (see llRot2Axis for the axis) | ||
3016 | public double llRot2Angle(LSL_Types.Quaternion rot) | ||
3017 | { | ||
3018 | m_host.AddScriptLPS(1); | ||
3019 | |||
3020 | if (rot.s > 1) // normalization needed | ||
3021 | { | ||
3022 | double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y + | ||
3023 | rot.z * rot.z + rot.s * rot.s); | ||
3024 | |||
3025 | rot.x /= length; | ||
3026 | rot.y /= length; | ||
3027 | rot.z /= length; | ||
3028 | rot.s /= length; | ||
3029 | |||
3030 | } | ||
3031 | |||
3032 | double angle = 2 * Math.Acos(rot.s); | ||
3033 | |||
3034 | return angle; | ||
3035 | |||
3036 | // NotImplemented("llRot2Angle"); | ||
3037 | } | ||
3038 | |||
3039 | public double llAcos(double val) | ||
3040 | { | ||
3041 | m_host.AddScriptLPS(1); | ||
3042 | return (double)Math.Acos(val); | ||
3043 | } | ||
3044 | |||
3045 | public double llAsin(double val) | ||
3046 | { | ||
3047 | m_host.AddScriptLPS(1); | ||
3048 | return (double)Math.Asin(val); | ||
3049 | } | ||
3050 | |||
3051 | // Xantor 30/apr/2008 | ||
3052 | public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) | ||
3053 | { | ||
3054 | m_host.AddScriptLPS(1); | ||
3055 | |||
3056 | return (double) Math.Acos(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s) * 2; | ||
3057 | } | ||
3058 | |||
3059 | public string llGetInventoryKey(string name) | ||
3060 | { | ||
3061 | m_host.AddScriptLPS(1); | ||
3062 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3063 | { | ||
3064 | if (inv.Value.Name == name) | ||
3065 | { | ||
3066 | if ((inv.Value.OwnerMask & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | ||
3067 | { | ||
3068 | return inv.Value.AssetID.ToString(); | ||
3069 | } | ||
3070 | else | ||
3071 | { | ||
3072 | return LLUUID.Zero.ToString(); | ||
3073 | } | ||
3074 | } | ||
3075 | } | ||
3076 | return LLUUID.Zero.ToString(); | ||
3077 | } | ||
3078 | |||
3079 | public void llAllowInventoryDrop(int add) | ||
3080 | { | ||
3081 | m_host.AddScriptLPS(1); | ||
3082 | NotImplemented("llAllowInventoryDrop"); | ||
3083 | } | ||
3084 | |||
3085 | public LSL_Types.Vector3 llGetSunDirection() | ||
3086 | { | ||
3087 | m_host.AddScriptLPS(1); | ||
3088 | |||
3089 | LSL_Types.Vector3 SunDoubleVector3; | ||
3090 | LLVector3 SunFloatVector3; | ||
3091 | |||
3092 | // sunPosition estate setting is set in OpenSim.Region.Environment.Modules.SunModule | ||
3093 | // have to convert from LLVector3 (float) to LSL_Types.Vector3 (double) | ||
3094 | SunFloatVector3 = World.RegionInfo.EstateSettings.sunPosition; | ||
3095 | SunDoubleVector3.x = (double)SunFloatVector3.X; | ||
3096 | SunDoubleVector3.y = (double)SunFloatVector3.Y; | ||
3097 | SunDoubleVector3.z = (double)SunFloatVector3.Z; | ||
3098 | |||
3099 | return SunDoubleVector3; | ||
3100 | } | ||
3101 | |||
3102 | public LSL_Types.Vector3 llGetTextureOffset(int face) | ||
3103 | { | ||
3104 | m_host.AddScriptLPS(1); | ||
3105 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
3106 | LSL_Types.Vector3 offset; | ||
3107 | if (face == -1) | ||
3108 | { | ||
3109 | face = 0; | ||
3110 | } | ||
3111 | offset.x = tex.GetFace((uint)face).OffsetU; | ||
3112 | offset.y = tex.GetFace((uint)face).OffsetV; | ||
3113 | offset.z = 0.0; | ||
3114 | return offset; | ||
3115 | } | ||
3116 | |||
3117 | public LSL_Types.Vector3 llGetTextureScale(int side) | ||
3118 | { | ||
3119 | m_host.AddScriptLPS(1); | ||
3120 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
3121 | LSL_Types.Vector3 scale; | ||
3122 | if (side == -1) | ||
3123 | { | ||
3124 | side = 0; | ||
3125 | } | ||
3126 | scale.x = tex.GetFace((uint)side).RepeatU; | ||
3127 | scale.y = tex.GetFace((uint)side).RepeatV; | ||
3128 | scale.z = 0.0; | ||
3129 | return scale; | ||
3130 | } | ||
3131 | |||
3132 | public double llGetTextureRot(int face) | ||
3133 | { | ||
3134 | m_host.AddScriptLPS(1); | ||
3135 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
3136 | if (face == -1) | ||
3137 | { | ||
3138 | face = 0; | ||
3139 | } | ||
3140 | return tex.GetFace((uint)face).Rotation; | ||
3141 | } | ||
3142 | |||
3143 | public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern) | ||
3144 | { | ||
3145 | m_host.AddScriptLPS(1); | ||
3146 | return source.IndexOf(pattern); | ||
3147 | } | ||
3148 | |||
3149 | public string llGetOwnerKey(string id) | ||
3150 | { | ||
3151 | m_host.AddScriptLPS(1); | ||
3152 | LLUUID key = new LLUUID(); | ||
3153 | if (LLUUID.TryParse(id, out key)) | ||
3154 | { | ||
3155 | return World.GetSceneObjectPart(World.Entities[key].LocalId).OwnerID.ToString(); | ||
3156 | } | ||
3157 | else | ||
3158 | { | ||
3159 | return LLUUID.Zero.ToString(); | ||
3160 | } | ||
3161 | } | ||
3162 | |||
3163 | public LSL_Types.Vector3 llGetCenterOfMass() | ||
3164 | { | ||
3165 | m_host.AddScriptLPS(1); | ||
3166 | NotImplemented("llGetCenterOfMass"); | ||
3167 | return new LSL_Types.Vector3(); | ||
3168 | } | ||
3169 | |||
3170 | public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending) | ||
3171 | { | ||
3172 | m_host.AddScriptLPS(1); | ||
3173 | return src.Sort(stride, ascending); | ||
3174 | } | ||
3175 | |||
3176 | public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src) | ||
3177 | { | ||
3178 | m_host.AddScriptLPS(1); | ||
3179 | return src.Length; | ||
3180 | } | ||
3181 | |||
3182 | public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index) | ||
3183 | { | ||
3184 | m_host.AddScriptLPS(1); | ||
3185 | if (index < 0) | ||
3186 | { | ||
3187 | index = src.Length + index; | ||
3188 | } | ||
3189 | if (index >= src.Length) | ||
3190 | { | ||
3191 | return 0; | ||
3192 | } | ||
3193 | try | ||
3194 | { | ||
3195 | return Convert.ToInt32(src.Data[index]); | ||
3196 | } | ||
3197 | catch (FormatException) | ||
3198 | { | ||
3199 | return 0; | ||
3200 | } | ||
3201 | } | ||
3202 | |||
3203 | public double osList2Double(LSL_Types.list src, int index) | ||
3204 | { | ||
3205 | m_host.AddScriptLPS(1); | ||
3206 | if (index < 0) | ||
3207 | { | ||
3208 | index = src.Length + index; | ||
3209 | } | ||
3210 | if (index >= src.Length) | ||
3211 | { | ||
3212 | return 0.0; | ||
3213 | } | ||
3214 | return Convert.ToDouble(src.Data[index]); | ||
3215 | } | ||
3216 | |||
3217 | public double llList2Float(LSL_Types.list src, int index) | ||
3218 | { | ||
3219 | m_host.AddScriptLPS(1); | ||
3220 | if (index < 0) | ||
3221 | { | ||
3222 | index = src.Length + index; | ||
3223 | } | ||
3224 | if (index >= src.Length) | ||
3225 | { | ||
3226 | return 0.0; | ||
3227 | } | ||
3228 | try | ||
3229 | { | ||
3230 | return Convert.ToDouble(src.Data[index]); | ||
3231 | } | ||
3232 | catch (FormatException) | ||
3233 | { | ||
3234 | return 0.0; | ||
3235 | } | ||
3236 | } | ||
3237 | |||
3238 | public string llList2String(LSL_Types.list src, int index) | ||
3239 | { | ||
3240 | m_host.AddScriptLPS(1); | ||
3241 | if (index < 0) | ||
3242 | { | ||
3243 | index = src.Length + index; | ||
3244 | } | ||
3245 | if (index >= src.Length) | ||
3246 | { | ||
3247 | return String.Empty; | ||
3248 | } | ||
3249 | return src.Data[index].ToString(); | ||
3250 | } | ||
3251 | |||
3252 | public string llList2Key(LSL_Types.list src, int index) | ||
3253 | { | ||
3254 | m_host.AddScriptLPS(1); | ||
3255 | if (index < 0) | ||
3256 | { | ||
3257 | index = src.Length + index; | ||
3258 | } | ||
3259 | if (index >= src.Length) | ||
3260 | { | ||
3261 | return ""; | ||
3262 | } | ||
3263 | return src.Data[index].ToString(); | ||
3264 | } | ||
3265 | |||
3266 | public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index) | ||
3267 | { | ||
3268 | m_host.AddScriptLPS(1); | ||
3269 | if (index < 0) | ||
3270 | { | ||
3271 | index = src.Length + index; | ||
3272 | } | ||
3273 | if (index >= src.Length) | ||
3274 | { | ||
3275 | return new LSL_Types.Vector3(0, 0, 0); | ||
3276 | } | ||
3277 | if (src.Data[index].GetType() == typeof(LSL_Types.Vector3)) | ||
3278 | { | ||
3279 | return (LSL_Types.Vector3)src.Data[index]; | ||
3280 | } | ||
3281 | else | ||
3282 | { | ||
3283 | return new LSL_Types.Vector3(src.Data[index].ToString()); | ||
3284 | } | ||
3285 | } | ||
3286 | |||
3287 | public LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index) | ||
3288 | { | ||
3289 | m_host.AddScriptLPS(1); | ||
3290 | if (index < 0) | ||
3291 | { | ||
3292 | index = src.Length + index; | ||
3293 | } | ||
3294 | if (index >= src.Length) | ||
3295 | { | ||
3296 | return new LSL_Types.Quaternion(0, 0, 0, 1); | ||
3297 | } | ||
3298 | if (src.Data[index].GetType() == typeof(LSL_Types.Quaternion)) | ||
3299 | { | ||
3300 | return (LSL_Types.Quaternion)src.Data[index]; | ||
3301 | } | ||
3302 | else | ||
3303 | { | ||
3304 | return new LSL_Types.Quaternion(src.Data[index].ToString()); | ||
3305 | } | ||
3306 | } | ||
3307 | |||
3308 | public LSL_Types.list llList2List(LSL_Types.list src, int start, int end) | ||
3309 | { | ||
3310 | m_host.AddScriptLPS(1); | ||
3311 | return src.GetSublist(start, end); | ||
3312 | } | ||
3313 | |||
3314 | public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end) | ||
3315 | { | ||
3316 | return src.DeleteSublist(end, start); | ||
3317 | } | ||
3318 | |||
3319 | public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index) | ||
3320 | { | ||
3321 | m_host.AddScriptLPS(1); | ||
3322 | if (index < 0) | ||
3323 | { | ||
3324 | index = src.Length + index; | ||
3325 | } | ||
3326 | if (index >= src.Length) | ||
3327 | { | ||
3328 | return 0; | ||
3329 | } | ||
3330 | |||
3331 | if (src.Data[index] is Int32) | ||
3332 | return 1; | ||
3333 | if (src.Data[index] is Double) | ||
3334 | return 2; | ||
3335 | if (src.Data[index] is String) | ||
3336 | { | ||
3337 | LLUUID tuuid; | ||
3338 | if (LLUUID.TryParse(src.Data[index].ToString(), out tuuid)) | ||
3339 | { | ||
3340 | return 3; | ||
3341 | } | ||
3342 | else | ||
3343 | { | ||
3344 | return 4; | ||
3345 | } | ||
3346 | } | ||
3347 | if (src.Data[index] is LSL_Types.Vector3) | ||
3348 | return 5; | ||
3349 | if (src.Data[index] is LSL_Types.Quaternion) | ||
3350 | return 6; | ||
3351 | if (src.Data[index] is LSL_Types.list) | ||
3352 | return 7; | ||
3353 | return 0; | ||
3354 | |||
3355 | } | ||
3356 | |||
3357 | /// <summary> | ||
3358 | /// Process the supplied list and return the | ||
3359 | /// content of the list formatted as a comma | ||
3360 | /// separated list. There is a space after | ||
3361 | /// each comma. | ||
3362 | /// </summary> | ||
3363 | |||
3364 | public string llList2CSV(LSL_Types.list src) | ||
3365 | { | ||
3366 | |||
3367 | string ret = String.Empty; | ||
3368 | int x = 0; | ||
3369 | |||
3370 | m_host.AddScriptLPS(1); | ||
3371 | |||
3372 | if (src.Data.Length > 0) | ||
3373 | { | ||
3374 | ret = src.Data[x++].ToString(); | ||
3375 | for (; x < src.Data.Length; x++) | ||
3376 | { | ||
3377 | ret += ", "+src.Data[x].ToString(); | ||
3378 | } | ||
3379 | } | ||
3380 | |||
3381 | return ret; | ||
3382 | } | ||
3383 | |||
3384 | /// <summary> | ||
3385 | /// The supplied string is scanned for commas | ||
3386 | /// and converted into a list. Commas are only | ||
3387 | /// effective if they are encountered outside | ||
3388 | /// of '<' '>' delimiters. Any whitespace | ||
3389 | /// before or after an element is trimmed. | ||
3390 | /// </summary> | ||
3391 | |||
3392 | public LSL_Types.list llCSV2List(string src) | ||
3393 | { | ||
3394 | |||
3395 | LSL_Types.list result = new LSL_Types.list(); | ||
3396 | int parens = 0; | ||
3397 | int start = 0; | ||
3398 | int length = 0; | ||
3399 | |||
3400 | m_host.AddScriptLPS(1); | ||
3401 | |||
3402 | for (int i = 0; i < src.Length; i++) | ||
3403 | { | ||
3404 | switch (src[i]) | ||
3405 | { | ||
3406 | case '<': | ||
3407 | parens++; | ||
3408 | length++; | ||
3409 | break; | ||
3410 | case '>': | ||
3411 | if (parens > 0) | ||
3412 | parens--; | ||
3413 | length++; | ||
3414 | break; | ||
3415 | case ',': | ||
3416 | if (parens == 0) | ||
3417 | { | ||
3418 | result.Add(src.Substring(start,length).Trim()); | ||
3419 | start += length+1; | ||
3420 | length = 0; | ||
3421 | } | ||
3422 | else | ||
3423 | { | ||
3424 | length++; | ||
3425 | } | ||
3426 | break; | ||
3427 | default: | ||
3428 | length++; | ||
3429 | break; | ||
3430 | } | ||
3431 | } | ||
3432 | |||
3433 | result.Add(src.Substring(start,length).Trim()); | ||
3434 | |||
3435 | return result; | ||
3436 | } | ||
3437 | |||
3438 | /// <summary> | ||
3439 | /// Randomizes the list, be arbitrarily reordering | ||
3440 | /// sublists of stride elements. As the stride approaches | ||
3441 | /// the size of the list, the options become very | ||
3442 | /// limited. | ||
3443 | /// </summary> | ||
3444 | /// <remarks> | ||
3445 | /// This could take a while for very large list | ||
3446 | /// sizes. | ||
3447 | /// </remarks> | ||
3448 | |||
3449 | public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) | ||
3450 | { | ||
3451 | |||
3452 | LSL_Types.list result; | ||
3453 | Random rand = new Random(); | ||
3454 | |||
3455 | int chunkk; | ||
3456 | int[] chunks; | ||
3457 | int index1; | ||
3458 | int index2; | ||
3459 | int tmp; | ||
3460 | |||
3461 | m_host.AddScriptLPS(1); | ||
3462 | |||
3463 | if (stride == 0) | ||
3464 | stride = 1; | ||
3465 | |||
3466 | // Stride MUST be a factor of the list length | ||
3467 | // If not, then return the src list. This also | ||
3468 | // traps those cases where stride > length. | ||
3469 | |||
3470 | if (src.Length != stride && src.Length%stride == 0) | ||
3471 | { | ||
3472 | chunkk = src.Length/stride; | ||
3473 | |||
3474 | chunks = new int[chunkk]; | ||
3475 | |||
3476 | for (int i = 0; i < chunkk; i++) | ||
3477 | chunks[i] = i; | ||
3478 | |||
3479 | for (int i = 0; i < chunkk - 1; i++) | ||
3480 | { | ||
3481 | // randomly select 2 chunks | ||
3482 | index1 = rand.Next(rand.Next(65536)); | ||
3483 | index1 = index1%chunkk; | ||
3484 | index2 = rand.Next(rand.Next(65536)); | ||
3485 | index2 = index2%chunkk; | ||
3486 | |||
3487 | // and swap their relative positions | ||
3488 | tmp = chunks[index1]; | ||
3489 | chunks[index1] = chunks[index2]; | ||
3490 | chunks[index2] = tmp; | ||
3491 | } | ||
3492 | |||
3493 | // Construct the randomized list | ||
3494 | |||
3495 | result = new LSL_Types.list(); | ||
3496 | |||
3497 | for (int i = 0; i < chunkk; i++) | ||
3498 | { | ||
3499 | for (int j = 0; j < stride; j++) | ||
3500 | { | ||
3501 | result.Add(src.Data[chunks[i]*stride+j]); | ||
3502 | } | ||
3503 | } | ||
3504 | } | ||
3505 | else { | ||
3506 | object[] array = new object[src.Length]; | ||
3507 | Array.Copy(src.Data, 0, array, 0, src.Length); | ||
3508 | result = new LSL_Types.list(array); | ||
3509 | } | ||
3510 | |||
3511 | return result; | ||
3512 | |||
3513 | } | ||
3514 | |||
3515 | /// <summary> | ||
3516 | /// Elements in the source list starting with 0 and then | ||
3517 | /// every i+stride. If the stride is negative then the scan | ||
3518 | /// is backwards producing an inverted result. | ||
3519 | /// Only those elements that are also in the specified | ||
3520 | /// range are included in the result. | ||
3521 | /// </summary> | ||
3522 | |||
3523 | public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride) | ||
3524 | { | ||
3525 | |||
3526 | LSL_Types.list result = new LSL_Types.list(); | ||
3527 | int[] si = new int[2]; | ||
3528 | int[] ei = new int[2]; | ||
3529 | bool twopass = false; | ||
3530 | |||
3531 | m_host.AddScriptLPS(1); | ||
3532 | |||
3533 | // First step is always to deal with negative indices | ||
3534 | |||
3535 | if (start < 0) | ||
3536 | start = src.Length+start; | ||
3537 | if (end < 0) | ||
3538 | end = src.Length+end; | ||
3539 | |||
3540 | // Out of bounds indices are OK, just trim them | ||
3541 | // accordingly | ||
3542 | |||
3543 | if (start > src.Length) | ||
3544 | start = src.Length; | ||
3545 | |||
3546 | if (end > src.Length) | ||
3547 | end = src.Length; | ||
3548 | |||
3549 | // There may be one or two ranges to be considered | ||
3550 | |||
3551 | if (start != end) | ||
3552 | { | ||
3553 | |||
3554 | if (start <= end) | ||
3555 | { | ||
3556 | si[0] = start; | ||
3557 | ei[0] = end; | ||
3558 | } | ||
3559 | else | ||
3560 | { | ||
3561 | si[1] = start; | ||
3562 | ei[1] = src.Length; | ||
3563 | si[0] = 0; | ||
3564 | ei[0] = end; | ||
3565 | twopass = true; | ||
3566 | } | ||
3567 | |||
3568 | // The scan always starts from the beginning of the | ||
3569 | // source list, but members are only selected if they | ||
3570 | // fall within the specified sub-range. The specified | ||
3571 | // range values are inclusive. | ||
3572 | // A negative stride reverses the direction of the | ||
3573 | // scan producing an inverted list as a result. | ||
3574 | |||
3575 | if (stride == 0) | ||
3576 | stride = 1; | ||
3577 | |||
3578 | if (stride > 0) | ||
3579 | { | ||
3580 | for (int i = 0; i < src.Length; i += stride) | ||
3581 | { | ||
3582 | if (i<=ei[0] && i>=si[0]) | ||
3583 | result.Add(src.Data[i]); | ||
3584 | if (twopass && i>=si[1] && i<=ei[1]) | ||
3585 | result.Add(src.Data[i]); | ||
3586 | } | ||
3587 | } | ||
3588 | else if (stride < 0) | ||
3589 | { | ||
3590 | for (int i = src.Length - 1; i >= 0; i += stride) | ||
3591 | { | ||
3592 | if (i <= ei[0] && i >= si[0]) | ||
3593 | result.Add(src.Data[i]); | ||
3594 | if (twopass && i >= si[1] && i <= ei[1]) | ||
3595 | result.Add(src.Data[i]); | ||
3596 | } | ||
3597 | } | ||
3598 | } | ||
3599 | |||
3600 | return result; | ||
3601 | } | ||
3602 | |||
3603 | public LSL_Types.Vector3 llGetRegionCorner() | ||
3604 | { | ||
3605 | m_host.AddScriptLPS(1); | ||
3606 | return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
3607 | } | ||
3608 | |||
3609 | /// <summary> | ||
3610 | /// Insert the list identified by <src> into the | ||
3611 | /// list designated by <dest> such that the first | ||
3612 | /// new element has the index specified by <index> | ||
3613 | /// </summary> | ||
3614 | |||
3615 | public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int index) | ||
3616 | { | ||
3617 | |||
3618 | LSL_Types.list pref = null; | ||
3619 | LSL_Types.list suff = null; | ||
3620 | |||
3621 | m_host.AddScriptLPS(1); | ||
3622 | |||
3623 | if (index < 0) | ||
3624 | { | ||
3625 | index = index+dest.Length; | ||
3626 | if (index < 0) | ||
3627 | { | ||
3628 | index = 0; | ||
3629 | } | ||
3630 | } | ||
3631 | |||
3632 | if (index != 0) | ||
3633 | { | ||
3634 | pref = dest.GetSublist(0,index-1); | ||
3635 | if (index < dest.Length) | ||
3636 | { | ||
3637 | suff = dest.GetSublist(index,-1); | ||
3638 | return pref + src + suff; | ||
3639 | } | ||
3640 | else | ||
3641 | { | ||
3642 | return pref + src; | ||
3643 | } | ||
3644 | } | ||
3645 | else | ||
3646 | { | ||
3647 | if (index < dest.Length) | ||
3648 | { | ||
3649 | suff = dest.GetSublist(index,-1); | ||
3650 | return src + suff; | ||
3651 | } | ||
3652 | else | ||
3653 | { | ||
3654 | return src; | ||
3655 | } | ||
3656 | } | ||
3657 | |||
3658 | } | ||
3659 | |||
3660 | /// <summary> | ||
3661 | /// Returns the index of the first occurrence of test | ||
3662 | /// in src. | ||
3663 | /// </summary> | ||
3664 | |||
3665 | public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test) | ||
3666 | { | ||
3667 | |||
3668 | int index = -1; | ||
3669 | int length = src.Length - test.Length + 1; | ||
3670 | |||
3671 | m_host.AddScriptLPS(1); | ||
3672 | |||
3673 | // If either list is empty, do not match | ||
3674 | |||
3675 | if (src.Length != 0 && test.Length != 0) | ||
3676 | { | ||
3677 | for (int i = 0; i < length; i++) | ||
3678 | { | ||
3679 | if (src.Data[i].Equals(test.Data[0])) | ||
3680 | { | ||
3681 | int j; | ||
3682 | for (j = 1; j < test.Length; j++) | ||
3683 | if (!src.Data[i+j].Equals(test.Data[j])) | ||
3684 | break; | ||
3685 | if (j == test.Length) | ||
3686 | { | ||
3687 | index = i; | ||
3688 | break; | ||
3689 | } | ||
3690 | } | ||
3691 | } | ||
3692 | } | ||
3693 | |||
3694 | return index; | ||
3695 | |||
3696 | } | ||
3697 | |||
3698 | public string llGetObjectName() | ||
3699 | { | ||
3700 | m_host.AddScriptLPS(1); | ||
3701 | return m_host.Name!=null?m_host.Name:String.Empty; | ||
3702 | } | ||
3703 | |||
3704 | public void llSetObjectName(string name) | ||
3705 | { | ||
3706 | m_host.AddScriptLPS(1); | ||
3707 | m_host.Name = name!=null?name:String.Empty; | ||
3708 | } | ||
3709 | |||
3710 | public string llGetDate() | ||
3711 | { | ||
3712 | m_host.AddScriptLPS(1); | ||
3713 | DateTime date = DateTime.Now.ToUniversalTime(); | ||
3714 | string result = date.ToString("yyyy-MM-dd"); | ||
3715 | return result; | ||
3716 | } | ||
3717 | |||
3718 | public LSL_Types.LSLInteger llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) | ||
3719 | { | ||
3720 | m_host.AddScriptLPS(1); | ||
3721 | NotImplemented("llEdgeOfWorld"); | ||
3722 | return 0; | ||
3723 | } | ||
3724 | |||
3725 | public LSL_Types.LSLInteger llGetAgentInfo(string id) | ||
3726 | { | ||
3727 | m_host.AddScriptLPS(1); | ||
3728 | NotImplemented("llGetAgentInfo"); | ||
3729 | return 0; | ||
3730 | } | ||
3731 | |||
3732 | public void llAdjustSoundVolume(double volume) | ||
3733 | { | ||
3734 | m_host.AddScriptLPS(1); | ||
3735 | m_host.AdjustSoundGain(volume); | ||
3736 | } | ||
3737 | |||
3738 | public void llSetSoundQueueing(int queue) | ||
3739 | { | ||
3740 | m_host.AddScriptLPS(1); | ||
3741 | NotImplemented("llSetSoundQueueing"); | ||
3742 | } | ||
3743 | |||
3744 | public void llSetSoundRadius(double radius) | ||
3745 | { | ||
3746 | m_host.AddScriptLPS(1); | ||
3747 | NotImplemented("llSetSoundRadius"); | ||
3748 | } | ||
3749 | |||
3750 | public string llKey2Name(string id) | ||
3751 | { | ||
3752 | m_host.AddScriptLPS(1); | ||
3753 | LLUUID key = new LLUUID(); | ||
3754 | if (LLUUID.TryParse(id,out key)) | ||
3755 | { | ||
3756 | ScenePresence presence = World.GetScenePresence(key); | ||
3757 | |||
3758 | if (presence != null) | ||
3759 | { | ||
3760 | return presence.ControllingClient.Name; | ||
3761 | //return presence.Name; | ||
3762 | } | ||
3763 | |||
3764 | if (World.GetSceneObjectPart(key) != null) | ||
3765 | { | ||
3766 | return World.GetSceneObjectPart(key).Name; | ||
3767 | } | ||
3768 | } | ||
3769 | return String.Empty; | ||
3770 | } | ||
3771 | |||
3772 | |||
3773 | |||
3774 | public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) | ||
3775 | { | ||
3776 | m_host.AddScriptLPS(1); | ||
3777 | Primitive.TextureAnimation pTexAnim = new Primitive.TextureAnimation(); | ||
3778 | pTexAnim.Flags =(uint) mode; | ||
3779 | |||
3780 | //ALL_SIDES | ||
3781 | if (face == -1) | ||
3782 | face = 255; | ||
3783 | |||
3784 | pTexAnim.Face = (uint)face; | ||
3785 | pTexAnim.Length = (float)length; | ||
3786 | pTexAnim.Rate = (float)rate; | ||
3787 | pTexAnim.SizeX = (uint)sizex; | ||
3788 | pTexAnim.SizeY = (uint)sizey; | ||
3789 | pTexAnim.Start = (float)start; | ||
3790 | |||
3791 | m_host.AddTextureAnimation(pTexAnim); | ||
3792 | m_host.SendFullUpdateToAllClients(); | ||
3793 | } | ||
3794 | |||
3795 | public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, | ||
3796 | LSL_Types.Vector3 bottom_south_west) | ||
3797 | { | ||
3798 | m_host.AddScriptLPS(1); | ||
3799 | NotImplemented("llTriggerSoundLimited"); | ||
3800 | } | ||
3801 | |||
3802 | public void llEjectFromLand(string pest) | ||
3803 | { | ||
3804 | m_host.AddScriptLPS(1); | ||
3805 | NotImplemented("llEjectFromLand"); | ||
3806 | } | ||
3807 | |||
3808 | public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers) | ||
3809 | { | ||
3810 | m_host.AddScriptLPS(1); | ||
3811 | LSL_Types.list ret = new LSL_Types.list(); | ||
3812 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
3813 | separators.Data.CopyTo(delimiters, 0); | ||
3814 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
3815 | bool dfound = false; | ||
3816 | do | ||
3817 | { | ||
3818 | dfound = false; | ||
3819 | int cindex = -1; | ||
3820 | string cdeli = ""; | ||
3821 | for (int i = 0; i < delimiters.Length; i++) | ||
3822 | { | ||
3823 | int index = str.IndexOf(delimiters[i].ToString()); | ||
3824 | bool found = index != -1; | ||
3825 | if (found) | ||
3826 | { | ||
3827 | if ((cindex > index) || (cindex == -1)) | ||
3828 | { | ||
3829 | cindex = index; | ||
3830 | cdeli = (string)delimiters[i]; | ||
3831 | } | ||
3832 | dfound = dfound || found; | ||
3833 | } | ||
3834 | } | ||
3835 | if (cindex != -1) | ||
3836 | { | ||
3837 | if (cindex > 0) | ||
3838 | { | ||
3839 | ret.Add(str.Substring(0, cindex)); | ||
3840 | if (spacers.Contains(cdeli)) | ||
3841 | { | ||
3842 | ret.Add(cdeli); | ||
3843 | } | ||
3844 | } | ||
3845 | if (cindex == 0 && spacers.Contains(cdeli)) | ||
3846 | { | ||
3847 | ret.Add(cdeli); | ||
3848 | } | ||
3849 | str = str.Substring(cindex + cdeli.Length); | ||
3850 | } | ||
3851 | } while (dfound); | ||
3852 | if (str != "") | ||
3853 | { | ||
3854 | ret.Add(str); | ||
3855 | } | ||
3856 | return ret; | ||
3857 | } | ||
3858 | |||
3859 | public LSL_Types.LSLInteger llOverMyLand(string id) | ||
3860 | { | ||
3861 | |||
3862 | m_host.AddScriptLPS(1); | ||
3863 | LLUUID key = new LLUUID(); | ||
3864 | if (LLUUID.TryParse(id,out key)) | ||
3865 | { | ||
3866 | SceneObjectPart obj = new SceneObjectPart(); | ||
3867 | obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | ||
3868 | if (obj.OwnerID == World.GetLandOwner(obj.AbsolutePosition.X, obj.AbsolutePosition.Y)) | ||
3869 | { | ||
3870 | return 1; | ||
3871 | } | ||
3872 | else | ||
3873 | { | ||
3874 | return 0; | ||
3875 | } | ||
3876 | } | ||
3877 | else | ||
3878 | { | ||
3879 | return 0; | ||
3880 | } | ||
3881 | } | ||
3882 | |||
3883 | public string llGetLandOwnerAt(LSL_Types.Vector3 pos) | ||
3884 | { | ||
3885 | m_host.AddScriptLPS(1); | ||
3886 | return World.GetLandOwner((float)pos.x, (float)pos.y).ToString(); | ||
3887 | } | ||
3888 | |||
3889 | public LSL_Types.Vector3 llGetAgentSize(string id) | ||
3890 | { | ||
3891 | m_host.AddScriptLPS(1); | ||
3892 | NotImplemented("llGetAgentSize"); | ||
3893 | return new LSL_Types.Vector3(); | ||
3894 | } | ||
3895 | |||
3896 | public LSL_Types.LSLInteger llSameGroup(string agent) | ||
3897 | { | ||
3898 | m_host.AddScriptLPS(1); | ||
3899 | NotImplemented("llSameGroup"); | ||
3900 | return 0; | ||
3901 | } | ||
3902 | |||
3903 | public void llUnSit(string id) | ||
3904 | { | ||
3905 | m_host.AddScriptLPS(1); | ||
3906 | |||
3907 | LLUUID key = new LLUUID(); | ||
3908 | if (LLUUID.TryParse(id, out key)) | ||
3909 | { | ||
3910 | ScenePresence av = World.GetScenePresence(key); | ||
3911 | |||
3912 | if (av != null) | ||
3913 | { | ||
3914 | if (llAvatarOnSitTarget() == id) | ||
3915 | { | ||
3916 | // if the avatar is sitting on this object, then | ||
3917 | // we can unsit them. We don't want random scripts unsitting random people | ||
3918 | // Lets avoid the popcorn avatar scenario. | ||
3919 | av.StandUp(); | ||
3920 | } | ||
3921 | else | ||
3922 | { | ||
3923 | // If the object owner also owns the parcel | ||
3924 | // or | ||
3925 | // if the land is group owned and the object is group owned by the same group | ||
3926 | // or | ||
3927 | // if the object is owned by a person with estate access. | ||
3928 | |||
3929 | ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition.X, av.AbsolutePosition.Y); | ||
3930 | if (parcel != null) | ||
3931 | { | ||
3932 | if (m_host.ObjectOwner == parcel.landData.ownerID || | ||
3933 | (m_host.OwnerID == m_host.GroupID && m_host.GroupID == parcel.landData.groupID | ||
3934 | && parcel.landData.isGroupOwned) || World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID)) | ||
3935 | { | ||
3936 | av.StandUp(); | ||
3937 | } | ||
3938 | } | ||
3939 | } | ||
3940 | } | ||
3941 | |||
3942 | } | ||
3943 | |||
3944 | } | ||
3945 | |||
3946 | public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) | ||
3947 | { | ||
3948 | m_host.AddScriptLPS(1); | ||
3949 | NotImplemented("llGroundSlope"); | ||
3950 | return new LSL_Types.Vector3(); | ||
3951 | } | ||
3952 | |||
3953 | public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) | ||
3954 | { | ||
3955 | m_host.AddScriptLPS(1); | ||
3956 | NotImplemented("llGroundNormal"); | ||
3957 | return new LSL_Types.Vector3(); | ||
3958 | } | ||
3959 | |||
3960 | public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) | ||
3961 | { | ||
3962 | m_host.AddScriptLPS(1); | ||
3963 | NotImplemented("llGroundContour"); | ||
3964 | return new LSL_Types.Vector3(); | ||
3965 | } | ||
3966 | |||
3967 | public LSL_Types.LSLInteger llGetAttached() | ||
3968 | { | ||
3969 | m_host.AddScriptLPS(1); | ||
3970 | NotImplemented("llGetAttached"); | ||
3971 | return 0; | ||
3972 | } | ||
3973 | |||
3974 | public LSL_Types.LSLInteger llGetFreeMemory() | ||
3975 | { | ||
3976 | m_host.AddScriptLPS(1); | ||
3977 | NotImplemented("llGetFreeMemory"); | ||
3978 | return 0; | ||
3979 | } | ||
3980 | |||
3981 | public string llGetRegionName() | ||
3982 | { | ||
3983 | m_host.AddScriptLPS(1); | ||
3984 | return World.RegionInfo.RegionName; | ||
3985 | } | ||
3986 | |||
3987 | public double llGetRegionTimeDilation() | ||
3988 | { | ||
3989 | m_host.AddScriptLPS(1); | ||
3990 | return (double)World.TimeDilation; | ||
3991 | } | ||
3992 | |||
3993 | public double llGetRegionFPS() | ||
3994 | { | ||
3995 | m_host.AddScriptLPS(1); | ||
3996 | //TODO: return actual FPS | ||
3997 | return 10.0f; | ||
3998 | } | ||
3999 | |||
4000 | /* particle system rules should be coming into this routine as doubles, that is | ||
4001 | rule[0] should be an integer from this list and rule[1] should be the arg | ||
4002 | for the same integer. wiki.secondlife.com has most of this mapping, but some | ||
4003 | came from http://www.caligari-designs.com/p4u2 | ||
4004 | |||
4005 | We iterate through the list for 'Count' elements, incrementing by two for each | ||
4006 | iteration and set the members of Primitive.ParticleSystem, one at a time. | ||
4007 | */ | ||
4008 | |||
4009 | public enum PrimitiveRule : int | ||
4010 | { | ||
4011 | PSYS_PART_FLAGS = 0, | ||
4012 | PSYS_PART_START_COLOR = 1, | ||
4013 | PSYS_PART_START_ALPHA = 2, | ||
4014 | PSYS_PART_END_COLOR = 3, | ||
4015 | PSYS_PART_END_ALPHA = 4, | ||
4016 | PSYS_PART_START_SCALE = 5, | ||
4017 | PSYS_PART_END_SCALE = 6, | ||
4018 | PSYS_PART_MAX_AGE = 7, | ||
4019 | PSYS_SRC_ACCEL = 8, | ||
4020 | PSYS_SRC_PATTERN = 9, | ||
4021 | PSYS_SRC_TEXTURE = 12, | ||
4022 | PSYS_SRC_BURST_RATE = 13, | ||
4023 | PSYS_SRC_BURST_PART_COUNT = 15, | ||
4024 | PSYS_SRC_BURST_RADIUS = 16, | ||
4025 | PSYS_SRC_BURST_SPEED_MIN = 17, | ||
4026 | PSYS_SRC_BURST_SPEED_MAX = 18, | ||
4027 | PSYS_SRC_MAX_AGE = 19, | ||
4028 | PSYS_SRC_TARGET_KEY = 20, | ||
4029 | PSYS_SRC_OMEGA = 21, | ||
4030 | PSYS_SRC_ANGLE_BEGIN = 22, | ||
4031 | PSYS_SRC_ANGLE_END = 23 | ||
4032 | } | ||
4033 | |||
4034 | internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags) | ||
4035 | { | ||
4036 | Primitive.ParticleSystem.ParticleDataFlags returnval = Primitive.ParticleSystem.ParticleDataFlags.None; | ||
4037 | |||
4038 | return returnval; | ||
4039 | } | ||
4040 | |||
4041 | |||
4042 | public void llParticleSystem(LSL_Types.list rules) | ||
4043 | { | ||
4044 | m_host.AddScriptLPS(1); | ||
4045 | Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); | ||
4046 | LSL_Types.Vector3 tempv = new LSL_Types.Vector3(); | ||
4047 | |||
4048 | float tempf = 0; | ||
4049 | |||
4050 | for (int i = 0; i < rules.Length; i += 2) | ||
4051 | { | ||
4052 | switch ((int)rules.Data[i]) | ||
4053 | { | ||
4054 | case (int)ScriptBaseClass.PSYS_PART_FLAGS: | ||
4055 | prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); | ||
4056 | break; | ||
4057 | |||
4058 | case (int)ScriptBaseClass.PSYS_PART_START_COLOR: | ||
4059 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4060 | prules.PartStartColor.R = (float)tempv.x; | ||
4061 | prules.PartStartColor.G = (float)tempv.y; | ||
4062 | prules.PartStartColor.B = (float)tempv.z; | ||
4063 | break; | ||
4064 | |||
4065 | case (int)ScriptBaseClass.PSYS_PART_START_ALPHA: | ||
4066 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4067 | prules.PartStartColor.A = (float)tempf; | ||
4068 | break; | ||
4069 | |||
4070 | case (int)ScriptBaseClass.PSYS_PART_END_COLOR: | ||
4071 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4072 | //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1); | ||
4073 | |||
4074 | prules.PartEndColor.R = (float)tempv.x; | ||
4075 | prules.PartEndColor.G = (float)tempv.y; | ||
4076 | prules.PartEndColor.B = (float)tempv.z; | ||
4077 | break; | ||
4078 | |||
4079 | case (int)ScriptBaseClass.PSYS_PART_END_ALPHA: | ||
4080 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4081 | prules.PartEndColor.A = (float)tempf; | ||
4082 | break; | ||
4083 | |||
4084 | case (int)ScriptBaseClass.PSYS_PART_START_SCALE: | ||
4085 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4086 | prules.PartStartScaleX = (float)tempv.x; | ||
4087 | prules.PartStartScaleY = (float)tempv.y; | ||
4088 | break; | ||
4089 | |||
4090 | case (int)ScriptBaseClass.PSYS_PART_END_SCALE: | ||
4091 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4092 | prules.PartEndScaleX = (float)tempv.x; | ||
4093 | prules.PartEndScaleY = (float)tempv.y; | ||
4094 | break; | ||
4095 | |||
4096 | case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: | ||
4097 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4098 | prules.PartMaxAge = (float)tempf; | ||
4099 | break; | ||
4100 | |||
4101 | case (int)ScriptBaseClass.PSYS_SRC_ACCEL: | ||
4102 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4103 | prules.PartAcceleration.X = (float)tempv.x; | ||
4104 | prules.PartAcceleration.Y = (float)tempv.y; | ||
4105 | prules.PartAcceleration.Z = (float)tempv.z; | ||
4106 | break; | ||
4107 | |||
4108 | case (int)ScriptBaseClass.PSYS_SRC_PATTERN: | ||
4109 | int tmpi = int.Parse(rules.Data[i + 1].ToString()); | ||
4110 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; | ||
4111 | break; | ||
4112 | |||
4113 | // Xantor 20080503 | ||
4114 | // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture | ||
4115 | // "" = default texture. | ||
4116 | // 20080530 Updated to remove code duplication | ||
4117 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: | ||
4118 | prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); | ||
4119 | break; | ||
4120 | |||
4121 | case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: | ||
4122 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4123 | prules.BurstRate = (float)tempf; | ||
4124 | break; | ||
4125 | |||
4126 | case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: | ||
4127 | prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); | ||
4128 | break; | ||
4129 | |||
4130 | case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: | ||
4131 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4132 | prules.BurstRadius = (float)tempf; | ||
4133 | break; | ||
4134 | |||
4135 | case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: | ||
4136 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4137 | prules.BurstSpeedMin = (float)tempf; | ||
4138 | break; | ||
4139 | |||
4140 | case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: | ||
4141 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4142 | prules.BurstSpeedMax = (float)tempf; | ||
4143 | break; | ||
4144 | |||
4145 | case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: | ||
4146 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4147 | prules.MaxAge = (float)tempf; | ||
4148 | break; | ||
4149 | |||
4150 | case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: | ||
4151 | LLUUID key = LLUUID.Zero; | ||
4152 | if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key)) | ||
4153 | { | ||
4154 | prules.Target = key; | ||
4155 | } | ||
4156 | else | ||
4157 | { | ||
4158 | prules.Target = m_host.UUID; | ||
4159 | } | ||
4160 | break; | ||
4161 | |||
4162 | case (int)ScriptBaseClass.PSYS_SRC_OMEGA: | ||
4163 | // AL: This is an assumption, since it is the only thing that would match. | ||
4164 | tempv = (LSL_Types.Vector3)rules.Data[i + 1]; | ||
4165 | prules.AngularVelocity.X = (float)tempv.x; | ||
4166 | prules.AngularVelocity.Y = (float)tempv.y; | ||
4167 | prules.AngularVelocity.Z = (float)tempv.z; | ||
4168 | //cast?? prules.MaxAge = (float)rules[i + 1]; | ||
4169 | break; | ||
4170 | |||
4171 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: | ||
4172 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4173 | prules.InnerAngle = (float)tempf; | ||
4174 | break; | ||
4175 | |||
4176 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: | ||
4177 | tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); | ||
4178 | prules.OuterAngle = (float)tempf; | ||
4179 | break; | ||
4180 | } | ||
4181 | |||
4182 | } | ||
4183 | prules.CRC = 1; | ||
4184 | |||
4185 | m_host.AddNewParticleSystem(prules); | ||
4186 | m_host.SendFullUpdateToAllClients(); | ||
4187 | } | ||
4188 | |||
4189 | public void llGroundRepel(double height, int water, double tau) | ||
4190 | { | ||
4191 | m_host.AddScriptLPS(1); | ||
4192 | NotImplemented("llGroundRepel"); | ||
4193 | } | ||
4194 | |||
4195 | public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory) | ||
4196 | { | ||
4197 | m_host.AddScriptLPS(1); | ||
4198 | NotImplemented("llGiveInventoryList"); | ||
4199 | } | ||
4200 | |||
4201 | public void llSetVehicleType(int type) | ||
4202 | { | ||
4203 | m_host.AddScriptLPS(1); | ||
4204 | NotImplemented("llSetVehicleType"); | ||
4205 | } | ||
4206 | |||
4207 | public void llSetVehicledoubleParam(int param, double value) | ||
4208 | { | ||
4209 | m_host.AddScriptLPS(1); | ||
4210 | NotImplemented("llSetVehicledoubleParam"); | ||
4211 | } | ||
4212 | |||
4213 | public void llSetVehicleFloatParam(int param, float value) | ||
4214 | { | ||
4215 | m_host.AddScriptLPS(1); | ||
4216 | NotImplemented("llSetVehicleFloatParam"); | ||
4217 | } | ||
4218 | |||
4219 | public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) | ||
4220 | { | ||
4221 | m_host.AddScriptLPS(1); | ||
4222 | NotImplemented("llSetVehicleVectorParam"); | ||
4223 | } | ||
4224 | |||
4225 | public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) | ||
4226 | { | ||
4227 | m_host.AddScriptLPS(1); | ||
4228 | NotImplemented("llSetVehicleRotationParam"); | ||
4229 | } | ||
4230 | |||
4231 | public void llSetVehicleFlags(int flags) | ||
4232 | { | ||
4233 | m_host.AddScriptLPS(1); | ||
4234 | NotImplemented("llSetVehicleFlags"); | ||
4235 | } | ||
4236 | |||
4237 | public void llRemoveVehicleFlags(int flags) | ||
4238 | { | ||
4239 | m_host.AddScriptLPS(1); | ||
4240 | NotImplemented("llRemoveVehicleFlags"); | ||
4241 | } | ||
4242 | |||
4243 | public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) | ||
4244 | { | ||
4245 | m_host.AddScriptLPS(1); | ||
4246 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
4247 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
4248 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | ||
4249 | |||
4250 | m_host.SetSitTarget(new Vector3((float)offset.x, (float)offset.y, (float)offset.z), new Quaternion((float)rot.s, (float)rot.x, (float)rot.y, (float)rot.z)); | ||
4251 | } | ||
4252 | |||
4253 | public string llAvatarOnSitTarget() | ||
4254 | { | ||
4255 | m_host.AddScriptLPS(1); | ||
4256 | return m_host.GetAvatarOnSitTarget().ToString(); | ||
4257 | } | ||
4258 | |||
4259 | public void llAddToLandPassList(string avatar, double hours) | ||
4260 | { | ||
4261 | m_host.AddScriptLPS(1); | ||
4262 | LLUUID key; | ||
4263 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
4264 | if (land.ownerID == m_host.OwnerID) | ||
4265 | { | ||
4266 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
4267 | if (LLUUID.TryParse(avatar, out key)) | ||
4268 | { | ||
4269 | entry.AgentID = key; | ||
4270 | entry.Flags = ParcelManager.AccessList.Access; | ||
4271 | entry.Time = DateTime.Now.AddHours(hours); | ||
4272 | land.parcelAccessList.Add(entry); | ||
4273 | } | ||
4274 | } | ||
4275 | } | ||
4276 | |||
4277 | public void llSetTouchText(string text) | ||
4278 | { | ||
4279 | m_host.AddScriptLPS(1); | ||
4280 | m_host.TouchName = text; | ||
4281 | } | ||
4282 | |||
4283 | public void llSetSitText(string text) | ||
4284 | { | ||
4285 | m_host.AddScriptLPS(1); | ||
4286 | m_host.SitName = text; | ||
4287 | } | ||
4288 | |||
4289 | public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) | ||
4290 | { | ||
4291 | m_host.AddScriptLPS(1); | ||
4292 | NotImplemented("llSetCameraEyeOffset"); | ||
4293 | } | ||
4294 | |||
4295 | public void llSetCameraAtOffset(LSL_Types.Vector3 offset) | ||
4296 | { | ||
4297 | m_host.AddScriptLPS(1); | ||
4298 | NotImplemented("llSetCameraAtOffset"); | ||
4299 | } | ||
4300 | |||
4301 | public string llDumpList2String(LSL_Types.list src, string seperator) | ||
4302 | { | ||
4303 | m_host.AddScriptLPS(1); | ||
4304 | if (src.Length == 0) | ||
4305 | { | ||
4306 | return String.Empty; | ||
4307 | } | ||
4308 | string ret = String.Empty; | ||
4309 | foreach (object o in src.Data) | ||
4310 | { | ||
4311 | ret = ret + o.ToString() + seperator; | ||
4312 | } | ||
4313 | ret = ret.Substring(0, ret.Length - seperator.Length); | ||
4314 | return ret; | ||
4315 | } | ||
4316 | |||
4317 | public LSL_Types.LSLInteger llScriptDanger(LSL_Types.Vector3 pos) | ||
4318 | { | ||
4319 | m_host.AddScriptLPS(1); | ||
4320 | bool result = World.scriptDanger(m_host.LocalId, new LLVector3((float)pos.x, (float)pos.y, (float)pos.z)); | ||
4321 | if (result) | ||
4322 | { | ||
4323 | return 1; | ||
4324 | } | ||
4325 | else | ||
4326 | { | ||
4327 | return 0; | ||
4328 | } | ||
4329 | |||
4330 | } | ||
4331 | |||
4332 | public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel) | ||
4333 | { | ||
4334 | m_host.AddScriptLPS(1); | ||
4335 | LLUUID av = new LLUUID(); | ||
4336 | if (!LLUUID.TryParse(avatar,out av)) | ||
4337 | { | ||
4338 | LSLError("First parameter to llDialog needs to be a key"); | ||
4339 | return; | ||
4340 | } | ||
4341 | if (buttons.Length > 12) | ||
4342 | { | ||
4343 | LSLError("No more than 12 buttons can be shown"); | ||
4344 | return; | ||
4345 | } | ||
4346 | string[] buts = new string[buttons.Length]; | ||
4347 | for (int i = 0; i < buttons.Length; i++) | ||
4348 | { | ||
4349 | if (buttons.Data[i].ToString() == String.Empty) | ||
4350 | { | ||
4351 | LSLError("button label cannot be blank"); | ||
4352 | return; | ||
4353 | } | ||
4354 | if (buttons.Data[i].ToString().Length > 24) | ||
4355 | { | ||
4356 | LSLError("button label cannot be longer than 24 characters"); | ||
4357 | return; | ||
4358 | } | ||
4359 | buts[i] = buttons.Data[i].ToString(); | ||
4360 | } | ||
4361 | World.SendDialogToUser(av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new LLUUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts); | ||
4362 | } | ||
4363 | |||
4364 | public void llVolumeDetect(int detect) | ||
4365 | { | ||
4366 | m_host.AddScriptLPS(1); | ||
4367 | NotImplemented("llVolumeDetect"); | ||
4368 | } | ||
4369 | |||
4370 | /// <summary> | ||
4371 | /// Reset the named script. The script must be present | ||
4372 | /// in the same prim. | ||
4373 | /// </summary> | ||
4374 | |||
4375 | public void llResetOtherScript(string name) | ||
4376 | { | ||
4377 | LLUUID item; | ||
4378 | |||
4379 | m_host.AddScriptLPS(1); | ||
4380 | |||
4381 | if ((item = ScriptByName(name)) != LLUUID.Zero) | ||
4382 | m_ScriptEngine.ResetScript(item); | ||
4383 | else | ||
4384 | ShoutError("llResetOtherScript: script "+name+" not found"); | ||
4385 | } | ||
4386 | |||
4387 | public LSL_Types.LSLInteger llGetScriptState(string name) | ||
4388 | { | ||
4389 | LLUUID item; | ||
4390 | |||
4391 | m_host.AddScriptLPS(1); | ||
4392 | |||
4393 | if ((item = ScriptByName(name)) != LLUUID.Zero) | ||
4394 | { | ||
4395 | return m_ScriptEngine.GetScriptState(item) ?1:0; | ||
4396 | } | ||
4397 | |||
4398 | ShoutError("llGetScriptState: script "+name+" not found"); | ||
4399 | |||
4400 | // If we didn't find it, then it's safe to | ||
4401 | // assume it is not running. | ||
4402 | |||
4403 | return 0; | ||
4404 | } | ||
4405 | |||
4406 | public void llRemoteLoadScript() | ||
4407 | { | ||
4408 | m_host.AddScriptLPS(1); | ||
4409 | Deprecated("llRemoteLoadScript"); | ||
4410 | } | ||
4411 | |||
4412 | public void llSetRemoteScriptAccessPin(int pin) | ||
4413 | { | ||
4414 | m_host.AddScriptLPS(1); | ||
4415 | NotImplemented("llSetRemoteScriptAccessPin"); | ||
4416 | } | ||
4417 | |||
4418 | public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) | ||
4419 | { | ||
4420 | m_host.AddScriptLPS(1); | ||
4421 | NotImplemented("llRemoteLoadScriptPin"); | ||
4422 | } | ||
4423 | |||
4424 | // remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) | ||
4425 | // Not sure where these constants should live: | ||
4426 | // REMOTE_DATA_CHANNEL = 1 | ||
4427 | // REMOTE_DATA_REQUEST = 2 | ||
4428 | // REMOTE_DATA_REPLY = 3 | ||
4429 | public void llOpenRemoteDataChannel() | ||
4430 | { | ||
4431 | m_host.AddScriptLPS(1); | ||
4432 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
4433 | if (xmlrpcMod.IsEnabled()) | ||
4434 | { | ||
4435 | LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, LLUUID.Zero); | ||
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) }; | ||
4437 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | ||
4438 | "remote_data", resobj, | ||
4439 | new DetectParams[0])); | ||
4440 | } | ||
4441 | } | ||
4442 | |||
4443 | public string llSendRemoteData(string channel, string dest, int idata, string sdata) | ||
4444 | { | ||
4445 | m_host.AddScriptLPS(1); | ||
4446 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
4447 | return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); | ||
4448 | } | ||
4449 | |||
4450 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) | ||
4451 | { | ||
4452 | m_host.AddScriptLPS(1); | ||
4453 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
4454 | xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata); | ||
4455 | } | ||
4456 | |||
4457 | public void llCloseRemoteDataChannel(string channel) | ||
4458 | { | ||
4459 | m_host.AddScriptLPS(1); | ||
4460 | IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
4461 | xmlrpcMod.CloseXMLRPCChannel(channel); | ||
4462 | } | ||
4463 | |||
4464 | public string llMD5String(string src, int nonce) | ||
4465 | { | ||
4466 | m_host.AddScriptLPS(1); | ||
4467 | return Util.Md5Hash(src + ":" + nonce.ToString()); | ||
4468 | } | ||
4469 | |||
4470 | public void llSetPrimitiveParams(LSL_Types.list rules) | ||
4471 | { | ||
4472 | llSetLinkPrimitiveParams(m_host.LinkNum+1, rules); | ||
4473 | } | ||
4474 | |||
4475 | public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules) | ||
4476 | { | ||
4477 | m_host.AddScriptLPS(1); | ||
4478 | |||
4479 | SceneObjectPart part=null; | ||
4480 | |||
4481 | if (m_host.LinkNum+1 != linknumber) | ||
4482 | { | ||
4483 | foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) | ||
4484 | { | ||
4485 | if ((partInst.LinkNum + 1) == linknumber) | ||
4486 | { | ||
4487 | part = partInst; | ||
4488 | break; | ||
4489 | } | ||
4490 | } | ||
4491 | } | ||
4492 | else | ||
4493 | { | ||
4494 | part = m_host; | ||
4495 | } | ||
4496 | |||
4497 | if (part == null) | ||
4498 | return; | ||
4499 | |||
4500 | int idx = 0; | ||
4501 | |||
4502 | while (idx < rules.Length) | ||
4503 | { | ||
4504 | int code = Convert.ToInt32(rules.Data[idx++]); | ||
4505 | |||
4506 | int remain = rules.Length - idx; | ||
4507 | |||
4508 | int face; | ||
4509 | LSL_Types.Vector3 v; | ||
4510 | |||
4511 | switch (code) | ||
4512 | { | ||
4513 | case 6: // PRIM_POSITION | ||
4514 | if (remain < 1) | ||
4515 | return; | ||
4516 | |||
4517 | v=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4518 | SetPos(part, v); | ||
4519 | |||
4520 | break; | ||
4521 | case 7: // PRIM_SIZE | ||
4522 | if (remain < 1) | ||
4523 | return; | ||
4524 | |||
4525 | v=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4526 | SetScale(part, v); | ||
4527 | |||
4528 | break; | ||
4529 | case 8: // PRIM_ROTATION | ||
4530 | if (remain < 1) | ||
4531 | return; | ||
4532 | |||
4533 | LSL_Types.Quaternion q = new LSL_Types.Quaternion(rules.Data[idx++].ToString()); | ||
4534 | SetRot(part, q); | ||
4535 | |||
4536 | break; | ||
4537 | |||
4538 | case 17: // PRIM_TEXTURE | ||
4539 | if (remain < 5) | ||
4540 | return; | ||
4541 | |||
4542 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4543 | string tex=rules.Data[idx++].ToString(); | ||
4544 | LSL_Types.Vector3 repeats=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4545 | LSL_Types.Vector3 offsets=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4546 | double rotation=Convert.ToDouble(rules.Data[idx++]); | ||
4547 | |||
4548 | SetTexture(part, tex, face); | ||
4549 | ScaleTexture(part, repeats.x, repeats.y, face); | ||
4550 | OffsetTexture(part, offsets.x, offsets.y, face); | ||
4551 | RotateTexture(part, rotation, face); | ||
4552 | |||
4553 | break; | ||
4554 | |||
4555 | case 18: // PRIM_COLOR | ||
4556 | if (remain < 3) | ||
4557 | return; | ||
4558 | |||
4559 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4560 | LSL_Types.Vector3 color=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4561 | double alpha=Convert.ToDouble(rules.Data[idx++]); | ||
4562 | |||
4563 | SetColor(part, color, face); | ||
4564 | SetAlpha(part, alpha, face); | ||
4565 | |||
4566 | break; | ||
4567 | case 21: // PRIM_FLEXI | ||
4568 | if (remain < 7) | ||
4569 | return; | ||
4570 | |||
4571 | int flexi = Convert.ToInt32(rules.Data[idx++]); | ||
4572 | int softness = Convert.ToInt32(rules.Data[idx++]); | ||
4573 | float gravity = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4574 | float friction = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4575 | float wind = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4576 | float tension = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4577 | LSL_Types.Vector3 force =new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4578 | |||
4579 | SetFlexi(part, (flexi == 1), softness, gravity, friction, wind, tension, force); | ||
4580 | |||
4581 | break; | ||
4582 | case 23: // PRIM_POINT_LIGHT | ||
4583 | if (remain < 5) | ||
4584 | return; | ||
4585 | int light = Convert.ToInt32(rules.Data[idx++]); | ||
4586 | LSL_Types.Vector3 lightcolor =new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4587 | float intensity = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4588 | float radius = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4589 | float falloff = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4590 | |||
4591 | SetPointLight(part, (light == 1), lightcolor, intensity, radius, falloff); | ||
4592 | |||
4593 | break; | ||
4594 | } | ||
4595 | } | ||
4596 | } | ||
4597 | |||
4598 | public string llStringToBase64(string str) | ||
4599 | { | ||
4600 | m_host.AddScriptLPS(1); | ||
4601 | try | ||
4602 | { | ||
4603 | byte[] encData_byte = new byte[str.Length]; | ||
4604 | encData_byte = Encoding.UTF8.GetBytes(str); | ||
4605 | string encodedData = Convert.ToBase64String(encData_byte); | ||
4606 | return encodedData; | ||
4607 | } | ||
4608 | catch (Exception e) | ||
4609 | { | ||
4610 | throw new Exception("Error in base64Encode" + e.Message); | ||
4611 | } | ||
4612 | } | ||
4613 | |||
4614 | public string llBase64ToString(string str) | ||
4615 | { | ||
4616 | m_host.AddScriptLPS(1); | ||
4617 | UTF8Encoding encoder = new UTF8Encoding(); | ||
4618 | Decoder utf8Decode = encoder.GetDecoder(); | ||
4619 | try | ||
4620 | { | ||
4621 | byte[] todecode_byte = Convert.FromBase64String(str); | ||
4622 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); | ||
4623 | char[] decoded_char = new char[charCount]; | ||
4624 | utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); | ||
4625 | string result = new String(decoded_char); | ||
4626 | return result; | ||
4627 | } | ||
4628 | catch (Exception e) | ||
4629 | { | ||
4630 | throw new Exception("Error in base64Decode" + e.Message); | ||
4631 | } | ||
4632 | } | ||
4633 | |||
4634 | public void llXorBase64Strings() | ||
4635 | { | ||
4636 | m_host.AddScriptLPS(1); | ||
4637 | Deprecated("llXorBase64Strings"); | ||
4638 | } | ||
4639 | |||
4640 | public void llRemoteDataSetRegion() | ||
4641 | { | ||
4642 | m_host.AddScriptLPS(1); | ||
4643 | NotImplemented("llRemoteDataSetRegion"); | ||
4644 | } | ||
4645 | |||
4646 | public double llLog10(double val) | ||
4647 | { | ||
4648 | m_host.AddScriptLPS(1); | ||
4649 | return (double)Math.Log10(val); | ||
4650 | } | ||
4651 | |||
4652 | public double llLog(double val) | ||
4653 | { | ||
4654 | m_host.AddScriptLPS(1); | ||
4655 | return (double)Math.Log(val); | ||
4656 | } | ||
4657 | |||
4658 | public LSL_Types.list llGetAnimationList(string id) | ||
4659 | { | ||
4660 | m_host.AddScriptLPS(1); | ||
4661 | NotImplemented("llGetAnimationList"); | ||
4662 | return new LSL_Types.list(); | ||
4663 | } | ||
4664 | |||
4665 | public void llSetParcelMusicURL(string url) | ||
4666 | { | ||
4667 | m_host.AddScriptLPS(1); | ||
4668 | LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | ||
4669 | if (landowner == LLUUID.Zero) | ||
4670 | { | ||
4671 | return; | ||
4672 | } | ||
4673 | if (landowner != m_host.ObjectOwner) | ||
4674 | { | ||
4675 | return; | ||
4676 | } | ||
4677 | World.SetLandMusicURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url); | ||
4678 | } | ||
4679 | |||
4680 | public void osSetParcelMediaURL(string url) | ||
4681 | { | ||
4682 | m_host.AddScriptLPS(1); | ||
4683 | LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | ||
4684 | |||
4685 | if (landowner == LLUUID.Zero) | ||
4686 | { | ||
4687 | return; | ||
4688 | } | ||
4689 | |||
4690 | if (landowner != m_host.ObjectOwner) | ||
4691 | { | ||
4692 | return; | ||
4693 | } | ||
4694 | |||
4695 | World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url); | ||
4696 | } | ||
4697 | |||
4698 | public LSL_Types.Vector3 llGetRootPosition() | ||
4699 | { | ||
4700 | m_host.AddScriptLPS(1); | ||
4701 | return new LSL_Types.Vector3(m_host.ParentGroup.AbsolutePosition.X, m_host.ParentGroup.AbsolutePosition.Y, m_host.ParentGroup.AbsolutePosition.Z); | ||
4702 | } | ||
4703 | |||
4704 | public LSL_Types.Quaternion llGetRootRotation() | ||
4705 | { | ||
4706 | m_host.AddScriptLPS(1); | ||
4707 | return new LSL_Types.Quaternion(m_host.ParentGroup.GroupRotation.X, m_host.ParentGroup.GroupRotation.Y, m_host.ParentGroup.GroupRotation.Z, m_host.ParentGroup.GroupRotation.W); | ||
4708 | } | ||
4709 | |||
4710 | public string llGetObjectDesc() | ||
4711 | { | ||
4712 | return m_host.Description!=null?m_host.Description:String.Empty; | ||
4713 | } | ||
4714 | |||
4715 | public void llSetObjectDesc(string desc) | ||
4716 | { | ||
4717 | m_host.AddScriptLPS(1); | ||
4718 | m_host.Description = desc!=null?desc:String.Empty; | ||
4719 | } | ||
4720 | |||
4721 | public string llGetCreator() | ||
4722 | { | ||
4723 | m_host.AddScriptLPS(1); | ||
4724 | return m_host.ObjectCreator.ToString(); | ||
4725 | } | ||
4726 | |||
4727 | public string llGetTimestamp() | ||
4728 | { | ||
4729 | m_host.AddScriptLPS(1); | ||
4730 | return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); | ||
4731 | } | ||
4732 | |||
4733 | public void llSetLinkAlpha(int linknumber, double alpha, int face) | ||
4734 | { | ||
4735 | m_host.AddScriptLPS(1); | ||
4736 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber); | ||
4737 | if (linknumber > -1) | ||
4738 | { | ||
4739 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
4740 | LLColor texcolor; | ||
4741 | if (face > -1) | ||
4742 | { | ||
4743 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
4744 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4745 | tex.FaceTextures[face].RGBA = texcolor; | ||
4746 | part.UpdateTexture(tex); | ||
4747 | return; | ||
4748 | } | ||
4749 | else if (face == -1) | ||
4750 | { | ||
4751 | texcolor = tex.DefaultTexture.RGBA; | ||
4752 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4753 | tex.DefaultTexture.RGBA = texcolor; | ||
4754 | for (uint i = 0; i < 32; i++) | ||
4755 | { | ||
4756 | if (tex.FaceTextures[i] != null) | ||
4757 | { | ||
4758 | texcolor = tex.FaceTextures[i].RGBA; | ||
4759 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4760 | tex.FaceTextures[i].RGBA = texcolor; | ||
4761 | } | ||
4762 | } | ||
4763 | texcolor = tex.DefaultTexture.RGBA; | ||
4764 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4765 | tex.DefaultTexture.RGBA = texcolor; | ||
4766 | part.UpdateTexture(tex); | ||
4767 | return; | ||
4768 | } | ||
4769 | return; | ||
4770 | } | ||
4771 | else if (linknumber == -1) | ||
4772 | { | ||
4773 | int num = m_host.ParentGroup.PrimCount; | ||
4774 | for (int w = 0; w < num; w++) | ||
4775 | { | ||
4776 | linknumber = w; | ||
4777 | part = m_host.ParentGroup.GetLinkNumPart(linknumber); | ||
4778 | LLObject.TextureEntry tex = part.Shape.Textures; | ||
4779 | LLColor texcolor; | ||
4780 | if (face > -1) | ||
4781 | { | ||
4782 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
4783 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4784 | tex.FaceTextures[face].RGBA = texcolor; | ||
4785 | part.UpdateTexture(tex); | ||
4786 | } | ||
4787 | else if (face == -1) | ||
4788 | { | ||
4789 | texcolor = tex.DefaultTexture.RGBA; | ||
4790 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4791 | tex.DefaultTexture.RGBA = texcolor; | ||
4792 | for (uint i = 0; i < 32; i++) | ||
4793 | { | ||
4794 | if (tex.FaceTextures[i] != null) | ||
4795 | { | ||
4796 | texcolor = tex.FaceTextures[i].RGBA; | ||
4797 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4798 | tex.FaceTextures[i].RGBA = texcolor; | ||
4799 | } | ||
4800 | } | ||
4801 | texcolor = tex.DefaultTexture.RGBA; | ||
4802 | texcolor.A = (float)Math.Abs(alpha - 1); | ||
4803 | tex.DefaultTexture.RGBA = texcolor; | ||
4804 | part.UpdateTexture(tex); | ||
4805 | } | ||
4806 | } | ||
4807 | return; | ||
4808 | } | ||
4809 | } | ||
4810 | |||
4811 | public LSL_Types.LSLInteger llGetNumberOfPrims() | ||
4812 | { | ||
4813 | m_host.AddScriptLPS(1); | ||
4814 | return m_host.ParentGroup.PrimCount; | ||
4815 | } | ||
4816 | |||
4817 | public LSL_Types.list llGetBoundingBox(string obj) | ||
4818 | { | ||
4819 | m_host.AddScriptLPS(1); | ||
4820 | NotImplemented("llGetBoundingBox"); | ||
4821 | return new LSL_Types.list(); | ||
4822 | } | ||
4823 | |||
4824 | public LSL_Types.Vector3 llGetGeometricCenter() | ||
4825 | { | ||
4826 | return new LSL_Types.Vector3(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); | ||
4827 | } | ||
4828 | |||
4829 | public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules) | ||
4830 | { | ||
4831 | m_host.AddScriptLPS(1); | ||
4832 | |||
4833 | LSL_Types.list res = new LSL_Types.list(); | ||
4834 | int idx=0; | ||
4835 | while (idx < rules.Length) | ||
4836 | { | ||
4837 | int code=Convert.ToInt32(rules.Data[idx++]); | ||
4838 | int remain=rules.Length-idx; | ||
4839 | |||
4840 | switch (code) | ||
4841 | { | ||
4842 | case 2: // PRIM_MATERIAL | ||
4843 | res.Add(new LSL_Types.LSLInteger(m_host.Material)); | ||
4844 | break; | ||
4845 | |||
4846 | case 3: // PRIM_PHYSICS | ||
4847 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) != 0) | ||
4848 | res.Add(new LSL_Types.LSLInteger(1)); | ||
4849 | else | ||
4850 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4851 | break; | ||
4852 | |||
4853 | case 4: // PRIM_TEMP_ON_REZ | ||
4854 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) != 0) | ||
4855 | res.Add(new LSL_Types.LSLInteger(1)); | ||
4856 | else | ||
4857 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4858 | break; | ||
4859 | |||
4860 | case 5: // PRIM_PHANTOM | ||
4861 | if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) != 0) | ||
4862 | res.Add(new LSL_Types.LSLInteger(1)); | ||
4863 | else | ||
4864 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4865 | break; | ||
4866 | |||
4867 | case 6: // PRIM_POSITION | ||
4868 | res.Add(new LSL_Types.Vector3(m_host.AbsolutePosition.X, | ||
4869 | m_host.AbsolutePosition.Y, | ||
4870 | m_host.AbsolutePosition.Z)); | ||
4871 | break; | ||
4872 | |||
4873 | case 7: // PRIM_SIZE | ||
4874 | res.Add(new LSL_Types.Vector3(m_host.Scale.X, | ||
4875 | m_host.Scale.Y, | ||
4876 | m_host.Scale.Z)); | ||
4877 | break; | ||
4878 | |||
4879 | case 8: // PRIM_ROTATION | ||
4880 | res.Add(new LSL_Types.Quaternion(m_host.RotationOffset.X, | ||
4881 | m_host.RotationOffset.Y, | ||
4882 | m_host.RotationOffset.Z, | ||
4883 | m_host.RotationOffset.W)); | ||
4884 | break; | ||
4885 | |||
4886 | case 9: // PRIM_TYPE | ||
4887 | // TODO-------------- | ||
4888 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4889 | break; | ||
4890 | |||
4891 | case 17: // PRIM_TEXTURE | ||
4892 | if (remain < 1) | ||
4893 | return res; | ||
4894 | |||
4895 | int face=Convert.ToInt32(rules.Data[idx++]); | ||
4896 | if (face == -1) | ||
4897 | face = 0; | ||
4898 | |||
4899 | LLObject.TextureEntry tex = m_host.Shape.Textures; | ||
4900 | LLObject.TextureEntryFace texface = tex.GetFace((uint)face); | ||
4901 | |||
4902 | res.Add(new LSL_Types.LSLString(texface.TextureID.ToString())); | ||
4903 | res.Add(new LSL_Types.Vector3(texface.RepeatU, | ||
4904 | texface.RepeatV, | ||
4905 | 0)); | ||
4906 | res.Add(new LSL_Types.Vector3(texface.OffsetU, | ||
4907 | texface.OffsetV, | ||
4908 | 0)); | ||
4909 | res.Add(new LSL_Types.LSLFloat(texface.Rotation)); | ||
4910 | break; | ||
4911 | |||
4912 | case 18: // PRIM_COLOR | ||
4913 | if (remain < 1) | ||
4914 | return res; | ||
4915 | |||
4916 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4917 | |||
4918 | tex = m_host.Shape.Textures; | ||
4919 | LLColor texcolor; | ||
4920 | if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color | ||
4921 | texcolor = tex.DefaultTexture.RGBA; | ||
4922 | else | ||
4923 | texcolor = tex.GetFace((uint)face).RGBA; | ||
4924 | res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255, | ||
4925 | (255 - (texcolor.G * 255)) / 255, | ||
4926 | (255 - (texcolor.B * 255)) / 255)); | ||
4927 | res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255)); | ||
4928 | break; | ||
4929 | |||
4930 | case 19: // PRIM_BUMP_SHINY | ||
4931 | // TODO-------------- | ||
4932 | if (remain < 1) | ||
4933 | return res; | ||
4934 | |||
4935 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4936 | |||
4937 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4938 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4939 | break; | ||
4940 | |||
4941 | case 20: // PRIM_FULLBRIGHT | ||
4942 | // TODO-------------- | ||
4943 | if (remain < 1) | ||
4944 | return res; | ||
4945 | |||
4946 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4947 | |||
4948 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4949 | break; | ||
4950 | |||
4951 | case 21: // PRIM_FLEXIBLE | ||
4952 | PrimitiveBaseShape shape = m_host.Shape; | ||
4953 | |||
4954 | if (shape.FlexiEntry) | ||
4955 | res.Add(new LSL_Types.LSLInteger(1)); // active | ||
4956 | else | ||
4957 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4958 | res.Add(new LSL_Types.LSLInteger(shape.FlexiSoftness));// softness | ||
4959 | res.Add(new LSL_Types.LSLFloat(shape.FlexiGravity)); // gravity | ||
4960 | res.Add(new LSL_Types.LSLFloat(shape.FlexiDrag)); // friction | ||
4961 | res.Add(new LSL_Types.LSLFloat(shape.FlexiWind)); // wind | ||
4962 | res.Add(new LSL_Types.LSLFloat(shape.FlexiTension)); // tension | ||
4963 | res.Add(new LSL_Types.Vector3(shape.FlexiForceX, // force | ||
4964 | shape.FlexiForceY, | ||
4965 | shape.FlexiForceZ)); | ||
4966 | break; | ||
4967 | |||
4968 | case 22: // PRIM_TEXGEN | ||
4969 | // TODO-------------- | ||
4970 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
4971 | if (remain < 1) | ||
4972 | return res; | ||
4973 | |||
4974 | face=Convert.ToInt32(rules.Data[idx++]); | ||
4975 | |||
4976 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4977 | break; | ||
4978 | |||
4979 | case 23: // PRIM_POINT_LIGHT: | ||
4980 | shape = m_host.Shape; | ||
4981 | |||
4982 | if (shape.LightEntry) | ||
4983 | res.Add(new LSL_Types.LSLInteger(1)); // active | ||
4984 | else | ||
4985 | res.Add(new LSL_Types.LSLInteger(0)); | ||
4986 | res.Add(new LSL_Types.Vector3(shape.LightColorR, // color | ||
4987 | shape.LightColorG, | ||
4988 | shape.LightColorB)); | ||
4989 | res.Add(new LSL_Types.LSLFloat(shape.LightIntensity)); // intensity | ||
4990 | res.Add(new LSL_Types.LSLFloat(shape.LightRadius)); // radius | ||
4991 | res.Add(new LSL_Types.LSLFloat(shape.LightFalloff)); // falloff | ||
4992 | break; | ||
4993 | |||
4994 | case 24: // PRIM_GLOW | ||
4995 | // TODO-------------- | ||
4996 | if (remain < 1) | ||
4997 | return res; | ||
4998 | |||
4999 | face=Convert.ToInt32(rules.Data[idx++]); | ||
5000 | |||
5001 | res.Add(new LSL_Types.LSLFloat(0)); | ||
5002 | break; | ||
5003 | } | ||
5004 | } | ||
5005 | return res; | ||
5006 | } | ||
5007 | |||
5008 | // <remarks> | ||
5009 | // <para> | ||
5010 | // The .NET definition of base 64 is: | ||
5011 | // <list> | ||
5012 | // <item> | ||
5013 | // Significant: A-Z a-z 0-9 + - | ||
5014 | // </item> | ||
5015 | // <item> | ||
5016 | // Whitespace: \t \n \r ' ' | ||
5017 | // </item> | ||
5018 | // <item> | ||
5019 | // Valueless: = | ||
5020 | // </item> | ||
5021 | // <item> | ||
5022 | // End-of-string: \0 or '==' | ||
5023 | // </item> | ||
5024 | // </list> | ||
5025 | // </para> | ||
5026 | // <para> | ||
5027 | // Each point in a base-64 string represents | ||
5028 | // a 6 bit value. A 32-bit integer can be | ||
5029 | // represented using 6 characters (with some | ||
5030 | // redundancy). | ||
5031 | // </para> | ||
5032 | // <para> | ||
5033 | // LSL requires a base64 string to be 8 | ||
5034 | // characters in length. LSL also uses '/' | ||
5035 | // rather than '-' (MIME compliant). | ||
5036 | // </para> | ||
5037 | // <para> | ||
5038 | // RFC 1341 used as a reference (as specified | ||
5039 | // by the SecondLife Wiki). | ||
5040 | // </para> | ||
5041 | // <para> | ||
5042 | // SL do not record any kind of exception for | ||
5043 | // these functions, so the string to integer | ||
5044 | // conversion returns '0' if an invalid | ||
5045 | // character is encountered during conversion. | ||
5046 | // </para> | ||
5047 | // <para> | ||
5048 | // References | ||
5049 | // <list> | ||
5050 | // <item> | ||
5051 | // http://lslwiki.net/lslwiki/wakka.php?wakka=Base64 | ||
5052 | // </item> | ||
5053 | // <item> | ||
5054 | // </item> | ||
5055 | // </list> | ||
5056 | // </para> | ||
5057 | // </remarks> | ||
5058 | |||
5059 | // <summary> | ||
5060 | // Table for converting 6-bit integers into | ||
5061 | // base-64 characters | ||
5062 | // </summary> | ||
5063 | |||
5064 | private static readonly char[] i2ctable = | ||
5065 | { | ||
5066 | 'A','B','C','D','E','F','G','H', | ||
5067 | 'I','J','K','L','M','N','O','P', | ||
5068 | 'Q','R','S','T','U','V','W','X', | ||
5069 | 'Y','Z', | ||
5070 | 'a','b','c','d','e','f','g','h', | ||
5071 | 'i','j','k','l','m','n','o','p', | ||
5072 | 'q','r','s','t','u','v','w','x', | ||
5073 | 'y','z', | ||
5074 | '0','1','2','3','4','5','6','7', | ||
5075 | '8','9', | ||
5076 | '+','/' | ||
5077 | }; | ||
5078 | |||
5079 | // <summary> | ||
5080 | // Table for converting base-64 characters | ||
5081 | // into 6-bit integers. | ||
5082 | // </summary> | ||
5083 | |||
5084 | private static readonly int[] c2itable = | ||
5085 | { | ||
5086 | -1,-1,-1,-1,-1,-1,-1,-1, // 0x | ||
5087 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5088 | -1,-1,-1,-1,-1,-1,-1,-1, // 1x | ||
5089 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5090 | -1,-1,-1,-1,-1,-1,-1,-1, // 2x | ||
5091 | -1,-1,-1,63,-1,-1,-1,64, | ||
5092 | 53,54,55,56,57,58,59,60, // 3x | ||
5093 | 61,62,-1,-1,-1,0,-1,-1, | ||
5094 | -1,1,2,3,4,5,6,7, // 4x | ||
5095 | 8,9,10,11,12,13,14,15, | ||
5096 | 16,17,18,19,20,21,22,23, // 5x | ||
5097 | 24,25,26,-1,-1,-1,-1,-1, | ||
5098 | -1,27,28,29,30,31,32,33, // 6x | ||
5099 | 34,35,36,37,38,39,40,41, | ||
5100 | 42,43,44,45,46,47,48,49, // 7x | ||
5101 | 50,51,52,-1,-1,-1,-1,-1, | ||
5102 | -1,-1,-1,-1,-1,-1,-1,-1, // 8x | ||
5103 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5104 | -1,-1,-1,-1,-1,-1,-1,-1, // 9x | ||
5105 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5106 | -1,-1,-1,-1,-1,-1,-1,-1, // Ax | ||
5107 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5108 | -1,-1,-1,-1,-1,-1,-1,-1, // Bx | ||
5109 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5110 | -1,-1,-1,-1,-1,-1,-1,-1, // Cx | ||
5111 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5112 | -1,-1,-1,-1,-1,-1,-1,-1, // Dx | ||
5113 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5114 | -1,-1,-1,-1,-1,-1,-1,-1, // Ex | ||
5115 | -1,-1,-1,-1,-1,-1,-1,-1, | ||
5116 | -1,-1,-1,-1,-1,-1,-1,-1, // Fx | ||
5117 | -1,-1,-1,-1,-1,-1,-1,-1 | ||
5118 | }; | ||
5119 | |||
5120 | // <summary> | ||
5121 | // Converts a 32-bit integer into a Base64 | ||
5122 | // character string. Base64 character strings | ||
5123 | // are always 8 characters long. All iinteger | ||
5124 | // values are acceptable. | ||
5125 | // </summary> | ||
5126 | // <param name="number"> | ||
5127 | // 32-bit integer to be converted. | ||
5128 | // </param> | ||
5129 | // <returns> | ||
5130 | // 8 character string. The 1st six characters | ||
5131 | // contain the encoded number, the last two | ||
5132 | // characters are padded with "=". | ||
5133 | // </returns> | ||
5134 | |||
5135 | public string llIntegerToBase64(int number) | ||
5136 | { | ||
5137 | // uninitialized string | ||
5138 | |||
5139 | char[] imdt = new char[8]; | ||
5140 | |||
5141 | m_host.AddScriptLPS(1); | ||
5142 | |||
5143 | // Manually unroll the loop | ||
5144 | |||
5145 | imdt[7] = '='; | ||
5146 | imdt[6] = '='; | ||
5147 | imdt[5] = i2ctable[number<<4 & 0x3F]; | ||
5148 | imdt[4] = i2ctable[number>>2 & 0x3F]; | ||
5149 | imdt[3] = i2ctable[number>>8 & 0x3F]; | ||
5150 | imdt[2] = i2ctable[number>>14 & 0x3F]; | ||
5151 | imdt[1] = i2ctable[number>>20 & 0x3F]; | ||
5152 | imdt[0] = i2ctable[number>>26 & 0x3F]; | ||
5153 | |||
5154 | return new string(imdt); | ||
5155 | } | ||
5156 | |||
5157 | // <summary> | ||
5158 | // Converts an eight character base-64 string | ||
5159 | // into a 32-bit integer. | ||
5160 | // </summary> | ||
5161 | // <param name="str"> | ||
5162 | // 8 characters string to be converted. Other | ||
5163 | // length strings return zero. | ||
5164 | // </param> | ||
5165 | // <returns> | ||
5166 | // Returns an integer representing the | ||
5167 | // encoded value providedint he 1st 6 | ||
5168 | // characters of the string. | ||
5169 | // </returns> | ||
5170 | // <remarks> | ||
5171 | // This is coded to behave like LSL's | ||
5172 | // implementation (I think), based upon the | ||
5173 | // information available at the Wiki. | ||
5174 | // If more than 8 characters are supplied, | ||
5175 | // zero is returned. | ||
5176 | // If a NULL string is supplied, zero will | ||
5177 | // be returned. | ||
5178 | // If fewer than 6 characters are supplied, then | ||
5179 | // the answer will reflect a partial | ||
5180 | // accumulation. | ||
5181 | // <para> | ||
5182 | // The 6-bit segments are | ||
5183 | // extracted left-to-right in big-endian mode, | ||
5184 | // which means that segment 6 only contains the | ||
5185 | // two low-order bits of the 32 bit integer as | ||
5186 | // its high order 2 bits. A short string therefore | ||
5187 | // means loss of low-order information. E.g. | ||
5188 | // | ||
5189 | // |<---------------------- 32-bit integer ----------------------->|<-Pad->| | ||
5190 | // |<--Byte 0----->|<--Byte 1----->|<--Byte 2----->|<--Byte 3----->|<-Pad->| | ||
5191 | // |3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1| | | | | | | | | | |P|P|P|P| | ||
5192 | // |1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|P|P|P|P| | ||
5193 | // | str[0] | str[1] | str[2] | str[3] | str[4] | str[6] | | ||
5194 | // | ||
5195 | // </para> | ||
5196 | // </remarks> | ||
5197 | |||
5198 | public LSL_Types.LSLInteger llBase64ToInteger(string str) | ||
5199 | { | ||
5200 | int number = 0; | ||
5201 | int digit; | ||
5202 | |||
5203 | m_host.AddScriptLPS(1); | ||
5204 | |||
5205 | // Require a well-fromed base64 string | ||
5206 | |||
5207 | if (str.Length > 8) | ||
5208 | return 0; | ||
5209 | |||
5210 | // The loop is unrolled in the interests | ||
5211 | // of performance and simple necessity. | ||
5212 | // | ||
5213 | // MUST find 6 digits to be well formed | ||
5214 | // -1 == invalid | ||
5215 | // 0 == padding | ||
5216 | |||
5217 | if ((digit=c2itable[str[0]])<=0) | ||
5218 | { | ||
5219 | return digit<0?(int)0:number; | ||
5220 | } | ||
5221 | number += --digit<<26; | ||
5222 | |||
5223 | if ((digit=c2itable[str[1]])<=0) | ||
5224 | { | ||
5225 | return digit<0?(int)0:number; | ||
5226 | } | ||
5227 | number += --digit<<20; | ||
5228 | |||
5229 | if ((digit=c2itable[str[2]])<=0) | ||
5230 | { | ||
5231 | return digit<0?(int)0:number; | ||
5232 | } | ||
5233 | number += --digit<<14; | ||
5234 | |||
5235 | if ((digit=c2itable[str[3]])<=0) | ||
5236 | { | ||
5237 | return digit<0?(int)0:number; | ||
5238 | } | ||
5239 | number += --digit<<8; | ||
5240 | |||
5241 | if ((digit=c2itable[str[4]])<=0) | ||
5242 | { | ||
5243 | return digit<0?(int)0:number; | ||
5244 | } | ||
5245 | number += --digit<<2; | ||
5246 | |||
5247 | if ((digit=c2itable[str[5]])<=0) | ||
5248 | { | ||
5249 | return digit<0?(int)0:number; | ||
5250 | } | ||
5251 | number += --digit>>4; | ||
5252 | |||
5253 | // ignore trailing padding | ||
5254 | |||
5255 | return number; | ||
5256 | } | ||
5257 | |||
5258 | public double llGetGMTclock() | ||
5259 | { | ||
5260 | m_host.AddScriptLPS(1); | ||
5261 | return DateTime.UtcNow.TimeOfDay.TotalSeconds; | ||
5262 | } | ||
5263 | |||
5264 | public string llGetSimulatorHostname() | ||
5265 | { | ||
5266 | m_host.AddScriptLPS(1); | ||
5267 | return System.Environment.MachineName; | ||
5268 | } | ||
5269 | |||
5270 | public void llSetLocalRot(LSL_Types.Quaternion rot) | ||
5271 | { | ||
5272 | m_host.AddScriptLPS(1); | ||
5273 | m_host.RotationOffset = new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
5274 | } | ||
5275 | |||
5276 | // <summary> | ||
5277 | // Scan the string supplied in 'src' and | ||
5278 | // tokenize it based upon two sets of | ||
5279 | // tokenizers provided in two lists, | ||
5280 | // separators and spacers. | ||
5281 | // </summary> | ||
5282 | // | ||
5283 | // <remarks> | ||
5284 | // Separators demarcate tokens and are | ||
5285 | // elided as they are encountered. Spacers | ||
5286 | // also demarcate tokens, but are themselves | ||
5287 | // retained as tokens. | ||
5288 | // | ||
5289 | // Both separators and spacers may be arbitrarily | ||
5290 | // long strings. i.e. ":::". | ||
5291 | // | ||
5292 | // The function returns an ordered list | ||
5293 | // representing the tokens found in the supplied | ||
5294 | // sources string. If two successive tokenizers | ||
5295 | // are encountered, then a NULL entry is added | ||
5296 | // to the list. | ||
5297 | // | ||
5298 | // It is a precondition that the source and | ||
5299 | // toekizer lisst are non-null. If they are null, | ||
5300 | // then a null pointer exception will be thrown | ||
5301 | // while their lengths are being determined. | ||
5302 | // | ||
5303 | // A small amount of working memoryis required | ||
5304 | // of approximately 8*#tokenizers. | ||
5305 | // | ||
5306 | // There are many ways in which this function | ||
5307 | // can be implemented, this implementation is | ||
5308 | // fairly naive and assumes that when the | ||
5309 | // function is invooked with a short source | ||
5310 | // string and/or short lists of tokenizers, then | ||
5311 | // performance will not be an issue. | ||
5312 | // | ||
5313 | // In order to minimize the perofrmance | ||
5314 | // effects of long strings, or large numbers | ||
5315 | // of tokeizers, the function skips as far as | ||
5316 | // possible whenever a toekenizer is found, | ||
5317 | // and eliminates redundant tokenizers as soon | ||
5318 | // as is possible. | ||
5319 | // | ||
5320 | // The implementation tries to avoid any copying | ||
5321 | // of arrays or other objects. | ||
5322 | // </remarks> | ||
5323 | |||
5324 | public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list separators, LSL_Types.list spacers) | ||
5325 | { | ||
5326 | int beginning = 0; | ||
5327 | int srclen = src.Length; | ||
5328 | int seplen = separators.Length; | ||
5329 | object[] separray = separators.Data; | ||
5330 | int spclen = spacers.Length; | ||
5331 | object[] spcarray = spacers.Data; | ||
5332 | int mlen = seplen+spclen; | ||
5333 | |||
5334 | int[] offset = new int[mlen+1]; | ||
5335 | bool[] active = new bool[mlen]; | ||
5336 | |||
5337 | int best; | ||
5338 | int j; | ||
5339 | |||
5340 | // Initial capacity reduces resize cost | ||
5341 | |||
5342 | LSL_Types.list tokens = new LSL_Types.list(); | ||
5343 | |||
5344 | m_host.AddScriptLPS(1); | ||
5345 | |||
5346 | // All entries are initially valid | ||
5347 | |||
5348 | for (int i = 0; i < mlen; i++) | ||
5349 | active[i] = true; | ||
5350 | |||
5351 | offset[mlen] = srclen; | ||
5352 | |||
5353 | while (beginning < srclen) | ||
5354 | { | ||
5355 | |||
5356 | best = mlen; // as bad as it gets | ||
5357 | |||
5358 | // Scan for separators | ||
5359 | |||
5360 | for (j = 0; j < seplen; j++) | ||
5361 | { | ||
5362 | if (active[j]) | ||
5363 | { | ||
5364 | // scan all of the markers | ||
5365 | if ((offset[j] = src.IndexOf((string)separray[j],beginning)) == -1) | ||
5366 | { | ||
5367 | // not present at all | ||
5368 | active[j] = false; | ||
5369 | } | ||
5370 | else | ||
5371 | { | ||
5372 | // present and correct | ||
5373 | if (offset[j] < offset[best]) | ||
5374 | { | ||
5375 | // closest so far | ||
5376 | best = j; | ||
5377 | if (offset[best] == beginning) | ||
5378 | break; | ||
5379 | } | ||
5380 | } | ||
5381 | } | ||
5382 | } | ||
5383 | |||
5384 | // Scan for spacers | ||
5385 | |||
5386 | if (offset[best] != beginning) | ||
5387 | { | ||
5388 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | ||
5389 | { | ||
5390 | if (active[j]) | ||
5391 | { | ||
5392 | // scan all of the markers | ||
5393 | if ((offset[j] = src.IndexOf((string)spcarray[j-seplen], beginning)) == -1) | ||
5394 | { | ||
5395 | // not present at all | ||
5396 | active[j] = false; | ||
5397 | } | ||
5398 | else | ||
5399 | { | ||
5400 | // present and correct | ||
5401 | if (offset[j] < offset[best]) | ||
5402 | { | ||
5403 | // closest so far | ||
5404 | best = j; | ||
5405 | } | ||
5406 | } | ||
5407 | } | ||
5408 | } | ||
5409 | } | ||
5410 | |||
5411 | // This is the normal exit from the scanning loop | ||
5412 | |||
5413 | if (best == mlen) | ||
5414 | { | ||
5415 | // no markers were found on this pass | ||
5416 | // so we're pretty much done | ||
5417 | tokens.Add(src.Substring(beginning, srclen - beginning)); | ||
5418 | break; | ||
5419 | } | ||
5420 | |||
5421 | // Otherwise we just add the newly delimited token | ||
5422 | // and recalculate where the search should continue. | ||
5423 | |||
5424 | tokens.Add(src.Substring(beginning,offset[best]-beginning)); | ||
5425 | |||
5426 | if (best < seplen) | ||
5427 | { | ||
5428 | beginning = offset[best] + ((string)separray[best]).Length; | ||
5429 | } | ||
5430 | else | ||
5431 | { | ||
5432 | beginning = offset[best] + ((string)spcarray[best - seplen]).Length; | ||
5433 | tokens.Add(spcarray[best - seplen]); | ||
5434 | } | ||
5435 | } | ||
5436 | |||
5437 | // This an awkward an not very intuitive boundary case. If the | ||
5438 | // last substring is a tokenizer, then there is an implied trailing | ||
5439 | // null list entry. Hopefully the single comparison will not be too | ||
5440 | // arduous. Alternatively the 'break' could be replced with a return | ||
5441 | // but that's shabby programming. | ||
5442 | |||
5443 | if (beginning == srclen) | ||
5444 | { | ||
5445 | if (srclen != 0) | ||
5446 | tokens.Add(""); | ||
5447 | } | ||
5448 | |||
5449 | return tokens; | ||
5450 | } | ||
5451 | |||
5452 | public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, | ||
5453 | LSL_Types.Quaternion rot, int param) | ||
5454 | { | ||
5455 | m_host.AddScriptLPS(1); | ||
5456 | NotImplemented("llRezAtRoot"); | ||
5457 | } | ||
5458 | |||
5459 | public LSL_Types.LSLInteger llGetObjectPermMask(int mask) | ||
5460 | { | ||
5461 | m_host.AddScriptLPS(1); | ||
5462 | |||
5463 | int permmask = 0; | ||
5464 | |||
5465 | if (mask == ScriptBaseClass.MASK_BASE)//0 | ||
5466 | { | ||
5467 | permmask = (int)m_host.BaseMask; | ||
5468 | } | ||
5469 | |||
5470 | else if (mask == ScriptBaseClass.MASK_OWNER)//1 | ||
5471 | { | ||
5472 | permmask = (int)m_host.OwnerMask; | ||
5473 | } | ||
5474 | |||
5475 | else if (mask == ScriptBaseClass.MASK_GROUP)//2 | ||
5476 | { | ||
5477 | permmask = (int)m_host.GroupMask; | ||
5478 | } | ||
5479 | |||
5480 | else if (mask == ScriptBaseClass.MASK_EVERYONE)//3 | ||
5481 | { | ||
5482 | permmask = (int)m_host.EveryoneMask; | ||
5483 | } | ||
5484 | |||
5485 | else if (mask == ScriptBaseClass.MASK_NEXT)//4 | ||
5486 | { | ||
5487 | permmask = (int)m_host.NextOwnerMask; | ||
5488 | } | ||
5489 | |||
5490 | return permmask; | ||
5491 | } | ||
5492 | |||
5493 | public void llSetObjectPermMask(int mask, int value) | ||
5494 | { | ||
5495 | m_host.AddScriptLPS(1); | ||
5496 | IConfigSource config = new IniConfigSource(Application.iniFilePath); | ||
5497 | if (config.Configs["XEngine"] == null) | ||
5498 | config.AddConfig("XEngine"); | ||
5499 | |||
5500 | if (config.Configs["XEngine"].GetBoolean("AllowGodFunctions", false)) | ||
5501 | { | ||
5502 | if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) | ||
5503 | { | ||
5504 | if (mask == ScriptBaseClass.MASK_BASE)//0 | ||
5505 | { | ||
5506 | m_host.BaseMask = (uint)value; | ||
5507 | } | ||
5508 | |||
5509 | else if (mask == ScriptBaseClass.MASK_OWNER)//1 | ||
5510 | { | ||
5511 | m_host.OwnerMask = (uint)value; | ||
5512 | } | ||
5513 | |||
5514 | else if (mask == ScriptBaseClass.MASK_GROUP)//2 | ||
5515 | { | ||
5516 | m_host.GroupMask = (uint)value; | ||
5517 | } | ||
5518 | |||
5519 | else if (mask == ScriptBaseClass.MASK_EVERYONE)//3 | ||
5520 | { | ||
5521 | m_host.EveryoneMask = (uint)value; | ||
5522 | } | ||
5523 | |||
5524 | else if (mask == ScriptBaseClass.MASK_NEXT)//4 | ||
5525 | { | ||
5526 | m_host.NextOwnerMask = (uint)value; | ||
5527 | } | ||
5528 | } | ||
5529 | } | ||
5530 | } | ||
5531 | |||
5532 | public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask) | ||
5533 | { | ||
5534 | m_host.AddScriptLPS(1); | ||
5535 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5536 | { | ||
5537 | if (inv.Value.Name == item) | ||
5538 | { | ||
5539 | switch (mask) | ||
5540 | { | ||
5541 | case 0: | ||
5542 | return (int)inv.Value.BaseMask; | ||
5543 | case 1: | ||
5544 | return (int)inv.Value.OwnerMask; | ||
5545 | case 2: | ||
5546 | return (int)inv.Value.GroupMask; | ||
5547 | case 3: | ||
5548 | return (int)inv.Value.EveryoneMask; | ||
5549 | case 4: | ||
5550 | return (int)inv.Value.NextOwnerMask; | ||
5551 | } | ||
5552 | } | ||
5553 | } | ||
5554 | return -1; | ||
5555 | } | ||
5556 | |||
5557 | public void llSetInventoryPermMask(string item, int mask, int value) | ||
5558 | { | ||
5559 | m_host.AddScriptLPS(1); | ||
5560 | NotImplemented("llSetInventoryPermMask"); | ||
5561 | } | ||
5562 | |||
5563 | public string llGetInventoryCreator(string item) | ||
5564 | { | ||
5565 | m_host.AddScriptLPS(1); | ||
5566 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5567 | { | ||
5568 | if (inv.Value.Name == item) | ||
5569 | { | ||
5570 | return inv.Value.CreatorID.ToString(); | ||
5571 | } | ||
5572 | } | ||
5573 | llSay(0, "No item name '" + item + "'"); | ||
5574 | return String.Empty; | ||
5575 | } | ||
5576 | |||
5577 | public void llOwnerSay(string msg) | ||
5578 | { | ||
5579 | m_host.AddScriptLPS(1); | ||
5580 | |||
5581 | World.SimChatBroadcast(Helpers.StringToField(msg), ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); | ||
5582 | // IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
5583 | // wComm.DeliverMessage(ChatTypeEnum.Owner, 0, m_host.Name, m_host.UUID, msg); | ||
5584 | } | ||
5585 | |||
5586 | public string llRequestSimulatorData(string simulator, int data) | ||
5587 | { | ||
5588 | try | ||
5589 | { | ||
5590 | m_host.AddScriptLPS(1); | ||
5591 | |||
5592 | string reply = String.Empty; | ||
5593 | |||
5594 | RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); | ||
5595 | |||
5596 | switch (data) | ||
5597 | { | ||
5598 | case 5: // DATA_SIM_POS | ||
5599 | if (info == null) | ||
5600 | return LLUUID.Zero.ToString(); | ||
5601 | reply = new LSL_Types.Vector3( | ||
5602 | info.RegionLocX * Constants.RegionSize, | ||
5603 | info.RegionLocY * Constants.RegionSize, | ||
5604 | 0).ToString(); | ||
5605 | break; | ||
5606 | case 6: // DATA_SIM_STATUS | ||
5607 | if (info != null) | ||
5608 | reply = "up"; // Duh! | ||
5609 | else | ||
5610 | reply = "unknown"; | ||
5611 | break; | ||
5612 | case 7: // DATA_SIM_RATING | ||
5613 | if (info == null) | ||
5614 | return LLUUID.Zero.ToString(); | ||
5615 | int access = (int)info.EstateSettings.simAccess; | ||
5616 | if (access == 21) | ||
5617 | reply = "MATURE"; | ||
5618 | else if (access == 13) | ||
5619 | reply = "MATURE"; | ||
5620 | else | ||
5621 | reply = "UNKNOWN"; | ||
5622 | break; | ||
5623 | default: | ||
5624 | return LLUUID.Zero.ToString(); // Raise no event | ||
5625 | } | ||
5626 | LLUUID rq = LLUUID.Random(); | ||
5627 | |||
5628 | LLUUID tid = AsyncCommands. | ||
5629 | DataserverPlugin.RegisterRequest(m_localID, | ||
5630 | m_itemID, rq.ToString()); | ||
5631 | |||
5632 | AsyncCommands. | ||
5633 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | ||
5634 | |||
5635 | return tid.ToString(); | ||
5636 | } | ||
5637 | catch(Exception e) | ||
5638 | { | ||
5639 | Console.WriteLine(e.ToString()); | ||
5640 | return LLUUID.Zero.ToString(); | ||
5641 | } | ||
5642 | } | ||
5643 | |||
5644 | public void llForceMouselook(int mouselook) | ||
5645 | { | ||
5646 | m_host.AddScriptLPS(1); | ||
5647 | NotImplemented("llForceMouselook"); | ||
5648 | } | ||
5649 | |||
5650 | public double llGetObjectMass(string id) | ||
5651 | { | ||
5652 | m_host.AddScriptLPS(1); | ||
5653 | LLUUID key = new LLUUID(); | ||
5654 | if (LLUUID.TryParse(id,out key)) | ||
5655 | { | ||
5656 | return (double) World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass(); | ||
5657 | } | ||
5658 | return 0; | ||
5659 | } | ||
5660 | |||
5661 | /// <summary> | ||
5662 | /// illListReplaceList removes the sub-list defined by the inclusive indices | ||
5663 | /// start and end and inserts the src list in its place. The inclusive | ||
5664 | /// nature of the indices means that at least one element must be deleted | ||
5665 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | ||
5666 | /// will remove the element at index 2 and replace it with the source | ||
5667 | /// list. Both indices may be negative, with the usual interpretation. An | ||
5668 | /// interesting case is where end is lower than start. As these indices | ||
5669 | /// bound the list to be removed, then 0->end, and start->lim are removed | ||
5670 | /// and the source list is added as a suffix. | ||
5671 | /// </summary> | ||
5672 | |||
5673 | public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) | ||
5674 | { | ||
5675 | LSL_Types.list pref = null; | ||
5676 | |||
5677 | m_host.AddScriptLPS(1); | ||
5678 | |||
5679 | // Note that although we have normalized, both | ||
5680 | // indices could still be negative. | ||
5681 | if (start < 0) | ||
5682 | { | ||
5683 | start = start+dest.Length; | ||
5684 | } | ||
5685 | |||
5686 | if (end < 0) | ||
5687 | { | ||
5688 | end = end+dest.Length; | ||
5689 | } | ||
5690 | // The comventional case, remove a sequence starting with | ||
5691 | // start and ending with end. And then insert the source | ||
5692 | // list. | ||
5693 | if (start <= end) | ||
5694 | { | ||
5695 | // If greater than zero, then there is going to be a | ||
5696 | // surviving prefix. Otherwise the inclusive nature | ||
5697 | // of the indices mean that we're going to add the | ||
5698 | // source list as a prefix. | ||
5699 | if (start > 0) | ||
5700 | { | ||
5701 | pref = dest.GetSublist(0,start-1); | ||
5702 | // Only add a suffix if there is something | ||
5703 | // beyond the end index (it's inclusive too). | ||
5704 | if (end + 1 < dest.Length) | ||
5705 | { | ||
5706 | return pref + src + dest.GetSublist(end + 1, -1); | ||
5707 | } | ||
5708 | else | ||
5709 | { | ||
5710 | return pref + src; | ||
5711 | } | ||
5712 | } | ||
5713 | // If start is less than or equal to zero, then | ||
5714 | // the new list is simply a prefix. We still need to | ||
5715 | // figure out any necessary surgery to the destination | ||
5716 | // based upon end. Note that if end exceeds the upper | ||
5717 | // bound in this case, the entire destination list | ||
5718 | // is removed. | ||
5719 | else | ||
5720 | { | ||
5721 | if (end + 1 < dest.Length) | ||
5722 | { | ||
5723 | return src + dest.GetSublist(end + 1, -1); | ||
5724 | } | ||
5725 | else | ||
5726 | { | ||
5727 | return src; | ||
5728 | } | ||
5729 | } | ||
5730 | } | ||
5731 | // Finally, if start > end, we strip away a prefix and | ||
5732 | // a suffix, to leave the list that sits <between> ens | ||
5733 | // and start, and then tag on the src list. AT least | ||
5734 | // that's my interpretation. We can get sublist to do | ||
5735 | // this for us. Note that one, or both of the indices | ||
5736 | // might have been negative. | ||
5737 | else | ||
5738 | { | ||
5739 | return dest.GetSublist(end + 1, start - 1) + src; | ||
5740 | } | ||
5741 | } | ||
5742 | |||
5743 | public void llLoadURL(string avatar_id, string message, string url) | ||
5744 | { | ||
5745 | m_host.AddScriptLPS(1); | ||
5746 | LLUUID avatarId = new LLUUID(avatar_id); | ||
5747 | m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, | ||
5748 | url); | ||
5749 | } | ||
5750 | |||
5751 | public void llParcelMediaCommandList(LSL_Types.list commandList) | ||
5752 | { | ||
5753 | m_host.AddScriptLPS(1); | ||
5754 | NotImplemented("llParcelMediaCommandList"); | ||
5755 | } | ||
5756 | |||
5757 | public void llParcelMediaQuery() | ||
5758 | { | ||
5759 | m_host.AddScriptLPS(1); | ||
5760 | NotImplemented("llParcelMediaQuery"); | ||
5761 | } | ||
5762 | |||
5763 | public LSL_Types.LSLInteger llModPow(int a, int b, int c) | ||
5764 | { | ||
5765 | m_host.AddScriptLPS(1); | ||
5766 | Int64 tmp = 0; | ||
5767 | Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); | ||
5768 | return Convert.ToInt32(tmp); | ||
5769 | } | ||
5770 | |||
5771 | public LSL_Types.LSLInteger llGetInventoryType(string name) | ||
5772 | { | ||
5773 | m_host.AddScriptLPS(1); | ||
5774 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5775 | { | ||
5776 | if (inv.Value.Name == name) | ||
5777 | { | ||
5778 | return inv.Value.InvType; | ||
5779 | } | ||
5780 | } | ||
5781 | return -1; | ||
5782 | } | ||
5783 | |||
5784 | public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons) | ||
5785 | { | ||
5786 | m_host.AddScriptLPS(1); | ||
5787 | |||
5788 | if (quick_pay_buttons.Data.Length != 4) | ||
5789 | { | ||
5790 | LSLError("List must have 4 elements"); | ||
5791 | return; | ||
5792 | } | ||
5793 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | ||
5794 | m_host.ParentGroup.RootPart.PayPrice[1]=(int)quick_pay_buttons.Data[0]; | ||
5795 | m_host.ParentGroup.RootPart.PayPrice[2]=(int)quick_pay_buttons.Data[1]; | ||
5796 | m_host.ParentGroup.RootPart.PayPrice[3]=(int)quick_pay_buttons.Data[2]; | ||
5797 | m_host.ParentGroup.RootPart.PayPrice[4]=(int)quick_pay_buttons.Data[3]; | ||
5798 | } | ||
5799 | |||
5800 | public LSL_Types.Vector3 llGetCameraPos() | ||
5801 | { | ||
5802 | m_host.AddScriptLPS(1); | ||
5803 | NotImplemented("llGetCameraPos"); | ||
5804 | return new LSL_Types.Vector3(); | ||
5805 | } | ||
5806 | |||
5807 | public LSL_Types.Quaternion llGetCameraRot() | ||
5808 | { | ||
5809 | m_host.AddScriptLPS(1); | ||
5810 | NotImplemented("llGetCameraRot"); | ||
5811 | return new LSL_Types.Quaternion(); | ||
5812 | } | ||
5813 | |||
5814 | public void llSetPrimURL() | ||
5815 | { | ||
5816 | m_host.AddScriptLPS(1); | ||
5817 | NotImplemented("llSetPrimURL"); | ||
5818 | } | ||
5819 | |||
5820 | public void llRefreshPrimURL() | ||
5821 | { | ||
5822 | m_host.AddScriptLPS(1); | ||
5823 | NotImplemented("llRefreshPrimURL"); | ||
5824 | } | ||
5825 | |||
5826 | public string llEscapeURL(string url) | ||
5827 | { | ||
5828 | m_host.AddScriptLPS(1); | ||
5829 | try | ||
5830 | { | ||
5831 | return Uri.EscapeUriString(url); | ||
5832 | } | ||
5833 | catch (Exception ex) | ||
5834 | { | ||
5835 | return "llEscapeURL: " + ex.ToString(); | ||
5836 | } | ||
5837 | } | ||
5838 | |||
5839 | public string llUnescapeURL(string url) | ||
5840 | { | ||
5841 | m_host.AddScriptLPS(1); | ||
5842 | try | ||
5843 | { | ||
5844 | return Uri.UnescapeDataString(url); | ||
5845 | } | ||
5846 | catch (Exception ex) | ||
5847 | { | ||
5848 | return "llUnescapeURL: " + ex.ToString(); | ||
5849 | } | ||
5850 | } | ||
5851 | |||
5852 | public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) | ||
5853 | { | ||
5854 | m_host.AddScriptLPS(1); | ||
5855 | NotImplemented("llMapDestination"); | ||
5856 | } | ||
5857 | |||
5858 | public void llAddToLandBanList(string avatar, double hours) | ||
5859 | { | ||
5860 | m_host.AddScriptLPS(1); | ||
5861 | LLUUID key; | ||
5862 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
5863 | if (land.ownerID == m_host.OwnerID) | ||
5864 | { | ||
5865 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
5866 | if (LLUUID.TryParse(avatar, out key)) | ||
5867 | { | ||
5868 | entry.AgentID = key; | ||
5869 | entry.Flags = ParcelManager.AccessList.Ban; | ||
5870 | entry.Time = DateTime.Now.AddHours(hours); | ||
5871 | land.parcelAccessList.Add(entry); | ||
5872 | } | ||
5873 | } | ||
5874 | } | ||
5875 | |||
5876 | public void llRemoveFromLandPassList(string avatar) | ||
5877 | { | ||
5878 | m_host.AddScriptLPS(1); | ||
5879 | LLUUID key; | ||
5880 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
5881 | if (land.ownerID == m_host.OwnerID) | ||
5882 | { | ||
5883 | if (LLUUID.TryParse(avatar, out key)) | ||
5884 | { | ||
5885 | foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList) | ||
5886 | { | ||
5887 | if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Access) | ||
5888 | { | ||
5889 | land.parcelAccessList.Remove(entry); | ||
5890 | break; | ||
5891 | } | ||
5892 | } | ||
5893 | } | ||
5894 | } | ||
5895 | } | ||
5896 | |||
5897 | public void llRemoveFromLandBanList(string avatar) | ||
5898 | { | ||
5899 | m_host.AddScriptLPS(1); | ||
5900 | LLUUID key; | ||
5901 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
5902 | if (land.ownerID == m_host.OwnerID) | ||
5903 | { | ||
5904 | if (LLUUID.TryParse(avatar, out key)) | ||
5905 | { | ||
5906 | foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList) | ||
5907 | { | ||
5908 | if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Ban) | ||
5909 | { | ||
5910 | land.parcelAccessList.Remove(entry); | ||
5911 | break; | ||
5912 | } | ||
5913 | } | ||
5914 | } | ||
5915 | } | ||
5916 | } | ||
5917 | |||
5918 | public void llSetCameraParams(LSL_Types.list rules) | ||
5919 | { | ||
5920 | m_host.AddScriptLPS(1); | ||
5921 | NotImplemented("llSetCameraParams"); | ||
5922 | } | ||
5923 | |||
5924 | public void llClearCameraParams() | ||
5925 | { | ||
5926 | m_host.AddScriptLPS(1); | ||
5927 | NotImplemented("llClearCameraParams"); | ||
5928 | } | ||
5929 | |||
5930 | public double llListStatistics(int operation, LSL_Types.list src) | ||
5931 | { | ||
5932 | m_host.AddScriptLPS(1); | ||
5933 | LSL_Types.list nums = LSL_Types.list.ToDoubleList(src); | ||
5934 | switch (operation) | ||
5935 | { | ||
5936 | case ScriptBaseClass.LIST_STAT_RANGE: | ||
5937 | return nums.Range(); | ||
5938 | case ScriptBaseClass.LIST_STAT_MIN: | ||
5939 | return nums.Min(); | ||
5940 | case ScriptBaseClass.LIST_STAT_MAX: | ||
5941 | return nums.Max(); | ||
5942 | case ScriptBaseClass.LIST_STAT_MEAN: | ||
5943 | return nums.Mean(); | ||
5944 | case ScriptBaseClass.LIST_STAT_MEDIAN: | ||
5945 | return nums.Median(); | ||
5946 | case ScriptBaseClass.LIST_STAT_NUM_COUNT: | ||
5947 | return nums.NumericLength(); | ||
5948 | case ScriptBaseClass.LIST_STAT_STD_DEV: | ||
5949 | return nums.StdDev(); | ||
5950 | case ScriptBaseClass.LIST_STAT_SUM: | ||
5951 | return nums.Sum(); | ||
5952 | case ScriptBaseClass.LIST_STAT_SUM_SQUARES: | ||
5953 | return nums.SumSqrs(); | ||
5954 | case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN: | ||
5955 | return nums.GeometricMean(); | ||
5956 | case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN: | ||
5957 | return nums.HarmonicMean(); | ||
5958 | default: | ||
5959 | return 0.0; | ||
5960 | } | ||
5961 | } | ||
5962 | |||
5963 | public LSL_Types.LSLInteger llGetUnixTime() | ||
5964 | { | ||
5965 | m_host.AddScriptLPS(1); | ||
5966 | return Util.UnixTimeSinceEpoch(); | ||
5967 | } | ||
5968 | |||
5969 | public LSL_Types.LSLInteger llGetParcelFlags(LSL_Types.Vector3 pos) | ||
5970 | { | ||
5971 | m_host.AddScriptLPS(1); | ||
5972 | return (int)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).landData.landFlags; | ||
5973 | } | ||
5974 | |||
5975 | public LSL_Types.LSLInteger llGetRegionFlags() | ||
5976 | { | ||
5977 | m_host.AddScriptLPS(1); | ||
5978 | return (int)World.RegionInfo.EstateSettings.regionFlags; | ||
5979 | } | ||
5980 | |||
5981 | public string llXorBase64StringsCorrect(string str1, string str2) | ||
5982 | { | ||
5983 | m_host.AddScriptLPS(1); | ||
5984 | string ret = String.Empty; | ||
5985 | string src1 = llBase64ToString(str1); | ||
5986 | string src2 = llBase64ToString(str2); | ||
5987 | int c = 0; | ||
5988 | for (int i = 0; i < src1.Length; i++) | ||
5989 | { | ||
5990 | ret += src1[i] ^ src2[c]; | ||
5991 | |||
5992 | c++; | ||
5993 | if (c > src2.Length) | ||
5994 | c = 0; | ||
5995 | } | ||
5996 | return llStringToBase64(ret); | ||
5997 | } | ||
5998 | |||
5999 | public string llHTTPRequest(string url, LSL_Types.list parameters, string body) | ||
6000 | { | ||
6001 | // Partial implementation: support for parameter flags needed | ||
6002 | // see http://wiki.secondlife.com/wiki/LlHTTPRequest | ||
6003 | // parameter flags support are implemented in ScriptsHttpRequests.cs | ||
6004 | // in StartHttpRequest | ||
6005 | |||
6006 | m_host.AddScriptLPS(1); | ||
6007 | IHttpRequests httpScriptMod = | ||
6008 | m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | ||
6009 | List<string> param = new List<string>(); | ||
6010 | foreach (object o in parameters.Data) | ||
6011 | { | ||
6012 | param.Add(o.ToString()); | ||
6013 | } | ||
6014 | LLUUID reqID = httpScriptMod. | ||
6015 | StartHttpRequest(m_localID, m_itemID, url, param, body); | ||
6016 | |||
6017 | if (reqID != LLUUID.Zero) | ||
6018 | return reqID.ToString(); | ||
6019 | else | ||
6020 | return null; | ||
6021 | } | ||
6022 | |||
6023 | public void llResetLandBanList() | ||
6024 | { | ||
6025 | m_host.AddScriptLPS(1); | ||
6026 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
6027 | if (land.ownerID == m_host.OwnerID) | ||
6028 | { | ||
6029 | foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList) | ||
6030 | { | ||
6031 | if (entry.Flags == ParcelManager.AccessList.Ban) | ||
6032 | { | ||
6033 | land.parcelAccessList.Remove(entry); | ||
6034 | } | ||
6035 | } | ||
6036 | } | ||
6037 | } | ||
6038 | |||
6039 | public void llResetLandPassList() | ||
6040 | { | ||
6041 | m_host.AddScriptLPS(1); | ||
6042 | LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData; | ||
6043 | if (land.ownerID == m_host.OwnerID) | ||
6044 | { | ||
6045 | foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList) | ||
6046 | { | ||
6047 | if (entry.Flags == ParcelManager.AccessList.Access) | ||
6048 | { | ||
6049 | land.parcelAccessList.Remove(entry); | ||
6050 | } | ||
6051 | } | ||
6052 | } | ||
6053 | } | ||
6054 | |||
6055 | public LSL_Types.LSLInteger llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) | ||
6056 | { | ||
6057 | m_host.AddScriptLPS(1); | ||
6058 | |||
6059 | LandData land = World.GetLandData((float)pos.x, (float)pos.y); | ||
6060 | |||
6061 | if (land == null) | ||
6062 | { | ||
6063 | return 0; | ||
6064 | } | ||
6065 | |||
6066 | else | ||
6067 | { | ||
6068 | if (sim_wide == 1) | ||
6069 | { | ||
6070 | if (category == 0) | ||
6071 | { | ||
6072 | return land.simwidePrims; | ||
6073 | } | ||
6074 | |||
6075 | else | ||
6076 | { | ||
6077 | //public int simwideArea = 0; | ||
6078 | return 0; | ||
6079 | } | ||
6080 | } | ||
6081 | |||
6082 | else | ||
6083 | { | ||
6084 | if (category == 0)//Total Prims | ||
6085 | { | ||
6086 | return 0;//land. | ||
6087 | } | ||
6088 | |||
6089 | else if (category == 1)//Owner Prims | ||
6090 | { | ||
6091 | return land.ownerPrims; | ||
6092 | } | ||
6093 | |||
6094 | else if (category == 2)//Group Prims | ||
6095 | { | ||
6096 | return land.groupPrims; | ||
6097 | } | ||
6098 | |||
6099 | else if (category == 3)//Other Prims | ||
6100 | { | ||
6101 | return land.otherPrims; | ||
6102 | } | ||
6103 | |||
6104 | else if (category == 4)//Selected | ||
6105 | { | ||
6106 | return land.selectedPrims; | ||
6107 | } | ||
6108 | |||
6109 | else if (category == 5)//Temp | ||
6110 | { | ||
6111 | return 0;//land. | ||
6112 | } | ||
6113 | } | ||
6114 | } | ||
6115 | return 0; | ||
6116 | } | ||
6117 | |||
6118 | public LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos) | ||
6119 | { | ||
6120 | m_host.AddScriptLPS(1); | ||
6121 | LandObject land = (LandObject)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); | ||
6122 | LSL_Types.list ret = new LSL_Types.list(); | ||
6123 | if (land != null) | ||
6124 | { | ||
6125 | foreach (KeyValuePair<LLUUID, int> d in land.getLandObjectOwners()) | ||
6126 | { | ||
6127 | ret.Add(d.Key.ToString()); | ||
6128 | ret.Add(d.Value); | ||
6129 | } | ||
6130 | } | ||
6131 | return ret; | ||
6132 | } | ||
6133 | |||
6134 | public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id) | ||
6135 | { | ||
6136 | m_host.AddScriptLPS(1); | ||
6137 | SceneObjectPart part = World.GetSceneObjectPart(new LLUUID(object_id)); | ||
6138 | if (part == null) | ||
6139 | { | ||
6140 | return 0; | ||
6141 | } | ||
6142 | else | ||
6143 | { | ||
6144 | return part.ParentGroup.Children.Count; | ||
6145 | } | ||
6146 | } | ||
6147 | |||
6148 | public LSL_Types.LSLInteger llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) | ||
6149 | { | ||
6150 | m_host.AddScriptLPS(1); | ||
6151 | // Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation | ||
6152 | // Which probably will be irrelevent in OpenSim.... | ||
6153 | LandData land = World.GetLandData((float)pos.x, (float)pos.y); | ||
6154 | |||
6155 | float bonusfactor = World.RegionInfo.EstateSettings.objectBonusFactor; | ||
6156 | |||
6157 | if (land == null) | ||
6158 | { | ||
6159 | return 0; | ||
6160 | } | ||
6161 | |||
6162 | if (sim_wide == 1) | ||
6163 | { | ||
6164 | decimal v = land.simwideArea * (decimal)(0.22) * (decimal)bonusfactor; | ||
6165 | |||
6166 | return (int)v; | ||
6167 | } | ||
6168 | |||
6169 | else | ||
6170 | { | ||
6171 | decimal v = land.area * (decimal)(0.22) * (decimal)bonusfactor; | ||
6172 | |||
6173 | return (int)v; | ||
6174 | } | ||
6175 | |||
6176 | } | ||
6177 | |||
6178 | public LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param) | ||
6179 | { | ||
6180 | m_host.AddScriptLPS(1); | ||
6181 | LandData land = World.GetLandData((float)pos.x, (float)pos.y); | ||
6182 | if (land == null) | ||
6183 | { | ||
6184 | return new LSL_Types.list(0); | ||
6185 | } | ||
6186 | LSL_Types.list ret = new LSL_Types.list(); | ||
6187 | foreach (object o in param.Data) | ||
6188 | { | ||
6189 | switch (o.ToString()) | ||
6190 | { | ||
6191 | case "0": | ||
6192 | ret = ret + new LSL_Types.list(land.landName); | ||
6193 | break; | ||
6194 | case "1": | ||
6195 | ret = ret + new LSL_Types.list(land.landDesc); | ||
6196 | break; | ||
6197 | case "2": | ||
6198 | ret = ret + new LSL_Types.list(land.ownerID.ToString()); | ||
6199 | break; | ||
6200 | case "3": | ||
6201 | ret = ret + new LSL_Types.list(land.groupID.ToString()); | ||
6202 | break; | ||
6203 | case "4": | ||
6204 | ret = ret + new LSL_Types.list(land.area); | ||
6205 | break; | ||
6206 | default: | ||
6207 | ret = ret + new LSL_Types.list(0); | ||
6208 | break; | ||
6209 | } | ||
6210 | } | ||
6211 | return ret; | ||
6212 | } | ||
6213 | |||
6214 | public void llSetLinkTexture(int linknumber, string texture, int face) | ||
6215 | { | ||
6216 | m_host.AddScriptLPS(1); | ||
6217 | NotImplemented("llSetLinkTexture"); | ||
6218 | } | ||
6219 | |||
6220 | public string llStringTrim(string src, int type) | ||
6221 | { | ||
6222 | m_host.AddScriptLPS(1); | ||
6223 | if (type == (int)ScriptBaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); } | ||
6224 | if (type == (int)ScriptBaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); } | ||
6225 | if (type == (int)ScriptBaseClass.STRING_TRIM) { return src.Trim(); } | ||
6226 | return src; | ||
6227 | } | ||
6228 | |||
6229 | public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args) | ||
6230 | { | ||
6231 | m_host.AddScriptLPS(1); | ||
6232 | LSL_Types.list ret = new LSL_Types.list(); | ||
6233 | LLUUID key = new LLUUID(); | ||
6234 | if (LLUUID.TryParse(id, out key)) | ||
6235 | { | ||
6236 | ScenePresence av = World.GetScenePresence(key); | ||
6237 | |||
6238 | if (av != null) | ||
6239 | { | ||
6240 | foreach (object o in args.Data) | ||
6241 | { | ||
6242 | switch (o.ToString()) | ||
6243 | { | ||
6244 | case "1": | ||
6245 | ret.Add(av.Firstname + " " + av.Lastname); | ||
6246 | break; | ||
6247 | case "2": | ||
6248 | ret.Add(""); | ||
6249 | break; | ||
6250 | case "3": | ||
6251 | ret.Add(new LSL_Types.Vector3((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); | ||
6252 | break; | ||
6253 | case "4": | ||
6254 | ret.Add(new LSL_Types.Quaternion((double)av.Rotation.x, (double)av.Rotation.y, (double)av.Rotation.z, (double)av.Rotation.w)); | ||
6255 | break; | ||
6256 | case "5": | ||
6257 | ret.Add(new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z)); | ||
6258 | break; | ||
6259 | case "6": | ||
6260 | ret.Add(id); | ||
6261 | break; | ||
6262 | case "7": | ||
6263 | ret.Add(LLUUID.Zero.ToString()); | ||
6264 | break; | ||
6265 | case "8": | ||
6266 | ret.Add(LLUUID.Zero.ToString()); | ||
6267 | break; | ||
6268 | } | ||
6269 | } | ||
6270 | return ret; | ||
6271 | } | ||
6272 | SceneObjectPart obj = World.GetSceneObjectPart(key); | ||
6273 | if (obj != null) | ||
6274 | { | ||
6275 | foreach (object o in args.Data) | ||
6276 | { | ||
6277 | switch (o.ToString()) | ||
6278 | { | ||
6279 | case "1": | ||
6280 | ret.Add(obj.Name); | ||
6281 | break; | ||
6282 | case "2": | ||
6283 | ret.Add(obj.Description); | ||
6284 | break; | ||
6285 | case "3": | ||
6286 | ret.Add(new LSL_Types.Vector3(obj.AbsolutePosition.X,obj.AbsolutePosition.Y,obj.AbsolutePosition.Z)); | ||
6287 | break; | ||
6288 | case "4": | ||
6289 | ret.Add(new LSL_Types.Quaternion(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); | ||
6290 | break; | ||
6291 | case "5": | ||
6292 | ret.Add(new LSL_Types.Vector3(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); | ||
6293 | break; | ||
6294 | case "6": | ||
6295 | ret.Add(obj.OwnerID.ToString()); | ||
6296 | break; | ||
6297 | case "7": | ||
6298 | ret.Add(obj.GroupID.ToString()); | ||
6299 | break; | ||
6300 | case "8": | ||
6301 | ret.Add(obj.CreatorID.ToString()); | ||
6302 | break; | ||
6303 | } | ||
6304 | } | ||
6305 | return ret; | ||
6306 | } | ||
6307 | } | ||
6308 | return new LSL_Types.list(); | ||
6309 | } | ||
6310 | |||
6311 | |||
6312 | internal LLUUID ScriptByName(string name) | ||
6313 | { | ||
6314 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
6315 | { | ||
6316 | if (item.Type == 10 && item.Name == name) | ||
6317 | return item.ItemID; | ||
6318 | } | ||
6319 | return LLUUID.Zero; | ||
6320 | } | ||
6321 | |||
6322 | internal void ShoutError(string msg) | ||
6323 | { | ||
6324 | llShout(ScriptBaseClass.DEBUG_CHANNEL, msg); | ||
6325 | } | ||
6326 | |||
6327 | |||
6328 | |||
6329 | internal void NotImplemented(string command) | ||
6330 | { | ||
6331 | if (throwErrorOnNotImplemented) | ||
6332 | throw new NotImplementedException("Command not implemented: " + command); | ||
6333 | } | ||
6334 | |||
6335 | internal void Deprecated(string command) | ||
6336 | { | ||
6337 | throw new Exception("Command deprecated: " + command); | ||
6338 | } | ||
6339 | |||
6340 | internal void LSLError(string msg) | ||
6341 | { | ||
6342 | throw new Exception("LSL Runtime Error: " + msg); | ||
6343 | } | ||
6344 | |||
6345 | public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); | ||
6346 | private void WithNotecard(LLUUID assetID, AssetRequestCallback cb) | ||
6347 | { | ||
6348 | World.AssetCache.GetAsset(assetID, delegate(LLUUID i, AssetBase a) { cb(i, a); }, false); | ||
6349 | } | ||
6350 | |||
6351 | public string llGetNumberOfNotecardLines(string name) | ||
6352 | { | ||
6353 | m_host.AddScriptLPS(1); | ||
6354 | |||
6355 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
6356 | { | ||
6357 | if (item.Type == 7 && item.Name == name) | ||
6358 | { | ||
6359 | LLUUID tid = AsyncCommands. | ||
6360 | DataserverPlugin.RegisterRequest(m_localID, | ||
6361 | m_itemID, item.AssetID.ToString()); | ||
6362 | if (NotecardCache.IsCached(item.AssetID)) | ||
6363 | { | ||
6364 | AsyncCommands. | ||
6365 | DataserverPlugin.DataserverReply(item.AssetID.ToString(), | ||
6366 | NotecardCache.GetLines(item.AssetID).ToString()); | ||
6367 | return tid.ToString(); | ||
6368 | } | ||
6369 | WithNotecard(item.AssetID, delegate (LLUUID id, AssetBase a) | ||
6370 | { | ||
6371 | System.Text.ASCIIEncoding enc = | ||
6372 | new System.Text.ASCIIEncoding(); | ||
6373 | string data = enc.GetString(a.Data); | ||
6374 | //Console.WriteLine(data); | ||
6375 | NotecardCache.Cache(id, data); | ||
6376 | AsyncCommands. | ||
6377 | DataserverPlugin.DataserverReply(id.ToString(), | ||
6378 | NotecardCache.GetLines(id).ToString()); | ||
6379 | }); | ||
6380 | |||
6381 | return tid.ToString(); | ||
6382 | } | ||
6383 | } | ||
6384 | return LLUUID.Zero.ToString(); | ||
6385 | } | ||
6386 | |||
6387 | public string llGetNotecardLine(string name, int line) | ||
6388 | { | ||
6389 | m_host.AddScriptLPS(1); | ||
6390 | |||
6391 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
6392 | { | ||
6393 | if (item.Type == 7 && item.Name == name) | ||
6394 | { | ||
6395 | LLUUID tid = AsyncCommands. | ||
6396 | DataserverPlugin.RegisterRequest(m_localID, | ||
6397 | m_itemID, item.AssetID.ToString()); | ||
6398 | if (NotecardCache.IsCached(item.AssetID)) | ||
6399 | { | ||
6400 | AsyncCommands. | ||
6401 | DataserverPlugin.DataserverReply(item.AssetID.ToString(), | ||
6402 | NotecardCache.GetLine(item.AssetID, line)); | ||
6403 | return tid.ToString(); | ||
6404 | } | ||
6405 | WithNotecard(item.AssetID, delegate (LLUUID id, AssetBase a) | ||
6406 | { | ||
6407 | System.Text.ASCIIEncoding enc = | ||
6408 | new System.Text.ASCIIEncoding(); | ||
6409 | string data = enc.GetString(a.Data); | ||
6410 | //Console.WriteLine(data); | ||
6411 | NotecardCache.Cache(id, data); | ||
6412 | AsyncCommands. | ||
6413 | DataserverPlugin.DataserverReply(id.ToString(), | ||
6414 | NotecardCache.GetLine(id, line)); | ||
6415 | }); | ||
6416 | |||
6417 | return tid.ToString(); | ||
6418 | } | ||
6419 | } | ||
6420 | |||
6421 | return String.Empty; | ||
6422 | } | ||
6423 | |||
6424 | } | ||
6425 | |||
6426 | public class NotecardCache | ||
6427 | { | ||
6428 | private class Notecard | ||
6429 | { | ||
6430 | public string[] text; | ||
6431 | public DateTime lastRef; | ||
6432 | } | ||
6433 | |||
6434 | private static Dictionary<LLUUID, Notecard> m_Notecards = | ||
6435 | new Dictionary<LLUUID, Notecard>(); | ||
6436 | |||
6437 | public static void Cache(LLUUID assetID, string text) | ||
6438 | { | ||
6439 | CacheCheck(); | ||
6440 | |||
6441 | lock (m_Notecards) | ||
6442 | { | ||
6443 | if (m_Notecards.ContainsKey(assetID)) | ||
6444 | return; | ||
6445 | |||
6446 | Notecard nc = new Notecard(); | ||
6447 | nc.lastRef = DateTime.Now; | ||
6448 | nc.text = ParseText(text.Replace("\r", "").Split('\n')); | ||
6449 | m_Notecards[assetID] = nc; | ||
6450 | } | ||
6451 | } | ||
6452 | |||
6453 | private static string[] ParseText(string[] input) | ||
6454 | { | ||
6455 | int idx = 0; | ||
6456 | int level = 0; | ||
6457 | List<string> output = new List<string>(); | ||
6458 | string[] words; | ||
6459 | |||
6460 | while (idx < input.Length) | ||
6461 | { | ||
6462 | if (input[idx] == "{") | ||
6463 | { | ||
6464 | level++; | ||
6465 | idx++; | ||
6466 | continue; | ||
6467 | } | ||
6468 | |||
6469 | if (input[idx]== "}") | ||
6470 | { | ||
6471 | level--; | ||
6472 | idx++; | ||
6473 | continue; | ||
6474 | } | ||
6475 | |||
6476 | switch (level) | ||
6477 | { | ||
6478 | case 0: | ||
6479 | words = input[idx].Split(' '); // Linden text ver | ||
6480 | int version = int.Parse(words[3]); | ||
6481 | if (version != 2) | ||
6482 | return new String[0]; | ||
6483 | break; | ||
6484 | case 1: | ||
6485 | words = input[idx].Split(' '); | ||
6486 | if (words[0] == "LLEmbeddedItems") | ||
6487 | break; | ||
6488 | if (words[0] == "Text") | ||
6489 | { | ||
6490 | int len = int.Parse(words[2]); | ||
6491 | idx++; | ||
6492 | |||
6493 | int count = -1; | ||
6494 | |||
6495 | while (count < len) | ||
6496 | { | ||
6497 | int l = input[idx].Length; | ||
6498 | string ln = input[idx]; | ||
6499 | |||
6500 | int need = len-count-1; | ||
6501 | if (ln.Length > need) | ||
6502 | ln = ln.Substring(0, need); | ||
6503 | |||
6504 | output.Add(ln); | ||
6505 | count += ln.Length + 1; | ||
6506 | idx++; | ||
6507 | } | ||
6508 | |||
6509 | return output.ToArray(); | ||
6510 | } | ||
6511 | break; | ||
6512 | case 2: | ||
6513 | words = input[idx].Split(' '); // count | ||
6514 | if (words[0] == "count") | ||
6515 | { | ||
6516 | int c = int.Parse(words[1]); | ||
6517 | if (c > 0) | ||
6518 | return new String[0]; | ||
6519 | break; | ||
6520 | } | ||
6521 | break; | ||
6522 | } | ||
6523 | idx++; | ||
6524 | } | ||
6525 | return output.ToArray(); | ||
6526 | } | ||
6527 | |||
6528 | public static bool IsCached(LLUUID assetID) | ||
6529 | { | ||
6530 | lock (m_Notecards) | ||
6531 | { | ||
6532 | return m_Notecards.ContainsKey(assetID); | ||
6533 | } | ||
6534 | } | ||
6535 | |||
6536 | public static int GetLines(LLUUID assetID) | ||
6537 | { | ||
6538 | if (!IsCached(assetID)) | ||
6539 | return -1; | ||
6540 | |||
6541 | lock (m_Notecards) | ||
6542 | { | ||
6543 | m_Notecards[assetID].lastRef = DateTime.Now; | ||
6544 | return m_Notecards[assetID].text.Length; | ||
6545 | } | ||
6546 | } | ||
6547 | |||
6548 | public static string GetLine(LLUUID assetID, int line) | ||
6549 | { | ||
6550 | if (line < 0) | ||
6551 | return ""; | ||
6552 | |||
6553 | string data; | ||
6554 | |||
6555 | if (!IsCached(assetID)) | ||
6556 | return ""; | ||
6557 | |||
6558 | lock (m_Notecards) | ||
6559 | { | ||
6560 | m_Notecards[assetID].lastRef = DateTime.Now; | ||
6561 | |||
6562 | if (line >= m_Notecards[assetID].text.Length) | ||
6563 | return "\n\n\n"; | ||
6564 | |||
6565 | data = m_Notecards[assetID].text[line]; | ||
6566 | if (data.Length > 255) | ||
6567 | data = data.Substring(0, 255); | ||
6568 | |||
6569 | return data; | ||
6570 | } | ||
6571 | } | ||
6572 | |||
6573 | public static void CacheCheck() | ||
6574 | { | ||
6575 | foreach (LLUUID key in new List<LLUUID>(m_Notecards.Keys)) | ||
6576 | { | ||
6577 | Notecard nc = m_Notecards[key]; | ||
6578 | if (nc.lastRef.AddSeconds(30) < DateTime.Now) | ||
6579 | m_Notecards.Remove(key); | ||
6580 | } | ||
6581 | } | ||
6582 | } | ||
6583 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs new file mode 100644 index 0000000..dbb78a4 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -0,0 +1,553 @@ | |||
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 | using System; | ||
28 | using Axiom.Math; | ||
29 | using libsecondlife; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework.Console; | ||
32 | using OpenSim.Region.Environment.Interfaces; | ||
33 | using OpenSim.Region.Environment.Scenes; | ||
34 | using OpenSim.Region.ScriptEngine.Shared; | ||
35 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
36 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
37 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
39 | |||
40 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
41 | { | ||
42 | [Serializable] | ||
43 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | ||
44 | { | ||
45 | internal IScriptEngine m_ScriptEngine; | ||
46 | internal SceneObjectPart m_host; | ||
47 | internal uint m_localID; | ||
48 | internal LLUUID m_itemID; | ||
49 | |||
50 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) | ||
51 | { | ||
52 | m_ScriptEngine = ScriptEngine; | ||
53 | m_host = host; | ||
54 | m_localID = localID; | ||
55 | m_itemID = itemID; | ||
56 | } | ||
57 | |||
58 | |||
59 | // | ||
60 | // OpenSim functions | ||
61 | // | ||
62 | |||
63 | public int osTerrainSetHeight(int x, int y, double val) | ||
64 | { | ||
65 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
66 | { | ||
67 | OSSLError("osTerrainSetHeight: permission denied"); | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | m_host.AddScriptLPS(1); | ||
72 | if (x > 255 || x < 0 || y > 255 || y < 0) | ||
73 | OSSLError("osTerrainSetHeight: Coordinate out of bounds"); | ||
74 | |||
75 | if (World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(x, y, 0))) | ||
76 | { | ||
77 | World.Heightmap[x, y] = val; | ||
78 | return 1; | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | return 0; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | public double osTerrainGetHeight(int x, int y) | ||
87 | { | ||
88 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
89 | { | ||
90 | OSSLError("osTerrainGetHeight: permission denied"); | ||
91 | return 0.0; | ||
92 | } | ||
93 | |||
94 | m_host.AddScriptLPS(1); | ||
95 | if (x > 255 || x < 0 || y > 255 || y < 0) | ||
96 | OSSLError("osTerrainGetHeight: Coordinate out of bounds"); | ||
97 | |||
98 | return World.Heightmap[x, y]; | ||
99 | } | ||
100 | |||
101 | public int osRegionRestart(double seconds) | ||
102 | { | ||
103 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
104 | { | ||
105 | OSSLError("osRegionRestart: permission denied"); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | m_host.AddScriptLPS(1); | ||
110 | if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID)) | ||
111 | { | ||
112 | World.Restart((float)seconds); | ||
113 | return 1; | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | return 0; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | public void osRegionNotice(string msg) | ||
122 | { | ||
123 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
124 | { | ||
125 | OSSLError("osRegionNotice: permission denied"); | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | m_host.AddScriptLPS(1); | ||
130 | World.SendGeneralAlert(msg); | ||
131 | } | ||
132 | |||
133 | public void osSetRot(LLUUID target, Quaternion rotation) | ||
134 | { | ||
135 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
136 | { | ||
137 | OSSLError("osSetRot: permission denied"); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | m_host.AddScriptLPS(1); | ||
142 | if (World.Entities.ContainsKey(target)) | ||
143 | { | ||
144 | World.Entities[target].Rotation = rotation; | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | OSSLError("osSetRot: Invalid target"); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, | ||
153 | int timer) | ||
154 | { | ||
155 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
156 | { | ||
157 | OSSLError("osSetDynamicTextureURL: permission denied"); | ||
158 | return String.Empty; | ||
159 | } | ||
160 | |||
161 | m_host.AddScriptLPS(1); | ||
162 | if (dynamicID == String.Empty) | ||
163 | { | ||
164 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
165 | LLUUID createdTexture = | ||
166 | textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, | ||
167 | extraParams, timer); | ||
168 | return createdTexture.ToString(); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | //TODO update existing dynamic textures | ||
173 | } | ||
174 | |||
175 | return LLUUID.Zero.ToString(); | ||
176 | } | ||
177 | |||
178 | public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | ||
179 | int timer, int alpha) | ||
180 | { | ||
181 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
182 | { | ||
183 | OSSLError("osSetDynamicTextureURLBlend: permission denied"); | ||
184 | return String.Empty; | ||
185 | } | ||
186 | |||
187 | m_host.AddScriptLPS(1); | ||
188 | if (dynamicID == String.Empty) | ||
189 | { | ||
190 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
191 | LLUUID createdTexture = | ||
192 | textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, | ||
193 | extraParams, timer, true, (byte) alpha); | ||
194 | return createdTexture.ToString(); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | //TODO update existing dynamic textures | ||
199 | } | ||
200 | |||
201 | return LLUUID.Zero.ToString(); | ||
202 | } | ||
203 | |||
204 | public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, | ||
205 | int timer) | ||
206 | { | ||
207 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
208 | { | ||
209 | OSSLError("osSetDynamicTextureData: permission denied"); | ||
210 | return String.Empty; | ||
211 | } | ||
212 | |||
213 | m_host.AddScriptLPS(1); | ||
214 | if (dynamicID == String.Empty) | ||
215 | { | ||
216 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
217 | if (textureManager != null) | ||
218 | { | ||
219 | LLUUID createdTexture = | ||
220 | textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, | ||
221 | extraParams, timer); | ||
222 | return createdTexture.ToString(); | ||
223 | } | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | //TODO update existing dynamic textures | ||
228 | } | ||
229 | |||
230 | return LLUUID.Zero.ToString(); | ||
231 | } | ||
232 | |||
233 | public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, | ||
234 | int timer, int alpha) | ||
235 | { | ||
236 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
237 | { | ||
238 | OSSLError("osSetDynamicTextureDataBlend: permission denied"); | ||
239 | return String.Empty; | ||
240 | } | ||
241 | |||
242 | m_host.AddScriptLPS(1); | ||
243 | if (dynamicID == String.Empty) | ||
244 | { | ||
245 | IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); | ||
246 | if (textureManager != null) | ||
247 | { | ||
248 | LLUUID createdTexture = | ||
249 | textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, | ||
250 | extraParams, timer, true, (byte) alpha); | ||
251 | return createdTexture.ToString(); | ||
252 | } | ||
253 | } | ||
254 | else | ||
255 | { | ||
256 | //TODO update existing dynamic textures | ||
257 | } | ||
258 | |||
259 | return LLUUID.Zero.ToString(); | ||
260 | } | ||
261 | |||
262 | public bool osConsoleCommand(string command) | ||
263 | { | ||
264 | m_host.AddScriptLPS(1); | ||
265 | if (m_ScriptEngine.Config.GetBoolean("AllowosConsoleCommand", false)) | ||
266 | { | ||
267 | if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) | ||
268 | { | ||
269 | MainConsole.Instance.RunCommand(command); | ||
270 | return true; | ||
271 | } | ||
272 | return false; | ||
273 | } | ||
274 | return false; | ||
275 | } | ||
276 | public void osSetPrimFloatOnWater(int floatYN) | ||
277 | { | ||
278 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
279 | { | ||
280 | OSSLError("osSetPrimFloatOnWater: permission denied"); | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | m_host.AddScriptLPS(1); | ||
285 | if (m_host.ParentGroup != null) | ||
286 | { | ||
287 | if (m_host.ParentGroup.RootPart != null) | ||
288 | { | ||
289 | m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | |||
294 | // Adam's super super custom animation functions | ||
295 | public void osAvatarPlayAnimation(string avatar, string animation) | ||
296 | { | ||
297 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
298 | { | ||
299 | OSSLError("osAvatarPlayAnimation: permission denied"); | ||
300 | return; | ||
301 | } | ||
302 | |||
303 | m_host.AddScriptLPS(1); | ||
304 | if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence) | ||
305 | { | ||
306 | ScenePresence target = (ScenePresence)World.Entities[avatar]; | ||
307 | target.AddAnimation(avatar); | ||
308 | } | ||
309 | } | ||
310 | |||
311 | public void osAvatarStopAnimation(string avatar, string animation) | ||
312 | { | ||
313 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
314 | { | ||
315 | OSSLError("osAvatarStopAnimation: permission denied"); | ||
316 | return; | ||
317 | } | ||
318 | |||
319 | m_host.AddScriptLPS(1); | ||
320 | if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence) | ||
321 | { | ||
322 | ScenePresence target = (ScenePresence)World.Entities[avatar]; | ||
323 | target.RemoveAnimation(animation); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | //Texture draw functions | ||
328 | public string osMovePen(string drawList, int x, int y) | ||
329 | { | ||
330 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
331 | { | ||
332 | OSSLError("osMovePen: permission denied"); | ||
333 | return String.Empty; | ||
334 | } | ||
335 | |||
336 | m_host.AddScriptLPS(1); | ||
337 | drawList += "MoveTo " + x + "," + y + ";"; | ||
338 | return drawList; | ||
339 | } | ||
340 | |||
341 | public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) | ||
342 | { | ||
343 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
344 | { | ||
345 | OSSLError("osDrawLine: permission denied"); | ||
346 | return String.Empty; | ||
347 | } | ||
348 | |||
349 | m_host.AddScriptLPS(1); | ||
350 | drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; | ||
351 | return drawList; | ||
352 | } | ||
353 | |||
354 | public string osDrawLine(string drawList, int endX, int endY) | ||
355 | { | ||
356 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
357 | { | ||
358 | OSSLError("osDrawLine: permission denied"); | ||
359 | return String.Empty; | ||
360 | } | ||
361 | |||
362 | m_host.AddScriptLPS(1); | ||
363 | drawList += "LineTo " + endX + "," + endY + "; "; | ||
364 | return drawList; | ||
365 | } | ||
366 | |||
367 | public string osDrawText(string drawList, string text) | ||
368 | { | ||
369 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
370 | { | ||
371 | OSSLError("osDrawText: permission denied"); | ||
372 | return String.Empty; | ||
373 | } | ||
374 | |||
375 | m_host.AddScriptLPS(1); | ||
376 | drawList += "Text " + text + "; "; | ||
377 | return drawList; | ||
378 | } | ||
379 | |||
380 | public string osDrawEllipse(string drawList, int width, int height) | ||
381 | { | ||
382 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
383 | { | ||
384 | OSSLError("osDrawEllipse: permission denied"); | ||
385 | return String.Empty; | ||
386 | } | ||
387 | |||
388 | m_host.AddScriptLPS(1); | ||
389 | drawList += "Ellipse " + width + "," + height + "; "; | ||
390 | return drawList; | ||
391 | } | ||
392 | |||
393 | public string osDrawRectangle(string drawList, int width, int height) | ||
394 | { | ||
395 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
396 | { | ||
397 | OSSLError("osDrawRectangle: permission denied"); | ||
398 | return String.Empty; | ||
399 | } | ||
400 | |||
401 | m_host.AddScriptLPS(1); | ||
402 | drawList += "Rectangle " + width + "," + height + "; "; | ||
403 | return drawList; | ||
404 | } | ||
405 | |||
406 | public string osDrawFilledRectangle(string drawList, int width, int height) | ||
407 | { | ||
408 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
409 | { | ||
410 | OSSLError("osDrawFilledRectangle: permission denied"); | ||
411 | return String.Empty; | ||
412 | } | ||
413 | |||
414 | m_host.AddScriptLPS(1); | ||
415 | drawList += "FillRectangle " + width + "," + height + "; "; | ||
416 | return drawList; | ||
417 | } | ||
418 | |||
419 | public string osSetFontSize(string drawList, int fontSize) | ||
420 | { | ||
421 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
422 | { | ||
423 | OSSLError("osSetFontSize: permission denied"); | ||
424 | return String.Empty; | ||
425 | } | ||
426 | |||
427 | m_host.AddScriptLPS(1); | ||
428 | drawList += "FontSize "+ fontSize +"; "; | ||
429 | return drawList; | ||
430 | } | ||
431 | |||
432 | public string osSetPenSize(string drawList, int penSize) | ||
433 | { | ||
434 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
435 | { | ||
436 | OSSLError("osSetPenSize: permission denied"); | ||
437 | return String.Empty; | ||
438 | } | ||
439 | |||
440 | m_host.AddScriptLPS(1); | ||
441 | drawList += "PenSize " + penSize + "; "; | ||
442 | return drawList; | ||
443 | } | ||
444 | |||
445 | public string osSetPenColour(string drawList, string colour) | ||
446 | { | ||
447 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
448 | { | ||
449 | OSSLError("osSetPenColour: permission denied"); | ||
450 | return String.Empty; | ||
451 | } | ||
452 | |||
453 | m_host.AddScriptLPS(1); | ||
454 | drawList += "PenColour " + colour + "; "; | ||
455 | return drawList; | ||
456 | } | ||
457 | |||
458 | public string osDrawImage(string drawList, int width, int height, string imageUrl) | ||
459 | { | ||
460 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
461 | { | ||
462 | OSSLError("osDrawImage: permission denied"); | ||
463 | return String.Empty; | ||
464 | } | ||
465 | |||
466 | m_host.AddScriptLPS(1); | ||
467 | drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; | ||
468 | return drawList; | ||
469 | } | ||
470 | |||
471 | public void osSetStateEvents(int events) | ||
472 | { | ||
473 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
474 | { | ||
475 | OSSLError("osSetStateEvents: permission denied"); | ||
476 | return; | ||
477 | } | ||
478 | |||
479 | m_host.SetScriptEvents(m_itemID, events); | ||
480 | } | ||
481 | |||
482 | public void osSetRegionWaterHeight(double height) | ||
483 | { | ||
484 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
485 | { | ||
486 | OSSLError("osSetRegionWaterHeight: permission denied"); | ||
487 | return; | ||
488 | } | ||
489 | |||
490 | m_host.AddScriptLPS(1); | ||
491 | //Check to make sure that the script's owner is the estate manager/master | ||
492 | //World.Permissions.GenericEstatePermission( | ||
493 | if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID)) | ||
494 | { | ||
495 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | public double osList2Double(LSL_Types.list src, int index) | ||
500 | { | ||
501 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
502 | { | ||
503 | OSSLError("osList2Double: permission denied"); | ||
504 | return 0.0; | ||
505 | } | ||
506 | |||
507 | m_host.AddScriptLPS(1); | ||
508 | if (index < 0) | ||
509 | { | ||
510 | index = src.Length + index; | ||
511 | } | ||
512 | if (index >= src.Length) | ||
513 | { | ||
514 | return 0.0; | ||
515 | } | ||
516 | return Convert.ToDouble(src.Data[index]); | ||
517 | } | ||
518 | |||
519 | public void osSetParcelMediaURL(string url) | ||
520 | { | ||
521 | if (!m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | ||
522 | { | ||
523 | OSSLError("osSetParcelMediaURL: permission denied"); | ||
524 | return; | ||
525 | } | ||
526 | |||
527 | m_host.AddScriptLPS(1); | ||
528 | LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | ||
529 | |||
530 | if (landowner == LLUUID.Zero) | ||
531 | { | ||
532 | return; | ||
533 | } | ||
534 | |||
535 | if (landowner != m_host.ObjectOwner) | ||
536 | { | ||
537 | return; | ||
538 | } | ||
539 | |||
540 | World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url); | ||
541 | } | ||
542 | |||
543 | public Scene World | ||
544 | { | ||
545 | get { return m_ScriptEngine.World; } | ||
546 | } | ||
547 | |||
548 | internal void OSSLError(string msg) | ||
549 | { | ||
550 | throw new Exception("OSSL Runtime Error: " + msg); | ||
551 | } | ||
552 | } | ||
553 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs new file mode 100644 index 0000000..6c88ae86 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs | |||
@@ -0,0 +1,128 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using libsecondlife; | ||
32 | using OpenSim.Region.ScriptEngine.Shared; | ||
33 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
34 | |||
35 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
36 | { | ||
37 | public class Dataserver | ||
38 | { | ||
39 | public AsyncCommandManager m_CmdManager; | ||
40 | |||
41 | private Dictionary<string, DataserverRequest> DataserverRequests = | ||
42 | new Dictionary<string, DataserverRequest>(); | ||
43 | |||
44 | public Dataserver(AsyncCommandManager CmdManager) | ||
45 | { | ||
46 | m_CmdManager = CmdManager; | ||
47 | } | ||
48 | |||
49 | private class DataserverRequest | ||
50 | { | ||
51 | public uint localID; | ||
52 | public LLUUID itemID; | ||
53 | |||
54 | public LLUUID ID; | ||
55 | public string handle; | ||
56 | |||
57 | public DateTime startTime; | ||
58 | } | ||
59 | |||
60 | public LLUUID RegisterRequest(uint localID, LLUUID itemID, | ||
61 | string identifier) | ||
62 | { | ||
63 | lock (DataserverRequests) | ||
64 | { | ||
65 | if (DataserverRequests.ContainsKey(identifier)) | ||
66 | return LLUUID.Zero; | ||
67 | |||
68 | DataserverRequest ds = new DataserverRequest(); | ||
69 | |||
70 | ds.localID = localID; | ||
71 | ds.itemID = itemID; | ||
72 | |||
73 | ds.ID = LLUUID.Random(); | ||
74 | ds.handle = identifier; | ||
75 | |||
76 | ds.startTime = DateTime.Now; | ||
77 | |||
78 | DataserverRequests[identifier]=ds; | ||
79 | |||
80 | return ds.ID; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void DataserverReply(string identifier, string reply) | ||
85 | { | ||
86 | DataserverRequest ds; | ||
87 | |||
88 | lock (DataserverRequests) | ||
89 | { | ||
90 | if (!DataserverRequests.ContainsKey(identifier)) | ||
91 | return; | ||
92 | |||
93 | ds=DataserverRequests[identifier]; | ||
94 | DataserverRequests.Remove(identifier); | ||
95 | } | ||
96 | |||
97 | m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID, | ||
98 | new EventParams("dataserver", new Object[] | ||
99 | { new LSL_Types.LSLString(ds.ID.ToString()), | ||
100 | new LSL_Types.LSLString(reply)}, | ||
101 | new DetectParams[0])); | ||
102 | } | ||
103 | |||
104 | public void RemoveEvents(uint localID, LLUUID itemID) | ||
105 | { | ||
106 | lock (DataserverRequests) | ||
107 | { | ||
108 | foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values)) | ||
109 | { | ||
110 | if (ds.itemID == itemID) | ||
111 | DataserverRequests.Remove(ds.handle); | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | public void ExpireRequests() | ||
117 | { | ||
118 | lock (DataserverRequests) | ||
119 | { | ||
120 | foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values)) | ||
121 | { | ||
122 | if (ds.startTime > DateTime.Now.AddSeconds(30)) | ||
123 | DataserverRequests.Remove(ds.handle); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs new file mode 100644 index 0000000..92f603d --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs | |||
@@ -0,0 +1,91 @@ | |||
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 | using System; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | using OpenSim.Region.Environment.Modules.Scripting.HttpRequest; | ||
31 | using OpenSim.Region.ScriptEngine.Shared; | ||
32 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
33 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
34 | |||
35 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
36 | { | ||
37 | public class HttpRequest | ||
38 | { | ||
39 | public AsyncCommandManager m_CmdManager; | ||
40 | |||
41 | public HttpRequest(AsyncCommandManager CmdManager) | ||
42 | { | ||
43 | m_CmdManager = CmdManager; | ||
44 | } | ||
45 | |||
46 | public void CheckHttpRequests() | ||
47 | { | ||
48 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
49 | return; | ||
50 | |||
51 | IHttpRequests iHttpReq = | ||
52 | m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | ||
53 | |||
54 | HttpRequestClass httpInfo = null; | ||
55 | |||
56 | if (iHttpReq != null) | ||
57 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
58 | |||
59 | while (httpInfo != null) | ||
60 | { | ||
61 | //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status); | ||
62 | |||
63 | // Deliver data to prim's remote_data handler | ||
64 | // | ||
65 | // TODO: Returning null for metadata, since the lsl function | ||
66 | // only returns the byte for HTTP_BODY_TRUNCATED, which is not | ||
67 | // implemented here yet anyway. Should be fixed if/when maxsize | ||
68 | // is supported | ||
69 | |||
70 | iHttpReq.RemoveCompletedRequest(httpInfo.reqID); | ||
71 | |||
72 | object[] resobj = new object[] | ||
73 | { | ||
74 | new LSL_Types.LSLString(httpInfo.reqID.ToString()), | ||
75 | new LSL_Types.LSLInteger(httpInfo.status), | ||
76 | new LSL_Types.list(), | ||
77 | new LSL_Types.LSLString(httpInfo.response_body) | ||
78 | }; | ||
79 | |||
80 | foreach (AsyncCommandManager m in m_CmdManager.Managers) | ||
81 | { | ||
82 | if (m.m_ScriptEngine.PostObjectEvent(httpInfo.localID, | ||
83 | new EventParams("http_response", | ||
84 | resobj, new DetectParams[0]))) | ||
85 | break; | ||
86 | } | ||
87 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs new file mode 100644 index 0000000..11b45b1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs | |||
@@ -0,0 +1,92 @@ | |||
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 | using System; | ||
29 | using libsecondlife; | ||
30 | using OpenSim.Region.Environment.Interfaces; | ||
31 | using OpenSim.Region.Environment.Modules.Scripting.WorldComm; | ||
32 | using OpenSim.Region.ScriptEngine.Shared; | ||
33 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
34 | |||
35 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
36 | { | ||
37 | public class Listener | ||
38 | { | ||
39 | // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
41 | public AsyncCommandManager m_CmdManager; | ||
42 | |||
43 | public Listener(AsyncCommandManager CmdManager) | ||
44 | { | ||
45 | m_CmdManager = CmdManager; | ||
46 | } | ||
47 | |||
48 | public void CheckListeners() | ||
49 | { | ||
50 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
51 | return; | ||
52 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
53 | |||
54 | if (comms != null) | ||
55 | { | ||
56 | while (comms.HasMessages()) | ||
57 | { | ||
58 | ListenerInfo lInfo = comms.GetNextMessage(); | ||
59 | |||
60 | //Deliver data to prim's listen handler | ||
61 | object[] resobj = new object[] | ||
62 | { | ||
63 | new LSL_Types.LSLInteger(lInfo.GetChannel()), | ||
64 | new LSL_Types.LSLString(lInfo.GetName()), | ||
65 | new LSL_Types.LSLString(lInfo.GetID().ToString()), | ||
66 | new LSL_Types.LSLString(lInfo.GetMessage()) | ||
67 | }; | ||
68 | |||
69 | m_CmdManager.m_ScriptEngine.PostScriptEvent( | ||
70 | lInfo.GetItemID(), new EventParams( | ||
71 | "listen", resobj, | ||
72 | new DetectParams[0])); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public Object[] GetSerializationData(LLUUID itemID) | ||
78 | { | ||
79 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
80 | |||
81 | return comms.GetSerializationData(itemID); | ||
82 | } | ||
83 | |||
84 | public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, | ||
85 | Object[] data) | ||
86 | { | ||
87 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
88 | |||
89 | comms.CreateFromData(localID, itemID, hostID, data); | ||
90 | } | ||
91 | } | ||
92 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs new file mode 100644 index 0000000..5833512 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -0,0 +1,389 @@ | |||
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 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Environment.Scenes; | ||
33 | using OpenSim.Region.ScriptEngine.Shared; | ||
34 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
35 | |||
36 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
37 | { | ||
38 | public class SensorRepeat | ||
39 | { | ||
40 | public AsyncCommandManager m_CmdManager; | ||
41 | |||
42 | public SensorRepeat(AsyncCommandManager CmdManager) | ||
43 | { | ||
44 | m_CmdManager = CmdManager; | ||
45 | } | ||
46 | |||
47 | public Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>> SenseEvents = | ||
48 | new Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>>(); | ||
49 | private Object SenseLock = new Object(); | ||
50 | |||
51 | // | ||
52 | // SenseRepeater and Sensors | ||
53 | // | ||
54 | private class SenseRepeatClass | ||
55 | { | ||
56 | public uint localID; | ||
57 | public LLUUID itemID; | ||
58 | public double interval; | ||
59 | public DateTime next; | ||
60 | |||
61 | public string name; | ||
62 | public LLUUID keyID; | ||
63 | public int type; | ||
64 | public double range; | ||
65 | public double arc; | ||
66 | public SceneObjectPart host; | ||
67 | } | ||
68 | |||
69 | private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); | ||
70 | private object SenseRepeatListLock = new object(); | ||
71 | |||
72 | public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID, | ||
73 | string name, LLUUID keyID, int type, double range, | ||
74 | double arc, double sec, SceneObjectPart host) | ||
75 | { | ||
76 | // Always remove first, in case this is a re-set | ||
77 | UnSetSenseRepeaterEvents(m_localID, m_itemID); | ||
78 | if (sec == 0) // Disabling timer | ||
79 | return; | ||
80 | |||
81 | // Add to timer | ||
82 | SenseRepeatClass ts = new SenseRepeatClass(); | ||
83 | ts.localID = m_localID; | ||
84 | ts.itemID = m_itemID; | ||
85 | ts.interval = sec; | ||
86 | ts.name = name; | ||
87 | ts.keyID = keyID; | ||
88 | ts.type = type; | ||
89 | ts.range = range; | ||
90 | ts.arc = arc; | ||
91 | ts.host = host; | ||
92 | |||
93 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
94 | lock (SenseRepeatListLock) | ||
95 | { | ||
96 | SenseRepeaters.Add(ts); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public void UnSetSenseRepeaterEvents(uint m_localID, LLUUID m_itemID) | ||
101 | { | ||
102 | // Remove from timer | ||
103 | lock (SenseRepeatListLock) | ||
104 | { | ||
105 | List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>(); | ||
106 | foreach (SenseRepeatClass ts in SenseRepeaters) | ||
107 | { | ||
108 | if (ts.localID != m_localID && ts.itemID != m_itemID) | ||
109 | { | ||
110 | NewSensors.Add(ts); | ||
111 | } | ||
112 | } | ||
113 | SenseRepeaters.Clear(); | ||
114 | SenseRepeaters = NewSensors; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public void CheckSenseRepeaterEvents() | ||
119 | { | ||
120 | // Nothing to do here? | ||
121 | if (SenseRepeaters.Count == 0) | ||
122 | return; | ||
123 | |||
124 | lock (SenseRepeatListLock) | ||
125 | { | ||
126 | // Go through all timers | ||
127 | foreach (SenseRepeatClass ts in SenseRepeaters) | ||
128 | { | ||
129 | // Time has passed? | ||
130 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | ||
131 | { | ||
132 | SensorSweep(ts); | ||
133 | // set next interval | ||
134 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
135 | } | ||
136 | } | ||
137 | } // lock | ||
138 | } | ||
139 | |||
140 | public void SenseOnce(uint m_localID, LLUUID m_itemID, | ||
141 | string name, LLUUID keyID, int type, | ||
142 | double range, double arc, SceneObjectPart host) | ||
143 | { | ||
144 | // Add to timer | ||
145 | SenseRepeatClass ts = new SenseRepeatClass(); | ||
146 | ts.localID = m_localID; | ||
147 | ts.itemID = m_itemID; | ||
148 | ts.interval = 0; | ||
149 | ts.name = name; | ||
150 | ts.keyID = keyID; | ||
151 | ts.type = type; | ||
152 | ts.range = range; | ||
153 | ts.arc = arc; | ||
154 | ts.host = host; | ||
155 | SensorSweep(ts); | ||
156 | } | ||
157 | |||
158 | public LSL_Types.list GetSensorList(uint m_localID, LLUUID m_itemID) | ||
159 | { | ||
160 | lock (SenseLock) | ||
161 | { | ||
162 | Dictionary<LLUUID, LSL_Types.list> Obj = null; | ||
163 | if (!SenseEvents.TryGetValue(m_localID, out Obj)) | ||
164 | { | ||
165 | return null; | ||
166 | } | ||
167 | lock (Obj) | ||
168 | { | ||
169 | // Get script | ||
170 | LSL_Types.list SenseList = null; | ||
171 | if (!Obj.TryGetValue(m_itemID, out SenseList)) | ||
172 | { | ||
173 | return null; | ||
174 | } | ||
175 | return SenseList; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | |||
180 | private void SensorSweep(SenseRepeatClass ts) | ||
181 | { | ||
182 | SceneObjectPart SensePoint = ts.host; | ||
183 | |||
184 | if (SensePoint == null) | ||
185 | { | ||
186 | return; | ||
187 | } | ||
188 | |||
189 | LLVector3 sensorPos = SensePoint.AbsolutePosition; | ||
190 | LLVector3 regionPos = new LLVector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
191 | LLVector3 fromRegionPos = sensorPos + regionPos; | ||
192 | |||
193 | LLQuaternion q = SensePoint.RotationOffset; | ||
194 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | ||
195 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | ||
196 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | ||
197 | |||
198 | // Here we should do some smart culling ... | ||
199 | // math seems quicker than strings so try that first | ||
200 | LSL_Types.list SensedObjects = new LSL_Types.list(); | ||
201 | LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); | ||
202 | |||
203 | foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values) | ||
204 | { | ||
205 | LLVector3 toRegionPos = ent.AbsolutePosition + regionPos; | ||
206 | double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos)); | ||
207 | if (dis <= ts.range) | ||
208 | { | ||
209 | // In Range, is it the right Type ? | ||
210 | int objtype = 0; | ||
211 | |||
212 | if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor | ||
213 | if (ent.Velocity.Equals(ZeroVector)) | ||
214 | objtype |= 0x04; // passive non-moving | ||
215 | else | ||
216 | objtype |= 0x02; // active moving | ||
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 ... | ||
221 | |||
222 | if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type)) | ||
223 | { | ||
224 | // docs claim AGENT|ACTIVE should find agent objects OR active objects | ||
225 | // so the bitwise AND with object type should be non-zero | ||
226 | |||
227 | // Right type too, what about the other params , key and name ? | ||
228 | bool keep = true; | ||
229 | if (ts.arc < Math.PI) | ||
230 | { | ||
231 | // not omni-directional. Can you see it ? | ||
232 | // vec forward_dir = llRot2Fwd(llGetRot()) | ||
233 | // vec obj_dir = toRegionPos-fromRegionPos | ||
234 | // dot=dot(forward_dir,obj_dir) | ||
235 | // mag_fwd = mag(forward_dir) | ||
236 | // mag_obj = mag(obj_dir) | ||
237 | // ang = acos(dot /(mag_fwd*mag_obj)) | ||
238 | double ang_obj = 0; | ||
239 | try | ||
240 | { | ||
241 | LLVector3 diff = toRegionPos - fromRegionPos; | ||
242 | LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); | ||
243 | double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); | ||
244 | double mag_obj = LSL_Types.Vector3.Mag(obj_dir); | ||
245 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); | ||
246 | } | ||
247 | catch | ||
248 | { | ||
249 | } | ||
250 | |||
251 | if (ang_obj > ts.arc) keep = false; | ||
252 | } | ||
253 | |||
254 | if (keep && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID)) | ||
255 | { | ||
256 | keep = false; | ||
257 | } | ||
258 | |||
259 | if (keep && (ts.name.Length > 0)) | ||
260 | { | ||
261 | string avatarname=null; | ||
262 | string objectname=null; | ||
263 | string entname =ent.Name; | ||
264 | |||
265 | // try avatar username surname | ||
266 | UserProfileData profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserService.GetUserProfile(ent.UUID); | ||
267 | if (profile != null) | ||
268 | { | ||
269 | avatarname = profile.FirstName + " " + profile.SurName; | ||
270 | } | ||
271 | // try an scene object | ||
272 | SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID); | ||
273 | if (SOP != null) | ||
274 | { | ||
275 | objectname = SOP.Name; | ||
276 | } | ||
277 | |||
278 | if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname)) | ||
279 | { | ||
280 | keep = false; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | if (keep == true) SensedObjects.Add(ent.UUID); | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | |||
289 | lock (SenseLock) | ||
290 | { | ||
291 | // Create object if it doesn't exist | ||
292 | if (SenseEvents.ContainsKey(ts.localID) == false) | ||
293 | { | ||
294 | SenseEvents.Add(ts.localID, new Dictionary<LLUUID, LSL_Types.list>()); | ||
295 | } | ||
296 | // clear if previous traces exist | ||
297 | Dictionary<LLUUID, LSL_Types.list> Obj; | ||
298 | SenseEvents.TryGetValue(ts.localID, out Obj); | ||
299 | if (Obj.ContainsKey(ts.itemID) == true) | ||
300 | Obj.Remove(ts.itemID); | ||
301 | |||
302 | // note list may be zero length | ||
303 | Obj.Add(ts.itemID, SensedObjects); | ||
304 | |||
305 | if (SensedObjects.Length == 0) | ||
306 | { | ||
307 | // send a "no_sensor" | ||
308 | // Add it to queue | ||
309 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | ||
310 | new EventParams("no_sensor", new Object[0], | ||
311 | new DetectParams[0])); | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | DetectParams[] detect = | ||
316 | new DetectParams[SensedObjects.Length]; | ||
317 | |||
318 | int idx; | ||
319 | for (idx = 0; idx < SensedObjects.Length; idx++) | ||
320 | { | ||
321 | detect[idx] = new DetectParams(); | ||
322 | detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]); | ||
323 | detect[idx].Populate(m_CmdManager.m_ScriptEngine.World); | ||
324 | } | ||
325 | |||
326 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | ||
327 | new EventParams("sensor", | ||
328 | new Object[] { | ||
329 | new LSL_Types.LSLInteger(SensedObjects.Length) }, | ||
330 | detect)); | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
335 | public Object[] GetSerializationData(LLUUID itemID) | ||
336 | { | ||
337 | List<Object> data = new List<Object>(); | ||
338 | |||
339 | foreach (SenseRepeatClass ts in SenseRepeaters) | ||
340 | { | ||
341 | if (ts.itemID == itemID) | ||
342 | { | ||
343 | data.Add(ts.interval); | ||
344 | data.Add(ts.name); | ||
345 | data.Add(ts.keyID); | ||
346 | data.Add(ts.type); | ||
347 | data.Add(ts.range); | ||
348 | data.Add(ts.arc); | ||
349 | } | ||
350 | } | ||
351 | return data.ToArray(); | ||
352 | } | ||
353 | |||
354 | public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID, | ||
355 | Object[] data) | ||
356 | { | ||
357 | SceneObjectPart part = | ||
358 | m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart( | ||
359 | objectID); | ||
360 | |||
361 | if (part == null) | ||
362 | return; | ||
363 | |||
364 | int idx = 0; | ||
365 | |||
366 | while (idx < data.Length) | ||
367 | { | ||
368 | SenseRepeatClass ts = new SenseRepeatClass(); | ||
369 | |||
370 | ts.localID = localID; | ||
371 | ts.itemID = itemID; | ||
372 | |||
373 | ts.interval = (double)data[idx]; | ||
374 | ts.name = (string)data[idx+1]; | ||
375 | ts.keyID = (LLUUID)data[idx+2]; | ||
376 | ts.type = (int)data[idx+3]; | ||
377 | ts.range = (double)data[idx+4]; | ||
378 | ts.arc = (double)data[idx+5]; | ||
379 | ts.host = part; | ||
380 | |||
381 | ts.next = | ||
382 | DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
383 | |||
384 | SenseRepeaters.Add(ts); | ||
385 | idx += 6; | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs new file mode 100644 index 0000000..36e992b --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -0,0 +1,162 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using libsecondlife; | ||
32 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
33 | |||
34 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
35 | { | ||
36 | public class Timer | ||
37 | { | ||
38 | public AsyncCommandManager m_CmdManager; | ||
39 | |||
40 | public Timer(AsyncCommandManager CmdManager) | ||
41 | { | ||
42 | m_CmdManager = CmdManager; | ||
43 | } | ||
44 | |||
45 | // | ||
46 | // TIMER | ||
47 | // | ||
48 | private class TimerClass | ||
49 | { | ||
50 | public uint localID; | ||
51 | public LLUUID itemID; | ||
52 | //public double interval; | ||
53 | public long interval; | ||
54 | //public DateTime next; | ||
55 | public long next; | ||
56 | } | ||
57 | |||
58 | private List<TimerClass> Timers = new List<TimerClass>(); | ||
59 | private object TimerListLock = new object(); | ||
60 | |||
61 | public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) | ||
62 | { | ||
63 | // Always remove first, in case this is a re-set | ||
64 | UnSetTimerEvents(m_localID, m_itemID); | ||
65 | if (sec == 0) // Disabling timer | ||
66 | return; | ||
67 | |||
68 | // Add to timer | ||
69 | TimerClass ts = new TimerClass(); | ||
70 | ts.localID = m_localID; | ||
71 | ts.itemID = m_itemID; | ||
72 | ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait | ||
73 | // 2193386136332921 ticks | ||
74 | // 219338613 seconds | ||
75 | |||
76 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
77 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
78 | lock (TimerListLock) | ||
79 | { | ||
80 | Timers.Add(ts); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) | ||
85 | { | ||
86 | // Remove from timer | ||
87 | lock (TimerListLock) | ||
88 | { | ||
89 | foreach (TimerClass ts in new ArrayList(Timers)) | ||
90 | { | ||
91 | if (ts.localID == m_localID && ts.itemID == m_itemID) | ||
92 | Timers.Remove(ts); | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public void CheckTimerEvents() | ||
98 | { | ||
99 | // Nothing to do here? | ||
100 | if (Timers.Count == 0) | ||
101 | return; | ||
102 | |||
103 | lock (TimerListLock) | ||
104 | { | ||
105 | // Go through all timers | ||
106 | foreach (TimerClass ts in Timers) | ||
107 | { | ||
108 | // Time has passed? | ||
109 | if (ts.next < DateTime.Now.Ticks) | ||
110 | { | ||
111 | // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | ||
112 | // Add it to queue | ||
113 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | ||
114 | new EventParams("timer", new Object[0], | ||
115 | new DetectParams[0])); | ||
116 | // set next interval | ||
117 | |||
118 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
119 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public Object[] GetSerializationData(LLUUID itemID) | ||
126 | { | ||
127 | List<Object> data = new List<Object>(); | ||
128 | |||
129 | lock (TimerListLock) | ||
130 | { | ||
131 | foreach (TimerClass ts in Timers) | ||
132 | { | ||
133 | if (ts.itemID == itemID) | ||
134 | { | ||
135 | data.Add(ts.interval); | ||
136 | data.Add(ts.next-DateTime.Now.Ticks); | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | return data.ToArray(); | ||
141 | } | ||
142 | |||
143 | public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID, | ||
144 | Object[] data) | ||
145 | { | ||
146 | int idx = 0; | ||
147 | |||
148 | while (idx < data.Length) | ||
149 | { | ||
150 | TimerClass ts = new TimerClass(); | ||
151 | |||
152 | ts.localID = localID; | ||
153 | ts.itemID = itemID; | ||
154 | ts.interval = (long)data[idx]; | ||
155 | ts.next = DateTime.Now.Ticks + (long)data[idx+1]; | ||
156 | idx += 2; | ||
157 | |||
158 | Timers.Add(ts); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs new file mode 100644 index 0000000..89bf51c --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs | |||
@@ -0,0 +1,117 @@ | |||
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 | using System; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | using OpenSim.Region.Environment.Modules.Scripting.XMLRPC; | ||
31 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
32 | using OpenSim.Region.ScriptEngine.Shared; | ||
33 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
34 | |||
35 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | ||
36 | { | ||
37 | public class XmlRequest | ||
38 | { | ||
39 | public AsyncCommandManager m_CmdManager; | ||
40 | |||
41 | public XmlRequest(AsyncCommandManager CmdManager) | ||
42 | { | ||
43 | m_CmdManager = CmdManager; | ||
44 | } | ||
45 | |||
46 | public void CheckXMLRPCRequests() | ||
47 | { | ||
48 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
49 | return; | ||
50 | |||
51 | IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
52 | |||
53 | if (xmlrpc != null) | ||
54 | { | ||
55 | RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest(); | ||
56 | |||
57 | while (rInfo != null) | ||
58 | { | ||
59 | xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID()); | ||
60 | |||
61 | //Deliver data to prim's remote_data handler | ||
62 | object[] resobj = new object[] | ||
63 | { | ||
64 | new LSL_Types.LSLInteger(2), | ||
65 | new LSL_Types.LSLString( | ||
66 | rInfo.GetChannelKey().ToString()), | ||
67 | new LSL_Types.LSLString( | ||
68 | rInfo.GetMessageID().ToString()), | ||
69 | new LSL_Types.LSLString(String.Empty), | ||
70 | new LSL_Types.LSLInteger(rInfo.GetIntValue()), | ||
71 | new LSL_Types.LSLString(rInfo.GetStrVal()) | ||
72 | }; | ||
73 | |||
74 | foreach (AsyncCommandManager m in m_CmdManager.Managers) | ||
75 | { | ||
76 | if (m.m_ScriptEngine.PostScriptEvent( | ||
77 | rInfo.GetItemID(), new EventParams( | ||
78 | "remote_data", resobj, | ||
79 | new DetectParams[0]))) | ||
80 | break; | ||
81 | } | ||
82 | |||
83 | rInfo = xmlrpc.GetNextCompletedRequest(); | ||
84 | } | ||
85 | |||
86 | SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest(); | ||
87 | |||
88 | while (srdInfo != null) | ||
89 | { | ||
90 | xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID()); | ||
91 | |||
92 | //Deliver data to prim's remote_data handler | ||
93 | object[] resobj = new object[] | ||
94 | { | ||
95 | new LSL_Types.LSLInteger(3), | ||
96 | new LSL_Types.LSLString(srdInfo.channel.ToString()), | ||
97 | new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), | ||
98 | new LSL_Types.LSLString(String.Empty), | ||
99 | new LSL_Types.LSLInteger(srdInfo.idata), | ||
100 | new LSL_Types.LSLString(srdInfo.sdata) | ||
101 | }; | ||
102 | |||
103 | foreach (AsyncCommandManager m in m_CmdManager.Managers) | ||
104 | { | ||
105 | if (m.m_ScriptEngine.PostScriptEvent( | ||
106 | srdInfo.m_itemID, new EventParams( | ||
107 | "remote_data", resobj, | ||
108 | new DetectParams[0]))) | ||
109 | break; | ||
110 | } | ||
111 | |||
112 | srdInfo = xmlrpc.GetNextCompletedSRDRequest(); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs new file mode 100644 index 0000000..75672a1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -0,0 +1,649 @@ | |||
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 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | |||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
34 | { | ||
35 | public interface ILSL_Api | ||
36 | { | ||
37 | void state(string newState); | ||
38 | void llSay(int channelID, string text); | ||
39 | double llSin(double f); | ||
40 | double llCos(double f); | ||
41 | double llTan(double f); | ||
42 | double llAtan2(double x, double y); | ||
43 | double llSqrt(double f); | ||
44 | double llPow(double fbase, double fexponent); | ||
45 | LSL_Types.LSLInteger llAbs(int i); | ||
46 | double llFabs(double f); | ||
47 | double llFrand(double mag); | ||
48 | LSL_Types.LSLInteger llFloor(double f); | ||
49 | LSL_Types.LSLInteger llCeil(double f); | ||
50 | LSL_Types.LSLInteger llRound(double f); | ||
51 | double llVecMag(LSL_Types.Vector3 v); | ||
52 | LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v); | ||
53 | double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b); | ||
54 | LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r); | ||
55 | LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v); | ||
56 | LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up); | ||
57 | LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r); | ||
58 | LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r); | ||
59 | LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r); | ||
60 | LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end); | ||
61 | void llWhisper(int channelID, string text); | ||
62 | //void llSay(int channelID, string text); | ||
63 | void llShout(int channelID, string text); | ||
64 | void llRegionSay(int channelID, string text); | ||
65 | LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg); | ||
66 | void llListenControl(int number, int active); | ||
67 | void llListenRemove(int number); | ||
68 | void llSensor(string name, string id, int type, double range, double arc); | ||
69 | void llSensorRepeat(string name, string id, int type, double range, double arc, double rate); | ||
70 | void llSensorRemove(); | ||
71 | string llDetectedName(int number); | ||
72 | string llDetectedKey(int number); | ||
73 | string llDetectedOwner(int number); | ||
74 | LSL_Types.LSLInteger llDetectedType(int number); | ||
75 | LSL_Types.Vector3 llDetectedPos(int number); | ||
76 | LSL_Types.Vector3 llDetectedVel(int number); | ||
77 | LSL_Types.Vector3 llDetectedGrab(int number); | ||
78 | LSL_Types.Quaternion llDetectedRot(int number); | ||
79 | LSL_Types.LSLInteger llDetectedGroup(int number); | ||
80 | LSL_Types.LSLInteger llDetectedLinkNumber(int number); | ||
81 | void llDie(); | ||
82 | double llGround(LSL_Types.Vector3 offset); | ||
83 | double llCloud(LSL_Types.Vector3 offset); | ||
84 | LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset); | ||
85 | void llSetStatus(int status, int value); | ||
86 | LSL_Types.LSLInteger llGetStatus(int status); | ||
87 | void llSetScale(LSL_Types.Vector3 scale); | ||
88 | LSL_Types.Vector3 llGetScale(); | ||
89 | void llSetColor(LSL_Types.Vector3 color, int face); | ||
90 | double llGetAlpha(int face); | ||
91 | void llSetAlpha(double alpha, int face); | ||
92 | LSL_Types.Vector3 llGetColor(int face); | ||
93 | void llSetTexture(string texture, int face); | ||
94 | void llScaleTexture(double u, double v, int face); | ||
95 | void llOffsetTexture(double u, double v, int face); | ||
96 | void llRotateTexture(double rotation, int face); | ||
97 | string llGetTexture(int face); | ||
98 | void llSetPos(LSL_Types.Vector3 pos); | ||
99 | |||
100 | //wiki: vector llGetPos() | ||
101 | LSL_Types.Vector3 llGetPos(); | ||
102 | //wiki: vector llGetLocalPos() | ||
103 | LSL_Types.Vector3 llGetLocalPos(); | ||
104 | //wiki: llSetRot(rotation rot) | ||
105 | void llSetRot(LSL_Types.Quaternion rot); | ||
106 | //wiki: rotation llGetRot() | ||
107 | LSL_Types.Quaternion llGetRot(); | ||
108 | //wiki: rotation llGetLocalRot() | ||
109 | LSL_Types.Quaternion llGetLocalRot(); | ||
110 | //wiki: llSetForce(vector force, integer local) | ||
111 | void llSetForce(LSL_Types.Vector3 force, int local); | ||
112 | //wiki: vector llGetForce() | ||
113 | LSL_Types.Vector3 llGetForce(); | ||
114 | //wiki: integer llTarget(vector position, double range) | ||
115 | LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range); | ||
116 | //wiki: llTargetRemove(integer number) | ||
117 | void llTargetRemove(int number); | ||
118 | //wiki: integer llRotTarget(rotation rot, double error) | ||
119 | LSL_Types.LSLInteger llRotTarget(LSL_Types.Quaternion rot, double error); | ||
120 | //wiki: integer llRotTargetRemove(integer number) | ||
121 | void llRotTargetRemove(int number); | ||
122 | //wiki: llMoveToTarget(vector target, double tau) | ||
123 | void llMoveToTarget(LSL_Types.Vector3 target, double tau); | ||
124 | //wiki: llStopMoveToTarget() | ||
125 | void llStopMoveToTarget(); | ||
126 | //wiki: llApplyImpulse(vector force, integer local) | ||
127 | void llApplyImpulse(LSL_Types.Vector3 force, int local); | ||
128 | //wiki: llapplyRotationalImpulse(vector force, integer local) | ||
129 | void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local); | ||
130 | //wiki: llSetTorque(vector torque, integer local) | ||
131 | void llSetTorque(LSL_Types.Vector3 torque, int local); | ||
132 | //wiki: vector llGetTorque() | ||
133 | LSL_Types.Vector3 llGetTorque(); | ||
134 | //wiki: llSeForceAndTorque(vector force, vector torque, integer local) | ||
135 | void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local); | ||
136 | //wiki: vector llGetVel() | ||
137 | LSL_Types.Vector3 llGetVel(); | ||
138 | //wiki: vector llGetAccel() | ||
139 | LSL_Types.Vector3 llGetAccel(); | ||
140 | //wiki: vector llGetOmega() | ||
141 | LSL_Types.Vector3 llGetOmega(); | ||
142 | //wiki: double llGetTimeOfDay() | ||
143 | double llGetTimeOfDay(); | ||
144 | //wiki: double llGetWallclock() | ||
145 | double llGetWallclock(); | ||
146 | //wiki: double llGetTime() | ||
147 | double llGetTime(); | ||
148 | //wiki: llResetTime() | ||
149 | void llResetTime(); | ||
150 | //wiki: double llGetAndResetTime() | ||
151 | double llGetAndResetTime(); | ||
152 | //wiki (deprecated) llSound(string sound, double volume, integer queue, integer loop) | ||
153 | void llSound(); | ||
154 | //wiki: llPlaySound(string sound, double volume) | ||
155 | void llPlaySound(string sound, double volume); | ||
156 | //wiki: llLoopSound(string sound, double volume) | ||
157 | void llLoopSound(string sound, double volume); | ||
158 | //wiki: llLoopSoundMaster(string sound, double volume) | ||
159 | void llLoopSoundMaster(string sound, double volume); | ||
160 | //wiki: llLoopSoundSlave(string sound, double volume) | ||
161 | void llLoopSoundSlave(string sound, double volume); | ||
162 | //wiki llPlaySoundSlave(string sound, double volume) | ||
163 | void llPlaySoundSlave(string sound, double volume); | ||
164 | //wiki: llTriggerSound(string sound, double volume) | ||
165 | void llTriggerSound(string sound, double volume); | ||
166 | //wiki: llStopSound() | ||
167 | void llStopSound(); | ||
168 | //wiki: llPreloadSound(string sound) | ||
169 | void llPreloadSound(string sound); | ||
170 | //wiki: string llGetSubString(string src, integer start, integer end) | ||
171 | string llGetSubString(string src, int start, int end); | ||
172 | //wiki: string llDeleteSubString(string src, integer start, integer end) | ||
173 | string llDeleteSubString(string src, int start, int end); | ||
174 | //wiki string llInsertString(string dst, integer position, string src) | ||
175 | string llInsertString(string dst, int position, string src); | ||
176 | //wiki: string llToUpper(string source) | ||
177 | string llToUpper(string source); | ||
178 | //wiki: string llToLower(string source) | ||
179 | string llToLower(string source); | ||
180 | //wiki: integer llGiveMoney(key destination, integer amount) | ||
181 | LSL_Types.LSLInteger llGiveMoney(string destination, int amount); | ||
182 | //wiki: (deprecated) | ||
183 | void llMakeExplosion(); | ||
184 | //wiki: (deprecated) | ||
185 | void llMakeFountain(); | ||
186 | //wiki: (deprecated) | ||
187 | void llMakeSmoke(); | ||
188 | //wiki: (deprecated) | ||
189 | void llMakeFire(); | ||
190 | //wiki: llRezObject(string inventory, vector pos, vector rel, rotation rot, integer param) | ||
191 | void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Vector3 vel, LSL_Types.Quaternion rot, int param); | ||
192 | //wiki: llLookAt(vector target, double strength, double damping) | ||
193 | void llLookAt(LSL_Types.Vector3 target, double strength, double damping); | ||
194 | //wiki: llStopLookAt() | ||
195 | void llStopLookAt(); | ||
196 | //wiki: llSetTimerEvent(double sec) | ||
197 | void llSetTimerEvent(double sec); | ||
198 | //wiki: llSleep(double sec) | ||
199 | void llSleep(double sec); | ||
200 | //wiki: double llGetMass() | ||
201 | double llGetMass(); | ||
202 | //wiki: llCollisionFilter(string name, key id, integer accept) | ||
203 | void llCollisionFilter(string name, string id, int accept); | ||
204 | //wiki: llTakeControls(integer controls, integer accept, integer pass_on) | ||
205 | void llTakeControls(int controls, int accept, int pass_on); | ||
206 | //wiki: llReleaseControls() | ||
207 | void llReleaseControls(); | ||
208 | //wiki: llAttachToAvatar(integer attachment) | ||
209 | void llAttachToAvatar(int attachment); | ||
210 | //wiki: llDetachFromAvatar() | ||
211 | void llDetachFromAvatar(); | ||
212 | //wiki: (deprecated) llTakeCamera() | ||
213 | void llTakeCamera(); | ||
214 | //wiki: (deprecated) llReleaseCamera() | ||
215 | void llReleaseCamera(); | ||
216 | //wiki: key llGetOwner() | ||
217 | string llGetOwner(); | ||
218 | //wiki: llInstantMessage(key user, string message) | ||
219 | void llInstantMessage(string user, string message); | ||
220 | //wiki: llEmail(string address, string subject, string message) | ||
221 | void llEmail(string address, string subject, string message); | ||
222 | //wiki: llGetNextEmail(string address, string subject) | ||
223 | void llGetNextEmail(string address, string subject); | ||
224 | //wiki: key llGetKey() | ||
225 | string llGetKey(); | ||
226 | //wiki: llSetBuoyancy(double buoyancy) | ||
227 | void llSetBuoyancy(double buoyancy); | ||
228 | //wiki: llSetHoverHeight(double height, integer water, double tau) | ||
229 | void llSetHoverHeight(double height, int water, double tau); | ||
230 | //wiki: llStopHover | ||
231 | void llStopHover(); | ||
232 | //wiki: llMinEventDelay(double delay) | ||
233 | void llMinEventDelay(double delay); | ||
234 | //wiki: (deprecated) llSoundPreload() | ||
235 | void llSoundPreload(); | ||
236 | //wiki: llRotLookAt(rotation target, double strength, double damping) | ||
237 | void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping); | ||
238 | //wiki: integer llStringLength(string str) | ||
239 | LSL_Types.LSLInteger llStringLength(string str); | ||
240 | //wiki: llStartAnimation(string anim) | ||
241 | void llStartAnimation(string anim); | ||
242 | //wiki: llStopAnimation(string anim) | ||
243 | void llStopAnimation(string anim); | ||
244 | //wiki: (deprecated) llPointAt | ||
245 | void llPointAt(); | ||
246 | //wiki: (deprecated) llStopPointAt | ||
247 | void llStopPointAt(); | ||
248 | //wiki: llTargetOmega(vector axis, double spinrate, double gain) | ||
249 | void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain); | ||
250 | //wiki: integer llGetStartParameter() | ||
251 | LSL_Types.LSLInteger llGetStartParameter(); | ||
252 | //wiki: llGodLikeRezObject(key inventory, vector pos) | ||
253 | void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos); | ||
254 | //wiki: llRequestPermissions(key agent, integer perm) | ||
255 | void llRequestPermissions(string agent, int perm); | ||
256 | //wiki: key llGetPermissionsKey() | ||
257 | string llGetPermissionsKey(); | ||
258 | //wiki: integer llGetPermissions() | ||
259 | LSL_Types.LSLInteger llGetPermissions(); | ||
260 | //wiki integer llGetLinkNumber() | ||
261 | LSL_Types.LSLInteger llGetLinkNumber(); | ||
262 | //wiki: llSetLinkColor(integer linknumber, vector color, integer face) | ||
263 | void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face); | ||
264 | //wiki: llCreateLink(key target, integer parent) | ||
265 | void llCreateLink(string target, int parent); | ||
266 | //wiki: llBreakLink(integer linknum) | ||
267 | void llBreakLink(int linknum); | ||
268 | //wiki: llBreakAllLinks() | ||
269 | void llBreakAllLinks(); | ||
270 | //wiki: key llGetLinkKey(integer linknum) | ||
271 | string llGetLinkKey(int linknum); | ||
272 | //wiki: llGetLinkName(integer linknum) | ||
273 | string llGetLinkName(int linknum); | ||
274 | //wiki: integer llGetInventoryNumber(integer type) | ||
275 | LSL_Types.LSLInteger llGetInventoryNumber(int type); | ||
276 | //wiki: string llGetInventoryName(integer type, integer number) | ||
277 | string llGetInventoryName(int type, int number); | ||
278 | //wiki: llSetScriptState(string name, integer run) | ||
279 | void llSetScriptState(string name, int run); | ||
280 | //wiki: double llGetEnergy() | ||
281 | double llGetEnergy(); | ||
282 | //wiki: llGiveInventory(key destination, string inventory) | ||
283 | void llGiveInventory(string destination, string inventory); | ||
284 | //wiki: llRemoveInventory(string item) | ||
285 | void llRemoveInventory(string item); | ||
286 | //wiki: llSetText(string text, vector color, double alpha) | ||
287 | void llSetText(string text, LSL_Types.Vector3 color, double alpha); | ||
288 | //wiki: double llWater(vector offset) | ||
289 | double llWater(LSL_Types.Vector3 offset); | ||
290 | //wiki: llPassTouches(integer pass) | ||
291 | void llPassTouches(int pass); | ||
292 | //wiki: key llRequestAgentData(key id, integer data) | ||
293 | string llRequestAgentData(string id, int data); | ||
294 | //wiki: key llRequestInventoryData(string name) | ||
295 | string llRequestInventoryData(string name); | ||
296 | //wiki: llSetDamage(double damage) | ||
297 | void llSetDamage(double damage); | ||
298 | //wiki: llTeleportAgentHome(key agent) | ||
299 | void llTeleportAgentHome(string agent); | ||
300 | //wiki: llModifyLand(integer action, integer brush) | ||
301 | void llModifyLand(int action, int brush); | ||
302 | //wiki: llCollisionSound(string impact_sound, double impact_volume) | ||
303 | void llCollisionSound(string impact_sound, double impact_volume); | ||
304 | //wiki: llCollisionSprite(string impact_sprite) | ||
305 | void llCollisionSprite(string impact_sprite); | ||
306 | //wiki: string llGetAnimation(key id) | ||
307 | string llGetAnimation(string id); | ||
308 | //wiki: llResetScript() | ||
309 | void llResetScript(); | ||
310 | //wiki: llMessageLinked(integer linknum, integer num, string str, key id) | ||
311 | void llMessageLinked(int linknum, int num, string str, string id); | ||
312 | //wiki: llPushObject(key target, vector impulse, vector ang_impulse, integer local) | ||
313 | void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local); | ||
314 | //wiki: llPassCollisions(integer pass) | ||
315 | void llPassCollisions(int pass); | ||
316 | //wiki: string llGetScriptName() | ||
317 | string llGetScriptName(); | ||
318 | //wiki: integer llGetNumberOfSides() | ||
319 | LSL_Types.LSLInteger llGetNumberOfSides(); | ||
320 | //wiki: rotation llAxisAngle2Rot(vector axis, double angle) | ||
321 | LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle); | ||
322 | //wiki: vector llRot2Axis(rotation rot) | ||
323 | LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot); | ||
324 | //wiki: double llRot2Angle(rotation rot); | ||
325 | double llRot2Angle(LSL_Types.Quaternion rot); | ||
326 | //wiki: double llAcos(double val) | ||
327 | double llAcos(double val); | ||
328 | //wiki: double llAsin(double val) | ||
329 | double llAsin(double val); | ||
330 | //wiki: double llAngleBetween(rotation a, rotation b) | ||
331 | double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b); | ||
332 | //wiki: string llGetInventoryKey(string name) | ||
333 | string llGetInventoryKey(string name); | ||
334 | //wiki: llAllowInventoryDrop(integer add) | ||
335 | void llAllowInventoryDrop(int add); | ||
336 | //wiki: vector llGetSunDirection() | ||
337 | LSL_Types.Vector3 llGetSunDirection(); | ||
338 | //wiki: vector llGetTextureOffset(integer face) | ||
339 | LSL_Types.Vector3 llGetTextureOffset(int face); | ||
340 | //wiki: vector llGetTextureScale(integer side) | ||
341 | LSL_Types.Vector3 llGetTextureScale(int side); | ||
342 | //wiki: double llGetTextureRot(integer side) | ||
343 | double llGetTextureRot(int side); | ||
344 | //wiki: integer llSubStringIndex(string source, string pattern) | ||
345 | LSL_Types.LSLInteger llSubStringIndex(string source, string pattern); | ||
346 | //wiki: key llGetOwnerKey(key id) | ||
347 | string llGetOwnerKey(string id); | ||
348 | //wiki: vector llGetCenterOfMass() | ||
349 | LSL_Types.Vector3 llGetCenterOfMass(); | ||
350 | //wiki: list llListSort(list src, integer stride, integer ascending) | ||
351 | LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending); | ||
352 | //integer llGetListLength(list src) | ||
353 | LSL_Types.LSLInteger llGetListLength(LSL_Types.list src); | ||
354 | //wiki: integer llList2Integer(list src, integer index) | ||
355 | LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index); | ||
356 | //wiki: double llList2double(list src, integer index) | ||
357 | double llList2Float(LSL_Types.list src, int index); | ||
358 | //wiki: string llList2String(list src, integer index) | ||
359 | string llList2String(LSL_Types.list src, int index); | ||
360 | //wiki: key llList2Key(list src, integer index) | ||
361 | string llList2Key(LSL_Types.list src, int index); | ||
362 | //wiki: vector llList2Vector(list src, integer index) | ||
363 | LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index); | ||
364 | //wiki rotation llList2Rot(list src, integer index) | ||
365 | LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index); | ||
366 | //wiki: list llList2List(list src, integer start, integer end) | ||
367 | LSL_Types.list llList2List(LSL_Types.list src, int start, int end); | ||
368 | //wiki: llDeleteSubList(list src, integer start, integer end) | ||
369 | LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end); | ||
370 | //wiki: integer llGetListEntryType(list src, integer index) | ||
371 | LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index); | ||
372 | //wiki: string llList2CSV(list src) | ||
373 | string llList2CSV(LSL_Types.list src); | ||
374 | //wiki: list llCSV2List(string src) | ||
375 | LSL_Types.list llCSV2List(string src); | ||
376 | //wiki: list llListRandomize(list src, integer stride) | ||
377 | LSL_Types.list llListRandomize(LSL_Types.list src, int stride); | ||
378 | //wiki: list llList2ListStrided(list src, integer start, integer end, integer stride) | ||
379 | LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride); | ||
380 | //wiki: vector llGetRegionCorner() | ||
381 | LSL_Types.Vector3 llGetRegionCorner(); | ||
382 | //wiki: list llListInsertList(list dest, list src, integer start) | ||
383 | LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start); | ||
384 | //wiki: integer llListFindList(list src, list test) | ||
385 | LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test); | ||
386 | //wiki: string llGetObjectName() | ||
387 | string llGetObjectName(); | ||
388 | //wiki: llSetObjectName(string name) | ||
389 | void llSetObjectName(string name); | ||
390 | //wiki: string llGetDate() | ||
391 | string llGetDate(); | ||
392 | //wiki: integer llEdgeOfWorld(vector pos, vector dir) | ||
393 | LSL_Types.LSLInteger llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir); | ||
394 | //wiki: integer llGetAgentInfo(key id) | ||
395 | LSL_Types.LSLInteger llGetAgentInfo(string id); | ||
396 | //wiki: llAdjustSoundVolume(double volume) | ||
397 | void llAdjustSoundVolume(double volume); | ||
398 | //wiki: llSetSoundQueueing(integer queue) | ||
399 | void llSetSoundQueueing(int queue); | ||
400 | //wiki: llSetSoundRadius(double radius) | ||
401 | void llSetSoundRadius(double radius); | ||
402 | //wiki: string llKey2Name(key id) | ||
403 | string llKey2Name(string id); | ||
404 | //wiki: llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, double start, double length, double rate) | ||
405 | void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate); | ||
406 | //wiki: llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) | ||
407 | void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, | ||
408 | LSL_Types.Vector3 bottom_south_west); | ||
409 | |||
410 | //wiki: llEjectFromLand(key pest) | ||
411 | void llEjectFromLand(string pest); | ||
412 | LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers); | ||
413 | //wiki: integer llOverMyLand(key id) | ||
414 | LSL_Types.LSLInteger llOverMyLand(string id); | ||
415 | //wiki: key llGetLandOwnerAt(vector pos) | ||
416 | string llGetLandOwnerAt(LSL_Types.Vector3 pos); | ||
417 | //wiki: key llGetNotecardLine(string name, integer line) | ||
418 | string llGetNotecardLine(string name, int line); | ||
419 | //wiki: vector llGetAgentSize(key id) | ||
420 | LSL_Types.Vector3 llGetAgentSize(string id); | ||
421 | //wiki: integer llSameGroup(key agent) | ||
422 | LSL_Types.LSLInteger llSameGroup(string agent); | ||
423 | //wiki: llUnSit(key id) | ||
424 | void llUnSit(string id); | ||
425 | //wiki: vector llGroundSlope(vector offset) | ||
426 | LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset); | ||
427 | //wiki: vector llGroundNormal(vector offset) | ||
428 | LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset); | ||
429 | //wiki: vector llGroundContour(vector offset) | ||
430 | LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset); | ||
431 | //wiki: integer llGetAttached() | ||
432 | LSL_Types.LSLInteger llGetAttached(); | ||
433 | //wiki: integer llGetFreeMemory() | ||
434 | LSL_Types.LSLInteger llGetFreeMemory(); | ||
435 | //wiki: string llGetRegionName() | ||
436 | string llGetRegionName(); | ||
437 | //wiki: double llGetRegionTimeDilation() | ||
438 | double llGetRegionTimeDilation(); | ||
439 | //wiki: double llGetRegionFPS() | ||
440 | double llGetRegionFPS(); | ||
441 | //wiki: llParticleSystem(List<Object> rules | ||
442 | void llParticleSystem(LSL_Types.list rules); | ||
443 | //wiki: llGroundRepel(double height, integer water, double tau) | ||
444 | void llGroundRepel(double height, int water, double tau); | ||
445 | //wiki: llGiveInventoryList(string destination, string category, LSL_Types.list inventory) | ||
446 | void llGiveInventoryList(string destination, string category, LSL_Types.list inventory); | ||
447 | //wiki: llSetVehicleType(integer type) | ||
448 | void llSetVehicleType(int type); | ||
449 | //wiki: llSetVehicledoubleParam(integer param, double value) | ||
450 | void llSetVehicledoubleParam(int param, double value); | ||
451 | // wiki: llSetVehicleFloatParam(integer param, float value) | ||
452 | void llSetVehicleFloatParam(int param, float value); | ||
453 | //wiki: llSetVehicleVectorParam(integer param, vector vec) | ||
454 | void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec); | ||
455 | //wiki: llSetVehicleRotationParam(integer param, rotation rot) | ||
456 | void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot); | ||
457 | //wiki: llSetVehicleFlags(integer flags) | ||
458 | void llSetVehicleFlags(int flags); | ||
459 | //wiki: llRemoveVehicleFlags(integer flags) | ||
460 | void llRemoveVehicleFlags(int flags); | ||
461 | //wiki: llSitTarget(vector offset, rotation rot) | ||
462 | void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot); | ||
463 | //wiki key llAvatarOnSitTarget() | ||
464 | string llAvatarOnSitTarget(); | ||
465 | //wiki: llAddToLandPassList(key avatar, double hours) | ||
466 | void llAddToLandPassList(string avatar, double hours); | ||
467 | //wiki: llSetTouchText(string text) | ||
468 | void llSetTouchText(string text); | ||
469 | //wiki: llSetSitText(string text) | ||
470 | void llSetSitText(string text); | ||
471 | //wiki: llSetCameraEyeOffset(vector offset) | ||
472 | void llSetCameraEyeOffset(LSL_Types.Vector3 offset); | ||
473 | //wiki: llSeteCameraAtOffset(vector offset) | ||
474 | void llSetCameraAtOffset(LSL_Types.Vector3 offset); | ||
475 | // | ||
476 | string llDumpList2String(LSL_Types.list src, string seperator); | ||
477 | //wiki: integer llScriptDanger(vector pos) | ||
478 | LSL_Types.LSLInteger llScriptDanger(LSL_Types.Vector3 pos); | ||
479 | //wiki: llDialog(key avatar, string message, list buttons, integer chat_channel) | ||
480 | void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel); | ||
481 | //wiki: llVolumeDetect(integer detect) | ||
482 | void llVolumeDetect(int detect); | ||
483 | //wiki: llResetOtherScript(string name) | ||
484 | void llResetOtherScript(string name); | ||
485 | //wiki: integer llGetScriptState(string name) | ||
486 | LSL_Types.LSLInteger llGetScriptState(string name); | ||
487 | //wiki: (deprecated) | ||
488 | void llRemoteLoadScript(); | ||
489 | //wiki: llSetRemoteScriptAccessPin(integer pin) | ||
490 | void llSetRemoteScriptAccessPin(int pin); | ||
491 | //wiki: llRemoteLoadScriptPin(key target, string name, integer pin, integer running, integer start_param) | ||
492 | void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param); | ||
493 | //wiki: llOpenRemoteDataChannel() | ||
494 | void llOpenRemoteDataChannel(); | ||
495 | //wiki: key llSendRemoteData(key channel, string dest, integer idata, string sdata) | ||
496 | string llSendRemoteData(string channel, string dest, int idata, string sdata); | ||
497 | //wiki: llRemoteDataReply(key channel, key message_id, string sdata, integer idata) | ||
498 | void llRemoteDataReply(string channel, string message_id, string sdata, int idata); | ||
499 | //wiki: llCloseRemoteDataChannel(key channel) | ||
500 | void llCloseRemoteDataChannel(string channel); | ||
501 | //wiki: string llMD5String(string src, integer nonce) | ||
502 | string llMD5String(string src, int nonce); | ||
503 | //wiki: llSetPrimitiveParams(list rules) | ||
504 | void llSetPrimitiveParams(LSL_Types.list rules); | ||
505 | //wiki: llSetLinkPrimitiveParams(integer linknumber, list rules) | ||
506 | void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules); | ||
507 | //wiki: string llStringToBase64(string str) | ||
508 | string llStringToBase64(string str); | ||
509 | //wiki: string llBase64ToString(string str) | ||
510 | string llBase64ToString(string str); | ||
511 | //wiki: (deprecated) | ||
512 | void llXorBase64Strings(); | ||
513 | //wiki: llRemoteDataSetRegion() | ||
514 | void llRemoteDataSetRegion(); | ||
515 | //wiki: double llLog10(double val) | ||
516 | double llLog10(double val); | ||
517 | //wiki: double llLog(double val) | ||
518 | double llLog(double val); | ||
519 | //wiki: list llGetAnimationList(key id) | ||
520 | LSL_Types.list llGetAnimationList(string id); | ||
521 | //wiki: llSetParcelMusicURL(string url) | ||
522 | void llSetParcelMusicURL(string url); | ||
523 | //wiki: vector llGetRootPosition() | ||
524 | LSL_Types.Vector3 llGetRootPosition(); | ||
525 | //wiki: rotation llGetRootRotation() | ||
526 | LSL_Types.Quaternion llGetRootRotation(); | ||
527 | //wiki: string llGetObjectDesc() | ||
528 | string llGetObjectDesc(); | ||
529 | //wiki: llSetObjectDesc(string desc) | ||
530 | void llSetObjectDesc(string desc); | ||
531 | //wiki: key llGetCreator() | ||
532 | string llGetCreator(); | ||
533 | //wiki: string llGetTimestamp() | ||
534 | string llGetTimestamp(); | ||
535 | //wiki: llSetLinkAlpha(integer linknumber, double alpha, integer face) | ||
536 | void llSetLinkAlpha(int linknumber, double alpha, int face); | ||
537 | //wiki: integer llGetNumberOfPrims() | ||
538 | LSL_Types.LSLInteger llGetNumberOfPrims(); | ||
539 | //wiki: key llGetNumberOfNotecardLines(string name) | ||
540 | string llGetNumberOfNotecardLines(string name); | ||
541 | //wiki: list llGetBoundingBox(key object) | ||
542 | LSL_Types.list llGetBoundingBox(string obj); | ||
543 | //wiki: vector llGetGeometricCenter() | ||
544 | LSL_Types.Vector3 llGetGeometricCenter(); | ||
545 | //wiki: list llGetPrimitiveParams(list rules) | ||
546 | LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules); | ||
547 | //wiki: string llIntegerToBase64(integer number) | ||
548 | string llIntegerToBase64(int number); | ||
549 | //wiki integer llBase64ToInteger(string str) | ||
550 | LSL_Types.LSLInteger llBase64ToInteger(string str); | ||
551 | //wiki: double llGetGMTclock() | ||
552 | double llGetGMTclock(); | ||
553 | //wiki: string llGetSimulatorHostname() | ||
554 | string llGetSimulatorHostname(); | ||
555 | //llSetLocalRot(rotation rot) | ||
556 | void llSetLocalRot(LSL_Types.Quaternion rot); | ||
557 | //wiki: list llParseStringKeepNulls(string src, list separators, list spacers) | ||
558 | LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers); | ||
559 | //wiki: llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, integer param) | ||
560 | void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, | ||
561 | LSL_Types.Quaternion rot, int param); | ||
562 | |||
563 | //wiki: integer llGetObjectPermMask(integer mask) | ||
564 | LSL_Types.LSLInteger llGetObjectPermMask(int mask); | ||
565 | //wiki: llSetObjectPermMask(integer mask, integer value) | ||
566 | void llSetObjectPermMask(int mask, int value); | ||
567 | //wiki integer llGetInventoryPermMask(string item, integer mask) | ||
568 | LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask); | ||
569 | //wiki: llSetInventoryPermMask(string item, integer mask, integer value) | ||
570 | void llSetInventoryPermMask(string item, int mask, int value); | ||
571 | //wiki: key llGetInventoryCreator(string item) | ||
572 | string llGetInventoryCreator(string item); | ||
573 | //wiki: llOwnerSay(string msg) | ||
574 | void llOwnerSay(string msg); | ||
575 | //wiki: key llRequestSimulatorData(string simulator, integer data) | ||
576 | string llRequestSimulatorData(string simulator, int data); | ||
577 | //wiki: llForceMouselook(integer mouselook) | ||
578 | void llForceMouselook(int mouselook); | ||
579 | //wiki: double llGetObjectMass(key id) | ||
580 | double llGetObjectMass(string id); | ||
581 | LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end); | ||
582 | //wiki: llLoadURL(key avatar_id, string message, string url) | ||
583 | void llLoadURL(string avatar_id, string message, string url); | ||
584 | //wiki: llParcelMediaCommandList(list commandList) | ||
585 | void llParcelMediaCommandList(LSL_Types.list commandList); | ||
586 | void llParcelMediaQuery(); | ||
587 | //wiki integer llModPow(integer a, integer b, integer c) | ||
588 | LSL_Types.LSLInteger llModPow(int a, int b, int c); | ||
589 | //wiki: integer llGetInventoryType(string name) | ||
590 | LSL_Types.LSLInteger llGetInventoryType(string name); | ||
591 | //wiki: llSetPayPrice(integer price, list quick_pay_buttons) | ||
592 | void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons); | ||
593 | //wiki: vector llGetCameraPos() | ||
594 | LSL_Types.Vector3 llGetCameraPos(); | ||
595 | //wiki rotation llGetCameraRot() | ||
596 | LSL_Types.Quaternion llGetCameraRot(); | ||
597 | //wiki: (deprecated) | ||
598 | void llSetPrimURL(); | ||
599 | //wiki: (deprecated) | ||
600 | void llRefreshPrimURL(); | ||
601 | //wiki: string llEscapeURL(string url) | ||
602 | string llEscapeURL(string url); | ||
603 | //wiki: string llUnescapeURL(string url) | ||
604 | string llUnescapeURL(string url); | ||
605 | //wiki: llMapDestination(string simname, vector pos, vector look_at) | ||
606 | void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at); | ||
607 | //wiki: llAddToLandBanList(key avatar, double hours) | ||
608 | void llAddToLandBanList(string avatar, double hours); | ||
609 | //wiki: llRemoveFromLandPassList(key avatar) | ||
610 | void llRemoveFromLandPassList(string avatar); | ||
611 | //wiki: llRemoveFromLandBanList(key avatar) | ||
612 | void llRemoveFromLandBanList(string avatar); | ||
613 | //wiki: llSetCameraParams(list rules) | ||
614 | void llSetCameraParams(LSL_Types.list rules); | ||
615 | //wiki: llClearCameraParams() | ||
616 | void llClearCameraParams(); | ||
617 | //wiki: double llListStatistics(integer operation, list src) | ||
618 | double llListStatistics(int operation, LSL_Types.list src); | ||
619 | //wiki: integer llGetUnixTime() | ||
620 | LSL_Types.LSLInteger llGetUnixTime(); | ||
621 | //wiki: integer llGetParcelFlags(vector pos) | ||
622 | LSL_Types.LSLInteger llGetParcelFlags(LSL_Types.Vector3 pos); | ||
623 | //wiki: integer llGetRegionFlags() | ||
624 | LSL_Types.LSLInteger llGetRegionFlags(); | ||
625 | //wiki: string llXorBase64StringsCorrect(string str1, string str2) | ||
626 | string llXorBase64StringsCorrect(string str1, string str2); | ||
627 | string llHTTPRequest(string url, LSL_Types.list parameters, string body); | ||
628 | //wiki: llResetLandBanList() | ||
629 | void llResetLandBanList(); | ||
630 | //wiki: llResetLandPassList() | ||
631 | void llResetLandPassList(); | ||
632 | //wiki: integer llGetParcelPrimCount(vector pos, integer category, integer sim_wide) | ||
633 | LSL_Types.LSLInteger llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide); | ||
634 | //wiki: list llGetParcelPrimOwners(vector pos) | ||
635 | LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos); | ||
636 | //wiki: integer llGetObjectPrimCount(key object_id) | ||
637 | LSL_Types.LSLInteger llGetObjectPrimCount(string object_id); | ||
638 | //wiki: integer llGetParcelMaxPrims(vector pos, integer sim_wide) | ||
639 | LSL_Types.LSLInteger llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide); | ||
640 | //wiki: llGetParcelDetails(vector pos, list params) | ||
641 | LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param); | ||
642 | //wiki: llSetLinkTexture(integer linknumber, string texture, integer face) | ||
643 | void llSetLinkTexture(int linknumber, string texture, int face); | ||
644 | //wiki: string llStringTrim(string src, int type) | ||
645 | string llStringTrim(string src, int type); | ||
646 | //wiki: LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args) | ||
647 | LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args); | ||
648 | } | ||
649 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs new file mode 100644 index 0000000..1e14c63 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -0,0 +1,68 @@ | |||
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 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
29 | { | ||
30 | public interface IOSSL_Api | ||
31 | { | ||
32 | //OpenSim functions | ||
33 | string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); | ||
34 | string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | ||
35 | int timer, int alpha); | ||
36 | string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); | ||
37 | string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, | ||
38 | int timer, int alpha); | ||
39 | double osTerrainGetHeight(int x, int y); | ||
40 | int osTerrainSetHeight(int x, int y, double val); | ||
41 | int osRegionRestart(double seconds); | ||
42 | void osRegionNotice(string msg); | ||
43 | bool osConsoleCommand(string Command); | ||
44 | void osSetParcelMediaURL(string url); | ||
45 | void osSetPrimFloatOnWater(int floatYN); | ||
46 | |||
47 | // Animation commands | ||
48 | void osAvatarPlayAnimation(string avatar, string animation); | ||
49 | void osAvatarStopAnimation(string avatar, string animation); | ||
50 | |||
51 | //texture draw functions | ||
52 | string osMovePen(string drawList, int x, int y); | ||
53 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); | ||
54 | string osDrawLine(string drawList, int endX, int endY); | ||
55 | string osDrawText(string drawList, string text); | ||
56 | string osDrawEllipse(string drawList, int width, int height); | ||
57 | string osDrawRectangle(string drawList, int width, int height); | ||
58 | string osDrawFilledRectangle(string drawList, int width, int height); | ||
59 | string osSetFontSize(string drawList, int fontSize); | ||
60 | string osSetPenSize(string drawList, int penSize); | ||
61 | string osSetPenColour(string drawList, string colour); | ||
62 | string osDrawImage(string drawList, int width, int height, string imageUrl); | ||
63 | void osSetStateEvents(int events); | ||
64 | |||
65 | double osList2Double(LSL_Types.list src, int index); | ||
66 | void osSetRegionWaterHeight(double height); | ||
67 | } | ||
68 | } | ||
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 | |||
28 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | |||
32 | namespace 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/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs new file mode 100644 index 0000000..7b3907f --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -0,0 +1,1732 @@ | |||
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 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
35 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
36 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using key = System.String; | ||
38 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
39 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
40 | |||
41 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
42 | { | ||
43 | public partial class ScriptBaseClass : MarshalByRefObject | ||
44 | { | ||
45 | public ILSL_Api m_LSL_Functions; | ||
46 | |||
47 | public void ApiTypeLSL(IScriptApi api) | ||
48 | { | ||
49 | if(!(api is ILSL_Api)) | ||
50 | return; | ||
51 | |||
52 | m_LSL_Functions = (ILSL_Api)api; | ||
53 | } | ||
54 | |||
55 | public void state(string newState) | ||
56 | { | ||
57 | m_LSL_Functions.state(newState); | ||
58 | } | ||
59 | |||
60 | // | ||
61 | // Script functions | ||
62 | // | ||
63 | public void llSay(int channelID, string text) | ||
64 | { | ||
65 | m_LSL_Functions.llSay(channelID, text); | ||
66 | } | ||
67 | |||
68 | public double llSin(double f) | ||
69 | { | ||
70 | return m_LSL_Functions.llSin(f); | ||
71 | } | ||
72 | |||
73 | public double llCos(double f) | ||
74 | { | ||
75 | return m_LSL_Functions.llCos(f); | ||
76 | } | ||
77 | |||
78 | public double llTan(double f) | ||
79 | { | ||
80 | return m_LSL_Functions.llTan(f); | ||
81 | } | ||
82 | |||
83 | public double llAtan2(double x, double y) | ||
84 | { | ||
85 | return m_LSL_Functions.llAtan2(x, y); | ||
86 | } | ||
87 | |||
88 | public double llSqrt(double f) | ||
89 | { | ||
90 | return m_LSL_Functions.llSqrt(f); | ||
91 | } | ||
92 | |||
93 | public double llPow(double fbase, double fexponent) | ||
94 | { | ||
95 | return m_LSL_Functions.llPow(fbase, fexponent); | ||
96 | } | ||
97 | |||
98 | public LSL_Types.LSLInteger llAbs(int i) | ||
99 | { | ||
100 | return m_LSL_Functions.llAbs(i); | ||
101 | } | ||
102 | |||
103 | public double llFabs(double f) | ||
104 | { | ||
105 | return m_LSL_Functions.llFabs(f); | ||
106 | } | ||
107 | |||
108 | public double llFrand(double mag) | ||
109 | { | ||
110 | return m_LSL_Functions.llFrand(mag); | ||
111 | } | ||
112 | |||
113 | public LSL_Types.LSLInteger llFloor(double f) | ||
114 | { | ||
115 | return m_LSL_Functions.llFloor(f); | ||
116 | } | ||
117 | |||
118 | public LSL_Types.LSLInteger llCeil(double f) | ||
119 | { | ||
120 | return m_LSL_Functions.llCeil(f); | ||
121 | } | ||
122 | |||
123 | public LSL_Types.LSLInteger llRound(double f) | ||
124 | { | ||
125 | return m_LSL_Functions.llRound(f); | ||
126 | } | ||
127 | |||
128 | public double llVecMag(vector v) | ||
129 | { | ||
130 | return m_LSL_Functions.llVecMag(v); | ||
131 | } | ||
132 | |||
133 | public vector llVecNorm(vector v) | ||
134 | { | ||
135 | return m_LSL_Functions.llVecNorm(v); | ||
136 | } | ||
137 | |||
138 | public double llVecDist(vector a, vector b) | ||
139 | { | ||
140 | return m_LSL_Functions.llVecDist(a, b); | ||
141 | } | ||
142 | |||
143 | public vector llRot2Euler(rotation r) | ||
144 | { | ||
145 | return m_LSL_Functions.llRot2Euler(r); | ||
146 | } | ||
147 | |||
148 | public rotation llEuler2Rot(vector v) | ||
149 | { | ||
150 | return m_LSL_Functions.llEuler2Rot(v); | ||
151 | } | ||
152 | |||
153 | public rotation llAxes2Rot(vector fwd, vector left, vector up) | ||
154 | { | ||
155 | return m_LSL_Functions.llAxes2Rot(fwd, left, up); | ||
156 | } | ||
157 | |||
158 | public vector llRot2Fwd(rotation r) | ||
159 | { | ||
160 | return m_LSL_Functions.llRot2Fwd(r); | ||
161 | } | ||
162 | |||
163 | public vector llRot2Left(rotation r) | ||
164 | { | ||
165 | return m_LSL_Functions.llRot2Left(r); | ||
166 | } | ||
167 | |||
168 | public vector llRot2Up(rotation r) | ||
169 | { | ||
170 | return m_LSL_Functions.llRot2Up(r); | ||
171 | } | ||
172 | |||
173 | public rotation llRotBetween(vector start, vector end) | ||
174 | { | ||
175 | return m_LSL_Functions.llRotBetween(start, end); | ||
176 | } | ||
177 | |||
178 | public void llWhisper(int channelID, string text) | ||
179 | { | ||
180 | m_LSL_Functions.llWhisper(channelID, text); | ||
181 | } | ||
182 | |||
183 | public void llShout(int channelID, string text) | ||
184 | { | ||
185 | m_LSL_Functions.llShout(channelID, text); | ||
186 | } | ||
187 | |||
188 | public void llRegionSay(int channelID, string text) | ||
189 | { | ||
190 | m_LSL_Functions.llRegionSay(channelID, text); | ||
191 | } | ||
192 | |||
193 | public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg) | ||
194 | { | ||
195 | return m_LSL_Functions.llListen(channelID, name, ID, msg); | ||
196 | } | ||
197 | |||
198 | public void llListenControl(int number, int active) | ||
199 | { | ||
200 | m_LSL_Functions.llListenControl(number, active); | ||
201 | } | ||
202 | |||
203 | public void llListenRemove(int number) | ||
204 | { | ||
205 | m_LSL_Functions.llListenRemove(number); | ||
206 | } | ||
207 | |||
208 | public void llSensor(string name, string id, int type, double range, double arc) | ||
209 | { | ||
210 | m_LSL_Functions.llSensor(name, id, type, range, arc); | ||
211 | } | ||
212 | |||
213 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) | ||
214 | { | ||
215 | m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate); | ||
216 | } | ||
217 | |||
218 | public void llSensorRemove() | ||
219 | { | ||
220 | m_LSL_Functions.llSensorRemove(); | ||
221 | } | ||
222 | |||
223 | public string llDetectedName(int number) | ||
224 | { | ||
225 | return m_LSL_Functions.llDetectedName(number); | ||
226 | } | ||
227 | |||
228 | public string llDetectedKey(int number) | ||
229 | { | ||
230 | return m_LSL_Functions.llDetectedKey(number); | ||
231 | } | ||
232 | |||
233 | public string llDetectedOwner(int number) | ||
234 | { | ||
235 | return m_LSL_Functions.llDetectedOwner(number); | ||
236 | } | ||
237 | |||
238 | public LSL_Types.LSLInteger llDetectedType(int number) | ||
239 | { | ||
240 | return m_LSL_Functions.llDetectedType(number); | ||
241 | } | ||
242 | |||
243 | public vector llDetectedPos(int number) | ||
244 | { | ||
245 | return m_LSL_Functions.llDetectedPos(number); | ||
246 | } | ||
247 | |||
248 | public vector llDetectedVel(int number) | ||
249 | { | ||
250 | return m_LSL_Functions.llDetectedVel(number); | ||
251 | } | ||
252 | |||
253 | public vector llDetectedGrab(int number) | ||
254 | { | ||
255 | return m_LSL_Functions.llDetectedGrab(number); | ||
256 | } | ||
257 | |||
258 | public rotation llDetectedRot(int number) | ||
259 | { | ||
260 | return m_LSL_Functions.llDetectedRot(number); | ||
261 | } | ||
262 | |||
263 | public LSL_Types.LSLInteger llDetectedGroup(int number) | ||
264 | { | ||
265 | return m_LSL_Functions.llDetectedGroup(number); | ||
266 | } | ||
267 | |||
268 | public LSL_Types.LSLInteger llDetectedLinkNumber(int number) | ||
269 | { | ||
270 | return m_LSL_Functions.llDetectedLinkNumber(number); | ||
271 | } | ||
272 | |||
273 | public void llDie() | ||
274 | { | ||
275 | m_LSL_Functions.llDie(); | ||
276 | } | ||
277 | |||
278 | public double llGround(vector offset) | ||
279 | { | ||
280 | return m_LSL_Functions.llGround(offset); | ||
281 | } | ||
282 | |||
283 | public double llCloud(vector offset) | ||
284 | { | ||
285 | return m_LSL_Functions.llCloud(offset); | ||
286 | } | ||
287 | |||
288 | public vector llWind(vector offset) | ||
289 | { | ||
290 | return m_LSL_Functions.llWind(offset); | ||
291 | } | ||
292 | |||
293 | public void llSetStatus(int status, int value) | ||
294 | { | ||
295 | m_LSL_Functions.llSetStatus(status, value); | ||
296 | } | ||
297 | |||
298 | public LSL_Types.LSLInteger llGetStatus(int status) | ||
299 | { | ||
300 | return m_LSL_Functions.llGetStatus(status); | ||
301 | } | ||
302 | |||
303 | public void llSetScale(vector scale) | ||
304 | { | ||
305 | m_LSL_Functions.llSetScale(scale); | ||
306 | } | ||
307 | |||
308 | public vector llGetScale() | ||
309 | { | ||
310 | return m_LSL_Functions.llGetScale(); | ||
311 | } | ||
312 | |||
313 | public void llSetColor(vector color, int face) | ||
314 | { | ||
315 | m_LSL_Functions.llSetColor(color, face); | ||
316 | } | ||
317 | |||
318 | public double llGetAlpha(int face) | ||
319 | { | ||
320 | return m_LSL_Functions.llGetAlpha(face); | ||
321 | } | ||
322 | |||
323 | public void llSetAlpha(double alpha, int face) | ||
324 | { | ||
325 | m_LSL_Functions.llSetAlpha(alpha, face); | ||
326 | } | ||
327 | |||
328 | public vector llGetColor(int face) | ||
329 | { | ||
330 | return m_LSL_Functions.llGetColor(face); | ||
331 | } | ||
332 | |||
333 | public void llSetTexture(string texture, int face) | ||
334 | { | ||
335 | m_LSL_Functions.llSetTexture(texture, face); | ||
336 | } | ||
337 | |||
338 | public void llScaleTexture(double u, double v, int face) | ||
339 | { | ||
340 | m_LSL_Functions.llScaleTexture(u, v, face); | ||
341 | } | ||
342 | |||
343 | public void llOffsetTexture(double u, double v, int face) | ||
344 | { | ||
345 | m_LSL_Functions.llOffsetTexture(u, v, face); | ||
346 | } | ||
347 | |||
348 | public void llRotateTexture(double rotation, int face) | ||
349 | { | ||
350 | m_LSL_Functions.llRotateTexture(rotation, face); | ||
351 | } | ||
352 | |||
353 | public string llGetTexture(int face) | ||
354 | { | ||
355 | return m_LSL_Functions.llGetTexture(face); | ||
356 | } | ||
357 | |||
358 | public void llSetPos(vector pos) | ||
359 | { | ||
360 | m_LSL_Functions.llSetPos(pos); | ||
361 | } | ||
362 | |||
363 | public vector llGetPos() | ||
364 | { | ||
365 | return m_LSL_Functions.llGetPos(); | ||
366 | } | ||
367 | |||
368 | public vector llGetLocalPos() | ||
369 | { | ||
370 | return m_LSL_Functions.llGetLocalPos(); | ||
371 | } | ||
372 | |||
373 | public void llSetRot(rotation rot) | ||
374 | { | ||
375 | m_LSL_Functions.llSetRot(rot); | ||
376 | } | ||
377 | |||
378 | public rotation llGetRot() | ||
379 | { | ||
380 | return m_LSL_Functions.llGetRot(); | ||
381 | } | ||
382 | |||
383 | public rotation llGetLocalRot() | ||
384 | { | ||
385 | return m_LSL_Functions.llGetLocalRot(); | ||
386 | } | ||
387 | |||
388 | public void llSetForce(vector force, int local) | ||
389 | { | ||
390 | m_LSL_Functions.llSetForce(force, local); | ||
391 | } | ||
392 | |||
393 | public vector llGetForce() | ||
394 | { | ||
395 | return m_LSL_Functions.llGetForce(); | ||
396 | } | ||
397 | |||
398 | public LSL_Types.LSLInteger llTarget(vector position, double range) | ||
399 | { | ||
400 | return m_LSL_Functions.llTarget(position, range); | ||
401 | } | ||
402 | |||
403 | public void llTargetRemove(int number) | ||
404 | { | ||
405 | m_LSL_Functions.llTargetRemove(number); | ||
406 | } | ||
407 | |||
408 | public LSL_Types.LSLInteger llRotTarget(rotation rot, double error) | ||
409 | { | ||
410 | return m_LSL_Functions.llRotTarget(rot, error); | ||
411 | } | ||
412 | |||
413 | public void llRotTargetRemove(int number) | ||
414 | { | ||
415 | m_LSL_Functions.llRotTargetRemove(number); | ||
416 | } | ||
417 | |||
418 | public void llMoveToTarget(vector target, double tau) | ||
419 | { | ||
420 | m_LSL_Functions.llMoveToTarget(target, tau); | ||
421 | } | ||
422 | |||
423 | public void llStopMoveToTarget() | ||
424 | { | ||
425 | m_LSL_Functions.llStopMoveToTarget(); | ||
426 | } | ||
427 | |||
428 | public void llApplyImpulse(vector force, int local) | ||
429 | { | ||
430 | m_LSL_Functions.llApplyImpulse(force, local); | ||
431 | } | ||
432 | |||
433 | public void llApplyRotationalImpulse(vector force, int local) | ||
434 | { | ||
435 | m_LSL_Functions.llApplyRotationalImpulse(force, local); | ||
436 | } | ||
437 | |||
438 | public void llSetTorque(vector torque, int local) | ||
439 | { | ||
440 | m_LSL_Functions.llSetTorque(torque, local); | ||
441 | } | ||
442 | |||
443 | public vector llGetTorque() | ||
444 | { | ||
445 | return m_LSL_Functions.llGetTorque(); | ||
446 | } | ||
447 | |||
448 | public void llSetForceAndTorque(vector force, vector torque, int local) | ||
449 | { | ||
450 | m_LSL_Functions.llSetForceAndTorque(force, torque, local); | ||
451 | } | ||
452 | |||
453 | public vector llGetVel() | ||
454 | { | ||
455 | return m_LSL_Functions.llGetVel(); | ||
456 | } | ||
457 | |||
458 | public vector llGetAccel() | ||
459 | { | ||
460 | return m_LSL_Functions.llGetAccel(); | ||
461 | } | ||
462 | |||
463 | public vector llGetOmega() | ||
464 | { | ||
465 | return m_LSL_Functions.llGetOmega(); | ||
466 | } | ||
467 | |||
468 | public double llGetTimeOfDay() | ||
469 | { | ||
470 | return m_LSL_Functions.llGetTimeOfDay(); | ||
471 | } | ||
472 | |||
473 | public double llGetWallclock() | ||
474 | { | ||
475 | return m_LSL_Functions.llGetWallclock(); | ||
476 | } | ||
477 | |||
478 | public double llGetTime() | ||
479 | { | ||
480 | return m_LSL_Functions.llGetTime(); | ||
481 | } | ||
482 | |||
483 | public void llResetTime() | ||
484 | { | ||
485 | m_LSL_Functions.llResetTime(); | ||
486 | } | ||
487 | |||
488 | public double llGetAndResetTime() | ||
489 | { | ||
490 | return m_LSL_Functions.llGetAndResetTime(); | ||
491 | } | ||
492 | |||
493 | public void llSound() | ||
494 | { | ||
495 | m_LSL_Functions.llSound(); | ||
496 | } | ||
497 | |||
498 | public void llPlaySound(string sound, double volume) | ||
499 | { | ||
500 | m_LSL_Functions.llPlaySound(sound, volume); | ||
501 | } | ||
502 | |||
503 | public void llLoopSound(string sound, double volume) | ||
504 | { | ||
505 | m_LSL_Functions.llLoopSound(sound, volume); | ||
506 | } | ||
507 | |||
508 | public void llLoopSoundMaster(string sound, double volume) | ||
509 | { | ||
510 | m_LSL_Functions.llLoopSoundMaster(sound, volume); | ||
511 | } | ||
512 | |||
513 | public void llLoopSoundSlave(string sound, double volume) | ||
514 | { | ||
515 | m_LSL_Functions.llLoopSoundSlave(sound, volume); | ||
516 | } | ||
517 | |||
518 | public void llPlaySoundSlave(string sound, double volume) | ||
519 | { | ||
520 | m_LSL_Functions.llPlaySoundSlave(sound, volume); | ||
521 | } | ||
522 | |||
523 | public void llTriggerSound(string sound, double volume) | ||
524 | { | ||
525 | m_LSL_Functions.llTriggerSound(sound, volume); | ||
526 | } | ||
527 | |||
528 | public void llStopSound() | ||
529 | { | ||
530 | m_LSL_Functions.llStopSound(); | ||
531 | } | ||
532 | |||
533 | public void llPreloadSound(string sound) | ||
534 | { | ||
535 | m_LSL_Functions.llPreloadSound(sound); | ||
536 | } | ||
537 | |||
538 | public string llGetSubString(string src, int start, int end) | ||
539 | { | ||
540 | return m_LSL_Functions.llGetSubString(src, start, end); | ||
541 | } | ||
542 | |||
543 | public string llDeleteSubString(string src, int start, int end) | ||
544 | { | ||
545 | return m_LSL_Functions.llDeleteSubString(src, start, end); | ||
546 | } | ||
547 | |||
548 | public string llInsertString(string dst, int position, string src) | ||
549 | { | ||
550 | return m_LSL_Functions.llInsertString(dst, position, src); | ||
551 | } | ||
552 | |||
553 | public string llToUpper(string source) | ||
554 | { | ||
555 | return m_LSL_Functions.llToUpper(source); | ||
556 | } | ||
557 | |||
558 | public string llToLower(string source) | ||
559 | { | ||
560 | return m_LSL_Functions.llToLower(source); | ||
561 | } | ||
562 | |||
563 | public LSL_Types.LSLInteger llGiveMoney(string destination, int amount) | ||
564 | { | ||
565 | return m_LSL_Functions.llGiveMoney(destination, amount); | ||
566 | } | ||
567 | |||
568 | public void llMakeExplosion() | ||
569 | { | ||
570 | m_LSL_Functions.llMakeExplosion(); | ||
571 | } | ||
572 | |||
573 | public void llMakeFountain() | ||
574 | { | ||
575 | m_LSL_Functions.llMakeFountain(); | ||
576 | } | ||
577 | |||
578 | public void llMakeSmoke() | ||
579 | { | ||
580 | m_LSL_Functions.llMakeSmoke(); | ||
581 | } | ||
582 | |||
583 | public void llMakeFire() | ||
584 | { | ||
585 | m_LSL_Functions.llMakeFire(); | ||
586 | } | ||
587 | |||
588 | public void llRezObject(string inventory, vector pos, vector vel, rotation rot, int param) | ||
589 | { | ||
590 | m_LSL_Functions.llRezObject(inventory, pos, vel, rot, param); | ||
591 | } | ||
592 | |||
593 | public void llLookAt(vector target, double strength, double damping) | ||
594 | { | ||
595 | m_LSL_Functions.llLookAt(target, strength, damping); | ||
596 | } | ||
597 | |||
598 | public void llStopLookAt() | ||
599 | { | ||
600 | m_LSL_Functions.llStopLookAt(); | ||
601 | } | ||
602 | |||
603 | public void llSetTimerEvent(double sec) | ||
604 | { | ||
605 | m_LSL_Functions.llSetTimerEvent(sec); | ||
606 | } | ||
607 | |||
608 | public void llSleep(double sec) | ||
609 | { | ||
610 | m_LSL_Functions.llSleep(sec); | ||
611 | } | ||
612 | |||
613 | public double llGetMass() | ||
614 | { | ||
615 | return m_LSL_Functions.llGetMass(); | ||
616 | } | ||
617 | |||
618 | public void llCollisionFilter(string name, string id, int accept) | ||
619 | { | ||
620 | m_LSL_Functions.llCollisionFilter(name, id, accept); | ||
621 | } | ||
622 | |||
623 | public void llTakeControls(int controls, int accept, int pass_on) | ||
624 | { | ||
625 | m_LSL_Functions.llTakeControls(controls, accept, pass_on); | ||
626 | } | ||
627 | |||
628 | public void llReleaseControls() | ||
629 | { | ||
630 | m_LSL_Functions.llReleaseControls(); | ||
631 | } | ||
632 | |||
633 | public void llAttachToAvatar(int attachment) | ||
634 | { | ||
635 | m_LSL_Functions.llAttachToAvatar(attachment); | ||
636 | } | ||
637 | |||
638 | public void llDetachFromAvatar() | ||
639 | { | ||
640 | m_LSL_Functions.llDetachFromAvatar(); | ||
641 | } | ||
642 | |||
643 | public void llTakeCamera() | ||
644 | { | ||
645 | m_LSL_Functions.llTakeCamera(); | ||
646 | } | ||
647 | |||
648 | public void llReleaseCamera() | ||
649 | { | ||
650 | m_LSL_Functions.llReleaseCamera(); | ||
651 | } | ||
652 | |||
653 | public string llGetOwner() | ||
654 | { | ||
655 | return m_LSL_Functions.llGetOwner(); | ||
656 | } | ||
657 | |||
658 | public void llInstantMessage(string user, string message) | ||
659 | { | ||
660 | m_LSL_Functions.llInstantMessage(user, message); | ||
661 | } | ||
662 | |||
663 | public void llEmail(string address, string subject, string message) | ||
664 | { | ||
665 | m_LSL_Functions.llEmail(address, subject, message); | ||
666 | } | ||
667 | |||
668 | public void llGetNextEmail(string address, string subject) | ||
669 | { | ||
670 | m_LSL_Functions.llGetNextEmail(address, subject); | ||
671 | } | ||
672 | |||
673 | public string llGetKey() | ||
674 | { | ||
675 | return m_LSL_Functions.llGetKey(); | ||
676 | } | ||
677 | |||
678 | public void llSetBuoyancy(double buoyancy) | ||
679 | { | ||
680 | m_LSL_Functions.llSetBuoyancy(buoyancy); | ||
681 | } | ||
682 | |||
683 | public void llSetHoverHeight(double height, int water, double tau) | ||
684 | { | ||
685 | m_LSL_Functions.llSetHoverHeight(height, water, tau); | ||
686 | } | ||
687 | |||
688 | public void llStopHover() | ||
689 | { | ||
690 | m_LSL_Functions.llStopHover(); | ||
691 | } | ||
692 | |||
693 | public void llMinEventDelay(double delay) | ||
694 | { | ||
695 | m_LSL_Functions.llMinEventDelay(delay); | ||
696 | } | ||
697 | |||
698 | public void llSoundPreload() | ||
699 | { | ||
700 | m_LSL_Functions.llSoundPreload(); | ||
701 | } | ||
702 | |||
703 | public void llRotLookAt(rotation target, double strength, double damping) | ||
704 | { | ||
705 | m_LSL_Functions.llRotLookAt(target, strength, damping); | ||
706 | } | ||
707 | |||
708 | public LSL_Types.LSLInteger llStringLength(string str) | ||
709 | { | ||
710 | return m_LSL_Functions.llStringLength(str); | ||
711 | } | ||
712 | |||
713 | public void llStartAnimation(string anim) | ||
714 | { | ||
715 | m_LSL_Functions.llStartAnimation(anim); | ||
716 | } | ||
717 | |||
718 | public void llStopAnimation(string anim) | ||
719 | { | ||
720 | m_LSL_Functions.llStopAnimation(anim); | ||
721 | } | ||
722 | |||
723 | public void llPointAt() | ||
724 | { | ||
725 | m_LSL_Functions.llPointAt(); | ||
726 | } | ||
727 | |||
728 | public void llStopPointAt() | ||
729 | { | ||
730 | m_LSL_Functions.llStopPointAt(); | ||
731 | } | ||
732 | |||
733 | public void llTargetOmega(vector axis, double spinrate, double gain) | ||
734 | { | ||
735 | m_LSL_Functions.llTargetOmega(axis, spinrate, gain); | ||
736 | } | ||
737 | |||
738 | public LSL_Types.LSLInteger llGetStartParameter() | ||
739 | { | ||
740 | return m_LSL_Functions.llGetStartParameter(); | ||
741 | } | ||
742 | |||
743 | public void llGodLikeRezObject(string inventory, vector pos) | ||
744 | { | ||
745 | m_LSL_Functions.llGodLikeRezObject(inventory, pos); | ||
746 | } | ||
747 | |||
748 | public void llRequestPermissions(string agent, int perm) | ||
749 | { | ||
750 | m_LSL_Functions.llRequestPermissions(agent, perm); | ||
751 | } | ||
752 | |||
753 | public string llGetPermissionsKey() | ||
754 | { | ||
755 | return m_LSL_Functions.llGetPermissionsKey(); | ||
756 | } | ||
757 | |||
758 | public LSL_Types.LSLInteger llGetPermissions() | ||
759 | { | ||
760 | return m_LSL_Functions.llGetPermissions(); | ||
761 | } | ||
762 | |||
763 | public LSL_Types.LSLInteger llGetLinkNumber() | ||
764 | { | ||
765 | return m_LSL_Functions.llGetLinkNumber(); | ||
766 | } | ||
767 | |||
768 | public void llSetLinkColor(int linknumber, vector color, int face) | ||
769 | { | ||
770 | m_LSL_Functions.llSetLinkColor(linknumber, color, face); | ||
771 | } | ||
772 | |||
773 | public void llCreateLink(string target, int parent) | ||
774 | { | ||
775 | m_LSL_Functions.llCreateLink(target, parent); | ||
776 | } | ||
777 | |||
778 | public void llBreakLink(int linknum) | ||
779 | { | ||
780 | m_LSL_Functions.llBreakLink(linknum); | ||
781 | } | ||
782 | |||
783 | public void llBreakAllLinks() | ||
784 | { | ||
785 | m_LSL_Functions.llBreakAllLinks(); | ||
786 | } | ||
787 | |||
788 | public string llGetLinkKey(int linknum) | ||
789 | { | ||
790 | return m_LSL_Functions.llGetLinkKey(linknum); | ||
791 | } | ||
792 | |||
793 | public string llGetLinkName(int linknum) | ||
794 | { | ||
795 | return m_LSL_Functions.llGetLinkName(linknum); | ||
796 | } | ||
797 | |||
798 | public LSL_Types.LSLInteger llGetInventoryNumber(int type) | ||
799 | { | ||
800 | return m_LSL_Functions.llGetInventoryNumber(type); | ||
801 | } | ||
802 | |||
803 | public string llGetInventoryName(int type, int number) | ||
804 | { | ||
805 | return m_LSL_Functions.llGetInventoryName(type, number); | ||
806 | } | ||
807 | |||
808 | public void llSetScriptState(string name, int run) | ||
809 | { | ||
810 | m_LSL_Functions.llSetScriptState(name, run); | ||
811 | } | ||
812 | |||
813 | public double llGetEnergy() | ||
814 | { | ||
815 | return m_LSL_Functions.llGetEnergy(); | ||
816 | } | ||
817 | |||
818 | public void llGiveInventory(string destination, string inventory) | ||
819 | { | ||
820 | m_LSL_Functions.llGiveInventory(destination, inventory); | ||
821 | } | ||
822 | |||
823 | public void llRemoveInventory(string item) | ||
824 | { | ||
825 | m_LSL_Functions.llRemoveInventory(item); | ||
826 | } | ||
827 | |||
828 | public void llSetText(string text, vector color, double alpha) | ||
829 | { | ||
830 | m_LSL_Functions.llSetText(text, color, alpha); | ||
831 | } | ||
832 | |||
833 | public double llWater(vector offset) | ||
834 | { | ||
835 | return m_LSL_Functions.llWater(offset); | ||
836 | } | ||
837 | |||
838 | public void llPassTouches(int pass) | ||
839 | { | ||
840 | m_LSL_Functions.llPassTouches(pass); | ||
841 | } | ||
842 | |||
843 | public string llRequestAgentData(string id, int data) | ||
844 | { | ||
845 | return m_LSL_Functions.llRequestAgentData(id, data); | ||
846 | } | ||
847 | |||
848 | public string llRequestInventoryData(string name) | ||
849 | { | ||
850 | return m_LSL_Functions.llRequestInventoryData(name); | ||
851 | } | ||
852 | |||
853 | public void llSetDamage(double damage) | ||
854 | { | ||
855 | m_LSL_Functions.llSetDamage(damage); | ||
856 | } | ||
857 | |||
858 | public void llTeleportAgentHome(string agent) | ||
859 | { | ||
860 | m_LSL_Functions.llTeleportAgentHome(agent); | ||
861 | } | ||
862 | |||
863 | public void llModifyLand(int action, int brush) | ||
864 | { | ||
865 | m_LSL_Functions.llModifyLand(action, brush); | ||
866 | } | ||
867 | |||
868 | public void llCollisionSound(string impact_sound, double impact_volume) | ||
869 | { | ||
870 | m_LSL_Functions.llCollisionSound(impact_sound, impact_volume); | ||
871 | } | ||
872 | |||
873 | public void llCollisionSprite(string impact_sprite) | ||
874 | { | ||
875 | m_LSL_Functions.llCollisionSprite(impact_sprite); | ||
876 | } | ||
877 | |||
878 | public string llGetAnimation(string id) | ||
879 | { | ||
880 | return m_LSL_Functions.llGetAnimation(id); | ||
881 | } | ||
882 | |||
883 | public void llResetScript() | ||
884 | { | ||
885 | m_LSL_Functions.llResetScript(); | ||
886 | } | ||
887 | |||
888 | public void llMessageLinked(int linknum, int num, string str, string id) | ||
889 | { | ||
890 | m_LSL_Functions.llMessageLinked(linknum, num, str, id); | ||
891 | } | ||
892 | |||
893 | public void llPushObject(string target, vector impulse, vector ang_impulse, int local) | ||
894 | { | ||
895 | m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local); | ||
896 | } | ||
897 | |||
898 | public void llPassCollisions(int pass) | ||
899 | { | ||
900 | m_LSL_Functions.llPassCollisions(pass); | ||
901 | } | ||
902 | |||
903 | public string llGetScriptName() | ||
904 | { | ||
905 | return m_LSL_Functions.llGetScriptName(); | ||
906 | } | ||
907 | |||
908 | public LSL_Types.LSLInteger llGetNumberOfSides() | ||
909 | { | ||
910 | return m_LSL_Functions.llGetNumberOfSides(); | ||
911 | } | ||
912 | |||
913 | public rotation llAxisAngle2Rot(vector axis, double angle) | ||
914 | { | ||
915 | return m_LSL_Functions.llAxisAngle2Rot(axis, angle); | ||
916 | } | ||
917 | |||
918 | public vector llRot2Axis(rotation rot) | ||
919 | { | ||
920 | return m_LSL_Functions.llRot2Axis(rot); | ||
921 | } | ||
922 | |||
923 | public double llRot2Angle(rotation rot) | ||
924 | { | ||
925 | return m_LSL_Functions.llRot2Angle(rot); | ||
926 | } | ||
927 | |||
928 | public double llAcos(double val) | ||
929 | { | ||
930 | return m_LSL_Functions.llAcos(val); | ||
931 | } | ||
932 | |||
933 | public double llAsin(double val) | ||
934 | { | ||
935 | return m_LSL_Functions.llAsin(val); | ||
936 | } | ||
937 | |||
938 | public double llAngleBetween(rotation a, rotation b) | ||
939 | { | ||
940 | return m_LSL_Functions.llAngleBetween(a, b); | ||
941 | } | ||
942 | |||
943 | public string llGetInventoryKey(string name) | ||
944 | { | ||
945 | return m_LSL_Functions.llGetInventoryKey(name); | ||
946 | } | ||
947 | |||
948 | public void llAllowInventoryDrop(int add) | ||
949 | { | ||
950 | m_LSL_Functions.llAllowInventoryDrop(add); | ||
951 | } | ||
952 | |||
953 | public vector llGetSunDirection() | ||
954 | { | ||
955 | return m_LSL_Functions.llGetSunDirection(); | ||
956 | } | ||
957 | |||
958 | public vector llGetTextureOffset(int face) | ||
959 | { | ||
960 | return m_LSL_Functions.llGetTextureOffset(face); | ||
961 | } | ||
962 | |||
963 | public vector llGetTextureScale(int side) | ||
964 | { | ||
965 | return m_LSL_Functions.llGetTextureScale(side); | ||
966 | } | ||
967 | |||
968 | public double llGetTextureRot(int side) | ||
969 | { | ||
970 | return m_LSL_Functions.llGetTextureRot(side); | ||
971 | } | ||
972 | |||
973 | public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern) | ||
974 | { | ||
975 | return m_LSL_Functions.llSubStringIndex(source, pattern); | ||
976 | } | ||
977 | |||
978 | public string llGetOwnerKey(string id) | ||
979 | { | ||
980 | return m_LSL_Functions.llGetOwnerKey(id); | ||
981 | } | ||
982 | |||
983 | public vector llGetCenterOfMass() | ||
984 | { | ||
985 | return m_LSL_Functions.llGetCenterOfMass(); | ||
986 | } | ||
987 | |||
988 | public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending) | ||
989 | { | ||
990 | return m_LSL_Functions.llListSort(src, stride, ascending); | ||
991 | } | ||
992 | |||
993 | public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src) | ||
994 | { | ||
995 | return m_LSL_Functions.llGetListLength(src); | ||
996 | } | ||
997 | |||
998 | public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index) | ||
999 | { | ||
1000 | return m_LSL_Functions.llList2Integer(src, index); | ||
1001 | } | ||
1002 | |||
1003 | public string llList2String(LSL_Types.list src, int index) | ||
1004 | { | ||
1005 | return m_LSL_Functions.llList2String(src, index); | ||
1006 | } | ||
1007 | |||
1008 | public string llList2Key(LSL_Types.list src, int index) | ||
1009 | { | ||
1010 | return m_LSL_Functions.llList2Key(src, index); | ||
1011 | } | ||
1012 | |||
1013 | public vector llList2Vector(LSL_Types.list src, int index) | ||
1014 | { | ||
1015 | return m_LSL_Functions.llList2Vector(src, index); | ||
1016 | } | ||
1017 | |||
1018 | public rotation llList2Rot(LSL_Types.list src, int index) | ||
1019 | { | ||
1020 | return m_LSL_Functions.llList2Rot(src, index); | ||
1021 | } | ||
1022 | |||
1023 | public LSL_Types.list llList2List(LSL_Types.list src, int start, int end) | ||
1024 | { | ||
1025 | return m_LSL_Functions.llList2List(src, start, end); | ||
1026 | } | ||
1027 | |||
1028 | public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end) | ||
1029 | { | ||
1030 | return m_LSL_Functions.llDeleteSubList(src, start, end); | ||
1031 | } | ||
1032 | |||
1033 | public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index) | ||
1034 | { | ||
1035 | return m_LSL_Functions.llGetListEntryType(src, index); | ||
1036 | } | ||
1037 | |||
1038 | public string llList2CSV(LSL_Types.list src) | ||
1039 | { | ||
1040 | return m_LSL_Functions.llList2CSV(src); | ||
1041 | } | ||
1042 | |||
1043 | public LSL_Types.list llCSV2List(string src) | ||
1044 | { | ||
1045 | return m_LSL_Functions.llCSV2List(src); | ||
1046 | } | ||
1047 | |||
1048 | public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) | ||
1049 | { | ||
1050 | return m_LSL_Functions.llListRandomize(src, stride); | ||
1051 | } | ||
1052 | |||
1053 | public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride) | ||
1054 | { | ||
1055 | return m_LSL_Functions.llList2ListStrided(src, start, end, stride); | ||
1056 | } | ||
1057 | |||
1058 | public vector llGetRegionCorner() | ||
1059 | { | ||
1060 | return m_LSL_Functions.llGetRegionCorner(); | ||
1061 | } | ||
1062 | |||
1063 | public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start) | ||
1064 | { | ||
1065 | return m_LSL_Functions.llListInsertList(dest, src, start); | ||
1066 | } | ||
1067 | |||
1068 | public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test) | ||
1069 | { | ||
1070 | return m_LSL_Functions.llListFindList(src, test); | ||
1071 | } | ||
1072 | |||
1073 | public string llGetObjectName() | ||
1074 | { | ||
1075 | return m_LSL_Functions.llGetObjectName(); | ||
1076 | } | ||
1077 | |||
1078 | public void llSetObjectName(string name) | ||
1079 | { | ||
1080 | m_LSL_Functions.llSetObjectName(name); | ||
1081 | } | ||
1082 | |||
1083 | public string llGetDate() | ||
1084 | { | ||
1085 | return m_LSL_Functions.llGetDate(); | ||
1086 | } | ||
1087 | |||
1088 | public LSL_Types.LSLInteger llEdgeOfWorld(vector pos, vector dir) | ||
1089 | { | ||
1090 | return m_LSL_Functions.llEdgeOfWorld(pos, dir); | ||
1091 | } | ||
1092 | |||
1093 | public LSL_Types.LSLInteger llGetAgentInfo(string id) | ||
1094 | { | ||
1095 | return m_LSL_Functions.llGetAgentInfo(id); | ||
1096 | } | ||
1097 | |||
1098 | public void llAdjustSoundVolume(double volume) | ||
1099 | { | ||
1100 | m_LSL_Functions.llAdjustSoundVolume(volume); | ||
1101 | } | ||
1102 | |||
1103 | public void llSetSoundQueueing(int queue) | ||
1104 | { | ||
1105 | m_LSL_Functions.llSetSoundQueueing(queue); | ||
1106 | } | ||
1107 | |||
1108 | public void llSetSoundRadius(double radius) | ||
1109 | { | ||
1110 | m_LSL_Functions.llSetSoundRadius(radius); | ||
1111 | } | ||
1112 | |||
1113 | public string llKey2Name(string id) | ||
1114 | { | ||
1115 | return m_LSL_Functions.llKey2Name(id); | ||
1116 | } | ||
1117 | |||
1118 | public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) | ||
1119 | { | ||
1120 | m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate); | ||
1121 | } | ||
1122 | |||
1123 | public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) | ||
1124 | { | ||
1125 | m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west); | ||
1126 | } | ||
1127 | |||
1128 | public void llEjectFromLand(string pest) | ||
1129 | { | ||
1130 | m_LSL_Functions.llEjectFromLand(pest); | ||
1131 | } | ||
1132 | |||
1133 | public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers) | ||
1134 | { | ||
1135 | return m_LSL_Functions.llParseString2List(str,separators,spacers); | ||
1136 | } | ||
1137 | |||
1138 | public LSL_Types.LSLInteger llOverMyLand(string id) | ||
1139 | { | ||
1140 | return m_LSL_Functions.llOverMyLand(id); | ||
1141 | } | ||
1142 | |||
1143 | public string llGetLandOwnerAt(vector pos) | ||
1144 | { | ||
1145 | return m_LSL_Functions.llGetLandOwnerAt(pos); | ||
1146 | } | ||
1147 | |||
1148 | public string llGetNotecardLine(string name, int line) | ||
1149 | { | ||
1150 | return m_LSL_Functions.llGetNotecardLine(name, line); | ||
1151 | } | ||
1152 | |||
1153 | public vector llGetAgentSize(string id) | ||
1154 | { | ||
1155 | return m_LSL_Functions.llGetAgentSize(id); | ||
1156 | } | ||
1157 | |||
1158 | public LSL_Types.LSLInteger llSameGroup(string agent) | ||
1159 | { | ||
1160 | return m_LSL_Functions.llSameGroup(agent); | ||
1161 | } | ||
1162 | |||
1163 | public void llUnSit(string id) | ||
1164 | { | ||
1165 | m_LSL_Functions.llUnSit(id); | ||
1166 | } | ||
1167 | |||
1168 | public vector llGroundSlope(vector offset) | ||
1169 | { | ||
1170 | return m_LSL_Functions.llGroundSlope(offset); | ||
1171 | } | ||
1172 | |||
1173 | public vector llGroundNormal(vector offset) | ||
1174 | { | ||
1175 | return m_LSL_Functions.llGroundNormal(offset); | ||
1176 | } | ||
1177 | |||
1178 | public vector llGroundContour(vector offset) | ||
1179 | { | ||
1180 | return m_LSL_Functions.llGroundContour(offset); | ||
1181 | } | ||
1182 | |||
1183 | public LSL_Types.LSLInteger llGetAttached() | ||
1184 | { | ||
1185 | return m_LSL_Functions.llGetAttached(); | ||
1186 | } | ||
1187 | |||
1188 | public LSL_Types.LSLInteger llGetFreeMemory() | ||
1189 | { | ||
1190 | return m_LSL_Functions.llGetFreeMemory(); | ||
1191 | } | ||
1192 | |||
1193 | public string llGetRegionName() | ||
1194 | { | ||
1195 | return m_LSL_Functions.llGetRegionName(); | ||
1196 | } | ||
1197 | |||
1198 | public double llGetRegionTimeDilation() | ||
1199 | { | ||
1200 | return m_LSL_Functions.llGetRegionTimeDilation(); | ||
1201 | } | ||
1202 | |||
1203 | public double llGetRegionFPS() | ||
1204 | { | ||
1205 | return m_LSL_Functions.llGetRegionFPS(); | ||
1206 | } | ||
1207 | |||
1208 | public void llParticleSystem(LSL_Types.list rules) | ||
1209 | { | ||
1210 | m_LSL_Functions.llParticleSystem(rules); | ||
1211 | } | ||
1212 | |||
1213 | public void llGroundRepel(double height, int water, double tau) | ||
1214 | { | ||
1215 | m_LSL_Functions.llGroundRepel(height, water, tau); | ||
1216 | } | ||
1217 | |||
1218 | public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory) | ||
1219 | { | ||
1220 | m_LSL_Functions.llGiveInventoryList(destination, category, inventory); | ||
1221 | } | ||
1222 | |||
1223 | public void llSetVehicleType(int type) | ||
1224 | { | ||
1225 | m_LSL_Functions.llSetVehicleType(type); | ||
1226 | } | ||
1227 | |||
1228 | public void llSetVehicledoubleParam(int param, double value) | ||
1229 | { | ||
1230 | m_LSL_Functions.llSetVehicledoubleParam(param, value); | ||
1231 | } | ||
1232 | |||
1233 | public void llSetVehicleFloatParam(int param, float value) | ||
1234 | { | ||
1235 | m_LSL_Functions.llSetVehicleFloatParam(param, value); | ||
1236 | } | ||
1237 | |||
1238 | public void llSetVehicleVectorParam(int param, vector vec) | ||
1239 | { | ||
1240 | m_LSL_Functions.llSetVehicleVectorParam(param, vec); | ||
1241 | } | ||
1242 | |||
1243 | public void llSetVehicleRotationParam(int param, rotation rot) | ||
1244 | { | ||
1245 | m_LSL_Functions.llSetVehicleRotationParam(param, rot); | ||
1246 | } | ||
1247 | |||
1248 | public void llSetVehicleFlags(int flags) | ||
1249 | { | ||
1250 | m_LSL_Functions.llSetVehicleFlags(flags); | ||
1251 | } | ||
1252 | |||
1253 | public void llRemoveVehicleFlags(int flags) | ||
1254 | { | ||
1255 | m_LSL_Functions.llRemoveVehicleFlags(flags); | ||
1256 | } | ||
1257 | |||
1258 | public void llSitTarget(vector offset, rotation rot) | ||
1259 | { | ||
1260 | m_LSL_Functions.llSitTarget(offset, rot); | ||
1261 | } | ||
1262 | |||
1263 | public string llAvatarOnSitTarget() | ||
1264 | { | ||
1265 | return m_LSL_Functions.llAvatarOnSitTarget(); | ||
1266 | } | ||
1267 | |||
1268 | public void llAddToLandPassList(string avatar, double hours) | ||
1269 | { | ||
1270 | m_LSL_Functions.llAddToLandPassList(avatar, hours); | ||
1271 | } | ||
1272 | |||
1273 | public void llSetTouchText(string text) | ||
1274 | { | ||
1275 | m_LSL_Functions.llSetTouchText(text); | ||
1276 | } | ||
1277 | |||
1278 | public void llSetSitText(string text) | ||
1279 | { | ||
1280 | m_LSL_Functions.llSetSitText(text); | ||
1281 | } | ||
1282 | |||
1283 | public void llSetCameraEyeOffset(vector offset) | ||
1284 | { | ||
1285 | m_LSL_Functions.llSetCameraEyeOffset(offset); | ||
1286 | } | ||
1287 | |||
1288 | public void llSetCameraAtOffset(vector offset) | ||
1289 | { | ||
1290 | m_LSL_Functions.llSetCameraAtOffset(offset); | ||
1291 | } | ||
1292 | |||
1293 | public string llDumpList2String(LSL_Types.list src, string seperator) | ||
1294 | { | ||
1295 | return m_LSL_Functions.llDumpList2String(src, seperator); | ||
1296 | } | ||
1297 | |||
1298 | public LSL_Types.LSLInteger llScriptDanger(vector pos) | ||
1299 | { | ||
1300 | return m_LSL_Functions.llScriptDanger(pos); | ||
1301 | } | ||
1302 | |||
1303 | public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel) | ||
1304 | { | ||
1305 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | ||
1306 | } | ||
1307 | |||
1308 | public void llVolumeDetect(int detect) | ||
1309 | { | ||
1310 | m_LSL_Functions.llVolumeDetect(detect); | ||
1311 | } | ||
1312 | |||
1313 | public void llResetOtherScript(string name) | ||
1314 | { | ||
1315 | m_LSL_Functions.llResetOtherScript(name); | ||
1316 | } | ||
1317 | |||
1318 | public LSL_Types.LSLInteger llGetScriptState(string name) | ||
1319 | { | ||
1320 | return m_LSL_Functions.llGetScriptState(name); | ||
1321 | } | ||
1322 | |||
1323 | public void llRemoteLoadScript() | ||
1324 | { | ||
1325 | m_LSL_Functions.llRemoteLoadScript(); | ||
1326 | } | ||
1327 | |||
1328 | public void llSetRemoteScriptAccessPin(int pin) | ||
1329 | { | ||
1330 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); | ||
1331 | } | ||
1332 | |||
1333 | public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) | ||
1334 | { | ||
1335 | m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); | ||
1336 | } | ||
1337 | |||
1338 | public void llOpenRemoteDataChannel() | ||
1339 | { | ||
1340 | m_LSL_Functions.llOpenRemoteDataChannel(); | ||
1341 | } | ||
1342 | |||
1343 | public string llSendRemoteData(string channel, string dest, int idata, string sdata) | ||
1344 | { | ||
1345 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); | ||
1346 | } | ||
1347 | |||
1348 | public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) | ||
1349 | { | ||
1350 | m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata); | ||
1351 | } | ||
1352 | |||
1353 | public void llCloseRemoteDataChannel(string channel) | ||
1354 | { | ||
1355 | m_LSL_Functions.llCloseRemoteDataChannel(channel); | ||
1356 | } | ||
1357 | |||
1358 | public string llMD5String(string src, int nonce) | ||
1359 | { | ||
1360 | return m_LSL_Functions.llMD5String(src, nonce); | ||
1361 | } | ||
1362 | |||
1363 | public void llSetPrimitiveParams(LSL_Types.list rules) | ||
1364 | { | ||
1365 | m_LSL_Functions.llSetPrimitiveParams(rules); | ||
1366 | } | ||
1367 | |||
1368 | public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules) | ||
1369 | { | ||
1370 | m_LSL_Functions.llSetLinkPrimitiveParams(linknumber, rules); | ||
1371 | } | ||
1372 | public string llStringToBase64(string str) | ||
1373 | { | ||
1374 | return m_LSL_Functions.llStringToBase64(str); | ||
1375 | } | ||
1376 | |||
1377 | public string llBase64ToString(string str) | ||
1378 | { | ||
1379 | return m_LSL_Functions.llBase64ToString(str); | ||
1380 | } | ||
1381 | |||
1382 | public void llXorBase64Strings() | ||
1383 | { | ||
1384 | m_LSL_Functions.llXorBase64Strings(); | ||
1385 | } | ||
1386 | |||
1387 | public void llRemoteDataSetRegion() | ||
1388 | { | ||
1389 | m_LSL_Functions.llRemoteDataSetRegion(); | ||
1390 | } | ||
1391 | |||
1392 | public double llLog10(double val) | ||
1393 | { | ||
1394 | return m_LSL_Functions.llLog10(val); | ||
1395 | } | ||
1396 | |||
1397 | public double llLog(double val) | ||
1398 | { | ||
1399 | return m_LSL_Functions.llLog(val); | ||
1400 | } | ||
1401 | |||
1402 | public LSL_Types.list llGetAnimationList(string id) | ||
1403 | { | ||
1404 | return m_LSL_Functions.llGetAnimationList(id); | ||
1405 | } | ||
1406 | |||
1407 | public void llSetParcelMusicURL(string url) | ||
1408 | { | ||
1409 | m_LSL_Functions.llSetParcelMusicURL(url); | ||
1410 | } | ||
1411 | |||
1412 | public vector llGetRootPosition() | ||
1413 | { | ||
1414 | return m_LSL_Functions.llGetRootPosition(); | ||
1415 | } | ||
1416 | |||
1417 | public rotation llGetRootRotation() | ||
1418 | { | ||
1419 | return m_LSL_Functions.llGetRootRotation(); | ||
1420 | } | ||
1421 | |||
1422 | public string llGetObjectDesc() | ||
1423 | { | ||
1424 | return m_LSL_Functions.llGetObjectDesc(); | ||
1425 | } | ||
1426 | |||
1427 | public void llSetObjectDesc(string desc) | ||
1428 | { | ||
1429 | m_LSL_Functions.llSetObjectDesc(desc); | ||
1430 | } | ||
1431 | |||
1432 | public string llGetCreator() | ||
1433 | { | ||
1434 | return m_LSL_Functions.llGetCreator(); | ||
1435 | } | ||
1436 | |||
1437 | public string llGetTimestamp() | ||
1438 | { | ||
1439 | return m_LSL_Functions.llGetTimestamp(); | ||
1440 | } | ||
1441 | |||
1442 | public void llSetLinkAlpha(int linknumber, double alpha, int face) | ||
1443 | { | ||
1444 | m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face); | ||
1445 | } | ||
1446 | |||
1447 | public LSL_Types.LSLInteger llGetNumberOfPrims() | ||
1448 | { | ||
1449 | return m_LSL_Functions.llGetNumberOfPrims(); | ||
1450 | } | ||
1451 | |||
1452 | public string llGetNumberOfNotecardLines(string name) | ||
1453 | { | ||
1454 | return m_LSL_Functions.llGetNumberOfNotecardLines(name); | ||
1455 | } | ||
1456 | |||
1457 | public LSL_Types.list llGetBoundingBox(string obj) | ||
1458 | { | ||
1459 | return m_LSL_Functions.llGetBoundingBox(obj); | ||
1460 | } | ||
1461 | |||
1462 | public vector llGetGeometricCenter() | ||
1463 | { | ||
1464 | return m_LSL_Functions.llGetGeometricCenter(); | ||
1465 | } | ||
1466 | |||
1467 | public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules) | ||
1468 | { | ||
1469 | return m_LSL_Functions.llGetPrimitiveParams(rules); | ||
1470 | } | ||
1471 | |||
1472 | public string llIntegerToBase64(int number) | ||
1473 | { | ||
1474 | return m_LSL_Functions.llIntegerToBase64(number); | ||
1475 | } | ||
1476 | |||
1477 | public LSL_Types.LSLInteger llBase64ToInteger(string str) | ||
1478 | { | ||
1479 | return m_LSL_Functions.llBase64ToInteger(str); | ||
1480 | } | ||
1481 | |||
1482 | public double llGetGMTclock() | ||
1483 | { | ||
1484 | return m_LSL_Functions.llGetGMTclock(); | ||
1485 | } | ||
1486 | |||
1487 | public string llGetSimulatorHostname() | ||
1488 | { | ||
1489 | return m_LSL_Functions.llGetSimulatorHostname(); | ||
1490 | } | ||
1491 | |||
1492 | public void llSetLocalRot(rotation rot) | ||
1493 | { | ||
1494 | m_LSL_Functions.llSetLocalRot(rot); | ||
1495 | } | ||
1496 | |||
1497 | public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers) | ||
1498 | { | ||
1499 | return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); | ||
1500 | } | ||
1501 | |||
1502 | public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param) | ||
1503 | { | ||
1504 | m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param); | ||
1505 | } | ||
1506 | |||
1507 | public LSL_Types.LSLInteger llGetObjectPermMask(int mask) | ||
1508 | { | ||
1509 | return m_LSL_Functions.llGetObjectPermMask(mask); | ||
1510 | } | ||
1511 | |||
1512 | public void llSetObjectPermMask(int mask, int value) | ||
1513 | { | ||
1514 | m_LSL_Functions.llSetObjectPermMask(mask, value); | ||
1515 | } | ||
1516 | |||
1517 | public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask) | ||
1518 | { | ||
1519 | return m_LSL_Functions.llGetInventoryPermMask(item, mask); | ||
1520 | } | ||
1521 | |||
1522 | public void llSetInventoryPermMask(string item, int mask, int value) | ||
1523 | { | ||
1524 | m_LSL_Functions.llSetInventoryPermMask(item, mask, value); | ||
1525 | } | ||
1526 | |||
1527 | public string llGetInventoryCreator(string item) | ||
1528 | { | ||
1529 | return m_LSL_Functions.llGetInventoryCreator(item); | ||
1530 | } | ||
1531 | |||
1532 | public void llOwnerSay(string msg) | ||
1533 | { | ||
1534 | m_LSL_Functions.llOwnerSay(msg); | ||
1535 | } | ||
1536 | |||
1537 | public string llRequestSimulatorData(string simulator, int data) | ||
1538 | { | ||
1539 | return m_LSL_Functions.llRequestSimulatorData(simulator, data); | ||
1540 | } | ||
1541 | |||
1542 | public void llForceMouselook(int mouselook) | ||
1543 | { | ||
1544 | m_LSL_Functions.llForceMouselook(mouselook); | ||
1545 | } | ||
1546 | |||
1547 | public double llGetObjectMass(string id) | ||
1548 | { | ||
1549 | return m_LSL_Functions.llGetObjectMass(id); | ||
1550 | } | ||
1551 | |||
1552 | public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) | ||
1553 | { | ||
1554 | return m_LSL_Functions.llListReplaceList(dest, src, start, end); | ||
1555 | } | ||
1556 | |||
1557 | public void llLoadURL(string avatar_id, string message, string url) | ||
1558 | { | ||
1559 | m_LSL_Functions.llLoadURL(avatar_id, message, url); | ||
1560 | } | ||
1561 | |||
1562 | public void llParcelMediaCommandList(LSL_Types.list commandList) | ||
1563 | { | ||
1564 | m_LSL_Functions.llParcelMediaCommandList(commandList); | ||
1565 | } | ||
1566 | |||
1567 | public void llParcelMediaQuery() | ||
1568 | { | ||
1569 | m_LSL_Functions.llParcelMediaQuery(); | ||
1570 | } | ||
1571 | |||
1572 | public LSL_Types.LSLInteger llModPow(int a, int b, int c) | ||
1573 | { | ||
1574 | return m_LSL_Functions.llModPow(a, b, c); | ||
1575 | } | ||
1576 | |||
1577 | public LSL_Types.LSLInteger llGetInventoryType(string name) | ||
1578 | { | ||
1579 | return m_LSL_Functions.llGetInventoryType(name); | ||
1580 | } | ||
1581 | |||
1582 | public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons) | ||
1583 | { | ||
1584 | m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); | ||
1585 | } | ||
1586 | |||
1587 | public vector llGetCameraPos() | ||
1588 | { | ||
1589 | return m_LSL_Functions.llGetCameraPos(); | ||
1590 | } | ||
1591 | |||
1592 | public rotation llGetCameraRot() | ||
1593 | { | ||
1594 | return m_LSL_Functions.llGetCameraRot(); | ||
1595 | } | ||
1596 | |||
1597 | public void llSetPrimURL() | ||
1598 | { | ||
1599 | m_LSL_Functions.llSetPrimURL(); | ||
1600 | } | ||
1601 | |||
1602 | public void llRefreshPrimURL() | ||
1603 | { | ||
1604 | m_LSL_Functions.llRefreshPrimURL(); | ||
1605 | } | ||
1606 | |||
1607 | public string llEscapeURL(string url) | ||
1608 | { | ||
1609 | return m_LSL_Functions.llEscapeURL(url); | ||
1610 | } | ||
1611 | |||
1612 | public string llUnescapeURL(string url) | ||
1613 | { | ||
1614 | return m_LSL_Functions.llUnescapeURL(url); | ||
1615 | } | ||
1616 | |||
1617 | public void llMapDestination(string simname, vector pos, vector look_at) | ||
1618 | { | ||
1619 | m_LSL_Functions.llMapDestination(simname, pos, look_at); | ||
1620 | } | ||
1621 | |||
1622 | public void llAddToLandBanList(string avatar, double hours) | ||
1623 | { | ||
1624 | m_LSL_Functions.llAddToLandBanList(avatar, hours); | ||
1625 | } | ||
1626 | |||
1627 | public void llRemoveFromLandPassList(string avatar) | ||
1628 | { | ||
1629 | m_LSL_Functions.llRemoveFromLandPassList(avatar); | ||
1630 | } | ||
1631 | |||
1632 | public void llRemoveFromLandBanList(string avatar) | ||
1633 | { | ||
1634 | m_LSL_Functions.llRemoveFromLandBanList(avatar); | ||
1635 | } | ||
1636 | |||
1637 | public void llSetCameraParams(LSL_Types.list rules) | ||
1638 | { | ||
1639 | m_LSL_Functions.llSetCameraParams(rules); | ||
1640 | } | ||
1641 | |||
1642 | public void llClearCameraParams() | ||
1643 | { | ||
1644 | m_LSL_Functions.llClearCameraParams(); | ||
1645 | } | ||
1646 | |||
1647 | public double llListStatistics(int operation, LSL_Types.list src) | ||
1648 | { | ||
1649 | return m_LSL_Functions.llListStatistics(operation, src); | ||
1650 | } | ||
1651 | |||
1652 | public LSL_Types.LSLInteger llGetUnixTime() | ||
1653 | { | ||
1654 | return m_LSL_Functions.llGetUnixTime(); | ||
1655 | } | ||
1656 | |||
1657 | public LSL_Types.LSLInteger llGetParcelFlags(vector pos) | ||
1658 | { | ||
1659 | return m_LSL_Functions.llGetParcelFlags(pos); | ||
1660 | } | ||
1661 | |||
1662 | public LSL_Types.LSLInteger llGetRegionFlags() | ||
1663 | { | ||
1664 | return m_LSL_Functions.llGetRegionFlags(); | ||
1665 | } | ||
1666 | |||
1667 | public string llXorBase64StringsCorrect(string str1, string str2) | ||
1668 | { | ||
1669 | return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); | ||
1670 | } | ||
1671 | |||
1672 | public string llHTTPRequest(string url, LSL_Types.list parameters, string body) | ||
1673 | { | ||
1674 | return m_LSL_Functions.llHTTPRequest(url, parameters, body); | ||
1675 | } | ||
1676 | |||
1677 | public void llResetLandBanList() | ||
1678 | { | ||
1679 | m_LSL_Functions.llResetLandBanList(); | ||
1680 | } | ||
1681 | |||
1682 | public void llResetLandPassList() | ||
1683 | { | ||
1684 | m_LSL_Functions.llResetLandPassList(); | ||
1685 | } | ||
1686 | |||
1687 | public LSL_Types.LSLInteger llGetParcelPrimCount(vector pos, int category, int sim_wide) | ||
1688 | { | ||
1689 | return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); | ||
1690 | } | ||
1691 | |||
1692 | public LSL_Types.list llGetParcelPrimOwners(vector pos) | ||
1693 | { | ||
1694 | return m_LSL_Functions.llGetParcelPrimOwners(pos); | ||
1695 | } | ||
1696 | |||
1697 | public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id) | ||
1698 | { | ||
1699 | return m_LSL_Functions.llGetObjectPrimCount(object_id); | ||
1700 | } | ||
1701 | |||
1702 | public LSL_Types.LSLInteger llGetParcelMaxPrims(vector pos, int sim_wide) | ||
1703 | { | ||
1704 | return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); | ||
1705 | } | ||
1706 | |||
1707 | public LSL_Types.list llGetParcelDetails(vector pos, LSL_Types.list param) | ||
1708 | { | ||
1709 | return m_LSL_Functions.llGetParcelDetails(pos, param); | ||
1710 | } | ||
1711 | |||
1712 | public void llSetLinkTexture(int linknumber, string texture, int face) | ||
1713 | { | ||
1714 | m_LSL_Functions.llSetLinkTexture(linknumber, texture, face); | ||
1715 | } | ||
1716 | |||
1717 | public string llStringTrim(string src, int type) | ||
1718 | { | ||
1719 | return m_LSL_Functions.llStringTrim(src, type); | ||
1720 | } | ||
1721 | |||
1722 | public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args) | ||
1723 | { | ||
1724 | return m_LSL_Functions.llGetObjectDetails(id, args); | ||
1725 | } | ||
1726 | |||
1727 | public double llList2Float(LSL_Types.list src, int index) | ||
1728 | { | ||
1729 | return m_LSL_Functions.llList2Float(src, index); | ||
1730 | } | ||
1731 | } | ||
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 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
37 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
38 | using key = System.String; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | |||
42 | namespace 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 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
35 | using OpenSim.Region.ScriptEngine.Shared; | ||
36 | |||
37 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Text; | ||
34 | |||
35 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | |||
35 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | |||
35 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | |||
35 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace 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 | |||
31 | using System; | ||
32 | |||
33 | namespace 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 | |||
31 | using System; | ||
32 | |||
33 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | |||
35 | namespace 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 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using System.IO; | ||
35 | using System.Reflection; | ||
36 | |||
37 | namespace 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 | |||
31 | using System; | ||
32 | using System.IO; | ||
33 | using System.Collections; | ||
34 | using System.Collections.Generic; | ||
35 | using System.Text; | ||
36 | using System.CodeDom.Compiler; | ||
37 | |||
38 | namespace 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(@" | ||
356 | using System; | ||
357 | using System.Collections.Generic; | ||
358 | using YieldProlog; | ||
359 | |||
360 | namespace 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/Shared/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs new file mode 100644 index 0000000..f9b160d --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs | |||
@@ -0,0 +1,65 @@ | |||
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 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | |||
32 | namespace OpenSim.Region.ScriptEngine.Shared | ||
33 | { | ||
34 | [Serializable] | ||
35 | public class AssemblyResolver | ||
36 | { | ||
37 | public static Assembly OnAssemblyResolve(object sender, | ||
38 | ResolveEventArgs args) | ||
39 | { | ||
40 | if (!(sender is System.AppDomain)) | ||
41 | return null; | ||
42 | |||
43 | AppDomain myDomain = (AppDomain)sender; | ||
44 | string dirName = myDomain.FriendlyName; | ||
45 | |||
46 | string[] pathList = new string[] {"bin", "ScriptEngines", | ||
47 | Path.Combine("ScriptEngines", dirName)}; | ||
48 | |||
49 | string assemblyName = args.Name; | ||
50 | if (assemblyName.IndexOf(",") != -1) | ||
51 | assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")); | ||
52 | |||
53 | foreach (string s in pathList) | ||
54 | { | ||
55 | string path = Path.Combine(Directory.GetCurrentDirectory(), | ||
56 | Path.Combine(s, assemblyName))+".dll"; | ||
57 | |||
58 | if (File.Exists(path)) | ||
59 | return Assembly.LoadFrom(path); | ||
60 | } | ||
61 | |||
62 | return null; | ||
63 | } | ||
64 | } | ||
65 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs new file mode 100644 index 0000000..2edcee0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -0,0 +1,515 @@ | |||
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 | using System; | ||
29 | using System.CodeDom.Compiler; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Globalization; | ||
32 | using System.IO; | ||
33 | using Microsoft.CSharp; | ||
34 | using Microsoft.JScript; | ||
35 | using Microsoft.VisualBasic; | ||
36 | using OpenSim.Region.Environment.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | ||
40 | { | ||
41 | public class Compiler | ||
42 | { | ||
43 | private static readonly log4net.ILog m_log | ||
44 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | // * Uses "LSL2Converter" to convert LSL to C# if necessary. | ||
47 | // * Compiles C#-code into an assembly | ||
48 | // * Returns assembly name ready for AppDomain load. | ||
49 | // | ||
50 | // Assembly is compiled using LSL_BaseClass as base. Look at debug C# code file created when LSL script is compiled for full details. | ||
51 | // | ||
52 | |||
53 | internal enum enumCompileType | ||
54 | { | ||
55 | lsl = 0, | ||
56 | cs = 1, | ||
57 | vb = 2, | ||
58 | js = 3 | ||
59 | } | ||
60 | |||
61 | /// <summary> | ||
62 | /// This contains number of lines WE use for header when compiling script. User will get error in line x-LinesToRemoveOnError when error occurs. | ||
63 | /// </summary> | ||
64 | public int LinesToRemoveOnError = 3; | ||
65 | private enumCompileType DefaultCompileLanguage; | ||
66 | private bool WriteScriptSourceToDebugFile; | ||
67 | private bool CompileWithDebugInformation; | ||
68 | private Dictionary<string, bool> AllowedCompilers = new Dictionary<string, bool>(StringComparer.CurrentCultureIgnoreCase); | ||
69 | private Dictionary<string, enumCompileType> LanguageMapping = new Dictionary<string, enumCompileType>(StringComparer.CurrentCultureIgnoreCase); | ||
70 | |||
71 | private string FilePrefix; | ||
72 | private string ScriptEnginesPath = "ScriptEngines"; | ||
73 | |||
74 | private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); | ||
75 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | ||
76 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | ||
77 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); | ||
78 | |||
79 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files | ||
80 | private static UInt64 scriptCompileCounter = 0; // And a counter | ||
81 | |||
82 | public IScriptEngine m_scriptEngine; | ||
83 | public Compiler(IScriptEngine scriptEngine) | ||
84 | { | ||
85 | m_scriptEngine = scriptEngine; | ||
86 | ReadConfig(); | ||
87 | } | ||
88 | public bool in_startup = true; | ||
89 | public void ReadConfig() | ||
90 | { | ||
91 | |||
92 | // Get some config | ||
93 | WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true); | ||
94 | CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true); | ||
95 | |||
96 | // Get file prefix from scriptengine name and make it file system safe: | ||
97 | FilePrefix = "CommonCompiler"; | ||
98 | foreach (char c in Path.GetInvalidFileNameChars()) | ||
99 | { | ||
100 | FilePrefix = FilePrefix.Replace(c, '_'); | ||
101 | } | ||
102 | |||
103 | // First time we start? Delete old files | ||
104 | if (in_startup) | ||
105 | { | ||
106 | in_startup = false; | ||
107 | DeleteOldFiles(); | ||
108 | } | ||
109 | |||
110 | // Map name and enum type of our supported languages | ||
111 | LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs); | ||
112 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); | ||
113 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); | ||
114 | LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); | ||
115 | |||
116 | // Allowed compilers | ||
117 | string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js"); | ||
118 | AllowedCompilers.Clear(); | ||
119 | |||
120 | #if DEBUG | ||
121 | m_scriptEngine.Log.Debug("[Compiler]: Allowed languages: " + allowComp); | ||
122 | #endif | ||
123 | |||
124 | |||
125 | foreach (string strl in allowComp.Split(',')) | ||
126 | { | ||
127 | string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); | ||
128 | if (!LanguageMapping.ContainsKey(strlan)) | ||
129 | { | ||
130 | m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | #if DEBUG | ||
135 | //m_scriptEngine.Log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); | ||
136 | #endif | ||
137 | } | ||
138 | AllowedCompilers.Add(strlan, true); | ||
139 | } | ||
140 | if (AllowedCompilers.Count == 0) | ||
141 | m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!"); | ||
142 | |||
143 | // Default language | ||
144 | string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower(); | ||
145 | |||
146 | // Is this language recognized at all? | ||
147 | if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) | ||
148 | { | ||
149 | m_scriptEngine.Log.Error("[Compiler]: " + | ||
150 | "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\"."); | ||
151 | defaultCompileLanguage = "lsl"; | ||
152 | } | ||
153 | |||
154 | // Is this language in allow-list? | ||
155 | if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) | ||
156 | { | ||
157 | m_scriptEngine.Log.Error("[Compiler]: " + | ||
158 | "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!"); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | #if DEBUG | ||
163 | // m_scriptEngine.Log.Debug("[Compiler]: " + | ||
164 | // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); | ||
165 | #endif | ||
166 | // LANGUAGE IS IN ALLOW-LIST | ||
167 | DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; | ||
168 | } | ||
169 | |||
170 | // We now have an allow-list, a mapping list, and a default language | ||
171 | |||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Delete old script files | ||
176 | /// </summary> | ||
177 | private void DeleteOldFiles() | ||
178 | { | ||
179 | |||
180 | // CREATE FOLDER IF IT DOESNT EXIST | ||
181 | if (!Directory.Exists(ScriptEnginesPath)) | ||
182 | { | ||
183 | try | ||
184 | { | ||
185 | Directory.CreateDirectory(ScriptEnginesPath); | ||
186 | } | ||
187 | catch (Exception ex) | ||
188 | { | ||
189 | m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString()); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | if (!Directory.Exists(Path.Combine(ScriptEnginesPath, | ||
194 | m_scriptEngine.World.RegionInfo.RegionID.ToString()))) | ||
195 | { | ||
196 | try | ||
197 | { | ||
198 | Directory.CreateDirectory(Path.Combine(ScriptEnginesPath, | ||
199 | m_scriptEngine.World.RegionInfo.RegionID.ToString())); | ||
200 | } | ||
201 | catch (Exception ex) | ||
202 | { | ||
203 | m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, | ||
204 | m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, | ||
209 | m_scriptEngine.World.RegionInfo.RegionID.ToString()))) | ||
210 | { | ||
211 | //m_scriptEngine.Log.Error("[Compiler]: FILE FOUND: " + file); | ||
212 | |||
213 | if (file.ToLower().StartsWith(FilePrefix + "_compiled_") || | ||
214 | file.ToLower().StartsWith(FilePrefix + "_source_")) | ||
215 | { | ||
216 | try | ||
217 | { | ||
218 | File.Delete(file); | ||
219 | } | ||
220 | catch (Exception ex) | ||
221 | { | ||
222 | m_scriptEngine.Log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString()); | ||
223 | } | ||
224 | |||
225 | } | ||
226 | } | ||
227 | |||
228 | } | ||
229 | |||
230 | ////private ICodeCompiler icc = codeProvider.CreateCompiler(); | ||
231 | //public string CompileFromFile(string LSOFileName) | ||
232 | //{ | ||
233 | // switch (Path.GetExtension(LSOFileName).ToLower()) | ||
234 | // { | ||
235 | // case ".txt": | ||
236 | // case ".lsl": | ||
237 | // Common.ScriptEngineBase.Shared.SendToDebug("Source code is LSL, converting to CS"); | ||
238 | // return CompileFromLSLText(File.ReadAllText(LSOFileName)); | ||
239 | // case ".cs": | ||
240 | // Common.ScriptEngineBase.Shared.SendToDebug("Source code is CS"); | ||
241 | // return CompileFromCSText(File.ReadAllText(LSOFileName)); | ||
242 | // default: | ||
243 | // throw new Exception("Unknown script type."); | ||
244 | // } | ||
245 | //} | ||
246 | |||
247 | /// <summary> | ||
248 | /// Converts script from LSL to CS and calls CompileFromCSText | ||
249 | /// </summary> | ||
250 | /// <param name="Script">LSL script</param> | ||
251 | /// <returns>Filename to .dll assembly</returns> | ||
252 | public string PerformScriptCompile(string Script, string asset) | ||
253 | { | ||
254 | string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( | ||
255 | m_scriptEngine.World.RegionInfo.RegionID.ToString(), | ||
256 | FilePrefix + "_compiled_" + asset + ".dll")); | ||
257 | // string OutFile = Path.Combine(ScriptEnginesPath, | ||
258 | // FilePrefix + "_compiled_" + asset + ".dll"); | ||
259 | |||
260 | if (File.Exists(OutFile)) | ||
261 | { | ||
262 | m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset); | ||
263 | return OutFile; | ||
264 | } | ||
265 | |||
266 | if (!Directory.Exists(ScriptEnginesPath)) | ||
267 | { | ||
268 | try | ||
269 | { | ||
270 | Directory.CreateDirectory(ScriptEnginesPath); | ||
271 | } | ||
272 | catch (Exception ex) | ||
273 | { | ||
274 | } | ||
275 | } | ||
276 | |||
277 | if (!Directory.Exists(Path.Combine(ScriptEnginesPath, | ||
278 | m_scriptEngine.World.RegionInfo.RegionID.ToString()))) | ||
279 | { | ||
280 | try | ||
281 | { | ||
282 | Directory.CreateDirectory(ScriptEnginesPath); | ||
283 | } | ||
284 | catch (Exception ex) | ||
285 | { | ||
286 | } | ||
287 | } | ||
288 | |||
289 | enumCompileType l = DefaultCompileLanguage; | ||
290 | |||
291 | if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) | ||
292 | l = enumCompileType.cs; | ||
293 | if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) | ||
294 | { | ||
295 | l = enumCompileType.vb; | ||
296 | // We need to remove //vb, it won't compile with that | ||
297 | |||
298 | Script = Script.Substring(4, Script.Length - 4); | ||
299 | } | ||
300 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) | ||
301 | l = enumCompileType.lsl; | ||
302 | |||
303 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | ||
304 | l = enumCompileType.js; | ||
305 | |||
306 | if (!AllowedCompilers.ContainsKey(l.ToString())) | ||
307 | { | ||
308 | // Not allowed to compile to this language! | ||
309 | string errtext = String.Empty; | ||
310 | errtext += "The compiler for language \"" + l.ToString() + "\" is not in list of allowed compilers. Script will not be executed!"; | ||
311 | throw new Exception(errtext); | ||
312 | } | ||
313 | |||
314 | string compileScript = Script; | ||
315 | |||
316 | if (l == enumCompileType.lsl) | ||
317 | { | ||
318 | // Its LSL, convert it to C# | ||
319 | compileScript = LSL_Converter.Convert(Script); | ||
320 | l = enumCompileType.cs; | ||
321 | } | ||
322 | |||
323 | // Insert additional assemblies here | ||
324 | |||
325 | //ADAM: Disabled for the moment until it's working right. | ||
326 | bool enableCommanderLSL = false; | ||
327 | |||
328 | if (enableCommanderLSL == true && l == enumCompileType.cs) | ||
329 | { | ||
330 | foreach (KeyValuePair<string, | ||
331 | ICommander> com | ||
332 | in m_scriptEngine.World.GetCommanders()) | ||
333 | { | ||
334 | compileScript = com.Value.GenerateRuntimeAPI() + compileScript; | ||
335 | } | ||
336 | } | ||
337 | |||
338 | // End of insert | ||
339 | |||
340 | switch (l) | ||
341 | { | ||
342 | case enumCompileType.cs: | ||
343 | compileScript = CreateCSCompilerScript(compileScript); | ||
344 | break; | ||
345 | case enumCompileType.vb: | ||
346 | compileScript = CreateVBCompilerScript(compileScript); | ||
347 | break; | ||
348 | case enumCompileType.js: | ||
349 | compileScript = CreateJSCompilerScript(compileScript); | ||
350 | break; | ||
351 | } | ||
352 | |||
353 | // m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); | ||
354 | // m_log.Debug(""); | ||
355 | // m_log.Debug(compileScript); | ||
356 | |||
357 | return CompileFromDotNetText(compileScript, l, asset); | ||
358 | } | ||
359 | |||
360 | private static string CreateJSCompilerScript(string compileScript) | ||
361 | { | ||
362 | compileScript = String.Empty + | ||
363 | "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" + | ||
364 | "package SecondLife {\r\n" + | ||
365 | "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + | ||
366 | compileScript + | ||
367 | "} }\r\n"; | ||
368 | return compileScript; | ||
369 | } | ||
370 | |||
371 | private static string CreateCSCompilerScript(string compileScript) | ||
372 | { | ||
373 | compileScript = String.Empty + | ||
374 | "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" + | ||
375 | String.Empty + "namespace SecondLife { " + | ||
376 | String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + | ||
377 | @"public Script() { } " + | ||
378 | compileScript + | ||
379 | "} }\r\n"; | ||
380 | return compileScript; | ||
381 | } | ||
382 | |||
383 | private static string CreateVBCompilerScript(string compileScript) | ||
384 | { | ||
385 | compileScript = String.Empty + | ||
386 | "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + | ||
387 | String.Empty + "NameSpace SecondLife:" + | ||
388 | String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " + | ||
389 | "\r\nPublic Sub New()\r\nEnd Sub: " + | ||
390 | compileScript + | ||
391 | ":End Class :End Namespace\r\n"; | ||
392 | return compileScript; | ||
393 | } | ||
394 | |||
395 | /// <summary> | ||
396 | /// Compile .NET script to .Net assembly (.dll) | ||
397 | /// </summary> | ||
398 | /// <param name="Script">CS script</param> | ||
399 | /// <returns>Filename to .dll assembly</returns> | ||
400 | internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset) | ||
401 | { | ||
402 | string ext = "." + lang.ToString(); | ||
403 | |||
404 | // Output assembly name | ||
405 | scriptCompileCounter++; | ||
406 | string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( | ||
407 | m_scriptEngine.World.RegionInfo.RegionID.ToString(), | ||
408 | FilePrefix + "_compiled_" + asset + ".dll")); | ||
409 | #if DEBUG | ||
410 | // m_scriptEngine.Log.Debug("[Compiler]: Starting compile of \"" + OutFile + "\"."); | ||
411 | #endif | ||
412 | try | ||
413 | { | ||
414 | File.Delete(OutFile); | ||
415 | } | ||
416 | catch (Exception e) // NOTLEGIT - Should be just catching FileIOException | ||
417 | { | ||
418 | //m_scriptEngine.Log.Error("[Compiler]: 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()); | ||
420 | } | ||
421 | //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll"); | ||
422 | |||
423 | // DEBUG - write source to disk | ||
424 | if (WriteScriptSourceToDebugFile) | ||
425 | { | ||
426 | string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext; | ||
427 | try | ||
428 | { | ||
429 | File.WriteAllText(Path.Combine(Path.Combine( | ||
430 | ScriptEnginesPath, | ||
431 | m_scriptEngine.World.RegionInfo.RegionID.ToString()), | ||
432 | srcFileName), Script); | ||
433 | } | ||
434 | catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException | ||
435 | { | ||
436 | m_scriptEngine.Log.Error("[Compiler]: Exception while trying to write script source to file \"" + srcFileName + "\": " + ex.ToString()); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | // Do actual compile | ||
441 | CompilerParameters parameters = new CompilerParameters(); | ||
442 | |||
443 | parameters.IncludeDebugInformation = true; | ||
444 | |||
445 | // Add all available assemblies | ||
446 | // foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) | ||
447 | // { | ||
448 | // Console.WriteLine("Adding assembly: " + asm.Location); | ||
449 | // parameters.ReferencedAssemblies.Add(asm.Location); | ||
450 | // } | ||
451 | |||
452 | string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); | ||
453 | string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location); | ||
454 | //Console.WriteLine("Assembly location: " + rootPath); | ||
455 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); | ||
456 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); | ||
457 | |||
458 | parameters.GenerateExecutable = false; | ||
459 | parameters.OutputAssembly = OutFile; | ||
460 | parameters.IncludeDebugInformation = CompileWithDebugInformation; | ||
461 | //parameters.WarningLevel = 1; // Should be 4? | ||
462 | parameters.TreatWarningsAsErrors = false; | ||
463 | |||
464 | //Console.WriteLine(Script); | ||
465 | CompilerResults results; | ||
466 | switch (lang) | ||
467 | { | ||
468 | case enumCompileType.vb: | ||
469 | results = VBcodeProvider.CompileAssemblyFromSource(parameters, Script); | ||
470 | break; | ||
471 | case enumCompileType.cs: | ||
472 | results = CScodeProvider.CompileAssemblyFromSource(parameters, Script); | ||
473 | break; | ||
474 | case enumCompileType.js: | ||
475 | results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); | ||
476 | break; | ||
477 | default: | ||
478 | throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); | ||
479 | } | ||
480 | |||
481 | // Check result | ||
482 | // Go through errors | ||
483 | |||
484 | // | ||
485 | // WARNINGS AND ERRORS | ||
486 | // | ||
487 | if (results.Errors.Count > 0) | ||
488 | { | ||
489 | string errtext = String.Empty; | ||
490 | foreach (CompilerError CompErr in results.Errors) | ||
491 | { | ||
492 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + | ||
493 | ", Error Number: " + CompErr.ErrorNumber + | ||
494 | ", '" + CompErr.ErrorText + "'\r\n"; | ||
495 | } | ||
496 | if (!File.Exists(OutFile)) | ||
497 | { | ||
498 | throw new Exception(errtext); | ||
499 | } | ||
500 | } | ||
501 | |||
502 | // | ||
503 | // NO ERRORS, BUT NO COMPILED FILE | ||
504 | // | ||
505 | if (!File.Exists(OutFile)) | ||
506 | { | ||
507 | string errtext = String.Empty; | ||
508 | errtext += "No compile error. But not able to locate compiled file."; | ||
509 | throw new Exception(errtext); | ||
510 | } | ||
511 | m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly for {0}", asset); | ||
512 | return OutFile; | ||
513 | } | ||
514 | } | ||
515 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs new file mode 100644 index 0000000..380686e --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSConverter.cs | |||
@@ -0,0 +1,374 @@ | |||
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 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text.RegularExpressions; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | ||
34 | { | ||
35 | public class LSL2CSConverter | ||
36 | { | ||
37 | // Uses regex to convert LSL code to C# code. | ||
38 | |||
39 | //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); | ||
40 | private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); | ||
41 | private Dictionary<string, string> quotes = new Dictionary<string, string>(); | ||
42 | // c Style | ||
43 | private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline); | ||
44 | // c# one liners | ||
45 | private Regex nonCommentFwsl = new Regex("\"[a-zA-Z0-9.,:/\\n ]+//[^\"+]+([\\\\\\\"+]+)?(\\s+)?[\"+](\\s+)?(;)?", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
46 | private Regex conelinecomments = new Regex(@"[^:].?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline); | ||
47 | // ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"]) | ||
48 | |||
49 | // value we're looking for: (?:[a-zA-Z])\.[a-zA-Z] | ||
50 | public LSL2CSConverter() | ||
51 | { | ||
52 | // Only the types we need to convert | ||
53 | dataTypes.Add("void", "void"); | ||
54 | dataTypes.Add("integer", "LSL_Types.LSLInteger"); | ||
55 | dataTypes.Add("float", "LSL_Types.LSLFloat"); | ||
56 | dataTypes.Add("string", "LSL_Types.LSLString"); | ||
57 | dataTypes.Add("key", "LSL_Types.LSLString"); | ||
58 | dataTypes.Add("vector", "LSL_Types.Vector3"); | ||
59 | dataTypes.Add("rotation", "LSL_Types.Quaternion"); | ||
60 | dataTypes.Add("list", "LSL_Types.list"); | ||
61 | dataTypes.Add("null", "null"); | ||
62 | } | ||
63 | |||
64 | public string Convert(string Script) | ||
65 | { | ||
66 | quotes.Clear(); | ||
67 | string Return = String.Empty; | ||
68 | Script = " \r\n" + Script; | ||
69 | |||
70 | // | ||
71 | // Prepare script for processing | ||
72 | // | ||
73 | |||
74 | // Clean up linebreaks | ||
75 | Script = Regex.Replace(Script, @"\r\n", "\n"); | ||
76 | Script = Regex.Replace(Script, @"\n", "\r\n"); | ||
77 | |||
78 | // QUOTE REPLACEMENT | ||
79 | // temporarily replace quotes so we can work our magic on the script without | ||
80 | // always considering if we are inside our outside quotes's | ||
81 | // TODO: Does this work on half-quotes in strings? ;) | ||
82 | string _Script = String.Empty; | ||
83 | string C; | ||
84 | bool in_quote = false; | ||
85 | bool quote_replaced = false; | ||
86 | string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_"; | ||
87 | string quote = String.Empty; | ||
88 | bool last_was_escape = false; | ||
89 | int quote_replaced_count = 0; | ||
90 | |||
91 | string removefwnoncomments = nonCommentFwsl.Replace(Script, "\"\";"); | ||
92 | |||
93 | string removecomments = conelinecomments.Replace(removefwnoncomments, ""); | ||
94 | removecomments = cstylecomments.Replace(removecomments, ""); | ||
95 | string[] localscript = removecomments.Split('"'); | ||
96 | string checkscript = String.Empty; | ||
97 | bool flip = true; | ||
98 | |||
99 | for (int p = 0; p < localscript.Length; p++) | ||
100 | { | ||
101 | //if (localscript[p].Length >= 1) | ||
102 | //{ | ||
103 | if (!localscript[p].EndsWith(@"\")) | ||
104 | { | ||
105 | flip = !flip; | ||
106 | //System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p] + " ! " + localscript[p].EndsWith(@"\").ToString()); | ||
107 | } | ||
108 | //} | ||
109 | //else | ||
110 | //{ | ||
111 | // flip = !flip; | ||
112 | // System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p]); | ||
113 | //} | ||
114 | if (!flip) | ||
115 | checkscript += localscript[p]; | ||
116 | } | ||
117 | |||
118 | //System.Console.WriteLine("SCRIPT:" + checkscript); | ||
119 | |||
120 | // checks for alpha.alpha way of referring to objects in C# | ||
121 | // ignores alpha.x alpha.y, alpha.z for refering to vector components | ||
122 | Match SecurityM; | ||
123 | |||
124 | // BROKEN: this check is very wrong. It block's any url in strings. | ||
125 | SecurityM = Regex.Match(checkscript, @"(?:[a-zA-Z])\.(?:[a-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
126 | |||
127 | if (SecurityM.Success) | ||
128 | throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'. Detected around: " + SecurityM.Captures[0].Value); | ||
129 | |||
130 | SecurityM = Regex.Match(checkscript, @"typeof\s", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
131 | if (SecurityM.Success) | ||
132 | throw new Exception("CS0103: 'The object.typeof method isn't allowed in LSL'"); | ||
133 | |||
134 | SecurityM = Regex.Match(checkscript, @"GetType\(", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
135 | if (SecurityM.Success) | ||
136 | throw new Exception("CS0103: 'The object.GetType method isn't allowed in LSL'"); | ||
137 | |||
138 | for (int p = 0; p < Script.Length; p++) | ||
139 | { | ||
140 | C = Script.Substring(p, 1); | ||
141 | while (true) | ||
142 | { | ||
143 | // found " and last was not \ so this is not an escaped \" | ||
144 | if (C == "\"" && last_was_escape == false) | ||
145 | { | ||
146 | // Toggle inside/outside quote | ||
147 | in_quote = !in_quote; | ||
148 | if (in_quote) | ||
149 | { | ||
150 | quote_replaced_count++; | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | if (quote == String.Empty) | ||
155 | { | ||
156 | // We didn't replace quote, probably because of empty string? | ||
157 | _Script += quote_replacement_string + | ||
158 | quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); | ||
159 | } | ||
160 | // We just left a quote | ||
161 | quotes.Add( | ||
162 | quote_replacement_string + | ||
163 | quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); | ||
164 | quote = String.Empty; | ||
165 | } | ||
166 | break; | ||
167 | } | ||
168 | |||
169 | if (!in_quote) | ||
170 | { | ||
171 | // We are not inside a quote | ||
172 | quote_replaced = false; | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | // We are inside a quote | ||
177 | if (!quote_replaced) | ||
178 | { | ||
179 | // Replace quote | ||
180 | _Script += quote_replacement_string + | ||
181 | quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); | ||
182 | quote_replaced = true; | ||
183 | } | ||
184 | quote += C; | ||
185 | break; | ||
186 | } | ||
187 | _Script += C; | ||
188 | break; | ||
189 | } | ||
190 | last_was_escape = false; | ||
191 | if (C == @"\") | ||
192 | { | ||
193 | last_was_escape = true; | ||
194 | } | ||
195 | } | ||
196 | Script = _Script; | ||
197 | // | ||
198 | // END OF QUOTE REPLACEMENT | ||
199 | // | ||
200 | |||
201 | // | ||
202 | // PROCESS STATES | ||
203 | // Remove state definitions and add state names to start of each event within state | ||
204 | // | ||
205 | int ilevel = 0; | ||
206 | int lastlevel = 0; | ||
207 | string ret = String.Empty; | ||
208 | string cache = String.Empty; | ||
209 | bool in_state = false; | ||
210 | string current_statename = String.Empty; | ||
211 | for (int p = 0; p < Script.Length; p++) | ||
212 | { | ||
213 | C = Script.Substring(p, 1); | ||
214 | while (true) | ||
215 | { | ||
216 | // inc / dec level | ||
217 | if (C == @"{") | ||
218 | ilevel++; | ||
219 | if (C == @"}") | ||
220 | ilevel--; | ||
221 | if (ilevel < 0) | ||
222 | ilevel = 0; | ||
223 | cache += C; | ||
224 | |||
225 | // if level == 0, add to return | ||
226 | if (ilevel == 1 && lastlevel == 0) | ||
227 | { | ||
228 | // 0 => 1: Get last | ||
229 | Match m = | ||
230 | //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", | ||
231 | Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{", | ||
232 | |||
233 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
234 | |||
235 | in_state = false; | ||
236 | if (m.Success) | ||
237 | { | ||
238 | // Go back to level 0, this is not a state | ||
239 | in_state = true; | ||
240 | current_statename = m.Groups["statename"].Captures[0].Value; | ||
241 | //Console.WriteLine("Current statename: " + current_statename); | ||
242 | cache = | ||
243 | //@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){", | ||
244 | Regex.Replace(cache, | ||
245 | @"(?<s1>(?![a-zA-Z_]+)\s*)" + @"(state\s+)?([a-zA-Z_][a-zA-Z_0-9]*)(?<s2>[^a-zA-Z_0-9\(\)]*){", | ||
246 | "${s1}${s2}", | ||
247 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); | ||
248 | } | ||
249 | ret += cache; | ||
250 | cache = String.Empty; | ||
251 | } | ||
252 | if (ilevel == 0 && lastlevel == 1) | ||
253 | { | ||
254 | // 1 => 0: Remove last } | ||
255 | if (in_state == true) | ||
256 | { | ||
257 | cache = cache.Remove(cache.Length - 1, 1); | ||
258 | //cache = Regex.Replace(cache, "}$", String.Empty, RegexOptions.Multiline | RegexOptions.Singleline); | ||
259 | |||
260 | //Replace function names | ||
261 | // void dataserver(key query_id, string data) { | ||
262 | //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
263 | //Console.WriteLine("Replacing using statename: " + current_statename); | ||
264 | cache = | ||
265 | Regex.Replace(cache, | ||
266 | @"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", | ||
267 | @"$1public " + current_statename + "_event_$2", | ||
268 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); | ||
269 | } | ||
270 | |||
271 | ret += cache; | ||
272 | cache = String.Empty; | ||
273 | in_state = true; | ||
274 | current_statename = String.Empty; | ||
275 | } | ||
276 | |||
277 | break; | ||
278 | } | ||
279 | lastlevel = ilevel; | ||
280 | } | ||
281 | ret += cache; | ||
282 | cache = String.Empty; | ||
283 | |||
284 | Script = ret; | ||
285 | ret = String.Empty; | ||
286 | |||
287 | foreach (string key in dataTypes.Keys) | ||
288 | { | ||
289 | string val; | ||
290 | dataTypes.TryGetValue(key, out val); | ||
291 | |||
292 | // Replace CAST - (integer) with (int) | ||
293 | Script = | ||
294 | Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", | ||
295 | RegexOptions.Compiled | RegexOptions.Multiline); | ||
296 | // Replace return types and function variables - integer a() and f(integer a, integer a) | ||
297 | Script = | ||
298 | Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s+)", @"$1$2" + val + "$3", | ||
299 | RegexOptions.Compiled | RegexOptions.Multiline); | ||
300 | Script = | ||
301 | Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)[,]", @"$1$2" + val + "$3,", | ||
302 | RegexOptions.Compiled | RegexOptions.Multiline); | ||
303 | } | ||
304 | |||
305 | // Change jumps into goto's and prefix its label | ||
306 | Script = | ||
307 | Regex.Replace(Script, | ||
308 | @"(\W)jump\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*;", | ||
309 | @"$1goto label_$2;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
310 | // and prefix labels so the do not clash with C#'s reserved words | ||
311 | Script = | ||
312 | Regex.Replace(Script, | ||
313 | @"@([a-zA-Z_][a-zA-Z_0-9]*)\s*;", | ||
314 | @"label_$1: ;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
315 | |||
316 | // Add "void" in front of functions that needs it | ||
317 | Script = | ||
318 | Regex.Replace(Script, | ||
319 | @"^(\s*public\s+)?((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", | ||
320 | @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
321 | |||
322 | // Replace <x,y,z> and <x,y,z,r> | ||
323 | Script = | ||
324 | Regex.Replace(Script, @"<([^,>;]*,[^,>;]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Quaternion($1)", | ||
325 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
326 | Script = | ||
327 | Regex.Replace(Script, @"<([^,>;)]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Vector3($1)", | ||
328 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
329 | |||
330 | // Replace List []'s | ||
331 | Script = | ||
332 | Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)", | ||
333 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
334 | |||
335 | // Replace (string) to .ToString() // | ||
336 | Script = | ||
337 | Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()", | ||
338 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
339 | Script = | ||
340 | Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", | ||
341 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
342 | |||
343 | // Replace "state STATENAME" with "state("statename")" | ||
344 | Script = | ||
345 | Regex.Replace(Script, @"(state)\s+([^;\n\r]+)(;[\r\n\s])", "$1(\"$2\")$3", | ||
346 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); | ||
347 | |||
348 | // REPLACE BACK QUOTES | ||
349 | foreach (string key in quotes.Keys) | ||
350 | { | ||
351 | string val; | ||
352 | quotes.TryGetValue(key, out val); | ||
353 | Script = Script.Replace(key, "\"" + val + "\""); | ||
354 | } | ||
355 | |||
356 | //System.Console.WriteLine(Script); | ||
357 | Return = String.Empty;// + | ||
358 | //"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;"; | ||
359 | |||
360 | //Return += String.Empty + | ||
361 | // "namespace SecondLife { "; | ||
362 | //Return += String.Empty + | ||
363 | // //"[Serializable] " + | ||
364 | // "public class Script : OpenSim.Region.ScriptEngine.Shared.LSL_BaseClass { "; | ||
365 | //Return += @"public Script() { } "; | ||
366 | Return += Script; | ||
367 | //Return += "} }\r\n"; | ||
368 | |||
369 | quotes.Clear(); | ||
370 | |||
371 | return Return; | ||
372 | } | ||
373 | } | ||
374 | } | ||
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 | |||
29 | using System; | ||
30 | using System.IO; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using OpenSim.Region.ScriptEngine.Shared.YieldProlog; | ||
35 | |||
36 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.IO; | ||
3 | using System.Threading; | ||
4 | using System.Collections; | ||
5 | using System.Collections.Generic; | ||
6 | using libsecondlife; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Environment; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | |||
11 | namespace 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/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs new file mode 100644 index 0000000..6b080a0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -0,0 +1,1519 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Text.RegularExpressions; | ||
31 | |||
32 | namespace OpenSim.Region.ScriptEngine.Shared | ||
33 | { | ||
34 | [Serializable] | ||
35 | public partial class LSL_Types | ||
36 | { | ||
37 | // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain | ||
38 | |||
39 | [Serializable] | ||
40 | public struct Vector3 | ||
41 | { | ||
42 | public double x; | ||
43 | public double y; | ||
44 | public double z; | ||
45 | |||
46 | #region Constructors | ||
47 | |||
48 | public Vector3(Vector3 vector) | ||
49 | { | ||
50 | x = (float)vector.x; | ||
51 | y = (float)vector.y; | ||
52 | z = (float)vector.z; | ||
53 | } | ||
54 | |||
55 | public Vector3(double X, double Y, double Z) | ||
56 | { | ||
57 | x = X; | ||
58 | y = Y; | ||
59 | z = Z; | ||
60 | } | ||
61 | |||
62 | public Vector3(string str) | ||
63 | { | ||
64 | str = str.Replace('<', ' '); | ||
65 | str = str.Replace('>', ' '); | ||
66 | string[] tmps = str.Split(new Char[] { ',', '<', '>' }); | ||
67 | if (tmps.Length < 3) | ||
68 | { | ||
69 | x=y=z=0; | ||
70 | return; | ||
71 | } | ||
72 | bool res; | ||
73 | res = Double.TryParse(tmps[0], out x); | ||
74 | res = res & Double.TryParse(tmps[1], out y); | ||
75 | res = res & Double.TryParse(tmps[2], out z); | ||
76 | } | ||
77 | |||
78 | #endregion | ||
79 | |||
80 | #region Overriders | ||
81 | |||
82 | public override string ToString() | ||
83 | { | ||
84 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | ||
85 | return s; | ||
86 | } | ||
87 | |||
88 | public static explicit operator LSLString(Vector3 vec) | ||
89 | { | ||
90 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | ||
91 | return new LSLString(s); | ||
92 | } | ||
93 | |||
94 | public static explicit operator string(Vector3 vec) | ||
95 | { | ||
96 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | ||
97 | return s; | ||
98 | } | ||
99 | |||
100 | public static explicit operator Vector3(string s) | ||
101 | { | ||
102 | return new Vector3(s); | ||
103 | } | ||
104 | |||
105 | public static bool operator ==(Vector3 lhs, Vector3 rhs) | ||
106 | { | ||
107 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); | ||
108 | } | ||
109 | |||
110 | public static bool operator !=(Vector3 lhs, Vector3 rhs) | ||
111 | { | ||
112 | return !(lhs == rhs); | ||
113 | } | ||
114 | |||
115 | public override int GetHashCode() | ||
116 | { | ||
117 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode()); | ||
118 | } | ||
119 | |||
120 | public override bool Equals(object o) | ||
121 | { | ||
122 | if (!(o is Vector3)) return false; | ||
123 | |||
124 | Vector3 vector = (Vector3)o; | ||
125 | |||
126 | return (x == vector.x && x == vector.x && z == vector.z); | ||
127 | } | ||
128 | |||
129 | #endregion | ||
130 | |||
131 | #region Vector & Vector Math | ||
132 | |||
133 | // Vector-Vector Math | ||
134 | public static Vector3 operator +(Vector3 lhs, Vector3 rhs) | ||
135 | { | ||
136 | return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); | ||
137 | } | ||
138 | |||
139 | public static Vector3 operator -(Vector3 lhs, Vector3 rhs) | ||
140 | { | ||
141 | return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); | ||
142 | } | ||
143 | |||
144 | public static Vector3 operator *(Vector3 lhs, Vector3 rhs) | ||
145 | { | ||
146 | return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); | ||
147 | } | ||
148 | |||
149 | public static Vector3 operator %(Vector3 v1, Vector3 v2) | ||
150 | { | ||
151 | //Cross product | ||
152 | Vector3 tv; | ||
153 | tv.x = (v1.y * v2.z) - (v1.z * v2.y); | ||
154 | tv.y = (v1.z * v2.x) - (v1.x * v2.z); | ||
155 | tv.z = (v1.x * v2.y) - (v1.y * v2.x); | ||
156 | return tv; | ||
157 | } | ||
158 | |||
159 | #endregion | ||
160 | |||
161 | #region Vector & Float Math | ||
162 | |||
163 | // Vector-Float and Float-Vector Math | ||
164 | public static Vector3 operator *(Vector3 vec, float val) | ||
165 | { | ||
166 | return new Vector3(vec.x * val, vec.y * val, vec.z * val); | ||
167 | } | ||
168 | |||
169 | public static Vector3 operator *(float val, Vector3 vec) | ||
170 | { | ||
171 | return new Vector3(vec.x * val, vec.y * val, vec.z * val); | ||
172 | } | ||
173 | |||
174 | public static Vector3 operator /(Vector3 v, float f) | ||
175 | { | ||
176 | v.x = v.x / f; | ||
177 | v.y = v.y / f; | ||
178 | v.z = v.z / f; | ||
179 | return v; | ||
180 | } | ||
181 | |||
182 | #endregion | ||
183 | |||
184 | #region Vector & Double Math | ||
185 | |||
186 | public static Vector3 operator *(Vector3 vec, double val) | ||
187 | { | ||
188 | return new Vector3(vec.x * val, vec.y * val, vec.z * val); | ||
189 | } | ||
190 | |||
191 | public static Vector3 operator *(double val, Vector3 vec) | ||
192 | { | ||
193 | return new Vector3(vec.x * val, vec.y * val, vec.z * val); | ||
194 | } | ||
195 | |||
196 | public static Vector3 operator /(Vector3 v, double f) | ||
197 | { | ||
198 | v.x = v.x / f; | ||
199 | v.y = v.y / f; | ||
200 | v.z = v.z / f; | ||
201 | return v; | ||
202 | } | ||
203 | |||
204 | #endregion | ||
205 | |||
206 | #region Vector & Rotation Math | ||
207 | |||
208 | // Vector-Rotation Math | ||
209 | public static Vector3 operator *(Vector3 v, Quaternion r) | ||
210 | { | ||
211 | Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); | ||
212 | Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); | ||
213 | |||
214 | // adapted for operator * computing "b * a" | ||
215 | Quaternion result = nq * (vq * r); | ||
216 | |||
217 | return new Vector3(result.x, result.y, result.z); | ||
218 | } | ||
219 | |||
220 | public static Vector3 operator /(Vector3 v, Quaternion r) | ||
221 | { | ||
222 | r.s = -r.s; | ||
223 | return v * r; | ||
224 | } | ||
225 | |||
226 | #endregion | ||
227 | |||
228 | #region Static Helper Functions | ||
229 | |||
230 | public static double Dot(Vector3 v1, Vector3 v2) | ||
231 | { | ||
232 | return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); | ||
233 | } | ||
234 | |||
235 | public static Vector3 Cross(Vector3 v1, Vector3 v2) | ||
236 | { | ||
237 | return new Vector3 | ||
238 | ( | ||
239 | v1.y * v2.z - v1.z * v2.y, | ||
240 | v1.z * v2.x - v1.x * v2.z, | ||
241 | v1.x * v2.y - v1.y * v2.x | ||
242 | ); | ||
243 | } | ||
244 | |||
245 | public static double Mag(Vector3 v) | ||
246 | { | ||
247 | return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); | ||
248 | } | ||
249 | |||
250 | public static Vector3 Norm(Vector3 vector) | ||
251 | { | ||
252 | double mag = Mag(vector); | ||
253 | return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); | ||
254 | } | ||
255 | |||
256 | #endregion | ||
257 | } | ||
258 | |||
259 | [Serializable] | ||
260 | public struct Quaternion | ||
261 | { | ||
262 | public double x; | ||
263 | public double y; | ||
264 | public double z; | ||
265 | public double s; | ||
266 | |||
267 | #region Constructors | ||
268 | |||
269 | public Quaternion(Quaternion Quat) | ||
270 | { | ||
271 | x = (float)Quat.x; | ||
272 | y = (float)Quat.y; | ||
273 | z = (float)Quat.z; | ||
274 | s = (float)Quat.s; | ||
275 | if (x == 0 && y == 0 && z == 0 && s == 0) | ||
276 | s = 1; | ||
277 | } | ||
278 | |||
279 | public Quaternion(double X, double Y, double Z, double S) | ||
280 | { | ||
281 | x = X; | ||
282 | y = Y; | ||
283 | z = Z; | ||
284 | s = S; | ||
285 | if (x == 0 && y == 0 && z == 0 && s == 0) | ||
286 | s = 1; | ||
287 | } | ||
288 | |||
289 | public Quaternion(string str) | ||
290 | { | ||
291 | str = str.Replace('<', ' '); | ||
292 | str = str.Replace('>', ' '); | ||
293 | string[] tmps = str.Split(new Char[] { ',', '<', '>' }); | ||
294 | if (tmps.Length < 4) | ||
295 | { | ||
296 | x=y=z=s=0; | ||
297 | return; | ||
298 | } | ||
299 | bool res; | ||
300 | res = Double.TryParse(tmps[0], out x); | ||
301 | res = res & Double.TryParse(tmps[1], out y); | ||
302 | res = res & Double.TryParse(tmps[2], out z); | ||
303 | res = res & Double.TryParse(tmps[3], out s); | ||
304 | if (x == 0 && y == 0 && z == 0 && s == 0) | ||
305 | s = 1; | ||
306 | } | ||
307 | |||
308 | #endregion | ||
309 | |||
310 | #region Overriders | ||
311 | |||
312 | public override int GetHashCode() | ||
313 | { | ||
314 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode()); | ||
315 | } | ||
316 | |||
317 | public override bool Equals(object o) | ||
318 | { | ||
319 | if (!(o is Quaternion)) return false; | ||
320 | |||
321 | Quaternion quaternion = (Quaternion)o; | ||
322 | |||
323 | return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; | ||
324 | } | ||
325 | |||
326 | public override string ToString() | ||
327 | { | ||
328 | string st=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | ||
329 | return st; | ||
330 | } | ||
331 | |||
332 | public static explicit operator string(Quaternion r) | ||
333 | { | ||
334 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | ||
335 | return s; | ||
336 | } | ||
337 | |||
338 | public static explicit operator LSLString(Quaternion r) | ||
339 | { | ||
340 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | ||
341 | return new LSLString(s); | ||
342 | } | ||
343 | |||
344 | public static explicit operator Quaternion(string s) | ||
345 | { | ||
346 | return new Quaternion(s); | ||
347 | } | ||
348 | |||
349 | public static bool operator ==(Quaternion lhs, Quaternion rhs) | ||
350 | { | ||
351 | // Return true if the fields match: | ||
352 | return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z && lhs.s == rhs.s; | ||
353 | } | ||
354 | |||
355 | public static bool operator !=(Quaternion lhs, Quaternion rhs) | ||
356 | { | ||
357 | return !(lhs == rhs); | ||
358 | } | ||
359 | |||
360 | #endregion | ||
361 | |||
362 | public static Quaternion operator +(Quaternion a, Quaternion b) | ||
363 | { | ||
364 | return new Quaternion(a.x + b.x, a.y + b.y, a.z + b.z, a.s + b.s); | ||
365 | } | ||
366 | |||
367 | public static Quaternion operator /(Quaternion a, Quaternion b) | ||
368 | { | ||
369 | b.s = -b.s; | ||
370 | return a * b; | ||
371 | } | ||
372 | |||
373 | public static Quaternion operator -(Quaternion a, Quaternion b) | ||
374 | { | ||
375 | return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s); | ||
376 | } | ||
377 | |||
378 | // using the equations below, we need to do "b * a" to be compatible with LSL | ||
379 | public static Quaternion operator *(Quaternion b, Quaternion a) | ||
380 | { | ||
381 | Quaternion c; | ||
382 | c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y; | ||
383 | c.y = a.s * b.y + a.y * b.s + a.z * b.x - a.x * b.z; | ||
384 | c.z = a.s * b.z + a.z * b.s + a.x * b.y - a.y * b.x; | ||
385 | c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z; | ||
386 | return c; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | [Serializable] | ||
391 | public class list | ||
392 | { | ||
393 | private object[] m_data; | ||
394 | |||
395 | public list(params object[] args) | ||
396 | { | ||
397 | m_data = new object[args.Length]; | ||
398 | m_data = args; | ||
399 | } | ||
400 | |||
401 | public int Length | ||
402 | { | ||
403 | get { | ||
404 | if (m_data == null) | ||
405 | m_data=new Object[0]; | ||
406 | return m_data.Length; | ||
407 | } | ||
408 | } | ||
409 | |||
410 | public object[] Data | ||
411 | { | ||
412 | get { | ||
413 | if (m_data == null) | ||
414 | m_data=new Object[0]; | ||
415 | return m_data; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | public static list operator +(list a, list b) | ||
420 | { | ||
421 | object[] tmp; | ||
422 | tmp = new object[a.Length + b.Length]; | ||
423 | a.Data.CopyTo(tmp, 0); | ||
424 | b.Data.CopyTo(tmp, a.Length); | ||
425 | return new list(tmp); | ||
426 | } | ||
427 | |||
428 | private void ExtendAndAdd(object o) | ||
429 | { | ||
430 | Array.Resize(ref m_data, Length + 1); | ||
431 | m_data.SetValue(o, Length - 1); | ||
432 | } | ||
433 | |||
434 | public static list operator +(list a, string s) | ||
435 | { | ||
436 | a.ExtendAndAdd(s); | ||
437 | return a; | ||
438 | } | ||
439 | |||
440 | public static list operator +(list a, int i) | ||
441 | { | ||
442 | a.ExtendAndAdd(i); | ||
443 | return a; | ||
444 | } | ||
445 | |||
446 | public static list operator +(list a, double d) | ||
447 | { | ||
448 | a.ExtendAndAdd(d); | ||
449 | return a; | ||
450 | } | ||
451 | |||
452 | public void Add(object o) | ||
453 | { | ||
454 | object[] tmp; | ||
455 | tmp = new object[m_data.Length + 1]; | ||
456 | m_data.CopyTo(tmp, 0); | ||
457 | tmp[m_data.Length] = o; | ||
458 | m_data = tmp; | ||
459 | } | ||
460 | |||
461 | public bool Contains(object o) | ||
462 | { | ||
463 | bool ret = false; | ||
464 | foreach (object i in Data) | ||
465 | { | ||
466 | if (i == o) | ||
467 | { | ||
468 | ret = true; | ||
469 | break; | ||
470 | } | ||
471 | } | ||
472 | return ret; | ||
473 | } | ||
474 | |||
475 | public list DeleteSublist(int start, int end) | ||
476 | { | ||
477 | // Not an easy one | ||
478 | // If start <= end, remove that part | ||
479 | // if either is negative, count from the end of the array | ||
480 | // if the resulting start > end, remove all BUT that part | ||
481 | |||
482 | Object[] ret; | ||
483 | |||
484 | if (start < 0) | ||
485 | start=m_data.Length-start; | ||
486 | |||
487 | if (start < 0) | ||
488 | start=0; | ||
489 | |||
490 | if (end < 0) | ||
491 | end=m_data.Length-end; | ||
492 | if (end < 0) | ||
493 | end=0; | ||
494 | |||
495 | if (start > end) | ||
496 | { | ||
497 | if (end >= m_data.Length) | ||
498 | return new list(new Object[0]); | ||
499 | |||
500 | if (start >= m_data.Length) | ||
501 | start=m_data.Length-1; | ||
502 | |||
503 | return GetSublist(end, start); | ||
504 | } | ||
505 | |||
506 | // start >= 0 && end >= 0 here | ||
507 | if (start >= m_data.Length) | ||
508 | { | ||
509 | ret=new Object[m_data.Length]; | ||
510 | Array.Copy(m_data, 0, ret, 0, m_data.Length); | ||
511 | |||
512 | return new list(ret); | ||
513 | } | ||
514 | |||
515 | if (end >= m_data.Length) | ||
516 | end=m_data.Length-1; | ||
517 | |||
518 | // now, this makes the math easier | ||
519 | int remove=end+1-start; | ||
520 | |||
521 | ret=new Object[m_data.Length-remove]; | ||
522 | if (ret.Length == 0) | ||
523 | return new list(ret); | ||
524 | |||
525 | int src; | ||
526 | int dest=0; | ||
527 | |||
528 | for (src = 0; src < m_data.Length; src++) | ||
529 | { | ||
530 | if (src < start || src > end) | ||
531 | ret[dest++]=m_data[src]; | ||
532 | } | ||
533 | |||
534 | return new list(ret); | ||
535 | } | ||
536 | |||
537 | public list GetSublist(int start, int end) | ||
538 | { | ||
539 | |||
540 | object[] ret; | ||
541 | |||
542 | // Take care of neg start or end's | ||
543 | // NOTE that either index may still be negative after | ||
544 | // adding the length, so we must take additional | ||
545 | // measures to protect against this. Note also that | ||
546 | // after normalisation the negative indices are no | ||
547 | // longer relative to the end of the list. | ||
548 | |||
549 | if (start < 0) | ||
550 | { | ||
551 | start = m_data.Length + start; | ||
552 | } | ||
553 | |||
554 | if (end < 0) | ||
555 | { | ||
556 | end = m_data.Length + end; | ||
557 | } | ||
558 | |||
559 | // The conventional case is start <= end | ||
560 | // NOTE that the case of an empty list is | ||
561 | // dealt with by the initial test. Start | ||
562 | // less than end is taken to be the most | ||
563 | // common case. | ||
564 | |||
565 | if (start <= end) | ||
566 | { | ||
567 | |||
568 | // Start sublist beyond length | ||
569 | // Also deals with start AND end still negative | ||
570 | if (start >= m_data.Length || end < 0) | ||
571 | { | ||
572 | return new list(); | ||
573 | } | ||
574 | |||
575 | // Sublist extends beyond the end of the supplied list | ||
576 | if (end >= m_data.Length) | ||
577 | { | ||
578 | end = m_data.Length - 1; | ||
579 | } | ||
580 | |||
581 | // Sublist still starts before the beginning of the list | ||
582 | if (start < 0) | ||
583 | { | ||
584 | start = 0; | ||
585 | } | ||
586 | |||
587 | ret = new object[end - start + 1]; | ||
588 | |||
589 | Array.Copy(m_data, start, ret, 0, end - start + 1); | ||
590 | |||
591 | return new list(ret); | ||
592 | |||
593 | } | ||
594 | |||
595 | // Deal with the segmented case: 0->end + start->EOL | ||
596 | |||
597 | else | ||
598 | { | ||
599 | |||
600 | list result = null; | ||
601 | |||
602 | // If end is negative, then prefix list is empty | ||
603 | if (end < 0) | ||
604 | { | ||
605 | result = new list(); | ||
606 | // If start is still negative, then the whole of | ||
607 | // the existing list is returned. This case is | ||
608 | // only admitted if end is also still negative. | ||
609 | if (start < 0) | ||
610 | { | ||
611 | return this; | ||
612 | } | ||
613 | |||
614 | } | ||
615 | else | ||
616 | { | ||
617 | result = GetSublist(0,end); | ||
618 | } | ||
619 | |||
620 | // If start is outside of list, then just return | ||
621 | // the prefix, whatever it is. | ||
622 | if (start >= m_data.Length) | ||
623 | { | ||
624 | return result; | ||
625 | } | ||
626 | |||
627 | return result + GetSublist(start, Data.Length); | ||
628 | |||
629 | } | ||
630 | } | ||
631 | |||
632 | public list Sort(int stride, int ascending) | ||
633 | { | ||
634 | if (Data.Length == 0) | ||
635 | return new list(); // Don't even bother | ||
636 | |||
637 | string[] keys; | ||
638 | |||
639 | if (stride == 1) // The simple case | ||
640 | { | ||
641 | Object[] ret=new Object[Data.Length]; | ||
642 | |||
643 | Array.Copy(Data, 0, ret, 0, Data.Length); | ||
644 | |||
645 | keys=new string[Data.Length]; | ||
646 | |||
647 | for (int k = 0; k < Data.Length; k++) | ||
648 | keys[k] = Data[k].ToString(); | ||
649 | |||
650 | Array.Sort(keys, ret); | ||
651 | |||
652 | if (ascending == 0) | ||
653 | Array.Reverse(ret); | ||
654 | return new list(ret); | ||
655 | } | ||
656 | |||
657 | int src=0; | ||
658 | |||
659 | int len=(Data.Length+stride-1)/stride; | ||
660 | |||
661 | keys=new string[len]; | ||
662 | Object[][] vals=new Object[len][]; | ||
663 | |||
664 | int i; | ||
665 | |||
666 | while (src < Data.Length) | ||
667 | { | ||
668 | Object[] o=new Object[stride]; | ||
669 | |||
670 | for (i = 0; i < stride; i++) | ||
671 | { | ||
672 | if (src < Data.Length) | ||
673 | o[i]=Data[src++]; | ||
674 | else | ||
675 | { | ||
676 | o[i]=new Object(); | ||
677 | src++; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | int idx=src/stride-1; | ||
682 | keys[idx]=o[0].ToString(); | ||
683 | vals[idx]=o; | ||
684 | } | ||
685 | |||
686 | Array.Sort(keys, vals); | ||
687 | if (ascending == 0) | ||
688 | { | ||
689 | Array.Reverse(vals); | ||
690 | } | ||
691 | |||
692 | Object[] sorted=new Object[stride*vals.Length]; | ||
693 | |||
694 | for (i = 0; i < vals.Length; i++) | ||
695 | for (int j = 0; j < stride; j++) | ||
696 | sorted[i*stride+j] = vals[i][j]; | ||
697 | |||
698 | return new list(sorted); | ||
699 | } | ||
700 | |||
701 | #region CSV Methods | ||
702 | |||
703 | public static list FromCSV(string csv) | ||
704 | { | ||
705 | return new list(csv.Split(',')); | ||
706 | } | ||
707 | |||
708 | public string ToCSV() | ||
709 | { | ||
710 | string ret = ""; | ||
711 | foreach (object o in this.Data) | ||
712 | { | ||
713 | if (ret == "") | ||
714 | { | ||
715 | ret = o.ToString(); | ||
716 | } | ||
717 | else | ||
718 | { | ||
719 | ret = ret + ", " + o.ToString(); | ||
720 | } | ||
721 | } | ||
722 | return ret; | ||
723 | } | ||
724 | |||
725 | private string ToSoup() | ||
726 | { | ||
727 | string output; | ||
728 | output = String.Empty; | ||
729 | if (m_data.Length == 0) | ||
730 | { | ||
731 | return String.Empty; | ||
732 | } | ||
733 | foreach (object o in m_data) | ||
734 | { | ||
735 | output = output + o.ToString(); | ||
736 | } | ||
737 | return output; | ||
738 | } | ||
739 | |||
740 | public static explicit operator String(list l) | ||
741 | { | ||
742 | return l.ToSoup(); | ||
743 | } | ||
744 | |||
745 | public static explicit operator LSLString(list l) | ||
746 | { | ||
747 | return new LSLString(l.ToSoup()); | ||
748 | } | ||
749 | |||
750 | public override string ToString() | ||
751 | { | ||
752 | return ToSoup(); | ||
753 | } | ||
754 | |||
755 | #endregion | ||
756 | |||
757 | #region Statistic Methods | ||
758 | |||
759 | public double Min() | ||
760 | { | ||
761 | double minimum = double.PositiveInfinity; | ||
762 | double entry; | ||
763 | for (int i = 0; i < Data.Length; i++) | ||
764 | { | ||
765 | if (double.TryParse(Data[i].ToString(), out entry)) | ||
766 | { | ||
767 | if (entry < minimum) minimum = entry; | ||
768 | } | ||
769 | } | ||
770 | return minimum; | ||
771 | } | ||
772 | |||
773 | public double Max() | ||
774 | { | ||
775 | double maximum = double.NegativeInfinity; | ||
776 | double entry; | ||
777 | for (int i = 0; i < Data.Length; i++) | ||
778 | { | ||
779 | if (double.TryParse(Data[i].ToString(), out entry)) | ||
780 | { | ||
781 | if (entry > maximum) maximum = entry; | ||
782 | } | ||
783 | } | ||
784 | return maximum; | ||
785 | } | ||
786 | |||
787 | public double Range() | ||
788 | { | ||
789 | return (this.Max() / this.Min()); | ||
790 | } | ||
791 | |||
792 | public int NumericLength() | ||
793 | { | ||
794 | int count = 0; | ||
795 | double entry; | ||
796 | for (int i = 0; i < Data.Length; i++) | ||
797 | { | ||
798 | if (double.TryParse(Data[i].ToString(), out entry)) | ||
799 | { | ||
800 | count++; | ||
801 | } | ||
802 | } | ||
803 | return count; | ||
804 | } | ||
805 | |||
806 | public static list ToDoubleList(list src) | ||
807 | { | ||
808 | list ret = new list(); | ||
809 | double entry; | ||
810 | for (int i = 0; i < src.Data.Length - 1; i++) | ||
811 | { | ||
812 | if (double.TryParse(src.Data[i].ToString(), out entry)) | ||
813 | { | ||
814 | ret.Add(entry); | ||
815 | } | ||
816 | } | ||
817 | return ret; | ||
818 | } | ||
819 | |||
820 | public double Sum() | ||
821 | { | ||
822 | double sum = 0; | ||
823 | double entry; | ||
824 | for (int i = 0; i < Data.Length; i++) | ||
825 | { | ||
826 | if (double.TryParse(Data[i].ToString(), out entry)) | ||
827 | { | ||
828 | sum = sum + entry; | ||
829 | } | ||
830 | } | ||
831 | return sum; | ||
832 | } | ||
833 | |||
834 | public double SumSqrs() | ||
835 | { | ||
836 | double sum = 0; | ||
837 | double entry; | ||
838 | for (int i = 0; i < Data.Length; i++) | ||
839 | { | ||
840 | if (double.TryParse(Data[i].ToString(), out entry)) | ||
841 | { | ||
842 | sum = sum + Math.Pow(entry, 2); | ||
843 | } | ||
844 | } | ||
845 | return sum; | ||
846 | } | ||
847 | |||
848 | public double Mean() | ||
849 | { | ||
850 | return (this.Sum() / this.NumericLength()); | ||
851 | } | ||
852 | |||
853 | public void NumericSort() | ||
854 | { | ||
855 | IComparer Numeric = new NumericComparer(); | ||
856 | Array.Sort(Data, Numeric); | ||
857 | } | ||
858 | |||
859 | public void AlphaSort() | ||
860 | { | ||
861 | IComparer Alpha = new AlphaCompare(); | ||
862 | Array.Sort(Data, Alpha); | ||
863 | } | ||
864 | |||
865 | public double Median() | ||
866 | { | ||
867 | return Qi(0.5); | ||
868 | } | ||
869 | |||
870 | public double GeometricMean() | ||
871 | { | ||
872 | double ret = 1.0; | ||
873 | list nums = ToDoubleList(this); | ||
874 | for (int i = 0; i < nums.Data.Length; i++) | ||
875 | { | ||
876 | ret *= (double)nums.Data[i]; | ||
877 | } | ||
878 | return Math.Exp(Math.Log(ret) / (double)nums.Data.Length); | ||
879 | } | ||
880 | |||
881 | public double HarmonicMean() | ||
882 | { | ||
883 | double ret = 0.0; | ||
884 | list nums = ToDoubleList(this); | ||
885 | for (int i = 0; i < nums.Data.Length; i++) | ||
886 | { | ||
887 | ret += 1.0 / (double)nums.Data[i]; | ||
888 | } | ||
889 | return ((double)nums.Data.Length / ret); | ||
890 | } | ||
891 | |||
892 | public double Variance() | ||
893 | { | ||
894 | double s = 0; | ||
895 | list num = ToDoubleList(this); | ||
896 | for (int i = 0; i < num.Data.Length; i++) | ||
897 | { | ||
898 | s += Math.Pow((double)num.Data[i], 2); | ||
899 | } | ||
900 | return (s - num.Data.Length * Math.Pow(num.Mean(), 2)) / (num.Data.Length - 1); | ||
901 | } | ||
902 | |||
903 | public double StdDev() | ||
904 | { | ||
905 | return Math.Sqrt(this.Variance()); | ||
906 | } | ||
907 | |||
908 | public double Qi(double i) | ||
909 | { | ||
910 | list j = this; | ||
911 | j.NumericSort(); | ||
912 | |||
913 | if (Math.Ceiling(this.Length * i) == this.Length * i) | ||
914 | { | ||
915 | return (double)((double)j.Data[(int)(this.Length * i - 1)] + (double)j.Data[(int)(this.Length * i)]) / 2; | ||
916 | } | ||
917 | else | ||
918 | { | ||
919 | return (double)j.Data[((int)(Math.Ceiling(this.Length * i))) - 1]; | ||
920 | } | ||
921 | } | ||
922 | |||
923 | #endregion | ||
924 | |||
925 | public string ToPrettyString() | ||
926 | { | ||
927 | string output; | ||
928 | if (m_data.Length == 0) | ||
929 | { | ||
930 | return "[]"; | ||
931 | } | ||
932 | output = "["; | ||
933 | foreach (object o in m_data) | ||
934 | { | ||
935 | if (o is String) | ||
936 | { | ||
937 | output = output + "\"" + o + "\", "; | ||
938 | } | ||
939 | else | ||
940 | { | ||
941 | output = output + o.ToString() + ", "; | ||
942 | } | ||
943 | } | ||
944 | output = output.Substring(0, output.Length - 2); | ||
945 | output = output + "]"; | ||
946 | return output; | ||
947 | } | ||
948 | |||
949 | public class AlphaCompare : IComparer | ||
950 | { | ||
951 | int IComparer.Compare(object x, object y) | ||
952 | { | ||
953 | return string.Compare(x.ToString(), y.ToString()); | ||
954 | } | ||
955 | } | ||
956 | |||
957 | public class NumericComparer : IComparer | ||
958 | { | ||
959 | int IComparer.Compare(object x, object y) | ||
960 | { | ||
961 | double a; | ||
962 | double b; | ||
963 | if (!double.TryParse(x.ToString(), out a)) | ||
964 | { | ||
965 | a = 0.0; | ||
966 | } | ||
967 | if (!double.TryParse(y.ToString(), out b)) | ||
968 | { | ||
969 | b = 0.0; | ||
970 | } | ||
971 | if (a < b) | ||
972 | { | ||
973 | return -1; | ||
974 | } | ||
975 | else if (a == b) | ||
976 | { | ||
977 | return 0; | ||
978 | } | ||
979 | else | ||
980 | { | ||
981 | return 1; | ||
982 | } | ||
983 | } | ||
984 | } | ||
985 | |||
986 | } | ||
987 | |||
988 | // | ||
989 | // BELOW IS WORK IN PROGRESS... IT WILL CHANGE, SO DON'T USE YET! :) | ||
990 | // | ||
991 | |||
992 | public struct StringTest | ||
993 | { | ||
994 | // Our own little string | ||
995 | internal string actualString; | ||
996 | public static implicit operator bool(StringTest mString) | ||
997 | { | ||
998 | if (mString.actualString.Length == 0) | ||
999 | return true; | ||
1000 | return false; | ||
1001 | } | ||
1002 | public override string ToString() | ||
1003 | { | ||
1004 | return actualString; | ||
1005 | } | ||
1006 | |||
1007 | } | ||
1008 | |||
1009 | [Serializable] | ||
1010 | public struct key | ||
1011 | { | ||
1012 | public string value; | ||
1013 | |||
1014 | #region Constructors | ||
1015 | public key(string s) | ||
1016 | { | ||
1017 | value = s; | ||
1018 | } | ||
1019 | |||
1020 | #endregion | ||
1021 | |||
1022 | #region Methods | ||
1023 | |||
1024 | static public bool Parse2Key(string s) | ||
1025 | { | ||
1026 | Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); | ||
1027 | if (isuuid.IsMatch(s)) | ||
1028 | { | ||
1029 | return true; | ||
1030 | } | ||
1031 | else | ||
1032 | { | ||
1033 | return false; | ||
1034 | } | ||
1035 | } | ||
1036 | |||
1037 | #endregion | ||
1038 | |||
1039 | #region Operators | ||
1040 | |||
1041 | static public implicit operator Boolean(key k) | ||
1042 | { | ||
1043 | if (k.value.Length == 0) | ||
1044 | { | ||
1045 | return false; | ||
1046 | } | ||
1047 | |||
1048 | if (k.value == "00000000-0000-0000-0000-000000000000") | ||
1049 | { | ||
1050 | return false; | ||
1051 | } | ||
1052 | Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); | ||
1053 | if (isuuid.IsMatch(k.value)) | ||
1054 | { | ||
1055 | return true; | ||
1056 | } | ||
1057 | else | ||
1058 | { | ||
1059 | return false; | ||
1060 | } | ||
1061 | } | ||
1062 | |||
1063 | static public implicit operator key(string s) | ||
1064 | { | ||
1065 | return new key(s); | ||
1066 | } | ||
1067 | |||
1068 | static public implicit operator String(key k) | ||
1069 | { | ||
1070 | return k.value; | ||
1071 | } | ||
1072 | |||
1073 | public static bool operator ==(key k1, key k2) | ||
1074 | { | ||
1075 | return k1.value == k2.value; | ||
1076 | } | ||
1077 | public static bool operator !=(key k1, key k2) | ||
1078 | { | ||
1079 | return k1.value != k2.value; | ||
1080 | } | ||
1081 | |||
1082 | #endregion | ||
1083 | |||
1084 | #region Overriders | ||
1085 | |||
1086 | public override bool Equals(object o) | ||
1087 | { | ||
1088 | return o.ToString() == value; | ||
1089 | } | ||
1090 | |||
1091 | public override int GetHashCode() | ||
1092 | { | ||
1093 | return value.GetHashCode(); | ||
1094 | } | ||
1095 | |||
1096 | #endregion | ||
1097 | } | ||
1098 | |||
1099 | [Serializable] | ||
1100 | public struct LSLString | ||
1101 | { | ||
1102 | public string m_string; | ||
1103 | #region Constructors | ||
1104 | public LSLString(string s) | ||
1105 | { | ||
1106 | m_string = s; | ||
1107 | } | ||
1108 | |||
1109 | public LSLString(int i) | ||
1110 | { | ||
1111 | m_string=i.ToString(); | ||
1112 | } | ||
1113 | |||
1114 | public LSLString(double d) | ||
1115 | { | ||
1116 | string s=String.Format("{0:0.000000}", d); | ||
1117 | m_string=s; | ||
1118 | } | ||
1119 | |||
1120 | public LSLString(LSLFloat f) | ||
1121 | { | ||
1122 | string s=String.Format("{0:0.000000}", f.value); | ||
1123 | m_string=s; | ||
1124 | } | ||
1125 | |||
1126 | #endregion | ||
1127 | |||
1128 | #region Operators | ||
1129 | static public implicit operator Boolean(LSLString s) | ||
1130 | { | ||
1131 | if (s.m_string.Length == 0) | ||
1132 | { | ||
1133 | return false; | ||
1134 | } | ||
1135 | else | ||
1136 | { | ||
1137 | return true; | ||
1138 | } | ||
1139 | } | ||
1140 | |||
1141 | |||
1142 | |||
1143 | static public implicit operator String(LSLString s) | ||
1144 | { | ||
1145 | return s.m_string; | ||
1146 | } | ||
1147 | |||
1148 | static public implicit operator LSLString(string s) | ||
1149 | { | ||
1150 | return new LSLString(s); | ||
1151 | } | ||
1152 | |||
1153 | public static string ToString(LSLString s) | ||
1154 | { | ||
1155 | return s.m_string; | ||
1156 | } | ||
1157 | |||
1158 | public override string ToString() | ||
1159 | { | ||
1160 | return m_string; | ||
1161 | } | ||
1162 | |||
1163 | public static bool operator ==(LSLString s1, string s2) | ||
1164 | { | ||
1165 | return s1.m_string == s2; | ||
1166 | } | ||
1167 | |||
1168 | public static bool operator !=(LSLString s1, string s2) | ||
1169 | { | ||
1170 | return s1.m_string != s2; | ||
1171 | } | ||
1172 | |||
1173 | public static explicit operator double(LSLString s) | ||
1174 | { | ||
1175 | return Convert.ToDouble(s.m_string); | ||
1176 | } | ||
1177 | |||
1178 | public static explicit operator LSLInteger(LSLString s) | ||
1179 | { | ||
1180 | return new LSLInteger(Convert.ToInt32(s.m_string)); | ||
1181 | } | ||
1182 | |||
1183 | public static explicit operator LSLString(int i) | ||
1184 | { | ||
1185 | return new LSLString(i); | ||
1186 | } | ||
1187 | |||
1188 | public static explicit operator LSLString(double d) | ||
1189 | { | ||
1190 | return new LSLString(d); | ||
1191 | } | ||
1192 | |||
1193 | public static explicit operator LSLString(LSLFloat f) | ||
1194 | { | ||
1195 | return new LSLString(f); | ||
1196 | } | ||
1197 | |||
1198 | public static implicit operator Vector3(LSLString s) | ||
1199 | { | ||
1200 | return new Vector3(s.m_string); | ||
1201 | } | ||
1202 | |||
1203 | #endregion | ||
1204 | |||
1205 | #region Overriders | ||
1206 | public override bool Equals(object o) | ||
1207 | { | ||
1208 | return m_string == o.ToString(); | ||
1209 | } | ||
1210 | |||
1211 | public override int GetHashCode() | ||
1212 | { | ||
1213 | return m_string.GetHashCode(); | ||
1214 | } | ||
1215 | |||
1216 | #endregion | ||
1217 | |||
1218 | #region " Standard string functions " | ||
1219 | //Clone,CompareTo,Contains | ||
1220 | //CopyTo,EndsWith,Equals,GetEnumerator,GetHashCode,GetType,GetTypeCode | ||
1221 | //IndexOf,IndexOfAny,Insert,IsNormalized,LastIndexOf,LastIndexOfAny | ||
1222 | //Length,Normalize,PadLeft,PadRight,Remove,Replace,Split,StartsWith,Substring,ToCharArray,ToLowerInvariant | ||
1223 | //ToString,ToUpper,ToUpperInvariant,Trim,TrimEnd,TrimStart | ||
1224 | public bool Contains(string value) { return m_string.Contains(value); } | ||
1225 | public int IndexOf(string value) { return m_string.IndexOf(value); } | ||
1226 | public int Length { get { return m_string.Length; } } | ||
1227 | |||
1228 | |||
1229 | #endregion | ||
1230 | } | ||
1231 | |||
1232 | [Serializable] | ||
1233 | public struct LSLInteger | ||
1234 | { | ||
1235 | public int value; | ||
1236 | |||
1237 | #region Constructors | ||
1238 | public LSLInteger(int i) | ||
1239 | { | ||
1240 | value = i; | ||
1241 | } | ||
1242 | |||
1243 | public LSLInteger(double d) | ||
1244 | { | ||
1245 | value = (int)d; | ||
1246 | } | ||
1247 | |||
1248 | public LSLInteger(Object o) | ||
1249 | { | ||
1250 | if (!(o is Int32)) | ||
1251 | value = 0; | ||
1252 | else | ||
1253 | value = (int)o; | ||
1254 | } | ||
1255 | |||
1256 | public LSLInteger(string s) | ||
1257 | { | ||
1258 | value = int.Parse(s); | ||
1259 | } | ||
1260 | |||
1261 | #endregion | ||
1262 | |||
1263 | #region Operators | ||
1264 | |||
1265 | static public implicit operator int(LSLInteger i) | ||
1266 | { | ||
1267 | return i.value; | ||
1268 | } | ||
1269 | |||
1270 | static public implicit operator uint(LSLInteger i) | ||
1271 | { | ||
1272 | return (uint)i.value; | ||
1273 | } | ||
1274 | |||
1275 | static public explicit operator LSLString(LSLInteger i) | ||
1276 | { | ||
1277 | return new LSLString(i.ToString()); | ||
1278 | } | ||
1279 | |||
1280 | static public explicit operator string(LSLInteger i) | ||
1281 | { | ||
1282 | return i.ToString(); | ||
1283 | } | ||
1284 | |||
1285 | static public implicit operator Boolean(LSLInteger i) | ||
1286 | { | ||
1287 | if (i.value == 0) | ||
1288 | { | ||
1289 | return false; | ||
1290 | } | ||
1291 | else | ||
1292 | { | ||
1293 | return true; | ||
1294 | } | ||
1295 | } | ||
1296 | |||
1297 | static public implicit operator LSLInteger(int i) | ||
1298 | { | ||
1299 | return new LSLInteger(i); | ||
1300 | } | ||
1301 | |||
1302 | static public explicit operator LSLInteger(string s) | ||
1303 | { | ||
1304 | return new LSLInteger(int.Parse(s)); | ||
1305 | } | ||
1306 | |||
1307 | static public implicit operator LSLInteger(double d) | ||
1308 | { | ||
1309 | return new LSLInteger(d); | ||
1310 | } | ||
1311 | |||
1312 | static public bool operator ==(LSLInteger i1, LSLInteger i2) | ||
1313 | { | ||
1314 | bool ret = i1.value == i2.value; | ||
1315 | return ret; | ||
1316 | } | ||
1317 | |||
1318 | static public bool operator !=(LSLInteger i1, LSLInteger i2) | ||
1319 | { | ||
1320 | bool ret = i1.value != i2.value; | ||
1321 | return ret; | ||
1322 | } | ||
1323 | |||
1324 | static public LSLInteger operator &(LSLInteger i1, LSLInteger i2) | ||
1325 | { | ||
1326 | int ret = i1.value & i2.value; | ||
1327 | return ret; | ||
1328 | } | ||
1329 | |||
1330 | public static LSLInteger operator ++(LSLInteger i) | ||
1331 | { | ||
1332 | i.value++; | ||
1333 | return i; | ||
1334 | } | ||
1335 | |||
1336 | |||
1337 | public static LSLInteger operator --(LSLInteger i) | ||
1338 | { | ||
1339 | i.value--; | ||
1340 | return i; | ||
1341 | } | ||
1342 | |||
1343 | static public implicit operator System.Double(LSLInteger i) | ||
1344 | { | ||
1345 | return (double)i.value; | ||
1346 | } | ||
1347 | |||
1348 | static public implicit operator LSLFloat(LSLInteger i) | ||
1349 | { | ||
1350 | return new LSLFloat((double)i.value); | ||
1351 | } | ||
1352 | |||
1353 | public static bool operator true(LSLInteger i) | ||
1354 | { | ||
1355 | return i.value != 0; | ||
1356 | } | ||
1357 | |||
1358 | public static bool operator false(LSLInteger i) | ||
1359 | { | ||
1360 | return i.value == 0; | ||
1361 | } | ||
1362 | |||
1363 | #endregion | ||
1364 | |||
1365 | #region Overriders | ||
1366 | |||
1367 | public override string ToString() | ||
1368 | { | ||
1369 | return this.value.ToString(); | ||
1370 | } | ||
1371 | |||
1372 | public override bool Equals(object o) | ||
1373 | { | ||
1374 | if (o is Int32) | ||
1375 | { | ||
1376 | return value == (Int32)o; | ||
1377 | } | ||
1378 | if (o is LSLInteger) | ||
1379 | { | ||
1380 | return value == ((LSLInteger)o).value; | ||
1381 | } | ||
1382 | return false; | ||
1383 | } | ||
1384 | |||
1385 | public override int GetHashCode() | ||
1386 | { | ||
1387 | return value.GetHashCode(); | ||
1388 | } | ||
1389 | |||
1390 | #endregion | ||
1391 | } | ||
1392 | |||
1393 | [Serializable] | ||
1394 | public struct LSLFloat | ||
1395 | { | ||
1396 | public double value; | ||
1397 | |||
1398 | #region Constructors | ||
1399 | |||
1400 | public LSLFloat(int i) | ||
1401 | { | ||
1402 | value = (double)i; | ||
1403 | } | ||
1404 | |||
1405 | public LSLFloat(double d) | ||
1406 | { | ||
1407 | value = d; | ||
1408 | } | ||
1409 | |||
1410 | public LSLFloat(string s) | ||
1411 | { | ||
1412 | value = double.Parse(s); | ||
1413 | } | ||
1414 | |||
1415 | public LSLFloat(Object o) | ||
1416 | { | ||
1417 | if (!((o is double) || (o is float))) | ||
1418 | { | ||
1419 | value = 0.0; | ||
1420 | return; | ||
1421 | } | ||
1422 | |||
1423 | value = (double)o; | ||
1424 | } | ||
1425 | |||
1426 | #endregion | ||
1427 | |||
1428 | #region Operators | ||
1429 | |||
1430 | static public implicit operator int(LSLFloat f) | ||
1431 | { | ||
1432 | return (int)f.value; | ||
1433 | } | ||
1434 | |||
1435 | static public implicit operator uint(LSLFloat f) | ||
1436 | { | ||
1437 | return (uint) Math.Abs(f.value); | ||
1438 | } | ||
1439 | |||
1440 | static public implicit operator Boolean(LSLFloat f) | ||
1441 | { | ||
1442 | if (f.value == 0.0) | ||
1443 | { | ||
1444 | return false; | ||
1445 | } | ||
1446 | else | ||
1447 | { | ||
1448 | return true; | ||
1449 | } | ||
1450 | } | ||
1451 | |||
1452 | static public implicit operator LSLFloat(int i) | ||
1453 | { | ||
1454 | return new LSLFloat(i); | ||
1455 | } | ||
1456 | |||
1457 | static public implicit operator LSLFloat(string s) | ||
1458 | { | ||
1459 | return new LSLFloat(double.Parse(s)); | ||
1460 | } | ||
1461 | |||
1462 | static public implicit operator LSLFloat(double d) | ||
1463 | { | ||
1464 | return new LSLFloat(d); | ||
1465 | } | ||
1466 | |||
1467 | static public bool operator ==(LSLFloat f1, LSLFloat f2) | ||
1468 | { | ||
1469 | return f1.value == f2.value; | ||
1470 | } | ||
1471 | |||
1472 | static public bool operator !=(LSLFloat f1, LSLFloat f2) | ||
1473 | { | ||
1474 | return f1.value != f2.value; | ||
1475 | } | ||
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 | |||
1490 | static public LSLFloat operator ++(LSLFloat f) | ||
1491 | { | ||
1492 | f.value++; | ||
1493 | return f; | ||
1494 | } | ||
1495 | |||
1496 | static public LSLFloat operator --(LSLFloat f) | ||
1497 | { | ||
1498 | f.value--; | ||
1499 | return f; | ||
1500 | } | ||
1501 | |||
1502 | static public implicit operator System.Double(LSLFloat f) | ||
1503 | { | ||
1504 | return f.value; | ||
1505 | } | ||
1506 | |||
1507 | #endregion | ||
1508 | |||
1509 | #region Overriders | ||
1510 | |||
1511 | public override string ToString() | ||
1512 | { | ||
1513 | return String.Format("{0:0.000000}", this.value); | ||
1514 | } | ||
1515 | |||
1516 | #endregion | ||
1517 | } | ||
1518 | } | ||
1519 | } | ||