diff options
Diffstat (limited to '')
13 files changed, 0 insertions, 3055 deletions
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs deleted file mode 100644 index 15c03f0..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | using System; | ||
30 | |||
31 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
32 | { | ||
33 | public static class Common | ||
34 | { | ||
35 | public static bool Debug = true; | ||
36 | public static bool IL_UseTryCatch = true; | ||
37 | public static bool IL_CreateConstructor = true; | ||
38 | public static bool IL_CreateFunctionList = true; | ||
39 | public static bool IL_ProcessCodeChunks = true; | ||
40 | |||
41 | public delegate void SendToDebugEventDelegate(string Message); | ||
42 | |||
43 | public delegate void SendToLogEventDelegate(string Message); | ||
44 | |||
45 | public static event SendToDebugEventDelegate SendToDebugEvent; | ||
46 | public static event SendToLogEventDelegate SendToLogEvent; | ||
47 | |||
48 | public static void SendToDebug(string Message) | ||
49 | { | ||
50 | //if (Debug == true) | ||
51 | Console.WriteLine("COMPILER:Debug: " + Message); | ||
52 | SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); | ||
53 | } | ||
54 | |||
55 | public static void SendToLog(string Message) | ||
56 | { | ||
57 | //if (Debug == true) | ||
58 | Console.WriteLine("COMPILER:LOG: " + Message); | ||
59 | SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | public static class IL_Helper | ||
64 | { | ||
65 | public static string ReverseFormatString(string text1, string format) | ||
66 | { | ||
67 | Common.SendToDebug("ReverseFormatString text1: " + text1); | ||
68 | Common.SendToDebug("ReverseFormatString format: " + format); | ||
69 | return string.Format(format, text1); | ||
70 | } | ||
71 | |||
72 | public static string ReverseFormatString(string text1, UInt32 text2, string format) | ||
73 | { | ||
74 | Common.SendToDebug("ReverseFormatString text1: " + text1); | ||
75 | Common.SendToDebug("ReverseFormatString text2: " + text2.ToString()); | ||
76 | Common.SendToDebug("ReverseFormatString format: " + format); | ||
77 | return string.Format(format, text1, text2.ToString()); | ||
78 | } | ||
79 | |||
80 | public static string Cast_ToString(object obj) | ||
81 | { | ||
82 | Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString()); | ||
83 | return "ABCDEFGIHJKLMNOPQ123"; | ||
84 | } | ||
85 | } | ||
86 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs deleted file mode 100644 index f53772e..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs +++ /dev/null | |||
@@ -1,291 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | using System; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Reflection.Emit; | ||
33 | using System.Text; | ||
34 | using System.Threading; | ||
35 | using OpenSim.Region.ScriptEngine.Common; | ||
36 | |||
37 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
38 | { | ||
39 | public class Engine | ||
40 | { | ||
41 | //private string LSO_FileName = @"LSO\AdditionTest.lso"; | ||
42 | private string LSO_FileName; // = @"LSO\CloseToDefault.lso"; | ||
43 | private AppDomain appDomain; | ||
44 | |||
45 | public string Compile(string LSOFileName) | ||
46 | { | ||
47 | LSO_FileName = LSOFileName; | ||
48 | |||
49 | |||
50 | //appDomain = AppDomain.CreateDomain("AlternateAppDomain"); | ||
51 | appDomain = Thread.GetDomain(); | ||
52 | |||
53 | // Create Assembly Name | ||
54 | AssemblyName asmName = new AssemblyName(); | ||
55 | asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName); | ||
56 | //asmName.Name = "TestAssembly"; | ||
57 | |||
58 | string DLL_FileName = asmName.Name + ".dll"; | ||
59 | string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; | ||
60 | |||
61 | Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName)); | ||
62 | Common.SendToLog("Assembly name: " + asmName.Name); | ||
63 | Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); | ||
64 | Common.SendToLog("Starting processing of LSL ByteCode..."); | ||
65 | Common.SendToLog(String.Empty); | ||
66 | |||
67 | |||
68 | // Create Assembly | ||
69 | AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( | ||
70 | asmName, | ||
71 | AssemblyBuilderAccess.RunAndSave | ||
72 | ); | ||
73 | //// Create Assembly | ||
74 | //AssemblyBuilder asmBuilder = | ||
75 | // Thread.GetDomain().DefineDynamicAssembly | ||
76 | //(asmName, AssemblyBuilderAccess.RunAndSave); | ||
77 | |||
78 | // Create a module (and save to disk) | ||
79 | ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule | ||
80 | (asmName.Name, | ||
81 | DLL_FileName); | ||
82 | |||
83 | //Common.SendToDebug("asmName.Name is still \String.Empty + asmName.Name + "\String.Empty); | ||
84 | // Create a Class (/Type) | ||
85 | TypeBuilder typeBuilder = modBuilder.DefineType( | ||
86 | "LSL_ScriptObject", | ||
87 | TypeAttributes.Public | TypeAttributes.BeforeFieldInit, | ||
88 | typeof (BuiltIn_Commands_BaseClass)); | ||
89 | //, | ||
90 | // typeof()); | ||
91 | //, typeof(LSL_BuiltIn_Commands_Interface)); | ||
92 | //, | ||
93 | // typeof(object), | ||
94 | // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); | ||
95 | |||
96 | |||
97 | /* | ||
98 | * Generate the IL itself | ||
99 | */ | ||
100 | |||
101 | LSO_Parser LSOP = new LSO_Parser(LSO_FileName, typeBuilder); | ||
102 | LSOP.OpenFile(); | ||
103 | LSOP.Parse(); | ||
104 | |||
105 | // Constructor has to be created AFTER LSO_Parser because of accumulated variables | ||
106 | if (Common.IL_CreateConstructor) | ||
107 | IL_CREATE_CONSTRUCTOR(typeBuilder, LSOP); | ||
108 | |||
109 | LSOP.CloseFile(); | ||
110 | /* | ||
111 | * Done generating. Create a type and run it. | ||
112 | */ | ||
113 | |||
114 | |||
115 | Common.SendToLog("Attempting to compile assembly..."); | ||
116 | // Compile it | ||
117 | Type type = typeBuilder.CreateType(); | ||
118 | Common.SendToLog("Compilation successful!"); | ||
119 | |||
120 | Common.SendToLog("Saving assembly: " + DLL_FileName); | ||
121 | asmBuilder.Save(DLL_FileName); | ||
122 | |||
123 | Common.SendToLog("Returning assembly filename: " + DLL_FileName); | ||
124 | |||
125 | |||
126 | return DLL_FileName; | ||
127 | |||
128 | |||
129 | //Common.SendToLog("Creating an instance of new assembly..."); | ||
130 | //// Create an instance we can play with | ||
131 | ////LSLScript hello = (LSLScript)Activator.CreateInstance(type); | ||
132 | ////LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); | ||
133 | //object MyScript = (object)Activator.CreateInstance(type); | ||
134 | |||
135 | |||
136 | //System.Reflection.MemberInfo[] Members = type.GetMembers(); | ||
137 | |||
138 | //Common.SendToLog("Members of assembly " + type.ToString() + ":"); | ||
139 | //foreach (MemberInfo member in Members) | ||
140 | // Common.SendToLog(member.ToString()); | ||
141 | |||
142 | |||
143 | //// Play with it | ||
144 | ////MyScript.event_state_entry("Test"); | ||
145 | //object[] args = { null }; | ||
146 | ////System.Collections.Generic.List<string> Functions = (System.Collections.Generic.List<string>)type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); | ||
147 | |||
148 | //string[] ret = { }; | ||
149 | //if (Common.IL_CreateFunctionList) | ||
150 | // ret = (string[])type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); | ||
151 | |||
152 | //foreach (string s in ret) | ||
153 | //{ | ||
154 | // Common.SendToLog(String.Empty); | ||
155 | // Common.SendToLog("*** Executing LSL Server Event: " + s); | ||
156 | // //object test = type.GetMember(s); | ||
157 | // //object runner = type.InvokeMember(s, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, MyScript, args); | ||
158 | // //runner(); | ||
159 | // //objBooks_Late = type.InvokeMember(s, BindingFlags.CreateInstance, null, objApp_Late, null); | ||
160 | // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); | ||
161 | |||
162 | //} | ||
163 | } | ||
164 | |||
165 | |||
166 | private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) | ||
167 | { | ||
168 | Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); | ||
169 | //ConstructorBuilder constructor = typeBuilder.DefineConstructor( | ||
170 | // MethodAttributes.Public, | ||
171 | // CallingConventions.Standard, | ||
172 | // new Type[0]); | ||
173 | ConstructorBuilder constructor = typeBuilder.DefineConstructor( | ||
174 | MethodAttributes.Public | | ||
175 | MethodAttributes.SpecialName | | ||
176 | MethodAttributes.RTSpecialName, | ||
177 | CallingConventions.Standard, | ||
178 | new Type[0]); | ||
179 | |||
180 | //Define the reflection ConstructorInfor for System.Object | ||
181 | ConstructorInfo conObj = typeof (BuiltIn_Commands_BaseClass).GetConstructor(new Type[0]); | ||
182 | |||
183 | //call constructor of base object | ||
184 | ILGenerator il = constructor.GetILGenerator(); | ||
185 | |||
186 | il.Emit(OpCodes.Ldarg_0); | ||
187 | il.Emit(OpCodes.Call, conObj); | ||
188 | |||
189 | |||
190 | //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: UInt32 State = 0;"); | ||
191 | //string FieldName; | ||
192 | //// Create state object | ||
193 | //FieldName = "State"; | ||
194 | //FieldBuilder State_fb = typeBuilder.DefineField( | ||
195 | // FieldName, | ||
196 | // typeof(UInt32), | ||
197 | // FieldAttributes.Public); | ||
198 | //il.Emit(OpCodes.Ldarg_0); | ||
199 | //il.Emit(OpCodes.Ldc_I4, 0); | ||
200 | //il.Emit(OpCodes.Stfld, State_fb); | ||
201 | |||
202 | |||
203 | //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: LSL_BuiltIn_Commands_TestImplementation LSL_BuiltIns = New LSL_BuiltIn_Commands_TestImplementation();"); | ||
204 | ////Type objType1 = typeof(object); | ||
205 | //Type objType1 = typeof(LSL_BuiltIn_Commands_TestImplementation); | ||
206 | |||
207 | //FieldName = "LSL_BuiltIns"; | ||
208 | //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField( | ||
209 | // FieldName, | ||
210 | // objType1, | ||
211 | // FieldAttributes.Public); | ||
212 | |||
213 | ////LSL_BuiltIn_Commands_TestImplementation _ti = new LSL_BuiltIn_Commands_TestImplementation(); | ||
214 | //il.Emit(OpCodes.Ldarg_0); | ||
215 | ////il.Emit(OpCodes.Ldstr, "Test 123"); | ||
216 | //il.Emit(OpCodes.Newobj, objType1.GetConstructor(new Type[] { })); | ||
217 | //il.Emit(OpCodes.Stfld, LSL_BuiltIns_fb); | ||
218 | |||
219 | foreach (UInt32 pos in LSOP.StaticBlocks.Keys) | ||
220 | { | ||
221 | LSO_Struct.StaticBlock sb; | ||
222 | LSOP.StaticBlocks.TryGetValue(pos, out sb); | ||
223 | |||
224 | if (sb.ObjectType > 0 && sb.ObjectType < 8) | ||
225 | { | ||
226 | // We don't want void or null's | ||
227 | |||
228 | il.Emit(OpCodes.Ldarg_0); | ||
229 | // Push position to stack | ||
230 | il.Emit(OpCodes.Ldc_I4, pos); | ||
231 | //il.Emit(OpCodes.Box, typeof(UInt32)); | ||
232 | |||
233 | |||
234 | Type datatype = null; | ||
235 | |||
236 | // Push data to stack | ||
237 | Common.SendToDebug("Adding to static (" + pos + ") type: " + | ||
238 | ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType + | ||
239 | ")"); | ||
240 | switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType) | ||
241 | { | ||
242 | case LSO_Enums.Variable_Type_Codes.Float: | ||
243 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
244 | //UInt32 | ||
245 | il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); | ||
246 | datatype = typeof (UInt32); | ||
247 | il.Emit(OpCodes.Box, datatype); | ||
248 | break; | ||
249 | case LSO_Enums.Variable_Type_Codes.String: | ||
250 | case LSO_Enums.Variable_Type_Codes.Key: | ||
251 | //String | ||
252 | LSO_Struct.HeapBlock hb = | ||
253 | LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); | ||
254 | il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data)); | ||
255 | datatype = typeof (string); | ||
256 | break; | ||
257 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
258 | datatype = typeof (LSO_Enums.Vector); | ||
259 | //TODO: Not implemented | ||
260 | break; | ||
261 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
262 | //Object | ||
263 | //TODO: Not implemented | ||
264 | datatype = typeof (LSO_Enums.Rotation); | ||
265 | break; | ||
266 | default: | ||
267 | datatype = typeof (object); | ||
268 | break; | ||
269 | } | ||
270 | |||
271 | |||
272 | // Make call | ||
273 | il.Emit(OpCodes.Call, | ||
274 | typeof (BuiltIn_Commands_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype})); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | |||
279 | ////il.Emit(OpCodes.Newobj, typeof(UInt32)); | ||
280 | //il.Emit(OpCodes.Starg_0); | ||
281 | //// Create LSL function library | ||
282 | //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField("LSL_BuiltIns", typeof(LSL_BuiltIn_Commands_Interface), FieldAttributes.Public); | ||
283 | //il.Emit(OpCodes.Newobj, typeof(LSL_BuiltIn_Commands_Interface)); | ||
284 | //il.Emit(OpCodes.Stloc_1); | ||
285 | |||
286 | il.Emit(OpCodes.Ret); | ||
287 | } | ||
288 | |||
289 | // End of class | ||
290 | } | ||
291 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs deleted file mode 100644 index 6d0e35c..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
30 | { | ||
31 | internal partial class LSO_Parser | ||
32 | { | ||
33 | // TODO: unused: | ||
34 | // private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName) | ||
35 | // { | ||
36 | // TypeBuilder typeBuilder = modBuilder.DefineType(typeName, | ||
37 | // TypeAttributes.Public | | ||
38 | // TypeAttributes.Class | | ||
39 | // TypeAttributes.AutoClass | | ||
40 | // TypeAttributes.AnsiClass | | ||
41 | // TypeAttributes.BeforeFieldInit | | ||
42 | // TypeAttributes.AutoLayout, | ||
43 | // typeof (object), | ||
44 | // new Type[] {typeof (object)}); | ||
45 | // return typeBuilder; | ||
46 | // } | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs deleted file mode 100644 index 7805aa3..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs +++ /dev/null | |||
@@ -1,391 +0,0 @@ | |||
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.LSOEngine.LSO | ||
29 | { | ||
30 | //public partial class LSL_BaseClass | ||
31 | //{ | ||
32 | // /* | ||
33 | // * OPCODES | ||
34 | // * | ||
35 | // * These are internal "assembly" commands, | ||
36 | // * basic operators like "ADD", "PUSH" and "POP" | ||
37 | // * | ||
38 | // * It also contains managed stack and keeps track of internal variables, etc. | ||
39 | // * | ||
40 | // */ | ||
41 | |||
42 | |||
43 | // public void StoreToLocal(UInt32 index) | ||
44 | // { | ||
45 | // // TODO: How to determine local? | ||
46 | // LSOEngine.LSO.Common.SendToDebug("::StoreToLocal " + index); | ||
47 | // if (LocalVariables.ContainsKey(index)) | ||
48 | // LocalVariables.Remove(index); | ||
49 | // LocalVariables.Add(index, LSLStack.Peek()); | ||
50 | // } | ||
51 | |||
52 | // public void StoreToGlobal(UInt32 index) | ||
53 | // { | ||
54 | // LSOEngine.LSO.Common.SendToDebug("::StoreToGlobal " + index); | ||
55 | // if (GlobalVariables.ContainsKey(index)) | ||
56 | // GlobalVariables.Remove(index); | ||
57 | // GlobalVariables.Add(index, LSLStack.Peek()); | ||
58 | // } | ||
59 | |||
60 | // public void StoreToStatic(UInt32 index) | ||
61 | // { | ||
62 | // LSOEngine.LSO.Common.SendToDebug("::StoreToStatic " + index); | ||
63 | // //if (StaticVariables.ContainsKey(index)) | ||
64 | // // StaticVariables.Remove(index); | ||
65 | // StaticVariables.Add(index, LSLStack.Peek()); | ||
66 | // } | ||
67 | |||
68 | // public void GetFromLocal(UInt32 index) | ||
69 | // { | ||
70 | // // TODO: How to determine local? | ||
71 | // LSOEngine.LSO.Common.SendToDebug("::GetFromLocal " + index); | ||
72 | // object ret; | ||
73 | // LocalVariables.TryGetValue(index, out ret); | ||
74 | // LSLStack.Push(ret); | ||
75 | // //return ret; | ||
76 | // } | ||
77 | |||
78 | // public void GetFromGlobal(UInt32 index) | ||
79 | // { | ||
80 | // LSOEngine.LSO.Common.SendToDebug("::GetFromGlobal " + index); | ||
81 | // object ret; | ||
82 | // GlobalVariables.TryGetValue(index, out ret); | ||
83 | // LSLStack.Push(ret); | ||
84 | // //return ret; | ||
85 | // } | ||
86 | |||
87 | // public void GetFromStatic(UInt32 index) | ||
88 | // { | ||
89 | // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic " + index); | ||
90 | // object ret; | ||
91 | // StaticVariables.TryGetValue(index, out ret); | ||
92 | // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString()); | ||
93 | // LSLStack.Push(ret); | ||
94 | // //return ret; | ||
95 | // } | ||
96 | |||
97 | // public object POPToStack() | ||
98 | // { | ||
99 | // LSOEngine.LSO.Common.SendToDebug("::POPToStack"); | ||
100 | // //return LSLStack.Pop(); | ||
101 | // object p = LSLStack.Pop(); | ||
102 | // if (p.GetType() == typeof (UInt32)) | ||
103 | // return (UInt32) p; | ||
104 | // if (p.GetType() == typeof (string)) | ||
105 | // return (string) p; | ||
106 | // if (p.GetType() == typeof (Int32)) | ||
107 | // return (Int32) p; | ||
108 | // if (p.GetType() == typeof (UInt16)) | ||
109 | // return (UInt16) p; | ||
110 | // if (p.GetType() == typeof (float)) | ||
111 | // return (float) p; | ||
112 | // if (p.GetType() == typeof (LSO_Enums.Vector)) | ||
113 | // return (LSO_Enums.Vector) p; | ||
114 | // if (p.GetType() == typeof (LSO_Enums.Rotation)) | ||
115 | // return (LSO_Enums.Rotation) p; | ||
116 | // if (p.GetType() == typeof (LSO_Enums.Key)) | ||
117 | // return (LSO_Enums.Key) p; | ||
118 | |||
119 | // return p; | ||
120 | // } | ||
121 | |||
122 | // //public object POPToStack(UInt32 count) | ||
123 | // //{ | ||
124 | // // // POP NUMBER FROM TOP OF STACK | ||
125 | // // //LSLStack.SetLength(LSLStack.Length - 4); | ||
126 | // // Common.SendToDebug("::POPToStack " + count); | ||
127 | // // if (count < 2) | ||
128 | // // return LSLStack.Pop(); | ||
129 | |||
130 | // // Stack<object> s = new Stack<object>(); | ||
131 | // // for (int i = 0; i < count; i++) | ||
132 | // // { | ||
133 | // // s.Push(LSLStack.Pop); | ||
134 | |||
135 | // // } | ||
136 | |||
137 | // //} | ||
138 | |||
139 | // public void POP() | ||
140 | // { | ||
141 | // // POP NUMBER FROM TOP OF STACK | ||
142 | // //LSLStack.SetLength(LSLStack.Length - 4); | ||
143 | // LSOEngine.LSO.Common.SendToDebug("::POP"); | ||
144 | // if (LSLStack.Count < 1) | ||
145 | // { | ||
146 | // //TODO: Temporary fix | ||
147 | // LSOEngine.LSO.Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!"); | ||
148 | // } | ||
149 | // else | ||
150 | // { | ||
151 | // LSLStack.Pop(); | ||
152 | // } | ||
153 | // } | ||
154 | |||
155 | // public void PUSH(object Param) | ||
156 | // { | ||
157 | // if (Param == null) | ||
158 | // { | ||
159 | // LSOEngine.LSO.Common.SendToDebug("::PUSH: <null>"); | ||
160 | // } | ||
161 | // else | ||
162 | // { | ||
163 | // //Common.SendToDebug("::PUSH: " + Param.GetType()); | ||
164 | // } | ||
165 | |||
166 | // LSLStack.Push(Param); | ||
167 | // } | ||
168 | |||
169 | // public void ADD(UInt32 Param) | ||
170 | // { | ||
171 | // LSOEngine.LSO.Common.SendToDebug("::ADD: " + Param); | ||
172 | // object o2 = LSLStack.Pop(); | ||
173 | // object o1 = LSLStack.Pop(); | ||
174 | // LSOEngine.LSO.Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + | ||
175 | // " (" + o2.ToString() + ")"); | ||
176 | // if (o2.GetType() == typeof (string)) | ||
177 | // { | ||
178 | // LSLStack.Push((string) o1 + (string) o2); | ||
179 | // return; | ||
180 | // } | ||
181 | // if (o2.GetType() == typeof (UInt32)) | ||
182 | // { | ||
183 | // LSLStack.Push((UInt32) o1 + (UInt32) o2); | ||
184 | // return; | ||
185 | // } | ||
186 | // } | ||
187 | |||
188 | // public void SUB(UInt32 Param) | ||
189 | // { | ||
190 | // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param); | ||
191 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
192 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
193 | // LSLStack.Push((UInt32) (i1 - i2)); | ||
194 | // } | ||
195 | |||
196 | // public void MUL(UInt32 Param) | ||
197 | // { | ||
198 | // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param); | ||
199 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
200 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
201 | // LSLStack.Push((UInt32) (i1*i2)); | ||
202 | // } | ||
203 | |||
204 | // public void DIV(UInt32 Param) | ||
205 | // { | ||
206 | // LSOEngine.LSO.Common.SendToDebug("::DIV: " + Param); | ||
207 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
208 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
209 | // LSLStack.Push((UInt32) (i1/i2)); | ||
210 | // } | ||
211 | |||
212 | |||
213 | // public void MOD(UInt32 Param) | ||
214 | // { | ||
215 | // LSOEngine.LSO.Common.SendToDebug("::MOD: " + Param); | ||
216 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
217 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
218 | // LSLStack.Push((UInt32) (i1%i2)); | ||
219 | // } | ||
220 | |||
221 | // public void EQ(UInt32 Param) | ||
222 | // { | ||
223 | // LSOEngine.LSO.Common.SendToDebug("::EQ: " + Param); | ||
224 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
225 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
226 | // if (i1 == i2) | ||
227 | // { | ||
228 | // LSLStack.Push((UInt32) 1); | ||
229 | // } | ||
230 | // else | ||
231 | // { | ||
232 | // LSLStack.Push((UInt32) 0); | ||
233 | // } | ||
234 | // } | ||
235 | |||
236 | // public void NEQ(UInt32 Param) | ||
237 | // { | ||
238 | // LSOEngine.LSO.Common.SendToDebug("::NEQ: " + Param); | ||
239 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
240 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
241 | // if (i1 != i2) | ||
242 | // { | ||
243 | // LSLStack.Push((UInt32) 1); | ||
244 | // } | ||
245 | // else | ||
246 | // { | ||
247 | // LSLStack.Push((UInt32) 0); | ||
248 | // } | ||
249 | // } | ||
250 | |||
251 | // public void LEQ(UInt32 Param) | ||
252 | // { | ||
253 | // LSOEngine.LSO.Common.SendToDebug("::LEQ: " + Param); | ||
254 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
255 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
256 | // if (i1 <= i2) | ||
257 | // { | ||
258 | // LSLStack.Push((UInt32) 1); | ||
259 | // } | ||
260 | // else | ||
261 | // { | ||
262 | // LSLStack.Push((UInt32) 0); | ||
263 | // } | ||
264 | // } | ||
265 | |||
266 | // public void GEQ(UInt32 Param) | ||
267 | // { | ||
268 | // LSOEngine.LSO.Common.SendToDebug("::GEQ: " + Param); | ||
269 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
270 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
271 | // if (i1 >= i2) | ||
272 | // { | ||
273 | // LSLStack.Push((UInt32) 1); | ||
274 | // } | ||
275 | // else | ||
276 | // { | ||
277 | // LSLStack.Push((UInt32) 0); | ||
278 | // } | ||
279 | // } | ||
280 | |||
281 | // public void LESS(UInt32 Param) | ||
282 | // { | ||
283 | // LSOEngine.LSO.Common.SendToDebug("::LESS: " + Param); | ||
284 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
285 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
286 | // if (i1 < i2) | ||
287 | // { | ||
288 | // LSLStack.Push((UInt32) 1); | ||
289 | // } | ||
290 | // else | ||
291 | // { | ||
292 | // LSLStack.Push((UInt32) 0); | ||
293 | // } | ||
294 | // } | ||
295 | |||
296 | // public void GREATER(UInt32 Param) | ||
297 | // { | ||
298 | // LSOEngine.LSO.Common.SendToDebug("::GREATER: " + Param); | ||
299 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
300 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
301 | // if (i1 > i2) | ||
302 | // { | ||
303 | // LSLStack.Push((UInt32) 1); | ||
304 | // } | ||
305 | // else | ||
306 | // { | ||
307 | // LSLStack.Push((UInt32) 0); | ||
308 | // } | ||
309 | // } | ||
310 | |||
311 | |||
312 | // public void BITAND() | ||
313 | // { | ||
314 | // LSOEngine.LSO.Common.SendToDebug("::BITAND"); | ||
315 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
316 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
317 | // LSLStack.Push((UInt32) (i1 & i2)); | ||
318 | // } | ||
319 | |||
320 | // public void BITOR() | ||
321 | // { | ||
322 | // LSOEngine.LSO.Common.SendToDebug("::BITOR"); | ||
323 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
324 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
325 | // LSLStack.Push((UInt32) (i1 | i2)); | ||
326 | // } | ||
327 | |||
328 | // public void BITXOR() | ||
329 | // { | ||
330 | // LSOEngine.LSO.Common.SendToDebug("::BITXOR"); | ||
331 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
332 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
333 | // LSLStack.Push((UInt32) (i1 ^ i2)); | ||
334 | // } | ||
335 | |||
336 | // public void BOOLAND() | ||
337 | // { | ||
338 | // LSOEngine.LSO.Common.SendToDebug("::BOOLAND"); | ||
339 | // bool b2 = bool.Parse((string) LSLStack.Pop()); | ||
340 | // bool b1 = bool.Parse((string) LSLStack.Pop()); | ||
341 | // if (b1 && b2) | ||
342 | // { | ||
343 | // LSLStack.Push((UInt32) 1); | ||
344 | // } | ||
345 | // else | ||
346 | // { | ||
347 | // LSLStack.Push((UInt32) 0); | ||
348 | // } | ||
349 | // } | ||
350 | |||
351 | // public void BOOLOR() | ||
352 | // { | ||
353 | // LSOEngine.LSO.Common.SendToDebug("::BOOLOR"); | ||
354 | // bool b2 = bool.Parse((string) LSLStack.Pop()); | ||
355 | // bool b1 = bool.Parse((string) LSLStack.Pop()); | ||
356 | |||
357 | // if (b1 || b2) | ||
358 | // { | ||
359 | // LSLStack.Push((UInt32) 1); | ||
360 | // } | ||
361 | // else | ||
362 | // { | ||
363 | // LSLStack.Push((UInt32) 0); | ||
364 | // } | ||
365 | // } | ||
366 | |||
367 | // public void NEG(UInt32 Param) | ||
368 | // { | ||
369 | // LSOEngine.LSO.Common.SendToDebug("::NEG: " + Param); | ||
370 | // //UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
371 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
372 | // LSLStack.Push((UInt32) (i1*-1)); | ||
373 | // } | ||
374 | |||
375 | // public void BITNOT() | ||
376 | // { | ||
377 | // //Common.SendToDebug("::BITNOT"); | ||
378 | // //UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
379 | // //UInt32 i1 = (UInt32)LSLStack.Pop(); | ||
380 | // //LSLStack.Push((UInt32)(i1 / i2)); | ||
381 | // } | ||
382 | |||
383 | // public void BOOLNOT() | ||
384 | // { | ||
385 | // //Common.SendToDebug("::BOOLNOT"); | ||
386 | // ////UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
387 | // //UInt32 i1 = (UInt32)LSLStack.Pop(); | ||
388 | // //LSLStack.Push((UInt32)(i1)); | ||
389 | // } | ||
390 | //} | ||
391 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs deleted file mode 100644 index 99b3376..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
30 | { | ||
31 | public class LSL_CLRInterface | ||
32 | { | ||
33 | public interface LSLScript | ||
34 | { | ||
35 | //public virtual void Run(object arg) | ||
36 | //{ | ||
37 | //} | ||
38 | //void Run(object arg); | ||
39 | |||
40 | //void event_state_entry(object arg); | ||
41 | //void event_state_exit(); | ||
42 | //void event_touch_start(object arg); | ||
43 | //void event_touch(); | ||
44 | //void event_touch_end(); | ||
45 | //void event_collision_start(); | ||
46 | //void event_collision(); | ||
47 | //void event_collision_end(); | ||
48 | //void event_land_collision_start(); | ||
49 | //void event_land_collision(); | ||
50 | //void event_land_collision_end(); | ||
51 | //void event_timer(); | ||
52 | //void event_listen(); | ||
53 | //void event_on_rez(); | ||
54 | //void event_sensor(); | ||
55 | //void event_no_sensor(); | ||
56 | //void event_control(); | ||
57 | //void event_money(); | ||
58 | //void event_email(); | ||
59 | //void event_at_target(); | ||
60 | //void event_not_at_target(); | ||
61 | //void event_at_rot_target(); | ||
62 | //void event_not_at_rot_target(); | ||
63 | //void event_run_time_permissions(); | ||
64 | //void event_changed(); | ||
65 | //void event_attach(); | ||
66 | //void event_dataserver(); | ||
67 | //void event_link_message(); | ||
68 | //void event_moving_start(); | ||
69 | //void event_moving_end(); | ||
70 | //void event_object_rez(); | ||
71 | //void event_remote_data(); | ||
72 | //void event_http_response(); | ||
73 | } | ||
74 | } | ||
75 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs deleted file mode 100644 index 34a784c..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs +++ /dev/null | |||
@@ -1,436 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Reflection.Emit; | ||
32 | using OpenSim.Region.ScriptEngine.Common; | ||
33 | |||
34 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
35 | { | ||
36 | internal partial class LSO_Parser | ||
37 | { | ||
38 | //internal Stack<Type> ILStack = new Stack<Type>(); | ||
39 | //LSO_Enums MyLSO_Enums = new LSO_Enums(); | ||
40 | |||
41 | internal bool LSL_PROCESS_OPCODE(ILGenerator il) | ||
42 | { | ||
43 | byte bp1; | ||
44 | UInt32 u32p1; | ||
45 | float fp1; | ||
46 | UInt16 opcode = br_read(1)[0]; | ||
47 | Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table) opcode).ToString()); | ||
48 | string idesc = ((LSO_Enums.Operation_Table) opcode).ToString(); | ||
49 | switch ((LSO_Enums.Operation_Table) opcode) | ||
50 | { | ||
51 | /*************** | ||
52 | * IMPLEMENTED * | ||
53 | ***************/ | ||
54 | case LSO_Enums.Operation_Table.NOOP: | ||
55 | break; | ||
56 | case LSO_Enums.Operation_Table.PUSHSP: | ||
57 | // Push Stack Top (Memory Address) to stack | ||
58 | Common.SendToDebug("Instruction " + idesc); | ||
59 | Common.SendToDebug("Instruction " + idesc + | ||
60 | ": Description: Pushing Stack Top (Memory Address from header) to stack"); | ||
61 | IL_Push(il, (UInt32) myHeader.SP); | ||
62 | break; | ||
63 | // BYTE | ||
64 | case LSO_Enums.Operation_Table.PUSHARGB: | ||
65 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
66 | break; | ||
67 | // INTEGER | ||
68 | case LSO_Enums.Operation_Table.PUSHARGI: | ||
69 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
70 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); | ||
71 | IL_Push(il, u32p1); | ||
72 | break; | ||
73 | // FLOAT | ||
74 | case LSO_Enums.Operation_Table.PUSHARGF: | ||
75 | fp1 = BitConverter.ToUInt32(br_read(4), 0); | ||
76 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); | ||
77 | IL_Push(il, fp1); | ||
78 | break; | ||
79 | // STRING | ||
80 | case LSO_Enums.Operation_Table.PUSHARGS: | ||
81 | string s = Read_String(); | ||
82 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); | ||
83 | IL_Debug(il, "OPCODE: " + idesc + ":" + s); | ||
84 | IL_Push(il, s); | ||
85 | break; | ||
86 | // VECTOR z,y,x | ||
87 | case LSO_Enums.Operation_Table.PUSHARGV: | ||
88 | LSO_Enums.Vector v = new LSO_Enums.Vector(); | ||
89 | v.Z = BitConverter.ToUInt32(br_read(4), 0); | ||
90 | v.Y = BitConverter.ToUInt32(br_read(4), 0); | ||
91 | v.X = BitConverter.ToUInt32(br_read(4), 0); | ||
92 | Common.SendToDebug("Param1 Z: " + v.Z); | ||
93 | Common.SendToDebug("Param1 Y: " + v.Y); | ||
94 | Common.SendToDebug("Param1 X: " + v.X); | ||
95 | IL_Push(il, v); | ||
96 | break; | ||
97 | // ROTATION s,z,y,x | ||
98 | case LSO_Enums.Operation_Table.PUSHARGQ: | ||
99 | LSO_Enums.Rotation r = new LSO_Enums.Rotation(); | ||
100 | r.S = BitConverter.ToUInt32(br_read(4), 0); | ||
101 | r.Z = BitConverter.ToUInt32(br_read(4), 0); | ||
102 | r.Y = BitConverter.ToUInt32(br_read(4), 0); | ||
103 | r.X = BitConverter.ToUInt32(br_read(4), 0); | ||
104 | Common.SendToDebug("Param1 S: " + r.S); | ||
105 | Common.SendToDebug("Param1 Z: " + r.Z); | ||
106 | Common.SendToDebug("Param1 Y: " + r.Y); | ||
107 | Common.SendToDebug("Param1 X: " + r.X); | ||
108 | IL_Push(il, r); | ||
109 | break; | ||
110 | |||
111 | case LSO_Enums.Operation_Table.PUSHE: | ||
112 | IL_Push(il, (UInt32) 0); | ||
113 | break; | ||
114 | |||
115 | case LSO_Enums.Operation_Table.PUSHARGE: | ||
116 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
117 | Common.SendToDebug("Param1: " + u32p1); | ||
118 | //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); | ||
119 | IL_Push(il, u32p1); | ||
120 | break; | ||
121 | // BYTE | ||
122 | case LSO_Enums.Operation_Table.ADD: | ||
123 | case LSO_Enums.Operation_Table.SUB: | ||
124 | case LSO_Enums.Operation_Table.MUL: | ||
125 | case LSO_Enums.Operation_Table.DIV: | ||
126 | case LSO_Enums.Operation_Table.EQ: | ||
127 | case LSO_Enums.Operation_Table.NEQ: | ||
128 | case LSO_Enums.Operation_Table.LEQ: | ||
129 | case LSO_Enums.Operation_Table.GEQ: | ||
130 | case LSO_Enums.Operation_Table.LESS: | ||
131 | case LSO_Enums.Operation_Table.GREATER: | ||
132 | case LSO_Enums.Operation_Table.NEG: | ||
133 | case LSO_Enums.Operation_Table.MOD: | ||
134 | bp1 = br_read(1)[0]; | ||
135 | Common.SendToDebug("Param1: " + bp1); | ||
136 | IL_CallBaseFunction(il, idesc, (UInt32) bp1); | ||
137 | break; | ||
138 | |||
139 | // NO ARGUMENTS | ||
140 | case LSO_Enums.Operation_Table.BITAND: | ||
141 | case LSO_Enums.Operation_Table.BITOR: | ||
142 | case LSO_Enums.Operation_Table.BITXOR: | ||
143 | case LSO_Enums.Operation_Table.BOOLAND: | ||
144 | case LSO_Enums.Operation_Table.BOOLOR: | ||
145 | case LSO_Enums.Operation_Table.BITNOT: | ||
146 | case LSO_Enums.Operation_Table.BOOLNOT: | ||
147 | IL_CallBaseFunction(il, idesc); | ||
148 | break; | ||
149 | // SHORT | ||
150 | case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: | ||
151 | // TODO: What is size of short? | ||
152 | UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); | ||
153 | Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + | ||
154 | ((LSO_Enums.BuiltIn_Functions) U16p1).ToString()); | ||
155 | //Common.SendToDebug("Param1: " + U16p1); | ||
156 | string fname = ((LSO_Enums.BuiltIn_Functions) U16p1).ToString(); | ||
157 | |||
158 | bool cmdFound = false; | ||
159 | foreach (MethodInfo mi in typeof (LSL_BuiltIn_Commands_Interface).GetMethods()) | ||
160 | { | ||
161 | // Found command | ||
162 | if (mi.Name == fname) | ||
163 | { | ||
164 | il.Emit(OpCodes.Ldarg_0); | ||
165 | il.Emit(OpCodes.Call, typeof (BuiltIn_Commands_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] {})); | ||
166 | // Pop required number of items from my stack to .Net stack | ||
167 | IL_PopToStack(il, mi.GetParameters().Length); | ||
168 | il.Emit(OpCodes.Callvirt, mi); | ||
169 | cmdFound = true; | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | if (cmdFound == false) | ||
174 | { | ||
175 | Common.SendToDebug("ERROR: UNABLE TO LOCATE OPCODE " + idesc + " IN BASECLASS"); | ||
176 | } | ||
177 | |||
178 | break; | ||
179 | |||
180 | // RETURN | ||
181 | case LSO_Enums.Operation_Table.RETURN: | ||
182 | |||
183 | Common.SendToDebug("OPCODE: RETURN"); | ||
184 | return true; | ||
185 | |||
186 | case LSO_Enums.Operation_Table.POP: | ||
187 | case LSO_Enums.Operation_Table.POPS: | ||
188 | case LSO_Enums.Operation_Table.POPL: | ||
189 | case LSO_Enums.Operation_Table.POPV: | ||
190 | case LSO_Enums.Operation_Table.POPQ: | ||
191 | // Pops a specific datatype from the stack | ||
192 | // We just ignore the datatype for now | ||
193 | IL_Pop(il); | ||
194 | break; | ||
195 | |||
196 | // LONG | ||
197 | case LSO_Enums.Operation_Table.STORE: | ||
198 | case LSO_Enums.Operation_Table.STORES: | ||
199 | case LSO_Enums.Operation_Table.STOREL: | ||
200 | case LSO_Enums.Operation_Table.STOREV: | ||
201 | case LSO_Enums.Operation_Table.STOREQ: | ||
202 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
203 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
204 | IL_CallBaseFunction(il, "StoreToLocal", u32p1); | ||
205 | break; | ||
206 | |||
207 | case LSO_Enums.Operation_Table.STOREG: | ||
208 | case LSO_Enums.Operation_Table.STOREGS: | ||
209 | case LSO_Enums.Operation_Table.STOREGL: | ||
210 | case LSO_Enums.Operation_Table.STOREGV: | ||
211 | case LSO_Enums.Operation_Table.STOREGQ: | ||
212 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
213 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
214 | IL_CallBaseFunction(il, "StoreToGlobal", u32p1); | ||
215 | break; | ||
216 | |||
217 | case LSO_Enums.Operation_Table.LOADP: | ||
218 | case LSO_Enums.Operation_Table.LOADSP: | ||
219 | case LSO_Enums.Operation_Table.LOADLP: | ||
220 | case LSO_Enums.Operation_Table.LOADVP: | ||
221 | case LSO_Enums.Operation_Table.LOADQP: | ||
222 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
223 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
224 | IL_CallBaseFunction(il, "StoreToLocal", u32p1); | ||
225 | IL_Pop(il); | ||
226 | break; | ||
227 | |||
228 | case LSO_Enums.Operation_Table.LOADGP: | ||
229 | case LSO_Enums.Operation_Table.LOADGSP: | ||
230 | case LSO_Enums.Operation_Table.LOADGLP: | ||
231 | case LSO_Enums.Operation_Table.LOADGVP: | ||
232 | case LSO_Enums.Operation_Table.LOADGQP: | ||
233 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
234 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
235 | IL_CallBaseFunction(il, "StoreToStatic", u32p1 - 6 + myHeader.GVR); | ||
236 | IL_Pop(il); | ||
237 | break; | ||
238 | |||
239 | // PUSH FROM LOCAL FRAME | ||
240 | case LSO_Enums.Operation_Table.PUSH: | ||
241 | case LSO_Enums.Operation_Table.PUSHS: | ||
242 | case LSO_Enums.Operation_Table.PUSHL: | ||
243 | case LSO_Enums.Operation_Table.PUSHV: | ||
244 | case LSO_Enums.Operation_Table.PUSHQ: | ||
245 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
246 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
247 | IL_CallBaseFunction(il, "GetFromLocal", u32p1); | ||
248 | |||
249 | break; | ||
250 | |||
251 | // PUSH FROM STATIC FRAME | ||
252 | case LSO_Enums.Operation_Table.PUSHG: | ||
253 | case LSO_Enums.Operation_Table.PUSHGS: | ||
254 | case LSO_Enums.Operation_Table.PUSHGL: | ||
255 | case LSO_Enums.Operation_Table.PUSHGV: | ||
256 | case LSO_Enums.Operation_Table.PUSHGQ: | ||
257 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
258 | Common.SendToDebug("Param1: " + u32p1.ToString()); | ||
259 | IL_CallBaseFunction(il, "GetFromStatic", u32p1 - 6 + myHeader.GVR); | ||
260 | break; | ||
261 | |||
262 | |||
263 | /*********************** | ||
264 | * NOT IMPLEMENTED YET * | ||
265 | ***********************/ | ||
266 | |||
267 | |||
268 | case LSO_Enums.Operation_Table.POPIP: | ||
269 | case LSO_Enums.Operation_Table.POPSP: | ||
270 | case LSO_Enums.Operation_Table.POPSLR: | ||
271 | case LSO_Enums.Operation_Table.POPARG: | ||
272 | case LSO_Enums.Operation_Table.POPBP: | ||
273 | //Common.SendToDebug("Instruction " + idesc + ": Ignored"); | ||
274 | Common.SendToDebug("Instruction " + idesc + | ||
275 | ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); | ||
276 | //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
277 | IL_Pop(il); | ||
278 | break; | ||
279 | |||
280 | |||
281 | // None | ||
282 | case LSO_Enums.Operation_Table.PUSHIP: | ||
283 | // PUSH INSTRUCTION POINTER | ||
284 | break; | ||
285 | case LSO_Enums.Operation_Table.PUSHBP: | ||
286 | |||
287 | case LSO_Enums.Operation_Table.PUSHEV: | ||
288 | break; | ||
289 | case LSO_Enums.Operation_Table.PUSHEQ: | ||
290 | break; | ||
291 | |||
292 | |||
293 | // LONG | ||
294 | case LSO_Enums.Operation_Table.JUMP: | ||
295 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
296 | break; | ||
297 | // BYTE, LONG | ||
298 | case LSO_Enums.Operation_Table.JUMPIF: | ||
299 | case LSO_Enums.Operation_Table.JUMPNIF: | ||
300 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
301 | Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
302 | break; | ||
303 | // LONG | ||
304 | case LSO_Enums.Operation_Table.STATE: | ||
305 | bp1 = br_read(1)[0]; | ||
306 | //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack | ||
307 | //il.Emit(OpCodes.Ldc_I4, 0); // Push index position | ||
308 | //il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value | ||
309 | //il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value | ||
310 | break; | ||
311 | case LSO_Enums.Operation_Table.CALL: | ||
312 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
313 | Common.SendToDebug("ERROR: Function CALL not implemented yet."); | ||
314 | break; | ||
315 | // BYTE | ||
316 | case LSO_Enums.Operation_Table.CAST: | ||
317 | bp1 = br_read(1)[0]; | ||
318 | Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + | ||
319 | ((LSO_Enums.OpCode_Cast_TypeDefs) bp1)); | ||
320 | Common.SendToDebug("Param1: " + bp1); | ||
321 | switch ((LSO_Enums.OpCode_Cast_TypeDefs) bp1) | ||
322 | { | ||
323 | case LSO_Enums.OpCode_Cast_TypeDefs.String: | ||
324 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); | ||
325 | break; | ||
326 | default: | ||
327 | Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!"); | ||
328 | break; | ||
329 | } | ||
330 | break; | ||
331 | // LONG | ||
332 | case LSO_Enums.Operation_Table.STACKTOS: | ||
333 | case LSO_Enums.Operation_Table.STACKTOL: | ||
334 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
335 | break; | ||
336 | // BYTE | ||
337 | case LSO_Enums.Operation_Table.PRINT: | ||
338 | case LSO_Enums.Operation_Table.CALLLIB: | ||
339 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
340 | break; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | // TODO: unused | ||
346 | // private void IL_PopToStack(ILGenerator il) | ||
347 | // { | ||
348 | // IL_PopToStack(il, 1); | ||
349 | // } | ||
350 | |||
351 | private void IL_PopToStack(ILGenerator il, int count) | ||
352 | { | ||
353 | Common.SendToDebug("IL_PopToStack();"); | ||
354 | for (int i = 0; i < count; i++) | ||
355 | { | ||
356 | IL_CallBaseFunction(il, "POPToStack"); | ||
357 | //il.Emit(OpCodes.Ldarg_0); | ||
358 | //il.Emit(OpCodes.Call, | ||
359 | // typeof(LSL_BaseClass).GetMethod("POPToStack", | ||
360 | // new Type[] { })); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | private void IL_Pop(ILGenerator il) | ||
365 | { | ||
366 | Common.SendToDebug("IL_Pop();"); | ||
367 | IL_CallBaseFunction(il, "POP"); | ||
368 | } | ||
369 | |||
370 | private void IL_Debug(ILGenerator il, string text) | ||
371 | { | ||
372 | il.Emit(OpCodes.Ldstr, text); | ||
373 | il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug", | ||
374 | new Type[] {typeof (string)} | ||
375 | )); | ||
376 | } | ||
377 | |||
378 | private void IL_CallBaseFunction(ILGenerator il, string methodname) | ||
379 | { | ||
380 | il.Emit(OpCodes.Ldarg_0); | ||
381 | il.Emit(OpCodes.Call, typeof (BuiltIn_Commands_BaseClass).GetMethod(methodname, new Type[] {})); | ||
382 | } | ||
383 | |||
384 | private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) | ||
385 | { | ||
386 | il.Emit(OpCodes.Ldarg_0); | ||
387 | if (data.GetType() == typeof (string)) | ||
388 | il.Emit(OpCodes.Ldstr, (string) data); | ||
389 | if (data.GetType() == typeof (UInt32)) | ||
390 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); | ||
391 | il.Emit(OpCodes.Call, typeof (BuiltIn_Commands_BaseClass).GetMethod(methodname, new Type[] {data.GetType()})); | ||
392 | } | ||
393 | |||
394 | private void IL_Push(ILGenerator il, object data) | ||
395 | { | ||
396 | il.Emit(OpCodes.Ldarg_0); | ||
397 | Common.SendToDebug("PUSH datatype: " + data.GetType()); | ||
398 | |||
399 | IL_PushDataTypeToILStack(il, data); | ||
400 | |||
401 | il.Emit(OpCodes.Call, typeof (BuiltIn_Commands_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()})); | ||
402 | } | ||
403 | |||
404 | private void IL_PushDataTypeToILStack(ILGenerator il, object data) | ||
405 | { | ||
406 | if (data.GetType() == typeof (UInt16)) | ||
407 | { | ||
408 | il.Emit(OpCodes.Ldc_I4, (UInt16) data); | ||
409 | il.Emit(OpCodes.Box, data.GetType()); | ||
410 | } | ||
411 | if (data.GetType() == typeof (UInt32)) | ||
412 | { | ||
413 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); | ||
414 | il.Emit(OpCodes.Box, data.GetType()); | ||
415 | } | ||
416 | if (data.GetType() == typeof (Int32)) | ||
417 | { | ||
418 | il.Emit(OpCodes.Ldc_I4, (Int32) data); | ||
419 | il.Emit(OpCodes.Box, data.GetType()); | ||
420 | } | ||
421 | if (data.GetType() == typeof (float)) | ||
422 | { | ||
423 | il.Emit(OpCodes.Ldc_I4, (float) data); | ||
424 | il.Emit(OpCodes.Box, data.GetType()); | ||
425 | } | ||
426 | if (data.GetType() == typeof (string)) | ||
427 | il.Emit(OpCodes.Ldstr, (string) data); | ||
428 | //if (data.GetType() == typeof(LSO_Enums.Rotation)) | ||
429 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); | ||
430 | //if (data.GetType() == typeof(LSO_Enums.Vector)) | ||
431 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); | ||
432 | //if (data.GetType() == typeof(LSO_Enums.Key)) | ||
433 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); | ||
434 | } | ||
435 | } | ||
436 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs deleted file mode 100644 index c721267..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs +++ /dev/null | |||
@@ -1,564 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | using System; | ||
30 | |||
31 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
32 | { | ||
33 | public static class LSO_Enums | ||
34 | { | ||
35 | //public System.Collections.Generic.Dictionary<Byte, Type> OpCode_Add_Types; | ||
36 | |||
37 | //LSO_Enums() | ||
38 | //{ | ||
39 | // OpCode_Add_Types.Add(51, typeof(String)); | ||
40 | // OpCode_Add_Types.Add(17, typeof(UInt32)); | ||
41 | //} | ||
42 | |||
43 | [Serializable] | ||
44 | public enum OpCode_Add_TypeDefs | ||
45 | { | ||
46 | String = 51, | ||
47 | UInt32 = 17 | ||
48 | } | ||
49 | |||
50 | [Serializable] | ||
51 | public enum OpCode_Cast_TypeDefs | ||
52 | { | ||
53 | String = 19 | ||
54 | } | ||
55 | |||
56 | [Serializable] | ||
57 | public struct Key | ||
58 | { | ||
59 | public string KeyString; | ||
60 | } | ||
61 | |||
62 | [Serializable] | ||
63 | public struct Vector | ||
64 | { | ||
65 | public UInt32 Z; | ||
66 | public UInt32 Y; | ||
67 | public UInt32 X; | ||
68 | } | ||
69 | |||
70 | [Serializable] | ||
71 | public struct Rotation | ||
72 | { | ||
73 | public UInt32 S; | ||
74 | public UInt32 Z; | ||
75 | public UInt32 Y; | ||
76 | public UInt32 X; | ||
77 | } | ||
78 | |||
79 | [Serializable] | ||
80 | public enum Variable_Type_Codes | ||
81 | { | ||
82 | Void = 0, | ||
83 | Integer = 1, | ||
84 | Float = 2, | ||
85 | String = 3, | ||
86 | Key = 4, | ||
87 | Vector = 5, | ||
88 | Rotation = 6, | ||
89 | List = 7, | ||
90 | Null = 8 | ||
91 | } | ||
92 | |||
93 | [Serializable] | ||
94 | public enum Event_Mask_Values | ||
95 | { | ||
96 | state_entry = 0, | ||
97 | state_exit = 1, | ||
98 | touch_start = 2, | ||
99 | touch = 3, | ||
100 | touch_end = 4, | ||
101 | collision_start = 5, | ||
102 | collision = 6, | ||
103 | collision_end = 7, | ||
104 | land_collision_start = 8, | ||
105 | land_collision = 9, | ||
106 | land_collision_end = 10, | ||
107 | timer = 11, | ||
108 | listen = 12, | ||
109 | on_rez = 13, | ||
110 | sensor = 14, | ||
111 | no_sensor = 15, | ||
112 | control = 16, | ||
113 | money = 17, | ||
114 | email = 18, | ||
115 | at_target = 19, | ||
116 | not_at_target = 20, | ||
117 | at_rot_target = 21, | ||
118 | not_at_rot_target = 22, | ||
119 | run_time_permissions = 23, | ||
120 | changed = 24, | ||
121 | attach = 25, | ||
122 | dataserver = 26, | ||
123 | link_message = 27, | ||
124 | moving_start = 28, | ||
125 | moving_end = 29, | ||
126 | object_rez = 30, | ||
127 | remote_data = 31, | ||
128 | http_response = 32 | ||
129 | } | ||
130 | |||
131 | [Serializable] | ||
132 | public enum Operation_Table | ||
133 | { | ||
134 | NOOP = 0x0, | ||
135 | POP = 0x1, | ||
136 | POPS = 0x2, | ||
137 | POPL = 0x3, | ||
138 | POPV = 0x4, | ||
139 | POPQ = 0x5, | ||
140 | POPARG = 0x6, | ||
141 | POPIP = 0x7, | ||
142 | POPBP = 0x8, | ||
143 | POPSP = 0x9, | ||
144 | POPSLR = 0xa, | ||
145 | DUP = 0x20, | ||
146 | DUPS = 0x21, | ||
147 | DUPL = 0x22, | ||
148 | DUPV = 0x23, | ||
149 | DUPQ = 0x24, | ||
150 | STORE = 0x30, | ||
151 | STORES = 0x31, | ||
152 | STOREL = 0x32, | ||
153 | STOREV = 0x33, | ||
154 | STOREQ = 0x34, | ||
155 | STOREG = 0x35, | ||
156 | STOREGS = 0x36, | ||
157 | STOREGL = 0x37, | ||
158 | STOREGV = 0x38, | ||
159 | STOREGQ = 0x39, | ||
160 | LOADP = 0x3a, | ||
161 | LOADSP = 0x3b, | ||
162 | LOADLP = 0x3c, | ||
163 | LOADVP = 0x3d, | ||
164 | LOADQP = 0x3e, | ||
165 | LOADGP = 0x3f, | ||
166 | LOADGSP = 0x40, | ||
167 | LOADGLP = 0x41, | ||
168 | LOADGVP = 0x42, | ||
169 | LOADGQP = 0x43, | ||
170 | PUSH = 0x50, | ||
171 | PUSHS = 0x51, | ||
172 | PUSHL = 0x52, | ||
173 | PUSHV = 0x53, | ||
174 | PUSHQ = 0x54, | ||
175 | PUSHG = 0x55, | ||
176 | PUSHGS = 0x56, | ||
177 | PUSHGL = 0x57, | ||
178 | PUSHGV = 0x58, | ||
179 | PUSHGQ = 0x59, | ||
180 | PUSHIP = 0x5a, | ||
181 | PUSHBP = 0x5b, | ||
182 | PUSHSP = 0x5c, | ||
183 | PUSHARGB = 0x5d, | ||
184 | PUSHARGI = 0x5e, | ||
185 | PUSHARGF = 0x5f, | ||
186 | PUSHARGS = 0x60, | ||
187 | PUSHARGV = 0x61, | ||
188 | PUSHARGQ = 0x62, | ||
189 | PUSHE = 0x63, | ||
190 | PUSHEV = 0x64, | ||
191 | PUSHEQ = 0x65, | ||
192 | PUSHARGE = 0x66, | ||
193 | ADD = 0x70, | ||
194 | SUB = 0x71, | ||
195 | MUL = 0x72, | ||
196 | DIV = 0x73, | ||
197 | MOD = 0x74, | ||
198 | EQ = 0x75, | ||
199 | NEQ = 0x76, | ||
200 | LEQ = 0x77, | ||
201 | GEQ = 0x78, | ||
202 | LESS = 0x79, | ||
203 | GREATER = 0x7a, | ||
204 | BITAND = 0x7b, | ||
205 | BITOR = 0x7c, | ||
206 | BITXOR = 0x7d, | ||
207 | BOOLAND = 0x7e, | ||
208 | BOOLOR = 0x7f, | ||
209 | NEG = 0x80, | ||
210 | BITNOT = 0x81, | ||
211 | BOOLNOT = 0x82, | ||
212 | JUMP = 0x90, | ||
213 | JUMPIF = 0x91, | ||
214 | JUMPNIF = 0x92, | ||
215 | STATE = 0x93, | ||
216 | CALL = 0x94, | ||
217 | RETURN = 0x95, | ||
218 | CAST = 0xa0, | ||
219 | STACKTOS = 0xb0, | ||
220 | STACKTOL = 0xb1, | ||
221 | PRINT = 0xc0, | ||
222 | CALLLIB = 0xd0, | ||
223 | CALLLIB_TWO_BYTE = 0xd1, | ||
224 | SHL = 0xe0, | ||
225 | SHR = 0xe1 | ||
226 | } | ||
227 | |||
228 | [Serializable] | ||
229 | public enum BuiltIn_Functions | ||
230 | { | ||
231 | llSin = 0, | ||
232 | llCos = 1, | ||
233 | llTan = 2, | ||
234 | llAtan2 = 3, | ||
235 | llSqrt = 4, | ||
236 | llPow = 5, | ||
237 | llAbs = 6, | ||
238 | llFabs = 7, | ||
239 | llFrand = 8, | ||
240 | llFloor = 9, | ||
241 | llCeil = 10, | ||
242 | llRound = 11, | ||
243 | llVecMag = 12, | ||
244 | llVecNorm = 13, | ||
245 | llVecDist = 14, | ||
246 | llRot2Euler = 15, | ||
247 | llEuler2Rot = 16, | ||
248 | llAxes2Rot = 17, | ||
249 | llRot2Fwd = 18, | ||
250 | llRot2Left = 19, | ||
251 | llRot2Up = 20, | ||
252 | llRotBetween = 21, | ||
253 | llWhisper = 22, | ||
254 | llSay = 23, | ||
255 | llShout = 24, | ||
256 | llListen = 25, | ||
257 | llListenControl = 26, | ||
258 | llListenRemove = 27, | ||
259 | llSensor = 28, | ||
260 | llSensorRepeat = 29, | ||
261 | llSensorRemove = 30, | ||
262 | llDetectedName = 31, | ||
263 | llDetectedKey = 32, | ||
264 | llDetectedOwner = 33, | ||
265 | llDetectedType = 34, | ||
266 | llDetectedPos = 35, | ||
267 | llDetectedVel = 36, | ||
268 | llDetectedGrab = 37, | ||
269 | llDetectedRot = 38, | ||
270 | llDetectedGroup = 39, | ||
271 | llDetectedLinkNumber = 40, | ||
272 | llDie = 41, | ||
273 | llGround = 42, | ||
274 | llCloud = 43, | ||
275 | llWind = 44, | ||
276 | llSetStatus = 45, | ||
277 | llGetStatus = 46, | ||
278 | llSetScale = 47, | ||
279 | llGetScale = 48, | ||
280 | llSetColor = 49, | ||
281 | llGetAlpha = 50, | ||
282 | llSetAlpha = 51, | ||
283 | llGetColor = 52, | ||
284 | llSetTexture = 53, | ||
285 | llScaleTexture = 54, | ||
286 | llOffsetTexture = 55, | ||
287 | llRotateTexture = 56, | ||
288 | llGetTexture = 57, | ||
289 | llSetPos = 58, | ||
290 | llGetPos = 59, | ||
291 | llGetLocalPos = 60, | ||
292 | llSetRot = 61, | ||
293 | llGetRot = 62, | ||
294 | llGetLocalRot = 63, | ||
295 | llSetForce = 64, | ||
296 | llGetForce = 65, | ||
297 | llTarget = 66, | ||
298 | llTargetRemove = 67, | ||
299 | llRotTarget = 68, | ||
300 | llRotTargetRemove = 69, | ||
301 | llMoveToTarget = 70, | ||
302 | llStopMoveToTarget = 71, | ||
303 | llApplyImpulse = 72, | ||
304 | llApplyRotationalImpulse = 73, | ||
305 | llSetTorque = 74, | ||
306 | llGetTorque = 75, | ||
307 | llSetForceAndTorque = 76, | ||
308 | llGetVel = 77, | ||
309 | llGetAccel = 78, | ||
310 | llGetOmega = 79, | ||
311 | llGetTimeOfDay = 80, | ||
312 | llGetWallclock = 81, | ||
313 | llGetTime = 82, | ||
314 | llResetTime = 83, | ||
315 | llGetAndResetTime = 84, | ||
316 | llSound = 85, | ||
317 | llPlaySound = 86, | ||
318 | llLoopSound = 87, | ||
319 | llLoopSoundMaster = 88, | ||
320 | llLoopSoundSlave = 89, | ||
321 | llPlaySoundSlave = 90, | ||
322 | llTriggerSound = 91, | ||
323 | llStopSound = 92, | ||
324 | llPreloadSound = 93, | ||
325 | llGetSubString = 94, | ||
326 | llDeleteSubString = 95, | ||
327 | llInsertString = 96, | ||
328 | llToUpper = 97, | ||
329 | llToLower = 98, | ||
330 | llGiveMoney = 99, | ||
331 | llMakeExplosion = 100, | ||
332 | llMakeFountain = 101, | ||
333 | llMakeSmoke = 102, | ||
334 | llMakeFire = 103, | ||
335 | llRezObject = 104, | ||
336 | llLookAt = 105, | ||
337 | llStopLookAt = 106, | ||
338 | llSetTimerEvent = 107, | ||
339 | llSleep = 108, | ||
340 | llGetMass = 109, | ||
341 | llCollisionFilter = 110, | ||
342 | llTakeControls = 111, | ||
343 | llReleaseControls = 112, | ||
344 | llAttachToAvatar = 113, | ||
345 | llDetachFromAvatar = 114, | ||
346 | llTakeCamera = 115, | ||
347 | llReleaseCamera = 116, | ||
348 | llGetOwner = 117, | ||
349 | llInstantMessage = 118, | ||
350 | llEmail = 119, | ||
351 | llGetNextEmail = 120, | ||
352 | llGetKey = 121, | ||
353 | llSetBuoyancy = 122, | ||
354 | llSetHoverHeight = 123, | ||
355 | llStopHover = 124, | ||
356 | llMinEventDelay = 125, | ||
357 | llSoundPreload = 126, | ||
358 | llRotLookAt = 127, | ||
359 | llStringLength = 128, | ||
360 | llStartAnimation = 129, | ||
361 | llStopAnimation = 130, | ||
362 | llPointAt = 131, | ||
363 | llStopPointAt = 132, | ||
364 | llTargetOmega = 133, | ||
365 | llGetStartParameter = 134, | ||
366 | llGodLikeRezObject = 135, | ||
367 | llRequestPermissions = 136, | ||
368 | llGetPermissionsKey = 137, | ||
369 | llGetPermissions = 138, | ||
370 | llGetLinkNumber = 139, | ||
371 | llSetLinkColor = 140, | ||
372 | llCreateLink = 141, | ||
373 | llBreakLink = 142, | ||
374 | llBreakAllLinks = 143, | ||
375 | llGetLinkKey = 144, | ||
376 | llGetLinkName = 145, | ||
377 | llGetInventoryNumber = 146, | ||
378 | llGetInventoryName = 147, | ||
379 | llSetScriptState = 148, | ||
380 | llGetEnergy = 149, | ||
381 | llGiveInventory = 150, | ||
382 | llRemoveInventory = 151, | ||
383 | llSetText = 152, | ||
384 | llWater = 153, | ||
385 | llPassTouches = 154, | ||
386 | llRequestAgentData = 155, | ||
387 | llRequestInventoryData = 156, | ||
388 | llSetDamage = 157, | ||
389 | llTeleportAgentHome = 158, | ||
390 | llModifyLand = 159, | ||
391 | llCollisionSound = 160, | ||
392 | llCollisionSprite = 161, | ||
393 | llGetAnimation = 162, | ||
394 | llResetScript = 163, | ||
395 | llMessageLinked = 164, | ||
396 | llPushObject = 165, | ||
397 | llPassCollisions = 166, | ||
398 | llGetScriptName = 167, | ||
399 | llGetNumberOfSides = 168, | ||
400 | llAxisAngle2Rot = 169, | ||
401 | llRot2Axis = 170, | ||
402 | llRot2Angle = 171, | ||
403 | llAcos = 172, | ||
404 | llAsin = 173, | ||
405 | llAngleBetween = 174, | ||
406 | llGetInventoryKey = 175, | ||
407 | llAllowInventoryDrop = 176, | ||
408 | llGetSunDirection = 177, | ||
409 | llGetTextureOffset = 178, | ||
410 | llGetTextureScale = 179, | ||
411 | llGetTextureRot = 180, | ||
412 | llSubStringIndex = 181, | ||
413 | llGetOwnerKey = 182, | ||
414 | llGetCenterOfMass = 183, | ||
415 | llListSort = 184, | ||
416 | llGetListLength = 185, | ||
417 | llList2Integer = 186, | ||
418 | llList2Float = 187, | ||
419 | llList2String = 188, | ||
420 | llList2Key = 189, | ||
421 | llList2Vector = 190, | ||
422 | llList2Rot = 191, | ||
423 | llList2List = 192, | ||
424 | llDeleteSubList = 193, | ||
425 | llGetListEntryType = 194, | ||
426 | llList2CSV = 195, | ||
427 | llCSV2List = 196, | ||
428 | llListRandomize = 197, | ||
429 | llList2ListStrided = 198, | ||
430 | llGetRegionCorner = 199, | ||
431 | llListInsertList = 200, | ||
432 | llListFindList = 201, | ||
433 | llGetObjectName = 202, | ||
434 | llSetObjectName = 203, | ||
435 | llGetDate = 204, | ||
436 | llEdgeOfWorld = 205, | ||
437 | llGetAgentInfo = 206, | ||
438 | llAdjustSoundVolume = 207, | ||
439 | llSetSoundQueueing = 208, | ||
440 | llSetSoundRadius = 209, | ||
441 | llKey2Name = 210, | ||
442 | llSetTextureAnim = 211, | ||
443 | llTriggerSoundLimited = 212, | ||
444 | llEjectFromLand = 213, | ||
445 | llParseString2List = 214, | ||
446 | llOverMyLand = 215, | ||
447 | llGetLandOwnerAt = 216, | ||
448 | llGetNotecardLine = 217, | ||
449 | llGetAgentSize = 218, | ||
450 | llSameGroup = 219, | ||
451 | llUnSit = 220, | ||
452 | llGroundSlope = 221, | ||
453 | llGroundNormal = 222, | ||
454 | llGroundContour = 223, | ||
455 | llGetAttached = 224, | ||
456 | llGetFreeMemory = 225, | ||
457 | llGetRegionName = 226, | ||
458 | llGetRegionTimeDilation = 227, | ||
459 | llGetRegionFPS = 228, | ||
460 | llParticleSystem = 229, | ||
461 | llGroundRepel = 230, | ||
462 | llGiveInventoryList = 231, | ||
463 | llSetVehicleType = 232, | ||
464 | llSetVehicleFloatParam = 233, | ||
465 | llSetVehicleVectorParam = 234, | ||
466 | llSetVehicleRotationParam = 235, | ||
467 | llSetVehicleFlags = 236, | ||
468 | llRemoveVehicleFlags = 237, | ||
469 | llSitTarget = 238, | ||
470 | llAvatarOnSitTarget = 239, | ||
471 | llAddToLandPassList = 240, | ||
472 | llSetTouchText = 241, | ||
473 | llSetSitText = 242, | ||
474 | llSetCameraEyeOffset = 243, | ||
475 | llSetCameraAtOffset = 244, | ||
476 | llDumpList2String = 245, | ||
477 | llScriptDanger = 246, | ||
478 | llDialog = 247, | ||
479 | llVolumeDetect = 248, | ||
480 | llResetOtherScript = 249, | ||
481 | llGetScriptState = 250, | ||
482 | llRemoteLoadScript = 251, | ||
483 | llSetRemoteScriptAccessPin = 252, | ||
484 | llRemoteLoadScriptPin = 253, | ||
485 | llOpenRemoteDataChannel = 254, | ||
486 | llSendRemoteData = 255, | ||
487 | llRemoteDataReply = 256, | ||
488 | llCloseRemoteDataChannel = 257, | ||
489 | llMD5String = 258, | ||
490 | llSetPrimitiveParams = 259, | ||
491 | llStringToBase64 = 260, | ||
492 | llBase64ToString = 261, | ||
493 | llXorBase64Strings = 262, | ||
494 | llRemoteDataSetRegion = 263, | ||
495 | llLog10 = 264, | ||
496 | llLog = 265, | ||
497 | llGetAnimationList = 266, | ||
498 | llSetParcelMusicURL = 267, | ||
499 | llGetRootPosition = 268, | ||
500 | llGetRootRotation = 269, | ||
501 | llGetObjectDesc = 270, | ||
502 | llSetObjectDesc = 271, | ||
503 | llGetCreator = 272, | ||
504 | llGetTimestamp = 273, | ||
505 | llSetLinkAlpha = 274, | ||
506 | llGetNumberOfPrims = 275, | ||
507 | llGetNumberOfNotecardLines = 276, | ||
508 | llGetBoundingBox = 277, | ||
509 | llGetGeometricCenter = 278, | ||
510 | llGetPrimitiveParams = 279, | ||
511 | llIntegerToBase64 = 280, | ||
512 | llBase64ToInteger = 281, | ||
513 | llGetGMTclock = 282, | ||
514 | llGetSimulatorHostname = 283, | ||
515 | llSetLocalRot = 284, | ||
516 | llParseStringKeepNulls = 285, | ||
517 | llRezAtRoot = 286, | ||
518 | llGetObjectPermMask = 287, | ||
519 | llSetObjectPermMask = 288, | ||
520 | llGetInventoryPermMask = 289, | ||
521 | llSetInventoryPermMask = 290, | ||
522 | llGetInventoryCreator = 291, | ||
523 | llOwnerSay = 292, | ||
524 | llRequestSimulatorData = 293, | ||
525 | llForceMouselook = 294, | ||
526 | llGetObjectMass = 295, | ||
527 | llListReplaceList = 296, | ||
528 | llLoadURL = 297, | ||
529 | llParcelMediaCommandList = 298, | ||
530 | llParcelMediaQuery = 299, | ||
531 | llModPow = 300, | ||
532 | llGetInventoryType = 301, | ||
533 | llSetPayPrice = 302, | ||
534 | llGetCameraPos = 303, | ||
535 | llGetCameraRot = 304, | ||
536 | llSetPrimURL = 305, | ||
537 | llRefreshPrimURL = 306, | ||
538 | llEscapeURL = 307, | ||
539 | llUnescapeURL = 308, | ||
540 | llMapDestination = 309, | ||
541 | llAddToLandBanList = 310, | ||
542 | llRemoveFromLandPassList = 311, | ||
543 | llRemoveFromLandBanList = 312, | ||
544 | llSetCameraParams = 313, | ||
545 | llClearCameraParams = 314, | ||
546 | llListStatistics = 315, | ||
547 | llGetUnixTime = 316, | ||
548 | llGetParcelFlags = 317, | ||
549 | llGetRegionFlags = 318, | ||
550 | llXorBase64StringsCorrect = 319, | ||
551 | llHTTPRequest = 320, | ||
552 | llResetLandBanList = 321, | ||
553 | llResetLandPassList = 322, | ||
554 | llGetParcelPrimCount = 323, | ||
555 | llGetParcelPrimOwners = 324, | ||
556 | llGetObjectPrimCount = 325, | ||
557 | llGetParcelMaxPrims = 326, | ||
558 | llGetParcelDetails = 327, | ||
559 | llSetLinkTexture = 328, | ||
560 | llStringTrim = 329, | ||
561 | llGetObjectDetails = 330 | ||
562 | } | ||
563 | } | ||
564 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs deleted file mode 100644 index b2a2f25..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs +++ /dev/null | |||
@@ -1,703 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.IO; | ||
33 | using System.Reflection; | ||
34 | using System.Reflection.Emit; | ||
35 | using System.Text; | ||
36 | |||
37 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
38 | { | ||
39 | internal partial class LSO_Parser | ||
40 | { | ||
41 | private string FileName; | ||
42 | private FileStream fs; | ||
43 | private BinaryReader br; | ||
44 | internal LSO_Struct.Header myHeader; | ||
45 | internal Dictionary<long, LSO_Struct.StaticBlock> StaticBlocks = new Dictionary<long, LSO_Struct.StaticBlock>(); | ||
46 | //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable(); | ||
47 | |||
48 | private TypeBuilder typeBuilder; | ||
49 | private List<string> EventList = new List<string>(); | ||
50 | |||
51 | public LSO_Parser(string _FileName, TypeBuilder _typeBuilder) | ||
52 | { | ||
53 | FileName = _FileName; | ||
54 | typeBuilder = _typeBuilder; | ||
55 | } | ||
56 | |||
57 | internal void OpenFile() | ||
58 | { | ||
59 | // Open | ||
60 | Common.SendToDebug("Opening filename: " + FileName); | ||
61 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); | ||
62 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); | ||
63 | } | ||
64 | |||
65 | internal void CloseFile() | ||
66 | { | ||
67 | // Close | ||
68 | br.Close(); | ||
69 | fs.Close(); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Parse LSO file. | ||
74 | /// </summary> | ||
75 | public void Parse() | ||
76 | { | ||
77 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. | ||
78 | |||
79 | // HEADER BLOCK | ||
80 | Common.SendToDebug("Reading HEADER BLOCK at: 0"); | ||
81 | fs.Seek(0, SeekOrigin.Begin); | ||
82 | myHeader = new LSO_Struct.Header(); | ||
83 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); | ||
84 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); | ||
85 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); | ||
86 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); | ||
87 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); | ||
88 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); | ||
89 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); | ||
90 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); | ||
91 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); | ||
92 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); | ||
93 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); | ||
94 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); | ||
95 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); | ||
96 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); | ||
97 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); | ||
98 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); | ||
99 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); | ||
100 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); | ||
101 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); | ||
102 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); | ||
103 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); | ||
104 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); | ||
105 | |||
106 | // Print Header Block to debug | ||
107 | Common.SendToDebug("TM - Top of memory (size): " + myHeader.TM); | ||
108 | Common.SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); | ||
109 | Common.SendToDebug("VN - Version number: " + myHeader.VN); | ||
110 | Common.SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); | ||
111 | Common.SendToDebug("SP - Stack Pointer: " + myHeader.SP); | ||
112 | Common.SendToDebug("HR - Heap Register: " + myHeader.HR); | ||
113 | Common.SendToDebug("HP - Heap Pointer: " + myHeader.HP); | ||
114 | Common.SendToDebug("CS - Current State: " + myHeader.CS); | ||
115 | Common.SendToDebug("NS - Next State: " + myHeader.NS); | ||
116 | Common.SendToDebug("CE - Current Events: " + myHeader.CE); | ||
117 | Common.SendToDebug("IE - In Event: " + myHeader.IE); | ||
118 | Common.SendToDebug("ER - Event Register: " + myHeader.ER); | ||
119 | Common.SendToDebug("FR - Fault Register: " + myHeader.FR); | ||
120 | Common.SendToDebug("SLR - Sleep Register: " + myHeader.SLR); | ||
121 | Common.SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); | ||
122 | Common.SendToDebug("GFR - Global Function Register: " + myHeader.GFR); | ||
123 | Common.SendToDebug("PR - Parameter Register: " + myHeader.PR); | ||
124 | Common.SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); | ||
125 | Common.SendToDebug("SR - State Register: " + myHeader.SR); | ||
126 | Common.SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); | ||
127 | Common.SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); | ||
128 | Common.SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); | ||
129 | Common.SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); | ||
130 | |||
131 | // STATIC BLOCK | ||
132 | Common.SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); | ||
133 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
134 | int StaticBlockCount = 0; | ||
135 | // Read function blocks until we hit GFR | ||
136 | while (fs.Position < myHeader.GFR) | ||
137 | { | ||
138 | StaticBlockCount++; | ||
139 | long startReadPos = fs.Position; | ||
140 | Common.SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + startReadPos); | ||
141 | |||
142 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
143 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | ||
144 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | ||
145 | myStaticBlock.ObjectType = br_read(1)[0]; | ||
146 | Common.SendToDebug("Static Block ObjectType: " + | ||
147 | ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); | ||
148 | myStaticBlock.Unknown = br_read(1)[0]; | ||
149 | // Size of datatype varies -- what about strings? | ||
150 | if (myStaticBlock.ObjectType != 0) | ||
151 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | ||
152 | |||
153 | StaticBlocks.Add((UInt32) startReadPos, myStaticBlock); | ||
154 | } | ||
155 | Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); | ||
156 | |||
157 | // FUNCTION BLOCK | ||
158 | // Always right after STATIC BLOCK | ||
159 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); | ||
160 | if (myHeader.GFR == myHeader.SR) | ||
161 | { | ||
162 | // If GFR and SR are at same position then there is no fuction block | ||
163 | Common.SendToDebug("No FUNCTION BLOCK found"); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | Common.SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); | ||
168 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); | ||
169 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); | ||
170 | Common.SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); | ||
171 | if (myFunctionBlock.FunctionCount > 0) | ||
172 | { | ||
173 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; | ||
174 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | ||
175 | { | ||
176 | Common.SendToDebug("Reading function " + i + " at: " + fs.Position); | ||
177 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) | ||
178 | // Note! Absolute position | ||
179 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; | ||
180 | Common.SendToDebug("Fuction " + i + " code chunk position: " + | ||
181 | myFunctionBlock.CodeChunkPointer[i]); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | |||
186 | // STATE FRAME BLOCK | ||
187 | // Always right after FUNCTION BLOCK | ||
188 | Common.SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); | ||
189 | fs.Seek(myHeader.SR, SeekOrigin.Begin); | ||
190 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); | ||
191 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); | ||
192 | if (myStateFrameBlock.StateCount > 0) | ||
193 | { | ||
194 | // Initialize array | ||
195 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; | ||
196 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
197 | { | ||
198 | Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); | ||
199 | // Position is relative to state frame | ||
200 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); | ||
201 | myStateFrameBlock.StatePointer[i].EventMask = new BitArray(br_read(8)); | ||
202 | Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); | ||
203 | Common.SendToDebug("Total potential EventMask bits: " + | ||
204 | myStateFrameBlock.StatePointer[i].EventMask.Count); | ||
205 | |||
206 | //// Read STATE BLOCK | ||
207 | //long CurPos = fs.Position; | ||
208 | //fs.Seek(CurPos, SeekOrigin.Begin); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | // STATE BLOCK | ||
213 | // For each StateFrameBlock there is one StateBlock with multiple event handlers | ||
214 | |||
215 | if (myStateFrameBlock.StateCount > 0) | ||
216 | { | ||
217 | // Go through all State Frame Pointers found | ||
218 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
219 | { | ||
220 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); | ||
221 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); | ||
222 | |||
223 | // READ: STATE BLOCK HEADER | ||
224 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); | ||
225 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32) fs.Position; // Note | ||
226 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); | ||
227 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; | ||
228 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32) fs.Position; // Note | ||
229 | Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); | ||
230 | Common.SendToDebug("State block Header Size: " + | ||
231 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); | ||
232 | Common.SendToDebug("State block Header End Pos: " + | ||
233 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos); | ||
234 | |||
235 | // We need to count number of bits flagged in EventMask? | ||
236 | |||
237 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask | ||
238 | |||
239 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE | ||
240 | //TODO: Create event hooks | ||
241 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = | ||
242 | new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; | ||
243 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
244 | { | ||
245 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) | ||
246 | { | ||
247 | // We got an event | ||
248 | // READ: STATE BLOCK HANDLER | ||
249 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + | ||
250 | " (" + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") at: " + | ||
251 | fs.Position); | ||
252 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = | ||
253 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos + | ||
254 | BitConverter.ToUInt32(br_read(4), 0); | ||
255 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = | ||
256 | BitConverter.ToUInt32(br_read(4), 0); | ||
257 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + | ||
258 | ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Code Chunk Pointer: " + | ||
259 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. | ||
260 | CodeChunkPointer); | ||
261 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + | ||
262 | ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Call Frame Size: " + | ||
263 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. | ||
264 | CallFrameSize); | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | |||
270 | //// READ FUNCTION CODE CHUNKS | ||
271 | //// Functions + Function start pos (GFR) | ||
272 | //// TODO: Somehow be able to identify and reference this | ||
273 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; | ||
274 | //if (myFunctionBlock.FunctionCount > 0) | ||
275 | //{ | ||
276 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; | ||
277 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | ||
278 | // { | ||
279 | // Common.SendToDebug("Reading Function Code Chunk " + i); | ||
280 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); | ||
281 | // } | ||
282 | |||
283 | //} | ||
284 | // READ EVENT CODE CHUNKS | ||
285 | if (myStateFrameBlock.StateCount > 0) | ||
286 | { | ||
287 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
288 | { | ||
289 | // TODO: Somehow organize events and functions so they can be found again, | ||
290 | // two level search ain't no good | ||
291 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
292 | { | ||
293 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) | ||
294 | { | ||
295 | Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + | ||
296 | (LSO_Enums.Event_Mask_Values) ii); | ||
297 | |||
298 | |||
299 | // Override a Method / Function | ||
300 | string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values) ii; | ||
301 | Common.SendToDebug("Event Name: " + eventname); | ||
302 | if (Common.IL_ProcessCodeChunks) | ||
303 | { | ||
304 | EventList.Add(eventname); | ||
305 | |||
306 | // JUMP TO CODE PROCESSOR | ||
307 | ProcessCodeChunk( | ||
308 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, | ||
309 | typeBuilder, eventname); | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | } | ||
315 | |||
316 | if (Common.IL_CreateFunctionList) | ||
317 | IL_INSERT_FUNCTIONLIST(); | ||
318 | } | ||
319 | |||
320 | internal LSO_Struct.HeapBlock GetHeap(UInt32 pos) | ||
321 | { | ||
322 | // HEAP BLOCK | ||
323 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) | ||
324 | Common.SendToDebug("Reading HEAP BLOCK at: " + pos); | ||
325 | fs.Seek(pos, SeekOrigin.Begin); | ||
326 | |||
327 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); | ||
328 | myHeapBlock.DataBlockSize = BitConverter.ToInt32(br_read(4), 0); | ||
329 | myHeapBlock.ObjectType = br_read(1)[0]; | ||
330 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); | ||
331 | //myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); | ||
332 | // Don't read it reversed | ||
333 | myHeapBlock.Data = new byte[myHeapBlock.DataBlockSize - 1]; | ||
334 | br.Read(myHeapBlock.Data, 0, myHeapBlock.DataBlockSize - 1); | ||
335 | |||
336 | |||
337 | Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); | ||
338 | Common.SendToDebug("Heap Block ObjectType: " + | ||
339 | ((LSO_Enums.Variable_Type_Codes) myHeapBlock.ObjectType).ToString()); | ||
340 | Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); | ||
341 | |||
342 | return myHeapBlock; | ||
343 | } | ||
344 | |||
345 | private byte[] br_read(int len) | ||
346 | { | ||
347 | if (len <= 0) | ||
348 | return null; | ||
349 | |||
350 | try | ||
351 | { | ||
352 | byte[] bytes = new byte[len]; | ||
353 | for (int i = len - 1; i > -1; i--) | ||
354 | bytes[i] = br.ReadByte(); | ||
355 | return bytes; | ||
356 | } | ||
357 | catch (Exception e) // NOTLEGIT: No user related exceptions throwable here? | ||
358 | { | ||
359 | Common.SendToDebug("Exception: " + e.ToString()); | ||
360 | throw (e); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | //private byte[] br_read_smallendian(int len) | ||
365 | //{ | ||
366 | // byte[] bytes = new byte[len]; | ||
367 | // br.Read(bytes,0, len); | ||
368 | // return bytes; | ||
369 | //} | ||
370 | private Type getLLObjectType(byte objectCode) | ||
371 | { | ||
372 | switch ((LSO_Enums.Variable_Type_Codes) objectCode) | ||
373 | { | ||
374 | case LSO_Enums.Variable_Type_Codes.Void: | ||
375 | return typeof (void); | ||
376 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
377 | return typeof (UInt32); | ||
378 | case LSO_Enums.Variable_Type_Codes.Float: | ||
379 | return typeof (float); | ||
380 | case LSO_Enums.Variable_Type_Codes.String: | ||
381 | return typeof (string); | ||
382 | case LSO_Enums.Variable_Type_Codes.Key: | ||
383 | return typeof (string); | ||
384 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
385 | return typeof (LSO_Enums.Vector); | ||
386 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
387 | return typeof (LSO_Enums.Rotation); | ||
388 | case LSO_Enums.Variable_Type_Codes.List: | ||
389 | Common.SendToDebug("TODO: List datatype not implemented yet!"); | ||
390 | return typeof (ArrayList); | ||
391 | case LSO_Enums.Variable_Type_Codes.Null: | ||
392 | Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!"); | ||
393 | return typeof (string); | ||
394 | default: | ||
395 | Common.SendToDebug("Lookup of LSL datatype " + objectCode + | ||
396 | " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); | ||
397 | return typeof (object); | ||
398 | } | ||
399 | } | ||
400 | |||
401 | private int getObjectSize(byte ObjectType) | ||
402 | { | ||
403 | switch ((LSO_Enums.Variable_Type_Codes) ObjectType) | ||
404 | { | ||
405 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
406 | case LSO_Enums.Variable_Type_Codes.Float: | ||
407 | case LSO_Enums.Variable_Type_Codes.String: | ||
408 | case LSO_Enums.Variable_Type_Codes.Key: | ||
409 | case LSO_Enums.Variable_Type_Codes.List: | ||
410 | return 4; | ||
411 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
412 | return 12; | ||
413 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
414 | return 16; | ||
415 | default: | ||
416 | return 0; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | private string Read_String() | ||
421 | { | ||
422 | string ret = String.Empty; | ||
423 | byte reader = br_read(1)[0]; | ||
424 | while (reader != 0x000) | ||
425 | { | ||
426 | ret += (char) reader; | ||
427 | reader = br_read(1)[0]; | ||
428 | } | ||
429 | return ret; | ||
430 | } | ||
431 | |||
432 | /// <summary> | ||
433 | /// Reads a code chunk and creates IL | ||
434 | /// </summary> | ||
435 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> | ||
436 | /// <param name="typeBuilder">TypeBuilder for assembly</param> | ||
437 | /// <param name="eventname">Name of event (function) to generate</param> | ||
438 | private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) | ||
439 | { | ||
440 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); | ||
441 | |||
442 | Common.SendToDebug("Reading Function Code Chunk at: " + pos); | ||
443 | fs.Seek(pos, SeekOrigin.Begin); | ||
444 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); | ||
445 | Common.SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize); | ||
446 | // Read until null | ||
447 | myCodeChunk.Comment = Read_String(); | ||
448 | Common.SendToDebug("Function comment: " + myCodeChunk.Comment); | ||
449 | myCodeChunk.ReturnTypePos = br_read(1)[0]; | ||
450 | myCodeChunk.ReturnType = GetStaticBlock((long) myCodeChunk.ReturnTypePos + (long) myHeader.GVR); | ||
451 | Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + | ||
452 | ((LSO_Enums.Variable_Type_Codes) myCodeChunk.ReturnType.ObjectType).ToString()); | ||
453 | |||
454 | // TODO: How to determine number of codechunks -- does this method work? | ||
455 | myCodeChunk.CodeChunkArguments = new List<LSO_Struct.CodeChunkArgument>(); | ||
456 | byte reader = br_read(1)[0]; | ||
457 | |||
458 | // NOTE ON CODE CHUNK ARGUMENTS | ||
459 | // This determins type definition | ||
460 | int ccount = 0; | ||
461 | while (reader != 0x000) | ||
462 | { | ||
463 | ccount++; | ||
464 | Common.SendToDebug("Reading Code Chunk Argument " + ccount); | ||
465 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); | ||
466 | CCA.FunctionReturnTypePos = reader; | ||
467 | reader = br_read(1)[0]; | ||
468 | CCA.NullString = reader; | ||
469 | CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR); | ||
470 | myCodeChunk.CodeChunkArguments.Add(CCA); | ||
471 | Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + | ||
472 | ": " + (LSO_Enums.Variable_Type_Codes) CCA.FunctionReturnType.ObjectType); | ||
473 | } | ||
474 | // Create string array | ||
475 | Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; | ||
476 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | ||
477 | { | ||
478 | MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType); | ||
479 | Common.SendToDebug("Method argument " + _ic + ": " + | ||
480 | getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType). | ||
481 | ToString()); | ||
482 | } | ||
483 | // End marker is 0x000 | ||
484 | myCodeChunk.EndMarker = reader; | ||
485 | |||
486 | // | ||
487 | // Emit: START OF METHOD (FUNCTION) | ||
488 | // | ||
489 | |||
490 | Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); | ||
491 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | ||
492 | MethodAttributes.Public, | ||
493 | typeof (void), | ||
494 | new Type[] {typeof (object)}); | ||
495 | //MethodArgs); | ||
496 | //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), | ||
497 | // new Type[] { typeof(object) }, //); | ||
498 | |||
499 | //Common.SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); | ||
500 | //typeBuilder.DefineMethodOverride(methodBuilder, | ||
501 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | ||
502 | |||
503 | // Create the IL generator | ||
504 | |||
505 | Common.SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); | ||
506 | ILGenerator il = methodBuilder.GetILGenerator(); | ||
507 | |||
508 | if (Common.IL_UseTryCatch) | ||
509 | IL_INSERT_TRY(il, eventname); | ||
510 | |||
511 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | ||
512 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
513 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod | ||
514 | // ("WriteLine", new Type[] { typeof(string) })); | ||
515 | |||
516 | //Common.SendToDebug("STARTUP: il.Emit(OpCodes.Ldc_I4_S, 0);"); | ||
517 | |||
518 | //il.Emit(OpCodes.Ldc_I4_S, 0); | ||
519 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | ||
520 | { | ||
521 | Common.SendToDebug("PARAMS: il.Emit(OpCodes.Ldarg, " + _ic + ");"); | ||
522 | il.Emit(OpCodes.Ldarg, _ic); | ||
523 | } | ||
524 | |||
525 | // | ||
526 | // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL | ||
527 | // | ||
528 | bool FoundRet = false; | ||
529 | while (FoundRet == false) | ||
530 | { | ||
531 | FoundRet = LSL_PROCESS_OPCODE(il); | ||
532 | } | ||
533 | |||
534 | if (Common.IL_UseTryCatch) | ||
535 | IL_INSERT_END_TRY(il, eventname); | ||
536 | |||
537 | // Emit: RETURN FROM METHOD | ||
538 | il.Emit(OpCodes.Ret); | ||
539 | |||
540 | return; | ||
541 | } | ||
542 | |||
543 | private void IL_INSERT_FUNCTIONLIST() | ||
544 | { | ||
545 | Common.SendToDebug("Creating function list"); | ||
546 | |||
547 | string eventname = "GetFunctions"; | ||
548 | |||
549 | Common.SendToDebug("Creating IL " + eventname); | ||
550 | // Define a private String field. | ||
551 | //FieldBuilder myField = myTypeBuilder.DefineField("EventList", typeof(String[]), FieldAttributes.Public); | ||
552 | |||
553 | //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); | ||
554 | |||
555 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | ||
556 | MethodAttributes.Public, | ||
557 | typeof (string[]), | ||
558 | null); | ||
559 | |||
560 | //typeBuilder.DefineMethodOverride(methodBuilder, | ||
561 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | ||
562 | |||
563 | ILGenerator il = methodBuilder.GetILGenerator(); | ||
564 | |||
565 | // IL_INSERT_TRY(il, eventname); | ||
566 | |||
567 | // // Push string to stack | ||
568 | // il.Emit(OpCodes.Ldstr, "Inside " + eventname); | ||
569 | |||
570 | //// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | ||
571 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod | ||
572 | // ("WriteLine", new Type[] { typeof(string) })); | ||
573 | |||
574 | //initIL.Emit(OpCodes.Newobj, typeof(string[])); | ||
575 | |||
576 | //string[] MyArray = new string[2] { "TestItem1" , "TestItem2" }; | ||
577 | |||
578 | ////il.Emit(OpCodes.Ldarg_0); | ||
579 | |||
580 | il.DeclareLocal(typeof (string[])); | ||
581 | |||
582 | ////il.Emit(OpCodes.Ldarg_0); | ||
583 | il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length | ||
584 | il.Emit(OpCodes.Newarr, typeof (String)); // create new string array | ||
585 | il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack | ||
586 | ////SetFunctionList | ||
587 | |||
588 | for (int lv = 0; lv < EventList.Count; lv++) | ||
589 | { | ||
590 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | ||
591 | il.Emit(OpCodes.Ldc_I4, lv); // Push index position | ||
592 | il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value | ||
593 | il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value | ||
594 | |||
595 | //il.Emit(OpCodes.Ldarg_0); | ||
596 | //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value | ||
597 | //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) })); | ||
598 | } | ||
599 | |||
600 | // IL_INSERT_END_TRY(il, eventname); | ||
601 | |||
602 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | ||
603 | // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) })); | ||
604 | |||
605 | il.Emit(OpCodes.Ret); // Return | ||
606 | } | ||
607 | |||
608 | private void IL_INSERT_TRY(ILGenerator il, string eventname) | ||
609 | { | ||
610 | /* | ||
611 | * CLR TRY | ||
612 | */ | ||
613 | //Common.SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); | ||
614 | il.BeginExceptionBlock(); | ||
615 | |||
616 | // Push "Hello World!" string to stack | ||
617 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | ||
618 | //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); | ||
619 | } | ||
620 | |||
621 | private void IL_INSERT_END_TRY(ILGenerator il, string eventname) | ||
622 | { | ||
623 | /* | ||
624 | * CATCH | ||
625 | */ | ||
626 | Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); | ||
627 | il.BeginCatchBlock(typeof (Exception)); | ||
628 | |||
629 | // Push "Hello World!" string to stack | ||
630 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | ||
631 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); | ||
632 | |||
633 | //call void [mscorlib]System.Console::WriteLine(string) | ||
634 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
635 | il.Emit(OpCodes.Call, typeof (Console).GetMethod | ||
636 | ("Write", new Type[] {typeof (string)})); | ||
637 | |||
638 | //callvirt instance string [mscorlib]System.Exception::get_Message() | ||
639 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); | ||
640 | il.Emit(OpCodes.Callvirt, typeof (Exception).GetMethod | ||
641 | ("get_Message")); | ||
642 | |||
643 | //call void [mscorlib]System.Console::WriteLine(string) | ||
644 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
645 | il.Emit(OpCodes.Call, typeof (Console).GetMethod | ||
646 | ("WriteLine", new Type[] {typeof (string)})); | ||
647 | |||
648 | /* | ||
649 | * CLR END TRY | ||
650 | */ | ||
651 | //Common.SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); | ||
652 | il.EndExceptionBlock(); | ||
653 | } | ||
654 | |||
655 | private LSO_Struct.StaticBlock GetStaticBlock(long pos) | ||
656 | { | ||
657 | long FirstPos = fs.Position; | ||
658 | try | ||
659 | { | ||
660 | UInt32 position = (UInt32) pos; | ||
661 | // STATIC BLOCK | ||
662 | Common.SendToDebug("Reading STATIC BLOCK at: " + position); | ||
663 | fs.Seek(position, SeekOrigin.Begin); | ||
664 | |||
665 | if (StaticBlocks.ContainsKey(position) == true) | ||
666 | { | ||
667 | Common.SendToDebug("Found cached STATIC BLOCK"); | ||
668 | |||
669 | return StaticBlocks[pos]; | ||
670 | } | ||
671 | |||
672 | //int StaticBlockCount = 0; | ||
673 | // Read function blocks until we hit GFR | ||
674 | //while (fs.Position < myHeader.GFR) | ||
675 | //{ | ||
676 | //StaticBlockCount++; | ||
677 | |||
678 | //Common.SendToDebug("Reading Static Block at: " + position); | ||
679 | |||
680 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
681 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | ||
682 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | ||
683 | myStaticBlock.ObjectType = br_read(1)[0]; | ||
684 | Common.SendToDebug("Static Block ObjectType: " + | ||
685 | ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); | ||
686 | myStaticBlock.Unknown = br_read(1)[0]; | ||
687 | // Size of datatype varies | ||
688 | if (myStaticBlock.ObjectType != 0) | ||
689 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | ||
690 | |||
691 | StaticBlocks.Add(position, myStaticBlock); | ||
692 | //} | ||
693 | Common.SendToDebug("Done reading Static Block."); | ||
694 | return myStaticBlock; | ||
695 | } | ||
696 | finally | ||
697 | { | ||
698 | // Go back to original read pos | ||
699 | fs.Seek(FirstPos, SeekOrigin.Begin); | ||
700 | } | ||
701 | } | ||
702 | } | ||
703 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs deleted file mode 100644 index b837d32..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs +++ /dev/null | |||
@@ -1,143 +0,0 @@ | |||
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 | /* Original code: Tedd Hansen */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
35 | { | ||
36 | internal static class LSO_Struct | ||
37 | { | ||
38 | public struct Header | ||
39 | { | ||
40 | public UInt32 TM; | ||
41 | public UInt32 IP; | ||
42 | public UInt32 VN; | ||
43 | public UInt32 BP; | ||
44 | public UInt32 SP; | ||
45 | public UInt32 HR; | ||
46 | public UInt32 HP; | ||
47 | public UInt32 CS; | ||
48 | public UInt32 NS; | ||
49 | public UInt32 CE; | ||
50 | public UInt32 IE; | ||
51 | public UInt32 ER; | ||
52 | public UInt32 FR; | ||
53 | public UInt32 SLR; | ||
54 | public UInt32 GVR; | ||
55 | public UInt32 GFR; | ||
56 | public UInt32 PR; | ||
57 | public UInt32 ESR; | ||
58 | public UInt32 SR; | ||
59 | public UInt64 NCE; | ||
60 | public UInt64 NIE; | ||
61 | public UInt64 NER; | ||
62 | } | ||
63 | |||
64 | public struct StaticBlock | ||
65 | { | ||
66 | public UInt32 Static_Chunk_Header_Size; | ||
67 | public byte ObjectType; | ||
68 | public byte Unknown; | ||
69 | public byte[] BlockVariable; | ||
70 | } | ||
71 | |||
72 | /* Not actually a structure | ||
73 | public struct StaticBlockVariable | ||
74 | { | ||
75 | public UInt32 Integer1; | ||
76 | public UInt32 Float1; | ||
77 | public UInt32 HeapPointer_String; | ||
78 | public UInt32 HeapPointer_Key; | ||
79 | public byte[] Vector_12; | ||
80 | public byte[] Rotation_16; | ||
81 | public UInt32 Pointer_List_Structure; | ||
82 | } */ | ||
83 | |||
84 | public struct HeapBlock | ||
85 | { | ||
86 | public Int32 DataBlockSize; | ||
87 | public byte ObjectType; | ||
88 | public UInt16 ReferenceCount; | ||
89 | public byte[] Data; | ||
90 | } | ||
91 | |||
92 | public struct StateFrameBlock | ||
93 | { | ||
94 | public UInt32 StateCount; | ||
95 | public StatePointerBlock[] StatePointer; | ||
96 | } | ||
97 | |||
98 | public struct StatePointerBlock | ||
99 | { | ||
100 | public UInt32 Location; | ||
101 | public BitArray EventMask; | ||
102 | public StateBlock StateBlock; | ||
103 | } | ||
104 | |||
105 | public struct StateBlock | ||
106 | { | ||
107 | public UInt32 StartPos; | ||
108 | public UInt32 EndPos; | ||
109 | public UInt32 HeaderSize; | ||
110 | public byte Unknown; | ||
111 | public StateBlockHandler[] StateBlockHandlers; | ||
112 | } | ||
113 | |||
114 | public struct StateBlockHandler | ||
115 | { | ||
116 | public UInt32 CodeChunkPointer; | ||
117 | public UInt32 CallFrameSize; | ||
118 | } | ||
119 | |||
120 | public struct FunctionBlock | ||
121 | { | ||
122 | public UInt32 FunctionCount; | ||
123 | public UInt32[] CodeChunkPointer; | ||
124 | } | ||
125 | |||
126 | public struct CodeChunk | ||
127 | { | ||
128 | public UInt32 CodeChunkHeaderSize; | ||
129 | public string Comment; | ||
130 | public List<CodeChunkArgument> CodeChunkArguments; | ||
131 | public byte EndMarker; | ||
132 | public byte ReturnTypePos; | ||
133 | public StaticBlock ReturnType; | ||
134 | } | ||
135 | |||
136 | public struct CodeChunkArgument | ||
137 | { | ||
138 | public byte FunctionReturnTypePos; | ||
139 | public byte NullString; | ||
140 | public StaticBlock FunctionReturnType; | ||
141 | } | ||
142 | } | ||
143 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs deleted file mode 100644 index f035c03..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
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 OpenSim.Region.ScriptEngine.LSOEngine.LSO; | ||
29 | |||
30 | namespace OpenSim.Region.ScriptEngine.LSOEngine | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// This class encapsulated an LSO file and contains execution-specific data | ||
34 | /// </summary> | ||
35 | public class LSOScript | ||
36 | { | ||
37 | private byte[] LSOCode = new byte[1024 * 16]; // Contains the LSO-file | ||
38 | //private System.IO.MemoryStream LSOCode = new MemoryStream(1024 * 16); | ||
39 | |||
40 | public void Execute(LSO_Enums.Event_Mask_Values Event, params object[] param) | ||
41 | { | ||
42 | } | ||
43 | } | ||
44 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/LSOEngine/Properties/AssemblyInfo.cs deleted file mode 100644 index 5210ff0..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
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.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | |||
35 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.LSOEngine")] | ||
36 | [assembly : AssemblyDescription("")] | ||
37 | [assembly : AssemblyConfiguration("")] | ||
38 | [assembly : AssemblyCompany("")] | ||
39 | [assembly: AssemblyProduct("OpenSim.Region.ScriptEngine.LSOEngine")] | ||
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] | ||
41 | [assembly : AssemblyTrademark("")] | ||
42 | [assembly : AssemblyCulture("")] | ||
43 | |||
44 | // Setting ComVisible to false makes the types in this assembly not visible | ||
45 | // to COM components. If you need to access a type in this assembly from | ||
46 | // COM, set the ComVisible attribute to true on that type. | ||
47 | |||
48 | [assembly : ComVisible(false)] | ||
49 | |||
50 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
51 | |||
52 | [assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")] | ||
53 | |||
54 | // Version information for an assembly consists of the following four values: | ||
55 | // | ||
56 | // Major Version | ||
57 | // Minor Version | ||
58 | // Build Number | ||
59 | // Revision | ||
60 | // | ||
61 | // You can specify all the values or you can default the Revision and Build Numbers | ||
62 | // by using the '*' as shown below: | ||
63 | |||
64 | [assembly : AssemblyVersion("1.0.0.0")] | ||
65 | [assembly : AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs deleted file mode 100644 index 3c0e9cd..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptEngine.cs +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Region.Environment.Scenes; | ||
31 | |||
32 | namespace OpenSim.Region.ScriptEngine.LSOEngine | ||
33 | { | ||
34 | [Serializable] | ||
35 | public class ScriptEngine : Common.ScriptEngineBase.ScriptEngine | ||
36 | { | ||
37 | // We need to override a few things for our DotNetEngine | ||
38 | public override void Initialise(Scene scene, IConfigSource config) | ||
39 | { | ||
40 | InitializeEngine(scene, config, true, GetScriptManager()); | ||
41 | } | ||
42 | |||
43 | public override Common.ScriptEngineBase.ScriptManager _GetScriptManager() | ||
44 | { | ||
45 | return new ScriptManager(this); | ||
46 | } | ||
47 | |||
48 | public override string ScriptEngineName | ||
49 | { | ||
50 | get { return "ScriptEngine.LSOEngine"; } | ||
51 | } | ||
52 | } | ||
53 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs deleted file mode 100644 index 617d6f6..0000000 --- a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
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.Framework; | ||
31 | using OpenSim.Region.Environment.Scenes; | ||
32 | using OpenSim.Region.ScriptEngine.Common; | ||
33 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; | ||
34 | |||
35 | namespace OpenSim.Region.ScriptEngine.LSOEngine | ||
36 | { | ||
37 | public class ScriptManager : Common.ScriptEngineBase.ScriptManager | ||
38 | { | ||
39 | public ScriptManager(Common.ScriptEngineBase.ScriptEngine scriptEngine) | ||
40 | : base(scriptEngine) | ||
41 | { | ||
42 | base.m_scriptEngine = scriptEngine; | ||
43 | |||
44 | } | ||
45 | |||
46 | // KEEP TRACK OF SCRIPTS <int id, whatever script> | ||
47 | //internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>(); | ||
48 | // LOAD SCRIPT | ||
49 | // UNLOAD SCRIPT | ||
50 | // PROVIDE SCRIPT WITH ITS INTERFACE TO OpenSim | ||
51 | |||
52 | public override void _StartScript(uint localID, LLUUID itemID, string Script) | ||
53 | { | ||
54 | //IScriptHost root = host.GetRoot(); | ||
55 | Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); | ||
56 | |||
57 | // We will initialize and start the script. | ||
58 | // It will be up to the script itself to hook up the correct events. | ||
59 | string ScriptSource = String.Empty; | ||
60 | |||
61 | SceneObjectPart m_host = World.GetSceneObjectPart(localID); | ||
62 | |||
63 | try | ||
64 | { | ||
65 | // Compile (We assume LSL) | ||
66 | //ScriptSource = LSLCompiler.CompileFromLSLText(Script); | ||
67 | |||
68 | //#if DEBUG | ||
69 | //long before; | ||
70 | //before = GC.GetTotalMemory(true); // This force a garbage collect that freezes some windows plateforms | ||
71 | //#endif | ||
72 | |||
73 | IScript CompiledScript; | ||
74 | CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); | ||
75 | |||
76 | //#if DEBUG | ||
77 | //Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); | ||
78 | //#endif | ||
79 | |||
80 | CompiledScript.Source = ScriptSource; | ||
81 | // Add it to our script memstruct | ||
82 | SetScript(localID, itemID, CompiledScript); | ||
83 | |||
84 | // We need to give (untrusted) assembly a private instance of BuiltIns | ||
85 | // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed. | ||
86 | |||
87 | |||
88 | BuilIn_Commands LSLB = new BuilIn_Commands(m_scriptEngine, m_host, localID, itemID); | ||
89 | |||
90 | // Start the script - giving it BuiltIns | ||
91 | CompiledScript.Start(LSLB); | ||
92 | |||
93 | // Fire the first start-event | ||
94 | int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID); | ||
95 | m_host.SetScriptEvents(itemID, eventFlags); | ||
96 | m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); | ||
97 | } | ||
98 | catch (Exception e) // LEGIT - User Script Compilation | ||
99 | { | ||
100 | //m_scriptEngine.Log.Error("[ScriptEngine]: Error compiling script: " + e.ToString()); | ||
101 | try | ||
102 | { | ||
103 | // DISPLAY ERROR INWORLD | ||
104 | string text = "Error compiling script:\r\n" + e.Message.ToString(); | ||
105 | if (text.Length > 1500) | ||
106 | text = text.Substring(0, 1500); | ||
107 | World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, | ||
108 | m_host.Name, m_host.UUID); | ||
109 | } | ||
110 | catch (Exception e2) // LEGIT - User Scripting | ||
111 | { | ||
112 | m_scriptEngine.Log.Error("[ScriptEngine]: Error displaying error in-world: " + e2.ToString()); | ||
113 | m_scriptEngine.Log.Error("[ScriptEngine]: " + | ||
114 | "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | public override void _StopScript(uint localID, LLUUID itemID) | ||
120 | { | ||
121 | // Stop script | ||
122 | Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); | ||
123 | |||
124 | // Stop long command on script | ||
125 | m_scriptEngine.m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); | ||
126 | |||
127 | IScript LSLBC = GetScript(localID, itemID); | ||
128 | if (LSLBC == null) | ||
129 | return; | ||
130 | |||
131 | // TEMP: First serialize it | ||
132 | //GetSerializedScript(localID, itemID); | ||
133 | |||
134 | try | ||
135 | { | ||
136 | // Get AppDomain | ||
137 | AppDomain ad = LSLBC.Exec.GetAppDomain(); | ||
138 | // Tell script not to accept new requests | ||
139 | GetScript(localID, itemID).Exec.StopScript(); | ||
140 | // Remove from internal structure | ||
141 | RemoveScript(localID, itemID); | ||
142 | // Tell AppDomain that we have stopped script | ||
143 | m_scriptEngine.m_AppDomainManager.StopScript(ad); | ||
144 | } | ||
145 | catch (Exception e) // LEGIT - Problems caused by User Scripting | ||
146 | { | ||
147 | Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + | ||
148 | ": " + e.ToString()); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | public override void Initialize() | ||
153 | { | ||
154 | } | ||
155 | } | ||
156 | } | ||