diff options
Diffstat (limited to '')
9 files changed, 2767 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs new file mode 100644 index 0000000..02f63d2 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Common.cs | |||
@@ -0,0 +1,86 @@ | |||
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 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs new file mode 100644 index 0000000..27acc9c --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs | |||
@@ -0,0 +1,293 @@ | |||
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 | using OpenSim.Region.ScriptEngine.LSOEngine.LSO; | ||
37 | |||
38 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
39 | { | ||
40 | public class Engine | ||
41 | { | ||
42 | //private string LSO_FileName = @"LSO\AdditionTest.lso"; | ||
43 | private string LSO_FileName; // = @"LSO\CloseToDefault.lso"; | ||
44 | private AppDomain appDomain; | ||
45 | |||
46 | public string Compile(string LSOFileName) | ||
47 | { | ||
48 | LSO_FileName = LSOFileName; | ||
49 | |||
50 | |||
51 | //appDomain = AppDomain.CreateDomain("AlternateAppDomain"); | ||
52 | appDomain = Thread.GetDomain(); | ||
53 | |||
54 | // Create Assembly Name | ||
55 | AssemblyName asmName = new AssemblyName(); | ||
56 | asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName); | ||
57 | //asmName.Name = "TestAssembly"; | ||
58 | |||
59 | string DLL_FileName = asmName.Name + ".dll"; | ||
60 | string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; | ||
61 | |||
62 | LSOEngine.LSO.Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName)); | ||
63 | LSOEngine.LSO.Common.SendToLog("Assembly name: " + asmName.Name); | ||
64 | LSOEngine.LSO.Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); | ||
65 | LSOEngine.LSO.Common.SendToLog("Starting processing of LSL ByteCode..."); | ||
66 | LSOEngine.LSO.Common.SendToLog(""); | ||
67 | |||
68 | |||
69 | // Create Assembly | ||
70 | AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( | ||
71 | asmName, | ||
72 | AssemblyBuilderAccess.RunAndSave | ||
73 | ); | ||
74 | //// Create Assembly | ||
75 | //AssemblyBuilder asmBuilder = | ||
76 | // Thread.GetDomain().DefineDynamicAssembly | ||
77 | //(asmName, AssemblyBuilderAccess.RunAndSave); | ||
78 | |||
79 | // Create a module (and save to disk) | ||
80 | ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule | ||
81 | (asmName.Name, | ||
82 | DLL_FileName); | ||
83 | |||
84 | //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\""); | ||
85 | // Create a Class (/Type) | ||
86 | TypeBuilder typeBuilder = modBuilder.DefineType( | ||
87 | "LSL_ScriptObject", | ||
88 | TypeAttributes.Public | TypeAttributes.BeforeFieldInit, | ||
89 | typeof (LSL_BaseClass)); | ||
90 | //, | ||
91 | // typeof()); | ||
92 | //, typeof(LSL_BuiltIn_Commands_Interface)); | ||
93 | //, | ||
94 | // typeof(object), | ||
95 | // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); | ||
96 | |||
97 | |||
98 | /* | ||
99 | * Generate the IL itself | ||
100 | */ | ||
101 | |||
102 | LSO_Parser LSOP = new LSO_Parser(LSO_FileName, typeBuilder); | ||
103 | LSOP.OpenFile(); | ||
104 | LSOP.Parse(); | ||
105 | |||
106 | // Constructor has to be created AFTER LSO_Parser because of accumulated variables | ||
107 | if (LSOEngine.LSO.Common.IL_CreateConstructor) | ||
108 | IL_CREATE_CONSTRUCTOR(typeBuilder, LSOP); | ||
109 | |||
110 | LSOP.CloseFile(); | ||
111 | /* | ||
112 | * Done generating. Create a type and run it. | ||
113 | */ | ||
114 | |||
115 | |||
116 | LSOEngine.LSO.Common.SendToLog("Attempting to compile assembly..."); | ||
117 | // Compile it | ||
118 | Type type = typeBuilder.CreateType(); | ||
119 | LSOEngine.LSO.Common.SendToLog("Compilation successful!"); | ||
120 | |||
121 | LSOEngine.LSO.Common.SendToLog("Saving assembly: " + DLL_FileName); | ||
122 | asmBuilder.Save(DLL_FileName); | ||
123 | |||
124 | LSOEngine.LSO.Common.SendToLog("Returning assembly filename: " + DLL_FileName); | ||
125 | |||
126 | |||
127 | return DLL_FileName; | ||
128 | |||
129 | |||
130 | //Common.SendToLog("Creating an instance of new assembly..."); | ||
131 | //// Create an instance we can play with | ||
132 | ////LSLScript hello = (LSLScript)Activator.CreateInstance(type); | ||
133 | ////LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); | ||
134 | //object MyScript = (object)Activator.CreateInstance(type); | ||
135 | |||
136 | |||
137 | //System.Reflection.MemberInfo[] Members = type.GetMembers(); | ||
138 | |||
139 | //Common.SendToLog("Members of assembly " + type.ToString() + ":"); | ||
140 | //foreach (MemberInfo member in Members) | ||
141 | // Common.SendToLog(member.ToString()); | ||
142 | |||
143 | |||
144 | //// Play with it | ||
145 | ////MyScript.event_state_entry("Test"); | ||
146 | //object[] args = { null }; | ||
147 | ////System.Collections.Generic.List<string> Functions = (System.Collections.Generic.List<string>)type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); | ||
148 | |||
149 | //string[] ret = { }; | ||
150 | //if (Common.IL_CreateFunctionList) | ||
151 | // ret = (string[])type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); | ||
152 | |||
153 | //foreach (string s in ret) | ||
154 | //{ | ||
155 | // Common.SendToLog(""); | ||
156 | // Common.SendToLog("*** Executing LSL Server Event: " + s); | ||
157 | // //object test = type.GetMember(s); | ||
158 | // //object runner = type.InvokeMember(s, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, MyScript, args); | ||
159 | // //runner(); | ||
160 | // //objBooks_Late = type.InvokeMember(s, BindingFlags.CreateInstance, null, objApp_Late, null); | ||
161 | // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); | ||
162 | |||
163 | //} | ||
164 | } | ||
165 | |||
166 | |||
167 | private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) | ||
168 | { | ||
169 | LSOEngine.LSO.Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); | ||
170 | //ConstructorBuilder constructor = typeBuilder.DefineConstructor( | ||
171 | // MethodAttributes.Public, | ||
172 | // CallingConventions.Standard, | ||
173 | // new Type[0]); | ||
174 | ConstructorBuilder constructor = typeBuilder.DefineConstructor( | ||
175 | MethodAttributes.Public | | ||
176 | MethodAttributes.SpecialName | | ||
177 | MethodAttributes.RTSpecialName, | ||
178 | CallingConventions.Standard, | ||
179 | new Type[0]); | ||
180 | |||
181 | //Define the reflection ConstructorInfor for System.Object | ||
182 | ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]); | ||
183 | |||
184 | //call constructor of base object | ||
185 | ILGenerator il = constructor.GetILGenerator(); | ||
186 | |||
187 | il.Emit(OpCodes.Ldarg_0); | ||
188 | il.Emit(OpCodes.Call, conObj); | ||
189 | |||
190 | |||
191 | //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: UInt32 State = 0;"); | ||
192 | //string FieldName; | ||
193 | //// Create state object | ||
194 | //FieldName = "State"; | ||
195 | //FieldBuilder State_fb = typeBuilder.DefineField( | ||
196 | // FieldName, | ||
197 | // typeof(UInt32), | ||
198 | // FieldAttributes.Public); | ||
199 | //il.Emit(OpCodes.Ldarg_0); | ||
200 | //il.Emit(OpCodes.Ldc_I4, 0); | ||
201 | //il.Emit(OpCodes.Stfld, State_fb); | ||
202 | |||
203 | |||
204 | //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: LSL_BuiltIn_Commands_TestImplementation LSL_BuiltIns = New LSL_BuiltIn_Commands_TestImplementation();"); | ||
205 | ////Type objType1 = typeof(object); | ||
206 | //Type objType1 = typeof(LSL_BuiltIn_Commands_TestImplementation); | ||
207 | |||
208 | //FieldName = "LSL_BuiltIns"; | ||
209 | //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField( | ||
210 | // FieldName, | ||
211 | // objType1, | ||
212 | // FieldAttributes.Public); | ||
213 | |||
214 | ////LSL_BuiltIn_Commands_TestImplementation _ti = new LSL_BuiltIn_Commands_TestImplementation(); | ||
215 | //il.Emit(OpCodes.Ldarg_0); | ||
216 | ////il.Emit(OpCodes.Ldstr, "Test 123"); | ||
217 | //il.Emit(OpCodes.Newobj, objType1.GetConstructor(new Type[] { })); | ||
218 | //il.Emit(OpCodes.Stfld, LSL_BuiltIns_fb); | ||
219 | |||
220 | foreach (UInt32 pos in LSOP.StaticBlocks.Keys) | ||
221 | { | ||
222 | LSO_Struct.StaticBlock sb; | ||
223 | LSOP.StaticBlocks.TryGetValue(pos, out sb); | ||
224 | |||
225 | if (sb.ObjectType > 0 && sb.ObjectType < 8) | ||
226 | { | ||
227 | // We don't want void or null's | ||
228 | |||
229 | il.Emit(OpCodes.Ldarg_0); | ||
230 | // Push position to stack | ||
231 | il.Emit(OpCodes.Ldc_I4, pos); | ||
232 | //il.Emit(OpCodes.Box, typeof(UInt32)); | ||
233 | |||
234 | |||
235 | Type datatype = null; | ||
236 | |||
237 | // Push data to stack | ||
238 | LSOEngine.LSO.Common.SendToDebug("Adding to static (" + pos + ") type: " + | ||
239 | ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType + | ||
240 | ")"); | ||
241 | switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType) | ||
242 | { | ||
243 | case LSO_Enums.Variable_Type_Codes.Float: | ||
244 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
245 | //UInt32 | ||
246 | il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); | ||
247 | datatype = typeof (UInt32); | ||
248 | il.Emit(OpCodes.Box, datatype); | ||
249 | break; | ||
250 | case LSO_Enums.Variable_Type_Codes.String: | ||
251 | case LSO_Enums.Variable_Type_Codes.Key: | ||
252 | //String | ||
253 | LSO_Struct.HeapBlock hb = | ||
254 | LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); | ||
255 | il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data)); | ||
256 | datatype = typeof (string); | ||
257 | break; | ||
258 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
259 | datatype = typeof (LSO_Enums.Vector); | ||
260 | //TODO: Not implemented | ||
261 | break; | ||
262 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
263 | //Object | ||
264 | //TODO: Not implemented | ||
265 | datatype = typeof (LSO_Enums.Rotation); | ||
266 | break; | ||
267 | default: | ||
268 | datatype = typeof (object); | ||
269 | break; | ||
270 | } | ||
271 | |||
272 | |||
273 | // Make call | ||
274 | il.Emit(OpCodes.Call, | ||
275 | typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype})); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | |||
280 | ////il.Emit(OpCodes.Newobj, typeof(UInt32)); | ||
281 | //il.Emit(OpCodes.Starg_0); | ||
282 | //// Create LSL function library | ||
283 | //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField("LSL_BuiltIns", typeof(LSL_BuiltIn_Commands_Interface), FieldAttributes.Public); | ||
284 | //il.Emit(OpCodes.Newobj, typeof(LSL_BuiltIn_Commands_Interface)); | ||
285 | //il.Emit(OpCodes.Stloc_1); | ||
286 | |||
287 | il.Emit(OpCodes.Ret); | ||
288 | } | ||
289 | |||
290 | |||
291 | // End of class | ||
292 | } | ||
293 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs new file mode 100644 index 0000000..5125c80 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/IL_common_functions.cs | |||
@@ -0,0 +1,51 @@ | |||
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 | |||
33 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
34 | { | ||
35 | internal partial class LSO_Parser | ||
36 | { | ||
37 | private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName) | ||
38 | { | ||
39 | TypeBuilder typeBuilder = modBuilder.DefineType(typeName, | ||
40 | TypeAttributes.Public | | ||
41 | TypeAttributes.Class | | ||
42 | TypeAttributes.AutoClass | | ||
43 | TypeAttributes.AnsiClass | | ||
44 | TypeAttributes.BeforeFieldInit | | ||
45 | TypeAttributes.AutoLayout, | ||
46 | typeof (object), | ||
47 | new Type[] {typeof (object)}); | ||
48 | return typeBuilder; | ||
49 | } | ||
50 | } | ||
51 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs new file mode 100644 index 0000000..339a99f --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_BaseClass_OPCODES.cs | |||
@@ -0,0 +1,395 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | |||
32 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
33 | { | ||
34 | //public partial class LSL_BaseClass | ||
35 | //{ | ||
36 | // /* | ||
37 | // * OPCODES | ||
38 | // * | ||
39 | // * These are internal "assembly" commands, | ||
40 | // * basic operators like "ADD", "PUSH" and "POP" | ||
41 | // * | ||
42 | // * It also contains managed stack and keeps track of internal variables, etc. | ||
43 | // * | ||
44 | // */ | ||
45 | |||
46 | |||
47 | // public void StoreToLocal(UInt32 index) | ||
48 | // { | ||
49 | // // TODO: How to determine local? | ||
50 | // LSOEngine.LSO.Common.SendToDebug("::StoreToLocal " + index); | ||
51 | // if (LocalVariables.ContainsKey(index)) | ||
52 | // LocalVariables.Remove(index); | ||
53 | // LocalVariables.Add(index, LSLStack.Peek()); | ||
54 | // } | ||
55 | |||
56 | // public void StoreToGlobal(UInt32 index) | ||
57 | // { | ||
58 | // LSOEngine.LSO.Common.SendToDebug("::StoreToGlobal " + index); | ||
59 | // if (GlobalVariables.ContainsKey(index)) | ||
60 | // GlobalVariables.Remove(index); | ||
61 | // GlobalVariables.Add(index, LSLStack.Peek()); | ||
62 | // } | ||
63 | |||
64 | // public void StoreToStatic(UInt32 index) | ||
65 | // { | ||
66 | // LSOEngine.LSO.Common.SendToDebug("::StoreToStatic " + index); | ||
67 | // //if (StaticVariables.ContainsKey(index)) | ||
68 | // // StaticVariables.Remove(index); | ||
69 | // StaticVariables.Add(index, LSLStack.Peek()); | ||
70 | // } | ||
71 | |||
72 | // public void GetFromLocal(UInt32 index) | ||
73 | // { | ||
74 | // // TODO: How to determine local? | ||
75 | // LSOEngine.LSO.Common.SendToDebug("::GetFromLocal " + index); | ||
76 | // object ret; | ||
77 | // LocalVariables.TryGetValue(index, out ret); | ||
78 | // LSLStack.Push(ret); | ||
79 | // //return ret; | ||
80 | // } | ||
81 | |||
82 | // public void GetFromGlobal(UInt32 index) | ||
83 | // { | ||
84 | // LSOEngine.LSO.Common.SendToDebug("::GetFromGlobal " + index); | ||
85 | // object ret; | ||
86 | // GlobalVariables.TryGetValue(index, out ret); | ||
87 | // LSLStack.Push(ret); | ||
88 | // //return ret; | ||
89 | // } | ||
90 | |||
91 | // public void GetFromStatic(UInt32 index) | ||
92 | // { | ||
93 | // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic " + index); | ||
94 | // object ret; | ||
95 | // StaticVariables.TryGetValue(index, out ret); | ||
96 | // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString()); | ||
97 | // LSLStack.Push(ret); | ||
98 | // //return ret; | ||
99 | // } | ||
100 | |||
101 | // public object POPToStack() | ||
102 | // { | ||
103 | // LSOEngine.LSO.Common.SendToDebug("::POPToStack"); | ||
104 | // //return LSLStack.Pop(); | ||
105 | // object p = LSLStack.Pop(); | ||
106 | // if (p.GetType() == typeof (UInt32)) | ||
107 | // return (UInt32) p; | ||
108 | // if (p.GetType() == typeof (string)) | ||
109 | // return (string) p; | ||
110 | // if (p.GetType() == typeof (Int32)) | ||
111 | // return (Int32) p; | ||
112 | // if (p.GetType() == typeof (UInt16)) | ||
113 | // return (UInt16) p; | ||
114 | // if (p.GetType() == typeof (float)) | ||
115 | // return (float) p; | ||
116 | // if (p.GetType() == typeof (LSO_Enums.Vector)) | ||
117 | // return (LSO_Enums.Vector) p; | ||
118 | // if (p.GetType() == typeof (LSO_Enums.Rotation)) | ||
119 | // return (LSO_Enums.Rotation) p; | ||
120 | // if (p.GetType() == typeof (LSO_Enums.Key)) | ||
121 | // return (LSO_Enums.Key) p; | ||
122 | |||
123 | // return p; | ||
124 | // } | ||
125 | |||
126 | // //public object POPToStack(UInt32 count) | ||
127 | // //{ | ||
128 | // // // POP NUMBER FROM TOP OF STACK | ||
129 | // // //LSLStack.SetLength(LSLStack.Length - 4); | ||
130 | // // Common.SendToDebug("::POPToStack " + count); | ||
131 | // // if (count < 2) | ||
132 | // // return LSLStack.Pop(); | ||
133 | |||
134 | // // Stack<object> s = new Stack<object>(); | ||
135 | // // for (int i = 0; i < count; i++) | ||
136 | // // { | ||
137 | // // s.Push(LSLStack.Pop); | ||
138 | |||
139 | // // } | ||
140 | |||
141 | // //} | ||
142 | |||
143 | // public void POP() | ||
144 | // { | ||
145 | // // POP NUMBER FROM TOP OF STACK | ||
146 | // //LSLStack.SetLength(LSLStack.Length - 4); | ||
147 | // LSOEngine.LSO.Common.SendToDebug("::POP"); | ||
148 | // if (LSLStack.Count < 1) | ||
149 | // { | ||
150 | // //TODO: Temporary fix | ||
151 | // LSOEngine.LSO.Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!"); | ||
152 | // } | ||
153 | // else | ||
154 | // { | ||
155 | // LSLStack.Pop(); | ||
156 | // } | ||
157 | // } | ||
158 | |||
159 | // public void PUSH(object Param) | ||
160 | // { | ||
161 | // if (Param == null) | ||
162 | // { | ||
163 | // LSOEngine.LSO.Common.SendToDebug("::PUSH: <null>"); | ||
164 | // } | ||
165 | // else | ||
166 | // { | ||
167 | // //Common.SendToDebug("::PUSH: " + Param.GetType()); | ||
168 | // } | ||
169 | |||
170 | // LSLStack.Push(Param); | ||
171 | // } | ||
172 | |||
173 | // public void ADD(UInt32 Param) | ||
174 | // { | ||
175 | // LSOEngine.LSO.Common.SendToDebug("::ADD: " + Param); | ||
176 | // object o2 = LSLStack.Pop(); | ||
177 | // object o1 = LSLStack.Pop(); | ||
178 | // LSOEngine.LSO.Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + | ||
179 | // " (" + o2.ToString() + ")"); | ||
180 | // if (o2.GetType() == typeof (string)) | ||
181 | // { | ||
182 | // LSLStack.Push((string) o1 + (string) o2); | ||
183 | // return; | ||
184 | // } | ||
185 | // if (o2.GetType() == typeof (UInt32)) | ||
186 | // { | ||
187 | // LSLStack.Push((UInt32) o1 + (UInt32) o2); | ||
188 | // return; | ||
189 | // } | ||
190 | // } | ||
191 | |||
192 | // public void SUB(UInt32 Param) | ||
193 | // { | ||
194 | // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param); | ||
195 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
196 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
197 | // LSLStack.Push((UInt32) (i1 - i2)); | ||
198 | // } | ||
199 | |||
200 | // public void MUL(UInt32 Param) | ||
201 | // { | ||
202 | // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param); | ||
203 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
204 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
205 | // LSLStack.Push((UInt32) (i1*i2)); | ||
206 | // } | ||
207 | |||
208 | // public void DIV(UInt32 Param) | ||
209 | // { | ||
210 | // LSOEngine.LSO.Common.SendToDebug("::DIV: " + Param); | ||
211 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
212 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
213 | // LSLStack.Push((UInt32) (i1/i2)); | ||
214 | // } | ||
215 | |||
216 | |||
217 | // public void MOD(UInt32 Param) | ||
218 | // { | ||
219 | // LSOEngine.LSO.Common.SendToDebug("::MOD: " + Param); | ||
220 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
221 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
222 | // LSLStack.Push((UInt32) (i1%i2)); | ||
223 | // } | ||
224 | |||
225 | // public void EQ(UInt32 Param) | ||
226 | // { | ||
227 | // LSOEngine.LSO.Common.SendToDebug("::EQ: " + Param); | ||
228 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
229 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
230 | // if (i1 == i2) | ||
231 | // { | ||
232 | // LSLStack.Push((UInt32) 1); | ||
233 | // } | ||
234 | // else | ||
235 | // { | ||
236 | // LSLStack.Push((UInt32) 0); | ||
237 | // } | ||
238 | // } | ||
239 | |||
240 | // public void NEQ(UInt32 Param) | ||
241 | // { | ||
242 | // LSOEngine.LSO.Common.SendToDebug("::NEQ: " + Param); | ||
243 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
244 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
245 | // if (i1 != i2) | ||
246 | // { | ||
247 | // LSLStack.Push((UInt32) 1); | ||
248 | // } | ||
249 | // else | ||
250 | // { | ||
251 | // LSLStack.Push((UInt32) 0); | ||
252 | // } | ||
253 | // } | ||
254 | |||
255 | // public void LEQ(UInt32 Param) | ||
256 | // { | ||
257 | // LSOEngine.LSO.Common.SendToDebug("::LEQ: " + Param); | ||
258 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
259 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
260 | // if (i1 <= i2) | ||
261 | // { | ||
262 | // LSLStack.Push((UInt32) 1); | ||
263 | // } | ||
264 | // else | ||
265 | // { | ||
266 | // LSLStack.Push((UInt32) 0); | ||
267 | // } | ||
268 | // } | ||
269 | |||
270 | // public void GEQ(UInt32 Param) | ||
271 | // { | ||
272 | // LSOEngine.LSO.Common.SendToDebug("::GEQ: " + Param); | ||
273 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
274 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
275 | // if (i1 >= i2) | ||
276 | // { | ||
277 | // LSLStack.Push((UInt32) 1); | ||
278 | // } | ||
279 | // else | ||
280 | // { | ||
281 | // LSLStack.Push((UInt32) 0); | ||
282 | // } | ||
283 | // } | ||
284 | |||
285 | // public void LESS(UInt32 Param) | ||
286 | // { | ||
287 | // LSOEngine.LSO.Common.SendToDebug("::LESS: " + Param); | ||
288 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
289 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
290 | // if (i1 < i2) | ||
291 | // { | ||
292 | // LSLStack.Push((UInt32) 1); | ||
293 | // } | ||
294 | // else | ||
295 | // { | ||
296 | // LSLStack.Push((UInt32) 0); | ||
297 | // } | ||
298 | // } | ||
299 | |||
300 | // public void GREATER(UInt32 Param) | ||
301 | // { | ||
302 | // LSOEngine.LSO.Common.SendToDebug("::GREATER: " + Param); | ||
303 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
304 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
305 | // if (i1 > i2) | ||
306 | // { | ||
307 | // LSLStack.Push((UInt32) 1); | ||
308 | // } | ||
309 | // else | ||
310 | // { | ||
311 | // LSLStack.Push((UInt32) 0); | ||
312 | // } | ||
313 | // } | ||
314 | |||
315 | |||
316 | // public void BITAND() | ||
317 | // { | ||
318 | // LSOEngine.LSO.Common.SendToDebug("::BITAND"); | ||
319 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
320 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
321 | // LSLStack.Push((UInt32) (i1 & i2)); | ||
322 | // } | ||
323 | |||
324 | // public void BITOR() | ||
325 | // { | ||
326 | // LSOEngine.LSO.Common.SendToDebug("::BITOR"); | ||
327 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
328 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
329 | // LSLStack.Push((UInt32) (i1 | i2)); | ||
330 | // } | ||
331 | |||
332 | // public void BITXOR() | ||
333 | // { | ||
334 | // LSOEngine.LSO.Common.SendToDebug("::BITXOR"); | ||
335 | // UInt32 i2 = (UInt32) LSLStack.Pop(); | ||
336 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
337 | // LSLStack.Push((UInt32) (i1 ^ i2)); | ||
338 | // } | ||
339 | |||
340 | // public void BOOLAND() | ||
341 | // { | ||
342 | // LSOEngine.LSO.Common.SendToDebug("::BOOLAND"); | ||
343 | // bool b2 = bool.Parse((string) LSLStack.Pop()); | ||
344 | // bool b1 = bool.Parse((string) LSLStack.Pop()); | ||
345 | // if (b1 && b2) | ||
346 | // { | ||
347 | // LSLStack.Push((UInt32) 1); | ||
348 | // } | ||
349 | // else | ||
350 | // { | ||
351 | // LSLStack.Push((UInt32) 0); | ||
352 | // } | ||
353 | // } | ||
354 | |||
355 | // public void BOOLOR() | ||
356 | // { | ||
357 | // LSOEngine.LSO.Common.SendToDebug("::BOOLOR"); | ||
358 | // bool b2 = bool.Parse((string) LSLStack.Pop()); | ||
359 | // bool b1 = bool.Parse((string) LSLStack.Pop()); | ||
360 | |||
361 | // if (b1 || b2) | ||
362 | // { | ||
363 | // LSLStack.Push((UInt32) 1); | ||
364 | // } | ||
365 | // else | ||
366 | // { | ||
367 | // LSLStack.Push((UInt32) 0); | ||
368 | // } | ||
369 | // } | ||
370 | |||
371 | // public void NEG(UInt32 Param) | ||
372 | // { | ||
373 | // LSOEngine.LSO.Common.SendToDebug("::NEG: " + Param); | ||
374 | // //UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
375 | // UInt32 i1 = (UInt32) LSLStack.Pop(); | ||
376 | // LSLStack.Push((UInt32) (i1*-1)); | ||
377 | // } | ||
378 | |||
379 | // public void BITNOT() | ||
380 | // { | ||
381 | // //Common.SendToDebug("::BITNOT"); | ||
382 | // //UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
383 | // //UInt32 i1 = (UInt32)LSLStack.Pop(); | ||
384 | // //LSLStack.Push((UInt32)(i1 / i2)); | ||
385 | // } | ||
386 | |||
387 | // public void BOOLNOT() | ||
388 | // { | ||
389 | // //Common.SendToDebug("::BOOLNOT"); | ||
390 | // ////UInt32 i2 = (UInt32)LSLStack.Pop(); | ||
391 | // //UInt32 i1 = (UInt32)LSLStack.Pop(); | ||
392 | // //LSLStack.Push((UInt32)(i1)); | ||
393 | // } | ||
394 | //} | ||
395 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs new file mode 100644 index 0000000..8454266 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_CLRInterface.cs | |||
@@ -0,0 +1,75 @@ | |||
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 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs new file mode 100644 index 0000000..68ecdca --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSL_OPCODE_IL_processor.cs | |||
@@ -0,0 +1,435 @@ | |||
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 (LSL_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 | private void IL_PopToStack(ILGenerator il) | ||
346 | { | ||
347 | IL_PopToStack(il, 1); | ||
348 | } | ||
349 | |||
350 | private void IL_PopToStack(ILGenerator il, int count) | ||
351 | { | ||
352 | Common.SendToDebug("IL_PopToStack();"); | ||
353 | for (int i = 0; i < count; i++) | ||
354 | { | ||
355 | IL_CallBaseFunction(il, "POPToStack"); | ||
356 | //il.Emit(OpCodes.Ldarg_0); | ||
357 | //il.Emit(OpCodes.Call, | ||
358 | // typeof(LSL_BaseClass).GetMethod("POPToStack", | ||
359 | // new Type[] { })); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | private void IL_Pop(ILGenerator il) | ||
364 | { | ||
365 | Common.SendToDebug("IL_Pop();"); | ||
366 | IL_CallBaseFunction(il, "POP"); | ||
367 | } | ||
368 | |||
369 | private void IL_Debug(ILGenerator il, string text) | ||
370 | { | ||
371 | il.Emit(OpCodes.Ldstr, text); | ||
372 | il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug", | ||
373 | new Type[] {typeof (string)} | ||
374 | )); | ||
375 | } | ||
376 | |||
377 | private void IL_CallBaseFunction(ILGenerator il, string methodname) | ||
378 | { | ||
379 | il.Emit(OpCodes.Ldarg_0); | ||
380 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {})); | ||
381 | } | ||
382 | |||
383 | private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) | ||
384 | { | ||
385 | il.Emit(OpCodes.Ldarg_0); | ||
386 | if (data.GetType() == typeof (string)) | ||
387 | il.Emit(OpCodes.Ldstr, (string) data); | ||
388 | if (data.GetType() == typeof (UInt32)) | ||
389 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); | ||
390 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {data.GetType()})); | ||
391 | } | ||
392 | |||
393 | private void IL_Push(ILGenerator il, object data) | ||
394 | { | ||
395 | il.Emit(OpCodes.Ldarg_0); | ||
396 | Common.SendToDebug("PUSH datatype: " + data.GetType()); | ||
397 | |||
398 | IL_PushDataTypeToILStack(il, data); | ||
399 | |||
400 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()})); | ||
401 | } | ||
402 | |||
403 | private void IL_PushDataTypeToILStack(ILGenerator il, object data) | ||
404 | { | ||
405 | if (data.GetType() == typeof (UInt16)) | ||
406 | { | ||
407 | il.Emit(OpCodes.Ldc_I4, (UInt16) data); | ||
408 | il.Emit(OpCodes.Box, data.GetType()); | ||
409 | } | ||
410 | if (data.GetType() == typeof (UInt32)) | ||
411 | { | ||
412 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); | ||
413 | il.Emit(OpCodes.Box, data.GetType()); | ||
414 | } | ||
415 | if (data.GetType() == typeof (Int32)) | ||
416 | { | ||
417 | il.Emit(OpCodes.Ldc_I4, (Int32) data); | ||
418 | il.Emit(OpCodes.Box, data.GetType()); | ||
419 | } | ||
420 | if (data.GetType() == typeof (float)) | ||
421 | { | ||
422 | il.Emit(OpCodes.Ldc_I4, (float) data); | ||
423 | il.Emit(OpCodes.Box, data.GetType()); | ||
424 | } | ||
425 | if (data.GetType() == typeof (string)) | ||
426 | il.Emit(OpCodes.Ldstr, (string) data); | ||
427 | //if (data.GetType() == typeof(LSO_Enums.Rotation)) | ||
428 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); | ||
429 | //if (data.GetType() == typeof(LSO_Enums.Vector)) | ||
430 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); | ||
431 | //if (data.GetType() == typeof(LSO_Enums.Key)) | ||
432 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); | ||
433 | } | ||
434 | } | ||
435 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs new file mode 100644 index 0000000..c7bce4a --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Enums.cs | |||
@@ -0,0 +1,560 @@ | |||
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 | // OpCode_Add_Types.Add(51, typeof(String)); | ||
39 | // OpCode_Add_Types.Add(17, typeof(UInt32)); | ||
40 | //} | ||
41 | |||
42 | [Serializable] | ||
43 | public enum OpCode_Add_TypeDefs | ||
44 | { | ||
45 | String = 51, | ||
46 | UInt32 = 17 | ||
47 | } | ||
48 | |||
49 | [Serializable] | ||
50 | public enum OpCode_Cast_TypeDefs | ||
51 | { | ||
52 | String = 19 | ||
53 | } | ||
54 | |||
55 | [Serializable] | ||
56 | public struct Key | ||
57 | { | ||
58 | public string KeyString; | ||
59 | } | ||
60 | |||
61 | [Serializable] | ||
62 | public struct Vector | ||
63 | { | ||
64 | public UInt32 Z; | ||
65 | public UInt32 Y; | ||
66 | public UInt32 X; | ||
67 | } | ||
68 | |||
69 | [Serializable] | ||
70 | public struct Rotation | ||
71 | { | ||
72 | public UInt32 S; | ||
73 | public UInt32 Z; | ||
74 | public UInt32 Y; | ||
75 | public UInt32 X; | ||
76 | } | ||
77 | |||
78 | [Serializable] | ||
79 | public enum Variable_Type_Codes | ||
80 | { | ||
81 | Void = 0, | ||
82 | Integer = 1, | ||
83 | Float = 2, | ||
84 | String = 3, | ||
85 | Key = 4, | ||
86 | Vector = 5, | ||
87 | Rotation = 6, | ||
88 | List = 7, | ||
89 | Null = 8 | ||
90 | } | ||
91 | |||
92 | [Serializable] | ||
93 | public enum Event_Mask_Values | ||
94 | { | ||
95 | state_entry = 0, | ||
96 | state_exit = 1, | ||
97 | touch_start = 2, | ||
98 | touch = 3, | ||
99 | touch_end = 4, | ||
100 | collision_start = 5, | ||
101 | collision = 6, | ||
102 | collision_end = 7, | ||
103 | land_collision_start = 8, | ||
104 | land_collision = 9, | ||
105 | land_collision_end = 10, | ||
106 | timer = 11, | ||
107 | listen = 12, | ||
108 | on_rez = 13, | ||
109 | sensor = 14, | ||
110 | no_sensor = 15, | ||
111 | control = 16, | ||
112 | money = 17, | ||
113 | email = 18, | ||
114 | at_target = 19, | ||
115 | not_at_target = 20, | ||
116 | at_rot_target = 21, | ||
117 | not_at_rot_target = 22, | ||
118 | run_time_permissions = 23, | ||
119 | changed = 24, | ||
120 | attach = 25, | ||
121 | dataserver = 26, | ||
122 | link_message = 27, | ||
123 | moving_start = 28, | ||
124 | moving_end = 29, | ||
125 | object_rez = 30, | ||
126 | remote_data = 31, | ||
127 | http_response = 32 | ||
128 | } | ||
129 | |||
130 | [Serializable] | ||
131 | public enum Operation_Table | ||
132 | { | ||
133 | NOOP = 0x0, | ||
134 | POP = 0x1, | ||
135 | POPS = 0x2, | ||
136 | POPL = 0x3, | ||
137 | POPV = 0x4, | ||
138 | POPQ = 0x5, | ||
139 | POPARG = 0x6, | ||
140 | POPIP = 0x7, | ||
141 | POPBP = 0x8, | ||
142 | POPSP = 0x9, | ||
143 | POPSLR = 0xa, | ||
144 | DUP = 0x20, | ||
145 | DUPS = 0x21, | ||
146 | DUPL = 0x22, | ||
147 | DUPV = 0x23, | ||
148 | DUPQ = 0x24, | ||
149 | STORE = 0x30, | ||
150 | STORES = 0x31, | ||
151 | STOREL = 0x32, | ||
152 | STOREV = 0x33, | ||
153 | STOREQ = 0x34, | ||
154 | STOREG = 0x35, | ||
155 | STOREGS = 0x36, | ||
156 | STOREGL = 0x37, | ||
157 | STOREGV = 0x38, | ||
158 | STOREGQ = 0x39, | ||
159 | LOADP = 0x3a, | ||
160 | LOADSP = 0x3b, | ||
161 | LOADLP = 0x3c, | ||
162 | LOADVP = 0x3d, | ||
163 | LOADQP = 0x3e, | ||
164 | LOADGP = 0x3f, | ||
165 | LOADGSP = 0x40, | ||
166 | LOADGLP = 0x41, | ||
167 | LOADGVP = 0x42, | ||
168 | LOADGQP = 0x43, | ||
169 | PUSH = 0x50, | ||
170 | PUSHS = 0x51, | ||
171 | PUSHL = 0x52, | ||
172 | PUSHV = 0x53, | ||
173 | PUSHQ = 0x54, | ||
174 | PUSHG = 0x55, | ||
175 | PUSHGS = 0x56, | ||
176 | PUSHGL = 0x57, | ||
177 | PUSHGV = 0x58, | ||
178 | PUSHGQ = 0x59, | ||
179 | PUSHIP = 0x5a, | ||
180 | PUSHBP = 0x5b, | ||
181 | PUSHSP = 0x5c, | ||
182 | PUSHARGB = 0x5d, | ||
183 | PUSHARGI = 0x5e, | ||
184 | PUSHARGF = 0x5f, | ||
185 | PUSHARGS = 0x60, | ||
186 | PUSHARGV = 0x61, | ||
187 | PUSHARGQ = 0x62, | ||
188 | PUSHE = 0x63, | ||
189 | PUSHEV = 0x64, | ||
190 | PUSHEQ = 0x65, | ||
191 | PUSHARGE = 0x66, | ||
192 | ADD = 0x70, | ||
193 | SUB = 0x71, | ||
194 | MUL = 0x72, | ||
195 | DIV = 0x73, | ||
196 | MOD = 0x74, | ||
197 | EQ = 0x75, | ||
198 | NEQ = 0x76, | ||
199 | LEQ = 0x77, | ||
200 | GEQ = 0x78, | ||
201 | LESS = 0x79, | ||
202 | GREATER = 0x7a, | ||
203 | BITAND = 0x7b, | ||
204 | BITOR = 0x7c, | ||
205 | BITXOR = 0x7d, | ||
206 | BOOLAND = 0x7e, | ||
207 | BOOLOR = 0x7f, | ||
208 | NEG = 0x80, | ||
209 | BITNOT = 0x81, | ||
210 | BOOLNOT = 0x82, | ||
211 | JUMP = 0x90, | ||
212 | JUMPIF = 0x91, | ||
213 | JUMPNIF = 0x92, | ||
214 | STATE = 0x93, | ||
215 | CALL = 0x94, | ||
216 | RETURN = 0x95, | ||
217 | CAST = 0xa0, | ||
218 | STACKTOS = 0xb0, | ||
219 | STACKTOL = 0xb1, | ||
220 | PRINT = 0xc0, | ||
221 | CALLLIB = 0xd0, | ||
222 | CALLLIB_TWO_BYTE = 0xd1, | ||
223 | SHL = 0xe0, | ||
224 | SHR = 0xe1 | ||
225 | } | ||
226 | |||
227 | [Serializable] | ||
228 | public enum BuiltIn_Functions | ||
229 | { | ||
230 | llSin = 0, | ||
231 | llCos = 1, | ||
232 | llTan = 2, | ||
233 | llAtan2 = 3, | ||
234 | llSqrt = 4, | ||
235 | llPow = 5, | ||
236 | llAbs = 6, | ||
237 | llFabs = 7, | ||
238 | llFrand = 8, | ||
239 | llFloor = 9, | ||
240 | llCeil = 10, | ||
241 | llRound = 11, | ||
242 | llVecMag = 12, | ||
243 | llVecNorm = 13, | ||
244 | llVecDist = 14, | ||
245 | llRot2Euler = 15, | ||
246 | llEuler2Rot = 16, | ||
247 | llAxes2Rot = 17, | ||
248 | llRot2Fwd = 18, | ||
249 | llRot2Left = 19, | ||
250 | llRot2Up = 20, | ||
251 | llRotBetween = 21, | ||
252 | llWhisper = 22, | ||
253 | llSay = 23, | ||
254 | llShout = 24, | ||
255 | llListen = 25, | ||
256 | llListenControl = 26, | ||
257 | llListenRemove = 27, | ||
258 | llSensor = 28, | ||
259 | llSensorRepeat = 29, | ||
260 | llSensorRemove = 30, | ||
261 | llDetectedName = 31, | ||
262 | llDetectedKey = 32, | ||
263 | llDetectedOwner = 33, | ||
264 | llDetectedType = 34, | ||
265 | llDetectedPos = 35, | ||
266 | llDetectedVel = 36, | ||
267 | llDetectedGrab = 37, | ||
268 | llDetectedRot = 38, | ||
269 | llDetectedGroup = 39, | ||
270 | llDetectedLinkNumber = 40, | ||
271 | llDie = 41, | ||
272 | llGround = 42, | ||
273 | llCloud = 43, | ||
274 | llWind = 44, | ||
275 | llSetStatus = 45, | ||
276 | llGetStatus = 46, | ||
277 | llSetScale = 47, | ||
278 | llGetScale = 48, | ||
279 | llSetColor = 49, | ||
280 | llGetAlpha = 50, | ||
281 | llSetAlpha = 51, | ||
282 | llGetColor = 52, | ||
283 | llSetTexture = 53, | ||
284 | llScaleTexture = 54, | ||
285 | llOffsetTexture = 55, | ||
286 | llRotateTexture = 56, | ||
287 | llGetTexture = 57, | ||
288 | llSetPos = 58, | ||
289 | llGetPos = 59, | ||
290 | llGetLocalPos = 60, | ||
291 | llSetRot = 61, | ||
292 | llGetRot = 62, | ||
293 | llGetLocalRot = 63, | ||
294 | llSetForce = 64, | ||
295 | llGetForce = 65, | ||
296 | llTarget = 66, | ||
297 | llTargetRemove = 67, | ||
298 | llRotTarget = 68, | ||
299 | llRotTargetRemove = 69, | ||
300 | llMoveToTarget = 70, | ||
301 | llStopMoveToTarget = 71, | ||
302 | llApplyImpulse = 72, | ||
303 | llApplyRotationalImpulse = 73, | ||
304 | llSetTorque = 74, | ||
305 | llGetTorque = 75, | ||
306 | llSetForceAndTorque = 76, | ||
307 | llGetVel = 77, | ||
308 | llGetAccel = 78, | ||
309 | llGetOmega = 79, | ||
310 | llGetTimeOfDay = 80, | ||
311 | llGetWallclock = 81, | ||
312 | llGetTime = 82, | ||
313 | llResetTime = 83, | ||
314 | llGetAndResetTime = 84, | ||
315 | llSound = 85, | ||
316 | llPlaySound = 86, | ||
317 | llLoopSound = 87, | ||
318 | llLoopSoundMaster = 88, | ||
319 | llLoopSoundSlave = 89, | ||
320 | llPlaySoundSlave = 90, | ||
321 | llTriggerSound = 91, | ||
322 | llStopSound = 92, | ||
323 | llPreloadSound = 93, | ||
324 | llGetSubString = 94, | ||
325 | llDeleteSubString = 95, | ||
326 | llInsertString = 96, | ||
327 | llToUpper = 97, | ||
328 | llToLower = 98, | ||
329 | llGiveMoney = 99, | ||
330 | llMakeExplosion = 100, | ||
331 | llMakeFountain = 101, | ||
332 | llMakeSmoke = 102, | ||
333 | llMakeFire = 103, | ||
334 | llRezObject = 104, | ||
335 | llLookAt = 105, | ||
336 | llStopLookAt = 106, | ||
337 | llSetTimerEvent = 107, | ||
338 | llSleep = 108, | ||
339 | llGetMass = 109, | ||
340 | llCollisionFilter = 110, | ||
341 | llTakeControls = 111, | ||
342 | llReleaseControls = 112, | ||
343 | llAttachToAvatar = 113, | ||
344 | llDetachFromAvatar = 114, | ||
345 | llTakeCamera = 115, | ||
346 | llReleaseCamera = 116, | ||
347 | llGetOwner = 117, | ||
348 | llInstantMessage = 118, | ||
349 | llEmail = 119, | ||
350 | llGetNextEmail = 120, | ||
351 | llGetKey = 121, | ||
352 | llSetBuoyancy = 122, | ||
353 | llSetHoverHeight = 123, | ||
354 | llStopHover = 124, | ||
355 | llMinEventDelay = 125, | ||
356 | llSoundPreload = 126, | ||
357 | llRotLookAt = 127, | ||
358 | llStringLength = 128, | ||
359 | llStartAnimation = 129, | ||
360 | llStopAnimation = 130, | ||
361 | llPointAt = 131, | ||
362 | llStopPointAt = 132, | ||
363 | llTargetOmega = 133, | ||
364 | llGetStartParameter = 134, | ||
365 | llGodLikeRezObject = 135, | ||
366 | llRequestPermissions = 136, | ||
367 | llGetPermissionsKey = 137, | ||
368 | llGetPermissions = 138, | ||
369 | llGetLinkNumber = 139, | ||
370 | llSetLinkColor = 140, | ||
371 | llCreateLink = 141, | ||
372 | llBreakLink = 142, | ||
373 | llBreakAllLinks = 143, | ||
374 | llGetLinkKey = 144, | ||
375 | llGetLinkName = 145, | ||
376 | llGetInventoryNumber = 146, | ||
377 | llGetInventoryName = 147, | ||
378 | llSetScriptState = 148, | ||
379 | llGetEnergy = 149, | ||
380 | llGiveInventory = 150, | ||
381 | llRemoveInventory = 151, | ||
382 | llSetText = 152, | ||
383 | llWater = 153, | ||
384 | llPassTouches = 154, | ||
385 | llRequestAgentData = 155, | ||
386 | llRequestInventoryData = 156, | ||
387 | llSetDamage = 157, | ||
388 | llTeleportAgentHome = 158, | ||
389 | llModifyLand = 159, | ||
390 | llCollisionSound = 160, | ||
391 | llCollisionSprite = 161, | ||
392 | llGetAnimation = 162, | ||
393 | llResetScript = 163, | ||
394 | llMessageLinked = 164, | ||
395 | llPushObject = 165, | ||
396 | llPassCollisions = 166, | ||
397 | llGetScriptName = 167, | ||
398 | llGetNumberOfSides = 168, | ||
399 | llAxisAngle2Rot = 169, | ||
400 | llRot2Axis = 170, | ||
401 | llRot2Angle = 171, | ||
402 | llAcos = 172, | ||
403 | llAsin = 173, | ||
404 | llAngleBetween = 174, | ||
405 | llGetInventoryKey = 175, | ||
406 | llAllowInventoryDrop = 176, | ||
407 | llGetSunDirection = 177, | ||
408 | llGetTextureOffset = 178, | ||
409 | llGetTextureScale = 179, | ||
410 | llGetTextureRot = 180, | ||
411 | llSubStringIndex = 181, | ||
412 | llGetOwnerKey = 182, | ||
413 | llGetCenterOfMass = 183, | ||
414 | llListSort = 184, | ||
415 | llGetListLength = 185, | ||
416 | llList2Integer = 186, | ||
417 | llList2Float = 187, | ||
418 | llList2String = 188, | ||
419 | llList2Key = 189, | ||
420 | llList2Vector = 190, | ||
421 | llList2Rot = 191, | ||
422 | llList2List = 192, | ||
423 | llDeleteSubList = 193, | ||
424 | llGetListEntryType = 194, | ||
425 | llList2CSV = 195, | ||
426 | llCSV2List = 196, | ||
427 | llListRandomize = 197, | ||
428 | llList2ListStrided = 198, | ||
429 | llGetRegionCorner = 199, | ||
430 | llListInsertList = 200, | ||
431 | llListFindList = 201, | ||
432 | llGetObjectName = 202, | ||
433 | llSetObjectName = 203, | ||
434 | llGetDate = 204, | ||
435 | llEdgeOfWorld = 205, | ||
436 | llGetAgentInfo = 206, | ||
437 | llAdjustSoundVolume = 207, | ||
438 | llSetSoundQueueing = 208, | ||
439 | llSetSoundRadius = 209, | ||
440 | llKey2Name = 210, | ||
441 | llSetTextureAnim = 211, | ||
442 | llTriggerSoundLimited = 212, | ||
443 | llEjectFromLand = 213, | ||
444 | llParseString2List = 214, | ||
445 | llOverMyLand = 215, | ||
446 | llGetLandOwnerAt = 216, | ||
447 | llGetNotecardLine = 217, | ||
448 | llGetAgentSize = 218, | ||
449 | llSameGroup = 219, | ||
450 | llUnSit = 220, | ||
451 | llGroundSlope = 221, | ||
452 | llGroundNormal = 222, | ||
453 | llGroundContour = 223, | ||
454 | llGetAttached = 224, | ||
455 | llGetFreeMemory = 225, | ||
456 | llGetRegionName = 226, | ||
457 | llGetRegionTimeDilation = 227, | ||
458 | llGetRegionFPS = 228, | ||
459 | llParticleSystem = 229, | ||
460 | llGroundRepel = 230, | ||
461 | llGiveInventoryList = 231, | ||
462 | llSetVehicleType = 232, | ||
463 | llSetVehicleFloatParam = 233, | ||
464 | llSetVehicleVectorParam = 234, | ||
465 | llSetVehicleRotationParam = 235, | ||
466 | llSetVehicleFlags = 236, | ||
467 | llRemoveVehicleFlags = 237, | ||
468 | llSitTarget = 238, | ||
469 | llAvatarOnSitTarget = 239, | ||
470 | llAddToLandPassList = 240, | ||
471 | llSetTouchText = 241, | ||
472 | llSetSitText = 242, | ||
473 | llSetCameraEyeOffset = 243, | ||
474 | llSetCameraAtOffset = 244, | ||
475 | llDumpList2String = 245, | ||
476 | llScriptDanger = 246, | ||
477 | llDialog = 247, | ||
478 | llVolumeDetect = 248, | ||
479 | llResetOtherScript = 249, | ||
480 | llGetScriptState = 250, | ||
481 | llRemoteLoadScript = 251, | ||
482 | llSetRemoteScriptAccessPin = 252, | ||
483 | llRemoteLoadScriptPin = 253, | ||
484 | llOpenRemoteDataChannel = 254, | ||
485 | llSendRemoteData = 255, | ||
486 | llRemoteDataReply = 256, | ||
487 | llCloseRemoteDataChannel = 257, | ||
488 | llMD5String = 258, | ||
489 | llSetPrimitiveParams = 259, | ||
490 | llStringToBase64 = 260, | ||
491 | llBase64ToString = 261, | ||
492 | llXorBase64Strings = 262, | ||
493 | llRemoteDataSetRegion = 263, | ||
494 | llLog10 = 264, | ||
495 | llLog = 265, | ||
496 | llGetAnimationList = 266, | ||
497 | llSetParcelMusicURL = 267, | ||
498 | llGetRootPosition = 268, | ||
499 | llGetRootRotation = 269, | ||
500 | llGetObjectDesc = 270, | ||
501 | llSetObjectDesc = 271, | ||
502 | llGetCreator = 272, | ||
503 | llGetTimestamp = 273, | ||
504 | llSetLinkAlpha = 274, | ||
505 | llGetNumberOfPrims = 275, | ||
506 | llGetNumberOfNotecardLines = 276, | ||
507 | llGetBoundingBox = 277, | ||
508 | llGetGeometricCenter = 278, | ||
509 | llGetPrimitiveParams = 279, | ||
510 | llIntegerToBase64 = 280, | ||
511 | llBase64ToInteger = 281, | ||
512 | llGetGMTclock = 282, | ||
513 | llGetSimulatorHostname = 283, | ||
514 | llSetLocalRot = 284, | ||
515 | llParseStringKeepNulls = 285, | ||
516 | llRezAtRoot = 286, | ||
517 | llGetObjectPermMask = 287, | ||
518 | llSetObjectPermMask = 288, | ||
519 | llGetInventoryPermMask = 289, | ||
520 | llSetInventoryPermMask = 290, | ||
521 | llGetInventoryCreator = 291, | ||
522 | llOwnerSay = 292, | ||
523 | llRequestSimulatorData = 293, | ||
524 | llForceMouselook = 294, | ||
525 | llGetObjectMass = 295, | ||
526 | llListReplaceList = 296, | ||
527 | llLoadURL = 297, | ||
528 | llParcelMediaCommandList = 298, | ||
529 | llParcelMediaQuery = 299, | ||
530 | llModPow = 300, | ||
531 | llGetInventoryType = 301, | ||
532 | llSetPayPrice = 302, | ||
533 | llGetCameraPos = 303, | ||
534 | llGetCameraRot = 304, | ||
535 | llSetPrimURL = 305, | ||
536 | llRefreshPrimURL = 306, | ||
537 | llEscapeURL = 307, | ||
538 | llUnescapeURL = 308, | ||
539 | llMapDestination = 309, | ||
540 | llAddToLandBanList = 310, | ||
541 | llRemoveFromLandPassList = 311, | ||
542 | llRemoveFromLandBanList = 312, | ||
543 | llSetCameraParams = 313, | ||
544 | llClearCameraParams = 314, | ||
545 | llListStatistics = 315, | ||
546 | llGetUnixTime = 316, | ||
547 | llGetParcelFlags = 317, | ||
548 | llGetRegionFlags = 318, | ||
549 | llXorBase64StringsCorrect = 319, | ||
550 | llHTTPRequest = 320, | ||
551 | llResetLandBanList = 321, | ||
552 | llResetLandPassList = 322, | ||
553 | llGetParcelPrimCount = 323, | ||
554 | llGetParcelPrimOwners = 324, | ||
555 | llGetObjectPrimCount = 325, | ||
556 | llGetParcelMaxPrims = 326, | ||
557 | llGetParcelDetails = 327 | ||
558 | } | ||
559 | } | ||
560 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs new file mode 100644 index 0000000..1d3992f --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Parser.cs | |||
@@ -0,0 +1,729 @@ | |||
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 | using OpenSim.Region.ScriptEngine.LSOEngine.LSO; | ||
37 | |||
38 | namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO | ||
39 | { | ||
40 | internal partial class LSO_Parser | ||
41 | { | ||
42 | private string FileName; | ||
43 | private FileStream fs; | ||
44 | private BinaryReader br; | ||
45 | internal LSO_Struct.Header myHeader; | ||
46 | internal Dictionary<long, LSO_Struct.StaticBlock> StaticBlocks = new Dictionary<long, LSO_Struct.StaticBlock>(); | ||
47 | //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable(); | ||
48 | |||
49 | private TypeBuilder typeBuilder; | ||
50 | private List<string> EventList = new List<string>(); | ||
51 | |||
52 | public LSO_Parser(string _FileName, TypeBuilder _typeBuilder) | ||
53 | { | ||
54 | FileName = _FileName; | ||
55 | typeBuilder = _typeBuilder; | ||
56 | } | ||
57 | |||
58 | internal void OpenFile() | ||
59 | { | ||
60 | // Open | ||
61 | Common.SendToDebug("Opening filename: " + FileName); | ||
62 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); | ||
63 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); | ||
64 | } | ||
65 | |||
66 | internal void CloseFile() | ||
67 | { | ||
68 | // Close | ||
69 | br.Close(); | ||
70 | fs.Close(); | ||
71 | } | ||
72 | |||
73 | |||
74 | /// <summary> | ||
75 | /// Parse LSO file. | ||
76 | /// </summary> | ||
77 | public void Parse() | ||
78 | { | ||
79 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. | ||
80 | |||
81 | |||
82 | // HEADER BLOCK | ||
83 | Common.SendToDebug("Reading HEADER BLOCK at: 0"); | ||
84 | fs.Seek(0, SeekOrigin.Begin); | ||
85 | myHeader = new LSO_Struct.Header(); | ||
86 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); | ||
87 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); | ||
88 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); | ||
89 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); | ||
90 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); | ||
91 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); | ||
92 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); | ||
93 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); | ||
94 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); | ||
95 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); | ||
96 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); | ||
97 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); | ||
98 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); | ||
99 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); | ||
100 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); | ||
101 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); | ||
102 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); | ||
103 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); | ||
104 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); | ||
105 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); | ||
106 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); | ||
107 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); | ||
108 | |||
109 | // Print Header Block to debug | ||
110 | Common.SendToDebug("TM - Top of memory (size): " + myHeader.TM); | ||
111 | Common.SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); | ||
112 | Common.SendToDebug("VN - Version number: " + myHeader.VN); | ||
113 | Common.SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); | ||
114 | Common.SendToDebug("SP - Stack Pointer: " + myHeader.SP); | ||
115 | Common.SendToDebug("HR - Heap Register: " + myHeader.HR); | ||
116 | Common.SendToDebug("HP - Heap Pointer: " + myHeader.HP); | ||
117 | Common.SendToDebug("CS - Current State: " + myHeader.CS); | ||
118 | Common.SendToDebug("NS - Next State: " + myHeader.NS); | ||
119 | Common.SendToDebug("CE - Current Events: " + myHeader.CE); | ||
120 | Common.SendToDebug("IE - In Event: " + myHeader.IE); | ||
121 | Common.SendToDebug("ER - Event Register: " + myHeader.ER); | ||
122 | Common.SendToDebug("FR - Fault Register: " + myHeader.FR); | ||
123 | Common.SendToDebug("SLR - Sleep Register: " + myHeader.SLR); | ||
124 | Common.SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); | ||
125 | Common.SendToDebug("GFR - Global Function Register: " + myHeader.GFR); | ||
126 | Common.SendToDebug("PR - Parameter Register: " + myHeader.PR); | ||
127 | Common.SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); | ||
128 | Common.SendToDebug("SR - State Register: " + myHeader.SR); | ||
129 | Common.SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); | ||
130 | Common.SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); | ||
131 | Common.SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); | ||
132 | Common.SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); | ||
133 | |||
134 | // STATIC BLOCK | ||
135 | Common.SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); | ||
136 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
137 | int StaticBlockCount = 0; | ||
138 | // Read function blocks until we hit GFR | ||
139 | while (fs.Position < myHeader.GFR) | ||
140 | { | ||
141 | StaticBlockCount++; | ||
142 | long startReadPos = fs.Position; | ||
143 | Common.SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + startReadPos); | ||
144 | |||
145 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
146 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | ||
147 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | ||
148 | myStaticBlock.ObjectType = br_read(1)[0]; | ||
149 | Common.SendToDebug("Static Block ObjectType: " + | ||
150 | ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); | ||
151 | myStaticBlock.Unknown = br_read(1)[0]; | ||
152 | // Size of datatype varies -- what about strings? | ||
153 | if (myStaticBlock.ObjectType != 0) | ||
154 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | ||
155 | |||
156 | StaticBlocks.Add((UInt32) startReadPos, myStaticBlock); | ||
157 | } | ||
158 | Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); | ||
159 | |||
160 | |||
161 | // FUNCTION BLOCK | ||
162 | // Always right after STATIC BLOCK | ||
163 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); | ||
164 | if (myHeader.GFR == myHeader.SR) | ||
165 | { | ||
166 | // If GFR and SR are at same position then there is no fuction block | ||
167 | Common.SendToDebug("No FUNCTION BLOCK found"); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | Common.SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); | ||
172 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); | ||
173 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); | ||
174 | Common.SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); | ||
175 | if (myFunctionBlock.FunctionCount > 0) | ||
176 | { | ||
177 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; | ||
178 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | ||
179 | { | ||
180 | Common.SendToDebug("Reading function " + i + " at: " + fs.Position); | ||
181 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) | ||
182 | // Note! Absolute position | ||
183 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; | ||
184 | Common.SendToDebug("Fuction " + i + " code chunk position: " + | ||
185 | myFunctionBlock.CodeChunkPointer[i]); | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | |||
190 | |||
191 | // STATE FRAME BLOCK | ||
192 | // Always right after FUNCTION BLOCK | ||
193 | Common.SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); | ||
194 | fs.Seek(myHeader.SR, SeekOrigin.Begin); | ||
195 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); | ||
196 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); | ||
197 | if (myStateFrameBlock.StateCount > 0) | ||
198 | { | ||
199 | // Initialize array | ||
200 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; | ||
201 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
202 | { | ||
203 | Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); | ||
204 | // Position is relative to state frame | ||
205 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); | ||
206 | myStateFrameBlock.StatePointer[i].EventMask = new BitArray(br_read(8)); | ||
207 | Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); | ||
208 | Common.SendToDebug("Total potential EventMask bits: " + | ||
209 | myStateFrameBlock.StatePointer[i].EventMask.Count); | ||
210 | |||
211 | //// Read STATE BLOCK | ||
212 | //long CurPos = fs.Position; | ||
213 | //fs.Seek(CurPos, SeekOrigin.Begin); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | |||
218 | // STATE BLOCK | ||
219 | // For each StateFrameBlock there is one StateBlock with multiple event handlers | ||
220 | |||
221 | if (myStateFrameBlock.StateCount > 0) | ||
222 | { | ||
223 | // Go through all State Frame Pointers found | ||
224 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
225 | { | ||
226 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); | ||
227 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); | ||
228 | |||
229 | // READ: STATE BLOCK HEADER | ||
230 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); | ||
231 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32) fs.Position; // Note | ||
232 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); | ||
233 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; | ||
234 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32) fs.Position; // Note | ||
235 | Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); | ||
236 | Common.SendToDebug("State block Header Size: " + | ||
237 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); | ||
238 | Common.SendToDebug("State block Header End Pos: " + | ||
239 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos); | ||
240 | |||
241 | // We need to count number of bits flagged in EventMask? | ||
242 | |||
243 | |||
244 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask | ||
245 | |||
246 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE | ||
247 | //TODO: Create event hooks | ||
248 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = | ||
249 | new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; | ||
250 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
251 | { | ||
252 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) | ||
253 | { | ||
254 | // We got an event | ||
255 | // READ: STATE BLOCK HANDLER | ||
256 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + | ||
257 | " (" + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") at: " + | ||
258 | fs.Position); | ||
259 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = | ||
260 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos + | ||
261 | BitConverter.ToUInt32(br_read(4), 0); | ||
262 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = | ||
263 | BitConverter.ToUInt32(br_read(4), 0); | ||
264 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + | ||
265 | ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Code Chunk Pointer: " + | ||
266 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. | ||
267 | CodeChunkPointer); | ||
268 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + | ||
269 | ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Call Frame Size: " + | ||
270 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. | ||
271 | CallFrameSize); | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | //// READ FUNCTION CODE CHUNKS | ||
279 | //// Functions + Function start pos (GFR) | ||
280 | //// TODO: Somehow be able to identify and reference this | ||
281 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; | ||
282 | //if (myFunctionBlock.FunctionCount > 0) | ||
283 | //{ | ||
284 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; | ||
285 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | ||
286 | // { | ||
287 | // Common.SendToDebug("Reading Function Code Chunk " + i); | ||
288 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); | ||
289 | // } | ||
290 | |||
291 | //} | ||
292 | // READ EVENT CODE CHUNKS | ||
293 | LSO_Struct.CodeChunk[] myEventCodeChunk; | ||
294 | if (myStateFrameBlock.StateCount > 0) | ||
295 | { | ||
296 | myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; | ||
297 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
298 | { | ||
299 | // TODO: Somehow organize events and functions so they can be found again, | ||
300 | // two level search ain't no good | ||
301 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
302 | { | ||
303 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) | ||
304 | { | ||
305 | Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + | ||
306 | (LSO_Enums.Event_Mask_Values) ii); | ||
307 | |||
308 | |||
309 | // Override a Method / Function | ||
310 | string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values) ii; | ||
311 | Common.SendToDebug("Event Name: " + eventname); | ||
312 | if (Common.IL_ProcessCodeChunks) | ||
313 | { | ||
314 | EventList.Add(eventname); | ||
315 | |||
316 | // JUMP TO CODE PROCESSOR | ||
317 | ProcessCodeChunk( | ||
318 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, | ||
319 | typeBuilder, eventname); | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | } | ||
324 | } | ||
325 | |||
326 | |||
327 | if (Common.IL_CreateFunctionList) | ||
328 | IL_INSERT_FUNCTIONLIST(); | ||
329 | } | ||
330 | |||
331 | internal LSO_Struct.HeapBlock GetHeap(UInt32 pos) | ||
332 | { | ||
333 | // HEAP BLOCK | ||
334 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) | ||
335 | Common.SendToDebug("Reading HEAP BLOCK at: " + pos); | ||
336 | fs.Seek(pos, SeekOrigin.Begin); | ||
337 | |||
338 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); | ||
339 | myHeapBlock.DataBlockSize = BitConverter.ToInt32(br_read(4), 0); | ||
340 | myHeapBlock.ObjectType = br_read(1)[0]; | ||
341 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); | ||
342 | //myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); | ||
343 | // Don't read it reversed | ||
344 | myHeapBlock.Data = new byte[myHeapBlock.DataBlockSize - 1]; | ||
345 | br.Read(myHeapBlock.Data, 0, myHeapBlock.DataBlockSize - 1); | ||
346 | |||
347 | |||
348 | Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); | ||
349 | Common.SendToDebug("Heap Block ObjectType: " + | ||
350 | ((LSO_Enums.Variable_Type_Codes) myHeapBlock.ObjectType).ToString()); | ||
351 | Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); | ||
352 | |||
353 | return myHeapBlock; | ||
354 | } | ||
355 | |||
356 | private byte[] br_read(int len) | ||
357 | { | ||
358 | if (len <= 0) | ||
359 | return null; | ||
360 | |||
361 | try | ||
362 | { | ||
363 | byte[] bytes = new byte[len]; | ||
364 | for (int i = len - 1; i > -1; i--) | ||
365 | bytes[i] = br.ReadByte(); | ||
366 | return bytes; | ||
367 | } | ||
368 | catch (Exception e) | ||
369 | { | ||
370 | Common.SendToDebug("Exception: " + e.ToString()); | ||
371 | throw (e); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | //private byte[] br_read_smallendian(int len) | ||
376 | //{ | ||
377 | // byte[] bytes = new byte[len]; | ||
378 | // br.Read(bytes,0, len); | ||
379 | // return bytes; | ||
380 | //} | ||
381 | private Type getLLObjectType(byte objectCode) | ||
382 | { | ||
383 | switch ((LSO_Enums.Variable_Type_Codes) objectCode) | ||
384 | { | ||
385 | case LSO_Enums.Variable_Type_Codes.Void: | ||
386 | return typeof (void); | ||
387 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
388 | return typeof (UInt32); | ||
389 | case LSO_Enums.Variable_Type_Codes.Float: | ||
390 | return typeof (float); | ||
391 | case LSO_Enums.Variable_Type_Codes.String: | ||
392 | return typeof (string); | ||
393 | case LSO_Enums.Variable_Type_Codes.Key: | ||
394 | return typeof (string); | ||
395 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
396 | return typeof (LSO_Enums.Vector); | ||
397 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
398 | return typeof (LSO_Enums.Rotation); | ||
399 | case LSO_Enums.Variable_Type_Codes.List: | ||
400 | Common.SendToDebug("TODO: List datatype not implemented yet!"); | ||
401 | return typeof (ArrayList); | ||
402 | case LSO_Enums.Variable_Type_Codes.Null: | ||
403 | Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!"); | ||
404 | return typeof (string); | ||
405 | default: | ||
406 | Common.SendToDebug("Lookup of LSL datatype " + objectCode + | ||
407 | " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); | ||
408 | return typeof (object); | ||
409 | } | ||
410 | } | ||
411 | |||
412 | private int getObjectSize(byte ObjectType) | ||
413 | { | ||
414 | switch ((LSO_Enums.Variable_Type_Codes) ObjectType) | ||
415 | { | ||
416 | case LSO_Enums.Variable_Type_Codes.Integer: | ||
417 | case LSO_Enums.Variable_Type_Codes.Float: | ||
418 | case LSO_Enums.Variable_Type_Codes.String: | ||
419 | case LSO_Enums.Variable_Type_Codes.Key: | ||
420 | case LSO_Enums.Variable_Type_Codes.List: | ||
421 | return 4; | ||
422 | case LSO_Enums.Variable_Type_Codes.Vector: | ||
423 | return 12; | ||
424 | case LSO_Enums.Variable_Type_Codes.Rotation: | ||
425 | return 16; | ||
426 | default: | ||
427 | return 0; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | private string Read_String() | ||
432 | { | ||
433 | string ret = ""; | ||
434 | byte reader = br_read(1)[0]; | ||
435 | while (reader != 0x000) | ||
436 | { | ||
437 | ret += (char) reader; | ||
438 | reader = br_read(1)[0]; | ||
439 | } | ||
440 | return ret; | ||
441 | } | ||
442 | |||
443 | /// <summary> | ||
444 | /// Reads a code chunk and creates IL | ||
445 | /// </summary> | ||
446 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> | ||
447 | /// <param name="typeBuilder">TypeBuilder for assembly</param> | ||
448 | /// <param name="eventname">Name of event (function) to generate</param> | ||
449 | private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) | ||
450 | { | ||
451 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); | ||
452 | |||
453 | Common.SendToDebug("Reading Function Code Chunk at: " + pos); | ||
454 | fs.Seek(pos, SeekOrigin.Begin); | ||
455 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); | ||
456 | Common.SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize); | ||
457 | // Read until null | ||
458 | myCodeChunk.Comment = Read_String(); | ||
459 | Common.SendToDebug("Function comment: " + myCodeChunk.Comment); | ||
460 | myCodeChunk.ReturnTypePos = br_read(1)[0]; | ||
461 | myCodeChunk.ReturnType = GetStaticBlock((long) myCodeChunk.ReturnTypePos + (long) myHeader.GVR); | ||
462 | Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + | ||
463 | ((LSO_Enums.Variable_Type_Codes) myCodeChunk.ReturnType.ObjectType).ToString()); | ||
464 | |||
465 | |||
466 | // TODO: How to determine number of codechunks -- does this method work? | ||
467 | myCodeChunk.CodeChunkArguments = new List<LSO_Struct.CodeChunkArgument>(); | ||
468 | byte reader = br_read(1)[0]; | ||
469 | reader = br_read(1)[0]; | ||
470 | |||
471 | // NOTE ON CODE CHUNK ARGUMENTS | ||
472 | // This determins type definition | ||
473 | int ccount = 0; | ||
474 | while (reader != 0x000) | ||
475 | { | ||
476 | ccount++; | ||
477 | Common.SendToDebug("Reading Code Chunk Argument " + ccount); | ||
478 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); | ||
479 | CCA.FunctionReturnTypePos = reader; | ||
480 | reader = br_read(1)[0]; | ||
481 | CCA.NullString = reader; | ||
482 | CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR); | ||
483 | myCodeChunk.CodeChunkArguments.Add(CCA); | ||
484 | Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + | ||
485 | ": " + (LSO_Enums.Variable_Type_Codes) CCA.FunctionReturnType.ObjectType); | ||
486 | } | ||
487 | // Create string array | ||
488 | Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; | ||
489 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | ||
490 | { | ||
491 | MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType); | ||
492 | Common.SendToDebug("Method argument " + _ic + ": " + | ||
493 | getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType). | ||
494 | ToString()); | ||
495 | } | ||
496 | // End marker is 0x000 | ||
497 | myCodeChunk.EndMarker = reader; | ||
498 | |||
499 | |||
500 | // | ||
501 | // Emit: START OF METHOD (FUNCTION) | ||
502 | // | ||
503 | |||
504 | Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); | ||
505 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | ||
506 | MethodAttributes.Public, | ||
507 | typeof (void), | ||
508 | new Type[] {typeof (object)}); | ||
509 | //MethodArgs); | ||
510 | //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), | ||
511 | // new Type[] { typeof(object) }, //); | ||
512 | |||
513 | //Common.SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); | ||
514 | //typeBuilder.DefineMethodOverride(methodBuilder, | ||
515 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | ||
516 | |||
517 | // Create the IL generator | ||
518 | |||
519 | Common.SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); | ||
520 | ILGenerator il = methodBuilder.GetILGenerator(); | ||
521 | |||
522 | |||
523 | if (Common.IL_UseTryCatch) | ||
524 | IL_INSERT_TRY(il, eventname); | ||
525 | |||
526 | |||
527 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | ||
528 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
529 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod | ||
530 | // ("WriteLine", new Type[] { typeof(string) })); | ||
531 | |||
532 | //Common.SendToDebug("STARTUP: il.Emit(OpCodes.Ldc_I4_S, 0);"); | ||
533 | |||
534 | //il.Emit(OpCodes.Ldc_I4_S, 0); | ||
535 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | ||
536 | { | ||
537 | Common.SendToDebug("PARAMS: il.Emit(OpCodes.Ldarg, " + _ic + ");"); | ||
538 | il.Emit(OpCodes.Ldarg, _ic); | ||
539 | } | ||
540 | |||
541 | |||
542 | // | ||
543 | // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL | ||
544 | // | ||
545 | bool FoundRet = false; | ||
546 | while (FoundRet == false) | ||
547 | { | ||
548 | FoundRet = LSL_PROCESS_OPCODE(il); | ||
549 | } | ||
550 | |||
551 | |||
552 | if (Common.IL_UseTryCatch) | ||
553 | IL_INSERT_END_TRY(il, eventname); | ||
554 | |||
555 | // Emit: RETURN FROM METHOD | ||
556 | il.Emit(OpCodes.Ret); | ||
557 | |||
558 | return; | ||
559 | } | ||
560 | |||
561 | private void IL_INSERT_FUNCTIONLIST() | ||
562 | { | ||
563 | Common.SendToDebug("Creating function list"); | ||
564 | |||
565 | |||
566 | string eventname = "GetFunctions"; | ||
567 | |||
568 | Common.SendToDebug("Creating IL " + eventname); | ||
569 | // Define a private String field. | ||
570 | //FieldBuilder myField = myTypeBuilder.DefineField("EventList", typeof(String[]), FieldAttributes.Public); | ||
571 | |||
572 | |||
573 | //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); | ||
574 | |||
575 | |||
576 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | ||
577 | MethodAttributes.Public, | ||
578 | typeof (string[]), | ||
579 | null); | ||
580 | |||
581 | //typeBuilder.DefineMethodOverride(methodBuilder, | ||
582 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | ||
583 | |||
584 | ILGenerator il = methodBuilder.GetILGenerator(); | ||
585 | |||
586 | |||
587 | // IL_INSERT_TRY(il, eventname); | ||
588 | |||
589 | // // Push string to stack | ||
590 | // il.Emit(OpCodes.Ldstr, "Inside " + eventname); | ||
591 | |||
592 | //// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | ||
593 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod | ||
594 | // ("WriteLine", new Type[] { typeof(string) })); | ||
595 | |||
596 | //initIL.Emit(OpCodes.Newobj, typeof(string[])); | ||
597 | |||
598 | //string[] MyArray = new string[2] { "TestItem1" , "TestItem2" }; | ||
599 | |||
600 | ////il.Emit(OpCodes.Ldarg_0); | ||
601 | |||
602 | il.DeclareLocal(typeof (string[])); | ||
603 | |||
604 | ////il.Emit(OpCodes.Ldarg_0); | ||
605 | il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length | ||
606 | il.Emit(OpCodes.Newarr, typeof (String)); // create new string array | ||
607 | il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack | ||
608 | ////SetFunctionList | ||
609 | |||
610 | for (int lv = 0; lv < EventList.Count; lv++) | ||
611 | { | ||
612 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | ||
613 | il.Emit(OpCodes.Ldc_I4, lv); // Push index position | ||
614 | il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value | ||
615 | il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value | ||
616 | |||
617 | //il.Emit(OpCodes.Ldarg_0); | ||
618 | //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value | ||
619 | //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) })); | ||
620 | } | ||
621 | |||
622 | |||
623 | // IL_INSERT_END_TRY(il, eventname); | ||
624 | |||
625 | |||
626 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | ||
627 | // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) })); | ||
628 | |||
629 | il.Emit(OpCodes.Ret); // Return | ||
630 | } | ||
631 | |||
632 | |||
633 | private void IL_INSERT_TRY(ILGenerator il, string eventname) | ||
634 | { | ||
635 | /* | ||
636 | * CLR TRY | ||
637 | */ | ||
638 | //Common.SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); | ||
639 | il.BeginExceptionBlock(); | ||
640 | |||
641 | // Push "Hello World!" string to stack | ||
642 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | ||
643 | //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); | ||
644 | } | ||
645 | |||
646 | private void IL_INSERT_END_TRY(ILGenerator il, string eventname) | ||
647 | { | ||
648 | /* | ||
649 | * CATCH | ||
650 | */ | ||
651 | Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); | ||
652 | il.BeginCatchBlock(typeof (Exception)); | ||
653 | |||
654 | // Push "Hello World!" string to stack | ||
655 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | ||
656 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); | ||
657 | |||
658 | //call void [mscorlib]System.Console::WriteLine(string) | ||
659 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
660 | il.Emit(OpCodes.Call, typeof (Console).GetMethod | ||
661 | ("Write", new Type[] {typeof (string)})); | ||
662 | |||
663 | //callvirt instance string [mscorlib]System.Exception::get_Message() | ||
664 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); | ||
665 | il.Emit(OpCodes.Callvirt, typeof (Exception).GetMethod | ||
666 | ("get_Message")); | ||
667 | |||
668 | //call void [mscorlib]System.Console::WriteLine(string) | ||
669 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | ||
670 | il.Emit(OpCodes.Call, typeof (Console).GetMethod | ||
671 | ("WriteLine", new Type[] {typeof (string)})); | ||
672 | |||
673 | /* | ||
674 | * CLR END TRY | ||
675 | */ | ||
676 | //Common.SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); | ||
677 | il.EndExceptionBlock(); | ||
678 | } | ||
679 | |||
680 | private LSO_Struct.StaticBlock GetStaticBlock(long pos) | ||
681 | { | ||
682 | long FirstPos = fs.Position; | ||
683 | try | ||
684 | { | ||
685 | UInt32 position = (UInt32) pos; | ||
686 | // STATIC BLOCK | ||
687 | Common.SendToDebug("Reading STATIC BLOCK at: " + position); | ||
688 | fs.Seek(position, SeekOrigin.Begin); | ||
689 | |||
690 | if (StaticBlocks.ContainsKey(position) == true) | ||
691 | { | ||
692 | Common.SendToDebug("Found cached STATIC BLOCK"); | ||
693 | |||
694 | |||
695 | return StaticBlocks[pos]; | ||
696 | } | ||
697 | |||
698 | //int StaticBlockCount = 0; | ||
699 | // Read function blocks until we hit GFR | ||
700 | //while (fs.Position < myHeader.GFR) | ||
701 | //{ | ||
702 | //StaticBlockCount++; | ||
703 | |||
704 | //Common.SendToDebug("Reading Static Block at: " + position); | ||
705 | |||
706 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
707 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | ||
708 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | ||
709 | myStaticBlock.ObjectType = br_read(1)[0]; | ||
710 | Common.SendToDebug("Static Block ObjectType: " + | ||
711 | ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); | ||
712 | myStaticBlock.Unknown = br_read(1)[0]; | ||
713 | // Size of datatype varies | ||
714 | if (myStaticBlock.ObjectType != 0) | ||
715 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | ||
716 | |||
717 | StaticBlocks.Add(position, myStaticBlock); | ||
718 | //} | ||
719 | Common.SendToDebug("Done reading Static Block."); | ||
720 | return myStaticBlock; | ||
721 | } | ||
722 | finally | ||
723 | { | ||
724 | // Go back to original read pos | ||
725 | fs.Seek(FirstPos, SeekOrigin.Begin); | ||
726 | } | ||
727 | } | ||
728 | } | ||
729 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs new file mode 100644 index 0000000..915280c --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/LSO_Struct.cs | |||
@@ -0,0 +1,143 @@ | |||
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 | } \ No newline at end of file | ||