aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO')
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs27
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs149
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs25
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs20
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs186
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs6
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs135
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs11
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs208
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs20
10 files changed, 401 insertions, 386 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs
index e1ea916..25c3346 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs
@@ -27,31 +27,32 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 31namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
34{ 32{
35 public static class Common 33 public static class Common
36 { 34 {
37 static public bool Debug = true; 35 public static bool Debug = true;
38 static public bool IL_UseTryCatch = true; 36 public static bool IL_UseTryCatch = true;
39 static public bool IL_CreateConstructor = true; 37 public static bool IL_CreateConstructor = true;
40 static public bool IL_CreateFunctionList = true; 38 public static bool IL_CreateFunctionList = true;
41 static public bool IL_ProcessCodeChunks = true; 39 public static bool IL_ProcessCodeChunks = true;
42 40
43 public delegate void SendToDebugEventDelegate(string Message); 41 public delegate void SendToDebugEventDelegate(string Message);
42
44 public delegate void SendToLogEventDelegate(string Message); 43 public delegate void SendToLogEventDelegate(string Message);
45 static public event SendToDebugEventDelegate SendToDebugEvent;
46 static public event SendToLogEventDelegate SendToLogEvent;
47 44
48 static public void SendToDebug(string Message) 45 public static event SendToDebugEventDelegate SendToDebugEvent;
46 public static event SendToLogEventDelegate SendToLogEvent;
47
48 public static void SendToDebug(string Message)
49 { 49 {
50 //if (Debug == true) 50 //if (Debug == true)
51 Console.WriteLine("COMPILER:Debug: " + Message); 51 Console.WriteLine("COMPILER:Debug: " + Message);
52 SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); 52 SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
53 } 53 }
54 static public void SendToLog(string Message) 54
55 public static void SendToLog(string Message)
55 { 56 {
56 //if (Debug == true) 57 //if (Debug == true)
57 Console.WriteLine("COMPILER:LOG: " + Message); 58 Console.WriteLine("COMPILER:LOG: " + Message);
@@ -68,6 +69,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
68 Common.SendToDebug("ReverseFormatString format: " + format); 69 Common.SendToDebug("ReverseFormatString format: " + format);
69 return string.Format(format, text1); 70 return string.Format(format, text1);
70 } 71 }
72
71 public static string ReverseFormatString(string text1, UInt32 text2, string format) 73 public static string ReverseFormatString(string text1, UInt32 text2, string format)
72 { 74 {
73 Common.SendToDebug("ReverseFormatString text1: " + text1); 75 Common.SendToDebug("ReverseFormatString text1: " + text1);
@@ -75,10 +77,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
75 Common.SendToDebug("ReverseFormatString format: " + format); 77 Common.SendToDebug("ReverseFormatString format: " + format);
76 return string.Format(format, text1, text2.ToString()); 78 return string.Format(format, text1, text2.ToString());
77 } 79 }
80
78 public static string Cast_ToString(object obj) 81 public static string Cast_ToString(object obj)
79 { 82 {
80 Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString()); 83 Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString());
81 return "ABCDEFGIHJKLMNOPQ123"; 84 return "ABCDEFGIHJKLMNOPQ123";
82 } 85 }
83 } 86 }
84} 87} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs
index cfae2c5..f3f4bea 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs
@@ -27,20 +27,19 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Reflection.Emit; 32using System.Reflection.Emit;
33using System.Text;
32using System.Threading; 34using System.Threading;
33 35
34
35namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 36namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
36{ 37{
37
38
39 public class Engine 38 public class Engine
40 { 39 {
41 //private string LSO_FileName = @"LSO\AdditionTest.lso"; 40 //private string LSO_FileName = @"LSO\AdditionTest.lso";
42 private string LSO_FileName;// = @"LSO\CloseToDefault.lso"; 41 private string LSO_FileName; // = @"LSO\CloseToDefault.lso";
43 AppDomain appDomain; 42 private AppDomain appDomain;
44 43
45 public string Compile(string LSOFileName) 44 public string Compile(string LSOFileName)
46 { 45 {
@@ -52,20 +51,19 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
52 51
53 // Create Assembly Name 52 // Create Assembly Name
54 AssemblyName asmName = new AssemblyName(); 53 AssemblyName asmName = new AssemblyName();
55 asmName.Name = System.IO.Path.GetFileNameWithoutExtension(LSO_FileName); 54 asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName);
56 //asmName.Name = "TestAssembly"; 55 //asmName.Name = "TestAssembly";
57 56
58 string DLL_FileName = asmName.Name + ".dll"; 57 string DLL_FileName = asmName.Name + ".dll";
59 string DLL_FileName_WithPath = System.IO.Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; 58 string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName;
60 59
61 Common.SendToLog("LSO File Name: " + System.IO.Path.GetFileName(LSO_FileName)); 60 Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName));
62 Common.SendToLog("Assembly name: " + asmName.Name); 61 Common.SendToLog("Assembly name: " + asmName.Name);
63 Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); 62 Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll");
64 Common.SendToLog("Starting processing of LSL ByteCode..."); 63 Common.SendToLog("Starting processing of LSL ByteCode...");
65 Common.SendToLog(""); 64 Common.SendToLog("");
66 65
67 66
68
69 // Create Assembly 67 // Create Assembly
70 AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( 68 AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly(
71 asmName, 69 asmName,
@@ -78,15 +76,15 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
78 76
79 // Create a module (and save to disk) 77 // Create a module (and save to disk)
80 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule 78 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule
81 (asmName.Name, 79 (asmName.Name,
82 DLL_FileName); 80 DLL_FileName);
83 81
84 //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\""); 82 //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\"");
85 // Create a Class (/Type) 83 // Create a Class (/Type)
86 TypeBuilder typeBuilder = modBuilder.DefineType( 84 TypeBuilder typeBuilder = modBuilder.DefineType(
87 "LSL_ScriptObject", 85 "LSL_ScriptObject",
88 TypeAttributes.Public | TypeAttributes.BeforeFieldInit, 86 TypeAttributes.Public | TypeAttributes.BeforeFieldInit,
89 typeof(OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass)); 87 typeof (LSL_BaseClass));
90 //, 88 //,
91 // typeof()); 89 // typeof());
92 //, typeof(LSL_BuiltIn_Commands_Interface)); 90 //, typeof(LSL_BuiltIn_Commands_Interface));
@@ -95,7 +93,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
95 // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); 93 // new Type[] { typeof(LSL_CLRInterface.LSLScript) });
96 94
97 95
98
99 /* 96 /*
100 * Generate the IL itself 97 * Generate the IL itself
101 */ 98 */
@@ -123,7 +120,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
123 asmBuilder.Save(DLL_FileName); 120 asmBuilder.Save(DLL_FileName);
124 121
125 Common.SendToLog("Returning assembly filename: " + DLL_FileName); 122 Common.SendToLog("Returning assembly filename: " + DLL_FileName);
126 123
127 124
128 return DLL_FileName; 125 return DLL_FileName;
129 126
@@ -135,9 +132,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
135 //object MyScript = (object)Activator.CreateInstance(type); 132 //object MyScript = (object)Activator.CreateInstance(type);
136 133
137 134
138
139
140
141 //System.Reflection.MemberInfo[] Members = type.GetMembers(); 135 //System.Reflection.MemberInfo[] Members = type.GetMembers();
142 136
143 //Common.SendToLog("Members of assembly " + type.ToString() + ":"); 137 //Common.SendToLog("Members of assembly " + type.ToString() + ":");
@@ -165,29 +159,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
165 // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); 159 // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" });
166 160
167 //} 161 //}
168
169
170 } 162 }
171 163
172 164
173 private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) 165 private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP)
174 { 166 {
175
176
177 Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); 167 Common.SendToDebug("IL_CREATE_CONSTRUCTOR()");
178 //ConstructorBuilder constructor = typeBuilder.DefineConstructor( 168 //ConstructorBuilder constructor = typeBuilder.DefineConstructor(
179 // MethodAttributes.Public, 169 // MethodAttributes.Public,
180 // CallingConventions.Standard, 170 // CallingConventions.Standard,
181 // new Type[0]); 171 // new Type[0]);
182 ConstructorBuilder constructor = typeBuilder.DefineConstructor( 172 ConstructorBuilder constructor = typeBuilder.DefineConstructor(
183 MethodAttributes.Public | 173 MethodAttributes.Public |
184 MethodAttributes.SpecialName | 174 MethodAttributes.SpecialName |
185 MethodAttributes.RTSpecialName, 175 MethodAttributes.RTSpecialName,
186 CallingConventions.Standard, 176 CallingConventions.Standard,
187 new Type[0]); 177 new Type[0]);
188 178
189 //Define the reflection ConstructorInfor for System.Object 179 //Define the reflection ConstructorInfor for System.Object
190 ConstructorInfo conObj = typeof(LSL_BaseClass).GetConstructor(new Type[0]); 180 ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]);
191 181
192 //call constructor of base object 182 //call constructor of base object
193 ILGenerator il = constructor.GetILGenerator(); 183 ILGenerator il = constructor.GetILGenerator();
@@ -230,58 +220,61 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
230 LSO_Struct.StaticBlock sb; 220 LSO_Struct.StaticBlock sb;
231 LSOP.StaticBlocks.TryGetValue(pos, out sb); 221 LSOP.StaticBlocks.TryGetValue(pos, out sb);
232 222
233 if (sb.ObjectType > 0 && sb.ObjectType < 8) { // We don't want void or null's 223 if (sb.ObjectType > 0 && sb.ObjectType < 8)
234
235 il.Emit(OpCodes.Ldarg_0);
236 // Push position to stack
237 il.Emit(OpCodes.Ldc_I4, pos);
238 //il.Emit(OpCodes.Box, typeof(UInt32));
239
240
241 Type datatype = null;
242
243 // Push data to stack
244 Common.SendToDebug("Adding to static (" + pos + ") type: " + ((LSO_Enums.Variable_Type_Codes)sb.ObjectType).ToString() + " (" + sb.ObjectType + ")");
245 switch ((LSO_Enums.Variable_Type_Codes)sb.ObjectType)
246 { 224 {
247 case LSO_Enums.Variable_Type_Codes.Float: 225 // We don't want void or null's
248 case LSO_Enums.Variable_Type_Codes.Integer: 226
249 //UInt32 227 il.Emit(OpCodes.Ldarg_0);
250 il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); 228 // Push position to stack
251 datatype = typeof(UInt32); 229 il.Emit(OpCodes.Ldc_I4, pos);
252 il.Emit(OpCodes.Box, datatype); 230 //il.Emit(OpCodes.Box, typeof(UInt32));
253 break; 231
254 case LSO_Enums.Variable_Type_Codes.String: 232
255 case LSO_Enums.Variable_Type_Codes.Key: 233 Type datatype = null;
256 //String 234
257 LSO_Struct.HeapBlock hb = LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); 235 // Push data to stack
258 il.Emit(OpCodes.Ldstr, System.Text.Encoding.UTF8.GetString(hb.Data)); 236 Common.SendToDebug("Adding to static (" + pos + ") type: " +
259 datatype = typeof(string); 237 ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType +
260 break; 238 ")");
261 case LSO_Enums.Variable_Type_Codes.Vector: 239 switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType)
262 datatype = typeof(LSO_Enums.Vector); 240 {
263 //TODO: Not implemented 241 case LSO_Enums.Variable_Type_Codes.Float:
264 break; 242 case LSO_Enums.Variable_Type_Codes.Integer:
265 case LSO_Enums.Variable_Type_Codes.Rotation: 243 //UInt32
266 //Object 244 il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0));
267 //TODO: Not implemented 245 datatype = typeof (UInt32);
268 datatype = typeof(LSO_Enums.Rotation); 246 il.Emit(OpCodes.Box, datatype);
269 break; 247 break;
270 default: 248 case LSO_Enums.Variable_Type_Codes.String:
271 datatype = typeof(object); 249 case LSO_Enums.Variable_Type_Codes.Key:
272 break; 250 //String
273 } 251 LSO_Struct.HeapBlock hb =
274 252 LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1);
275 253 il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data));
276 // Make call 254 datatype = typeof (string);
277 il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddToStatic", new Type[] { typeof(UInt32), datatype })); 255 break;
256 case LSO_Enums.Variable_Type_Codes.Vector:
257 datatype = typeof (LSO_Enums.Vector);
258 //TODO: Not implemented
259 break;
260 case LSO_Enums.Variable_Type_Codes.Rotation:
261 //Object
262 //TODO: Not implemented
263 datatype = typeof (LSO_Enums.Rotation);
264 break;
265 default:
266 datatype = typeof (object);
267 break;
268 }
269
270
271 // Make call
272 il.Emit(OpCodes.Call,
273 typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype}));
278 } 274 }
279
280 } 275 }
281 276
282 277
283
284
285 ////il.Emit(OpCodes.Newobj, typeof(UInt32)); 278 ////il.Emit(OpCodes.Newobj, typeof(UInt32));
286 //il.Emit(OpCodes.Starg_0); 279 //il.Emit(OpCodes.Starg_0);
287 //// Create LSL function library 280 //// Create LSL function library
@@ -293,8 +286,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
293 } 286 }
294 287
295 288
296
297
298 // End of class 289 // End of class
299 } 290 }
300} 291} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs
index eef9d20..064166b 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs
@@ -27,30 +27,25 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Reflection; 30using System.Reflection;
33using System.Reflection.Emit; 31using System.Reflection.Emit;
34 32
35namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
36{ 34{
37 partial class LSO_Parser 35 internal partial class LSO_Parser
38 { 36 {
39 private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName) 37 private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName)
40 { 38 {
41 TypeBuilder typeBuilder = modBuilder.DefineType(typeName, 39 TypeBuilder typeBuilder = modBuilder.DefineType(typeName,
42 TypeAttributes.Public | 40 TypeAttributes.Public |
43 TypeAttributes.Class | 41 TypeAttributes.Class |
44 TypeAttributes.AutoClass | 42 TypeAttributes.AutoClass |
45 TypeAttributes.AnsiClass | 43 TypeAttributes.AnsiClass |
46 TypeAttributes.BeforeFieldInit | 44 TypeAttributes.BeforeFieldInit |
47 TypeAttributes.AutoLayout, 45 TypeAttributes.AutoLayout,
48 typeof(object), 46 typeof (object),
49 new Type[] { typeof(object) }); 47 new Type[] {typeof (object)});
50 return typeBuilder; 48 return typeBuilder;
51
52 } 49 }
53
54
55 } 50 }
56} 51} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs
index ac3bc11..46da5f8 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs
@@ -28,9 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler;
34using OpenSim.Region.ScriptEngine.Common; 31using OpenSim.Region.ScriptEngine.Common;
35 32
36namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
@@ -39,9 +36,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
39 { 36 {
40 //public MemoryStream LSLStack = new MemoryStream(); 37 //public MemoryStream LSLStack = new MemoryStream();
41 public Stack<object> LSLStack = new Stack<object>(); 38 public Stack<object> LSLStack = new Stack<object>();
42 public Dictionary<UInt32, object> StaticVariables = new Dictionary<UInt32, object>(); 39 public Dictionary<uint, object> StaticVariables = new Dictionary<uint, object>();
43 public Dictionary<UInt32, object> GlobalVariables = new Dictionary<UInt32, object>(); 40 public Dictionary<uint, object> GlobalVariables = new Dictionary<uint, object>();
44 public Dictionary<UInt32, object> LocalVariables = new Dictionary<UInt32, object>(); 41 public Dictionary<uint, object> LocalVariables = new Dictionary<uint, object>();
45 //public System.Collections.Generic.List<string> FunctionList = new System.Collections.Generic.List<string>(); 42 //public System.Collections.Generic.List<string> FunctionList = new System.Collections.Generic.List<string>();
46 //public void AddFunction(String x) { 43 //public void AddFunction(String x) {
47 // FunctionList.Add(x); 44 // FunctionList.Add(x);
@@ -54,19 +51,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
54 //} 51 //}
55 public UInt32 State = 0; 52 public UInt32 State = 0;
56 public LSL_BuiltIn_Commands_Interface LSL_Builtins; 53 public LSL_BuiltIn_Commands_Interface LSL_Builtins;
54
57 public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn() 55 public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn()
58 { 56 {
59 return LSL_Builtins; 57 return LSL_Builtins;
60 } 58 }
61 59
62 60
63 public LSL_BaseClass() { } 61 public LSL_BaseClass()
62 {
63 }
64 64
65 65
66 public virtual int OverrideMe() 66 public virtual int OverrideMe()
67 { 67 {
68 return 0; 68 return 0;
69 } 69 }
70
70 public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins) 71 public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins)
71 { 72 {
72 LSL_Builtins = LSLBuiltins; 73 LSL_Builtins = LSLBuiltins;
@@ -81,8 +82,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
81 Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType()); 82 Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType());
82 StaticVariables.Add(index, obj); 83 StaticVariables.Add(index, obj);
83 } 84 }
84
85
86
87 } 85 }
88} 86} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
index 8a43cc1..0b6970a 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 31namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
34{ 32{
@@ -53,6 +51,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
53 LocalVariables.Remove(index); 51 LocalVariables.Remove(index);
54 LocalVariables.Add(index, LSLStack.Peek()); 52 LocalVariables.Add(index, LSLStack.Peek());
55 } 53 }
54
56 public void StoreToGlobal(UInt32 index) 55 public void StoreToGlobal(UInt32 index)
57 { 56 {
58 Common.SendToDebug("::StoreToGlobal " + index); 57 Common.SendToDebug("::StoreToGlobal " + index);
@@ -60,6 +59,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
60 GlobalVariables.Remove(index); 59 GlobalVariables.Remove(index);
61 GlobalVariables.Add(index, LSLStack.Peek()); 60 GlobalVariables.Add(index, LSLStack.Peek());
62 } 61 }
62
63 public void StoreToStatic(UInt32 index) 63 public void StoreToStatic(UInt32 index)
64 { 64 {
65 Common.SendToDebug("::StoreToStatic " + index); 65 Common.SendToDebug("::StoreToStatic " + index);
@@ -67,6 +67,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
67 // StaticVariables.Remove(index); 67 // StaticVariables.Remove(index);
68 StaticVariables.Add(index, LSLStack.Peek()); 68 StaticVariables.Add(index, LSLStack.Peek());
69 } 69 }
70
70 public void GetFromLocal(UInt32 index) 71 public void GetFromLocal(UInt32 index)
71 { 72 {
72 // TODO: How to determine local? 73 // TODO: How to determine local?
@@ -76,6 +77,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
76 LSLStack.Push(ret); 77 LSLStack.Push(ret);
77 //return ret; 78 //return ret;
78 } 79 }
80
79 public void GetFromGlobal(UInt32 index) 81 public void GetFromGlobal(UInt32 index)
80 { 82 {
81 Common.SendToDebug("::GetFromGlobal " + index); 83 Common.SendToDebug("::GetFromGlobal " + index);
@@ -84,6 +86,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
84 LSLStack.Push(ret); 86 LSLStack.Push(ret);
85 //return ret; 87 //return ret;
86 } 88 }
89
87 public void GetFromStatic(UInt32 index) 90 public void GetFromStatic(UInt32 index)
88 { 91 {
89 Common.SendToDebug("::GetFromStatic " + index); 92 Common.SendToDebug("::GetFromStatic " + index);
@@ -99,22 +102,22 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
99 Common.SendToDebug("::POPToStack"); 102 Common.SendToDebug("::POPToStack");
100 //return LSLStack.Pop(); 103 //return LSLStack.Pop();
101 object p = LSLStack.Pop(); 104 object p = LSLStack.Pop();
102 if (p.GetType() == typeof(UInt32)) 105 if (p.GetType() == typeof (UInt32))
103 return (UInt32)p; 106 return (UInt32) p;
104 if (p.GetType() == typeof(string)) 107 if (p.GetType() == typeof (string))
105 return (string)p; 108 return (string) p;
106 if (p.GetType() == typeof(Int32)) 109 if (p.GetType() == typeof (Int32))
107 return (Int32)p; 110 return (Int32) p;
108 if (p.GetType() == typeof(UInt16)) 111 if (p.GetType() == typeof (UInt16))
109 return (UInt16)p; 112 return (UInt16) p;
110 if (p.GetType() == typeof(float)) 113 if (p.GetType() == typeof (float))
111 return (float)p; 114 return (float) p;
112 if (p.GetType() == typeof(LSO_Enums.Vector)) 115 if (p.GetType() == typeof (LSO_Enums.Vector))
113 return (LSO_Enums.Vector)p; 116 return (LSO_Enums.Vector) p;
114 if (p.GetType() == typeof(LSO_Enums.Rotation)) 117 if (p.GetType() == typeof (LSO_Enums.Rotation))
115 return (LSO_Enums.Rotation)p; 118 return (LSO_Enums.Rotation) p;
116 if (p.GetType() == typeof(LSO_Enums.Key)) 119 if (p.GetType() == typeof (LSO_Enums.Key))
117 return (LSO_Enums.Key)p; 120 return (LSO_Enums.Key) p;
118 121
119 return p; 122 return p;
120 } 123 }
@@ -151,6 +154,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
151 LSLStack.Pop(); 154 LSLStack.Pop();
152 } 155 }
153 } 156 }
157
154 public void PUSH(object Param) 158 public void PUSH(object Param)
155 { 159 {
156 if (Param == null) 160 if (Param == null)
@@ -159,205 +163,218 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
159 } 163 }
160 else 164 else
161 { 165 {
162
163 //Common.SendToDebug("::PUSH: " + Param.GetType()); 166 //Common.SendToDebug("::PUSH: " + Param.GetType());
164 } 167 }
165 168
166 LSLStack.Push(Param); 169 LSLStack.Push(Param);
167 } 170 }
171
168 public void ADD(UInt32 Param) 172 public void ADD(UInt32 Param)
169 { 173 {
170 Common.SendToDebug("::ADD: " + Param); 174 Common.SendToDebug("::ADD: " + Param);
171 object o2 = LSLStack.Pop(); 175 object o2 = LSLStack.Pop();
172 object o1 = LSLStack.Pop(); 176 object o1 = LSLStack.Pop();
173 Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + " (" + o2.ToString() + ")"); 177 Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() +
174 if (o2.GetType() == typeof(string)) 178 " (" + o2.ToString() + ")");
179 if (o2.GetType() == typeof (string))
175 { 180 {
176 LSLStack.Push((string)o1 + (string)o2); 181 LSLStack.Push((string) o1 + (string) o2);
177 return; 182 return;
178 } 183 }
179 if (o2.GetType() == typeof(UInt32)) 184 if (o2.GetType() == typeof (UInt32))
180 { 185 {
181 LSLStack.Push((UInt32)o1 + (UInt32)o2); 186 LSLStack.Push((UInt32) o1 + (UInt32) o2);
182 return; 187 return;
183 } 188 }
184
185 } 189 }
190
186 public void SUB(UInt32 Param) 191 public void SUB(UInt32 Param)
187 { 192 {
188 Common.SendToDebug("::SUB: " + Param); 193 Common.SendToDebug("::SUB: " + Param);
189 UInt32 i2 = (UInt32)LSLStack.Pop(); 194 UInt32 i2 = (UInt32) LSLStack.Pop();
190 UInt32 i1 = (UInt32)LSLStack.Pop(); 195 UInt32 i1 = (UInt32) LSLStack.Pop();
191 LSLStack.Push((UInt32)(i1 - i2)); 196 LSLStack.Push((UInt32) (i1 - i2));
192 } 197 }
198
193 public void MUL(UInt32 Param) 199 public void MUL(UInt32 Param)
194 { 200 {
195 Common.SendToDebug("::SUB: " + Param); 201 Common.SendToDebug("::SUB: " + Param);
196 UInt32 i2 = (UInt32)LSLStack.Pop(); 202 UInt32 i2 = (UInt32) LSLStack.Pop();
197 UInt32 i1 = (UInt32)LSLStack.Pop(); 203 UInt32 i1 = (UInt32) LSLStack.Pop();
198 LSLStack.Push((UInt32)(i1 * i2)); 204 LSLStack.Push((UInt32) (i1*i2));
199 } 205 }
206
200 public void DIV(UInt32 Param) 207 public void DIV(UInt32 Param)
201 { 208 {
202 Common.SendToDebug("::DIV: " + Param); 209 Common.SendToDebug("::DIV: " + Param);
203 UInt32 i2 = (UInt32)LSLStack.Pop(); 210 UInt32 i2 = (UInt32) LSLStack.Pop();
204 UInt32 i1 = (UInt32)LSLStack.Pop(); 211 UInt32 i1 = (UInt32) LSLStack.Pop();
205 LSLStack.Push((UInt32)(i1 / i2)); 212 LSLStack.Push((UInt32) (i1/i2));
206 } 213 }
207 214
208 215
209 public void MOD(UInt32 Param) 216 public void MOD(UInt32 Param)
210 { 217 {
211 Common.SendToDebug("::MOD: " + Param); 218 Common.SendToDebug("::MOD: " + Param);
212 UInt32 i2 = (UInt32)LSLStack.Pop(); 219 UInt32 i2 = (UInt32) LSLStack.Pop();
213 UInt32 i1 = (UInt32)LSLStack.Pop(); 220 UInt32 i1 = (UInt32) LSLStack.Pop();
214 LSLStack.Push((UInt32)(i1 % i2)); 221 LSLStack.Push((UInt32) (i1%i2));
215 } 222 }
223
216 public void EQ(UInt32 Param) 224 public void EQ(UInt32 Param)
217 { 225 {
218 Common.SendToDebug("::EQ: " + Param); 226 Common.SendToDebug("::EQ: " + Param);
219 UInt32 i2 = (UInt32)LSLStack.Pop(); 227 UInt32 i2 = (UInt32) LSLStack.Pop();
220 UInt32 i1 = (UInt32)LSLStack.Pop(); 228 UInt32 i1 = (UInt32) LSLStack.Pop();
221 if (i1 == i2) 229 if (i1 == i2)
222 { 230 {
223 LSLStack.Push((UInt32)1); 231 LSLStack.Push((UInt32) 1);
224 } 232 }
225 else 233 else
226 { 234 {
227 LSLStack.Push((UInt32)0); 235 LSLStack.Push((UInt32) 0);
228 } 236 }
229 } 237 }
238
230 public void NEQ(UInt32 Param) 239 public void NEQ(UInt32 Param)
231 { 240 {
232 Common.SendToDebug("::NEQ: " + Param); 241 Common.SendToDebug("::NEQ: " + Param);
233 UInt32 i2 = (UInt32)LSLStack.Pop(); 242 UInt32 i2 = (UInt32) LSLStack.Pop();
234 UInt32 i1 = (UInt32)LSLStack.Pop(); 243 UInt32 i1 = (UInt32) LSLStack.Pop();
235 if (i1 != i2) 244 if (i1 != i2)
236 { 245 {
237 LSLStack.Push((UInt32)1); 246 LSLStack.Push((UInt32) 1);
238 } 247 }
239 else 248 else
240 { 249 {
241 LSLStack.Push((UInt32)0); 250 LSLStack.Push((UInt32) 0);
242 } 251 }
243 } 252 }
253
244 public void LEQ(UInt32 Param) 254 public void LEQ(UInt32 Param)
245 { 255 {
246 Common.SendToDebug("::LEQ: " + Param); 256 Common.SendToDebug("::LEQ: " + Param);
247 UInt32 i2 = (UInt32)LSLStack.Pop(); 257 UInt32 i2 = (UInt32) LSLStack.Pop();
248 UInt32 i1 = (UInt32)LSLStack.Pop(); 258 UInt32 i1 = (UInt32) LSLStack.Pop();
249 if (i1 <= i2) 259 if (i1 <= i2)
250 { 260 {
251 LSLStack.Push((UInt32)1); 261 LSLStack.Push((UInt32) 1);
252 } 262 }
253 else 263 else
254 { 264 {
255 LSLStack.Push((UInt32)0); 265 LSLStack.Push((UInt32) 0);
256 } 266 }
257 } 267 }
268
258 public void GEQ(UInt32 Param) 269 public void GEQ(UInt32 Param)
259 { 270 {
260 Common.SendToDebug("::GEQ: " + Param); 271 Common.SendToDebug("::GEQ: " + Param);
261 UInt32 i2 = (UInt32)LSLStack.Pop(); 272 UInt32 i2 = (UInt32) LSLStack.Pop();
262 UInt32 i1 = (UInt32)LSLStack.Pop(); 273 UInt32 i1 = (UInt32) LSLStack.Pop();
263 if (i1 >= i2) 274 if (i1 >= i2)
264 { 275 {
265 LSLStack.Push((UInt32)1); 276 LSLStack.Push((UInt32) 1);
266 } 277 }
267 else 278 else
268 { 279 {
269 LSLStack.Push((UInt32)0); 280 LSLStack.Push((UInt32) 0);
270 } 281 }
271 } 282 }
283
272 public void LESS(UInt32 Param) 284 public void LESS(UInt32 Param)
273 { 285 {
274 Common.SendToDebug("::LESS: " + Param); 286 Common.SendToDebug("::LESS: " + Param);
275 UInt32 i2 = (UInt32)LSLStack.Pop(); 287 UInt32 i2 = (UInt32) LSLStack.Pop();
276 UInt32 i1 = (UInt32)LSLStack.Pop(); 288 UInt32 i1 = (UInt32) LSLStack.Pop();
277 if (i1 < i2) 289 if (i1 < i2)
278 { 290 {
279 LSLStack.Push((UInt32)1); 291 LSLStack.Push((UInt32) 1);
280 } 292 }
281 else 293 else
282 { 294 {
283 LSLStack.Push((UInt32)0); 295 LSLStack.Push((UInt32) 0);
284 } 296 }
285 } 297 }
298
286 public void GREATER(UInt32 Param) 299 public void GREATER(UInt32 Param)
287 { 300 {
288 Common.SendToDebug("::GREATER: " + Param); 301 Common.SendToDebug("::GREATER: " + Param);
289 UInt32 i2 = (UInt32)LSLStack.Pop(); 302 UInt32 i2 = (UInt32) LSLStack.Pop();
290 UInt32 i1 = (UInt32)LSLStack.Pop(); 303 UInt32 i1 = (UInt32) LSLStack.Pop();
291 if (i1 > i2) 304 if (i1 > i2)
292 { 305 {
293 LSLStack.Push((UInt32)1); 306 LSLStack.Push((UInt32) 1);
294 } 307 }
295 else 308 else
296 { 309 {
297 LSLStack.Push((UInt32)0); 310 LSLStack.Push((UInt32) 0);
298 } 311 }
299 } 312 }
300 313
301 314
302
303 public void BITAND() 315 public void BITAND()
304 { 316 {
305 Common.SendToDebug("::BITAND"); 317 Common.SendToDebug("::BITAND");
306 UInt32 i2 = (UInt32)LSLStack.Pop(); 318 UInt32 i2 = (UInt32) LSLStack.Pop();
307 UInt32 i1 = (UInt32)LSLStack.Pop(); 319 UInt32 i1 = (UInt32) LSLStack.Pop();
308 LSLStack.Push((UInt32)(i1 & i2)); 320 LSLStack.Push((UInt32) (i1 & i2));
309 } 321 }
322
310 public void BITOR() 323 public void BITOR()
311 { 324 {
312 Common.SendToDebug("::BITOR"); 325 Common.SendToDebug("::BITOR");
313 UInt32 i2 = (UInt32)LSLStack.Pop(); 326 UInt32 i2 = (UInt32) LSLStack.Pop();
314 UInt32 i1 = (UInt32)LSLStack.Pop(); 327 UInt32 i1 = (UInt32) LSLStack.Pop();
315 LSLStack.Push((UInt32)(i1 | i2)); 328 LSLStack.Push((UInt32) (i1 | i2));
316 } 329 }
330
317 public void BITXOR() 331 public void BITXOR()
318 { 332 {
319 Common.SendToDebug("::BITXOR"); 333 Common.SendToDebug("::BITXOR");
320 UInt32 i2 = (UInt32)LSLStack.Pop(); 334 UInt32 i2 = (UInt32) LSLStack.Pop();
321 UInt32 i1 = (UInt32)LSLStack.Pop(); 335 UInt32 i1 = (UInt32) LSLStack.Pop();
322 LSLStack.Push((UInt32)(i1 ^ i2)); 336 LSLStack.Push((UInt32) (i1 ^ i2));
323 } 337 }
338
324 public void BOOLAND() 339 public void BOOLAND()
325 { 340 {
326 Common.SendToDebug("::BOOLAND"); 341 Common.SendToDebug("::BOOLAND");
327 bool b2 = bool.Parse((string)LSLStack.Pop()); 342 bool b2 = bool.Parse((string) LSLStack.Pop());
328 bool b1 = bool.Parse((string)LSLStack.Pop()); 343 bool b1 = bool.Parse((string) LSLStack.Pop());
329 if (b1 && b2) 344 if (b1 && b2)
330 { 345 {
331 LSLStack.Push((UInt32)1); 346 LSLStack.Push((UInt32) 1);
332 } 347 }
333 else 348 else
334 { 349 {
335 LSLStack.Push((UInt32)0); 350 LSLStack.Push((UInt32) 0);
336 } 351 }
337 } 352 }
353
338 public void BOOLOR() 354 public void BOOLOR()
339 { 355 {
340 Common.SendToDebug("::BOOLOR"); 356 Common.SendToDebug("::BOOLOR");
341 bool b2 = bool.Parse((string)LSLStack.Pop()); 357 bool b2 = bool.Parse((string) LSLStack.Pop());
342 bool b1 = bool.Parse((string)LSLStack.Pop()); 358 bool b1 = bool.Parse((string) LSLStack.Pop());
343 359
344 if (b1 || b2) 360 if (b1 || b2)
345 { 361 {
346 LSLStack.Push((UInt32)1); 362 LSLStack.Push((UInt32) 1);
347 } 363 }
348 else 364 else
349 { 365 {
350 LSLStack.Push((UInt32)0); 366 LSLStack.Push((UInt32) 0);
351 } 367 }
352
353 } 368 }
369
354 public void NEG(UInt32 Param) 370 public void NEG(UInt32 Param)
355 { 371 {
356 Common.SendToDebug("::NEG: " + Param); 372 Common.SendToDebug("::NEG: " + Param);
357 //UInt32 i2 = (UInt32)LSLStack.Pop(); 373 //UInt32 i2 = (UInt32)LSLStack.Pop();
358 UInt32 i1 = (UInt32)LSLStack.Pop(); 374 UInt32 i1 = (UInt32) LSLStack.Pop();
359 LSLStack.Push((UInt32)(i1 * -1)); 375 LSLStack.Push((UInt32) (i1*-1));
360 } 376 }
377
361 public void BITNOT() 378 public void BITNOT()
362 { 379 {
363 //Common.SendToDebug("::BITNOT"); 380 //Common.SendToDebug("::BITNOT");
@@ -365,6 +382,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
365 //UInt32 i1 = (UInt32)LSLStack.Pop(); 382 //UInt32 i1 = (UInt32)LSLStack.Pop();
366 //LSLStack.Push((UInt32)(i1 / i2)); 383 //LSLStack.Push((UInt32)(i1 / i2));
367 } 384 }
385
368 public void BOOLNOT() 386 public void BOOLNOT()
369 { 387 {
370 //Common.SendToDebug("::BOOLNOT"); 388 //Common.SendToDebug("::BOOLNOT");
@@ -372,7 +390,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
372 //UInt32 i1 = (UInt32)LSLStack.Pop(); 390 //UInt32 i1 = (UInt32)LSLStack.Pop();
373 //LSLStack.Push((UInt32)(i1)); 391 //LSLStack.Push((UInt32)(i1));
374 } 392 }
375
376
377 } 393 }
378} 394} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs
index 5da1d71..ed07cfc 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 29namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
34{ 30{
35 public class LSL_CLRInterface 31 public class LSL_CLRInterface
@@ -76,4 +72,4 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
76 //void event_http_response(); 72 //void event_http_response();
77 } 73 }
78 } 74 }
79} 75} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs
index 45cca25..d25644c 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs
@@ -27,32 +27,28 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Reflection; 30using System.Reflection;
33using System.Reflection.Emit; 31using System.Reflection.Emit;
34using OpenSim.Region.ScriptEngine.Common; 32using OpenSim.Region.ScriptEngine.Common;
35 33
36namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 34namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
37{ 35{
38 partial class LSO_Parser 36 internal partial class LSO_Parser
39 { 37 {
40 //internal Stack<Type> ILStack = new Stack<Type>(); 38 //internal Stack<Type> ILStack = new Stack<Type>();
41 //LSO_Enums MyLSO_Enums = new LSO_Enums(); 39 //LSO_Enums MyLSO_Enums = new LSO_Enums();
42 40
43 internal bool LSL_PROCESS_OPCODE(ILGenerator il) 41 internal bool LSL_PROCESS_OPCODE(ILGenerator il)
44 { 42 {
45
46 byte bp1; 43 byte bp1;
47 UInt32 u32p1; 44 UInt32 u32p1;
48 float fp1; 45 float fp1;
49 UInt16 opcode = br_read(1)[0]; 46 UInt16 opcode = br_read(1)[0];
50 Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); 47 Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table) opcode).ToString());
51 string idesc = ((LSO_Enums.Operation_Table)opcode).ToString(); 48 string idesc = ((LSO_Enums.Operation_Table) opcode).ToString();
52 switch ((LSO_Enums.Operation_Table)opcode) 49 switch ((LSO_Enums.Operation_Table) opcode)
53 { 50 {
54 51 /***************
55 /***************
56 * IMPLEMENTED * 52 * IMPLEMENTED *
57 ***************/ 53 ***************/
58 case LSO_Enums.Operation_Table.NOOP: 54 case LSO_Enums.Operation_Table.NOOP:
@@ -60,33 +56,34 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
60 case LSO_Enums.Operation_Table.PUSHSP: 56 case LSO_Enums.Operation_Table.PUSHSP:
61 // Push Stack Top (Memory Address) to stack 57 // Push Stack Top (Memory Address) to stack
62 Common.SendToDebug("Instruction " + idesc); 58 Common.SendToDebug("Instruction " + idesc);
63 Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); 59 Common.SendToDebug("Instruction " + idesc +
64 IL_Push(il, (UInt32)myHeader.SP); 60 ": Description: Pushing Stack Top (Memory Address from header) to stack");
61 IL_Push(il, (UInt32) myHeader.SP);
65 break; 62 break;
66 // BYTE 63 // BYTE
67 case LSO_Enums.Operation_Table.PUSHARGB: 64 case LSO_Enums.Operation_Table.PUSHARGB:
68 Common.SendToDebug("Param1: " + br_read(1)[0]); 65 Common.SendToDebug("Param1: " + br_read(1)[0]);
69 break; 66 break;
70 // INTEGER 67 // INTEGER
71 case LSO_Enums.Operation_Table.PUSHARGI: 68 case LSO_Enums.Operation_Table.PUSHARGI:
72 u32p1 = BitConverter.ToUInt32(br_read(4), 0); 69 u32p1 = BitConverter.ToUInt32(br_read(4), 0);
73 Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); 70 Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1);
74 IL_Push(il, u32p1); 71 IL_Push(il, u32p1);
75 break; 72 break;
76 // FLOAT 73 // FLOAT
77 case LSO_Enums.Operation_Table.PUSHARGF: 74 case LSO_Enums.Operation_Table.PUSHARGF:
78 fp1 = BitConverter.ToUInt32(br_read(4), 0); 75 fp1 = BitConverter.ToUInt32(br_read(4), 0);
79 Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); 76 Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1);
80 IL_Push(il, fp1); 77 IL_Push(il, fp1);
81 break; 78 break;
82 // STRING 79 // STRING
83 case LSO_Enums.Operation_Table.PUSHARGS: 80 case LSO_Enums.Operation_Table.PUSHARGS:
84 string s = Read_String(); 81 string s = Read_String();
85 Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); 82 Common.SendToDebug("Instruction " + idesc + ", Param1: " + s);
86 IL_Debug(il, "OPCODE: " + idesc + ":" + s); 83 IL_Debug(il, "OPCODE: " + idesc + ":" + s);
87 IL_Push(il, s); 84 IL_Push(il, s);
88 break; 85 break;
89 // VECTOR z,y,x 86 // VECTOR z,y,x
90 case LSO_Enums.Operation_Table.PUSHARGV: 87 case LSO_Enums.Operation_Table.PUSHARGV:
91 LSO_Enums.Vector v = new LSO_Enums.Vector(); 88 LSO_Enums.Vector v = new LSO_Enums.Vector();
92 v.Z = BitConverter.ToUInt32(br_read(4), 0); 89 v.Z = BitConverter.ToUInt32(br_read(4), 0);
@@ -97,7 +94,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
97 Common.SendToDebug("Param1 X: " + v.X); 94 Common.SendToDebug("Param1 X: " + v.X);
98 IL_Push(il, v); 95 IL_Push(il, v);
99 break; 96 break;
100 // ROTATION s,z,y,x 97 // ROTATION s,z,y,x
101 case LSO_Enums.Operation_Table.PUSHARGQ: 98 case LSO_Enums.Operation_Table.PUSHARGQ:
102 LSO_Enums.Rotation r = new LSO_Enums.Rotation(); 99 LSO_Enums.Rotation r = new LSO_Enums.Rotation();
103 r.S = BitConverter.ToUInt32(br_read(4), 0); 100 r.S = BitConverter.ToUInt32(br_read(4), 0);
@@ -112,7 +109,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
112 break; 109 break;
113 110
114 case LSO_Enums.Operation_Table.PUSHE: 111 case LSO_Enums.Operation_Table.PUSHE:
115 IL_Push(il, (UInt32)0); 112 IL_Push(il, (UInt32) 0);
116 break; 113 break;
117 114
118 case LSO_Enums.Operation_Table.PUSHARGE: 115 case LSO_Enums.Operation_Table.PUSHARGE:
@@ -121,7 +118,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
121 //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); 118 //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1)));
122 IL_Push(il, u32p1); 119 IL_Push(il, u32p1);
123 break; 120 break;
124 // BYTE 121 // BYTE
125 case LSO_Enums.Operation_Table.ADD: 122 case LSO_Enums.Operation_Table.ADD:
126 case LSO_Enums.Operation_Table.SUB: 123 case LSO_Enums.Operation_Table.SUB:
127 case LSO_Enums.Operation_Table.MUL: 124 case LSO_Enums.Operation_Table.MUL:
@@ -136,10 +133,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
136 case LSO_Enums.Operation_Table.MOD: 133 case LSO_Enums.Operation_Table.MOD:
137 bp1 = br_read(1)[0]; 134 bp1 = br_read(1)[0];
138 Common.SendToDebug("Param1: " + bp1); 135 Common.SendToDebug("Param1: " + bp1);
139 IL_CallBaseFunction(il, idesc, (UInt32)bp1); 136 IL_CallBaseFunction(il, idesc, (UInt32) bp1);
140 break; 137 break;
141 138
142 // NO ARGUMENTS 139 // NO ARGUMENTS
143 case LSO_Enums.Operation_Table.BITAND: 140 case LSO_Enums.Operation_Table.BITAND:
144 case LSO_Enums.Operation_Table.BITOR: 141 case LSO_Enums.Operation_Table.BITOR:
145 case LSO_Enums.Operation_Table.BITXOR: 142 case LSO_Enums.Operation_Table.BITXOR:
@@ -149,22 +146,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
149 case LSO_Enums.Operation_Table.BOOLNOT: 146 case LSO_Enums.Operation_Table.BOOLNOT:
150 IL_CallBaseFunction(il, idesc); 147 IL_CallBaseFunction(il, idesc);
151 break; 148 break;
152 // SHORT 149 // SHORT
153 case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: 150 case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
154 // TODO: What is size of short? 151 // TODO: What is size of short?
155 UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); 152 UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0);
156 Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); 153 Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " +
154 ((LSO_Enums.BuiltIn_Functions) U16p1).ToString());
157 //Common.SendToDebug("Param1: " + U16p1); 155 //Common.SendToDebug("Param1: " + U16p1);
158 string fname = ((LSO_Enums.BuiltIn_Functions)U16p1).ToString(); 156 string fname = ((LSO_Enums.BuiltIn_Functions) U16p1).ToString();
159 157
160 bool cmdFound = false; 158 bool cmdFound = false;
161 foreach (MethodInfo mi in typeof(LSL_BuiltIn_Commands_Interface).GetMethods()) 159 foreach (MethodInfo mi in typeof (LSL_BuiltIn_Commands_Interface).GetMethods())
162 { 160 {
163 // Found command 161 // Found command
164 if (mi.Name == fname) 162 if (mi.Name == fname)
165 { 163 {
166 il.Emit(OpCodes.Ldarg_0); 164 il.Emit(OpCodes.Ldarg_0);
167 il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] { })); 165 il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] {}));
168 // Pop required number of items from my stack to .Net stack 166 // Pop required number of items from my stack to .Net stack
169 IL_PopToStack(il, mi.GetParameters().Length); 167 IL_PopToStack(il, mi.GetParameters().Length);
170 il.Emit(OpCodes.Callvirt, mi); 168 il.Emit(OpCodes.Callvirt, mi);
@@ -179,7 +177,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
179 177
180 break; 178 break;
181 179
182 // RETURN 180 // RETURN
183 case LSO_Enums.Operation_Table.RETURN: 181 case LSO_Enums.Operation_Table.RETURN:
184 182
185 Common.SendToDebug("OPCODE: RETURN"); 183 Common.SendToDebug("OPCODE: RETURN");
@@ -195,7 +193,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
195 IL_Pop(il); 193 IL_Pop(il);
196 break; 194 break;
197 195
198 // LONG 196 // LONG
199 case LSO_Enums.Operation_Table.STORE: 197 case LSO_Enums.Operation_Table.STORE:
200 case LSO_Enums.Operation_Table.STORES: 198 case LSO_Enums.Operation_Table.STORES:
201 case LSO_Enums.Operation_Table.STOREL: 199 case LSO_Enums.Operation_Table.STOREL:
@@ -238,7 +236,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
238 IL_Pop(il); 236 IL_Pop(il);
239 break; 237 break;
240 238
241 // PUSH FROM LOCAL FRAME 239 // PUSH FROM LOCAL FRAME
242 case LSO_Enums.Operation_Table.PUSH: 240 case LSO_Enums.Operation_Table.PUSH:
243 case LSO_Enums.Operation_Table.PUSHS: 241 case LSO_Enums.Operation_Table.PUSHS:
244 case LSO_Enums.Operation_Table.PUSHL: 242 case LSO_Enums.Operation_Table.PUSHL:
@@ -250,7 +248,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
250 248
251 break; 249 break;
252 250
253 // PUSH FROM STATIC FRAME 251 // PUSH FROM STATIC FRAME
254 case LSO_Enums.Operation_Table.PUSHG: 252 case LSO_Enums.Operation_Table.PUSHG:
255 case LSO_Enums.Operation_Table.PUSHGS: 253 case LSO_Enums.Operation_Table.PUSHGS:
256 case LSO_Enums.Operation_Table.PUSHGL: 254 case LSO_Enums.Operation_Table.PUSHGL:
@@ -262,26 +260,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
262 break; 260 break;
263 261
264 262
265 /*********************** 263 /***********************
266 * NOT IMPLEMENTED YET * 264 * NOT IMPLEMENTED YET *
267 ***********************/ 265 ***********************/
268 266
269 267
270
271 case LSO_Enums.Operation_Table.POPIP: 268 case LSO_Enums.Operation_Table.POPIP:
272 case LSO_Enums.Operation_Table.POPSP: 269 case LSO_Enums.Operation_Table.POPSP:
273 case LSO_Enums.Operation_Table.POPSLR: 270 case LSO_Enums.Operation_Table.POPSLR:
274 case LSO_Enums.Operation_Table.POPARG: 271 case LSO_Enums.Operation_Table.POPARG:
275 case LSO_Enums.Operation_Table.POPBP: 272 case LSO_Enums.Operation_Table.POPBP:
276 //Common.SendToDebug("Instruction " + idesc + ": Ignored"); 273 //Common.SendToDebug("Instruction " + idesc + ": Ignored");
277 Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); 274 Common.SendToDebug("Instruction " + idesc +
275 ": Description: Drop x bytes from the stack (TODO: Only popping 1)");
278 //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); 276 //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
279 IL_Pop(il); 277 IL_Pop(il);
280 break; 278 break;
281 279
282 280
283 281 // None
284 // None
285 case LSO_Enums.Operation_Table.PUSHIP: 282 case LSO_Enums.Operation_Table.PUSHIP:
286 // PUSH INSTRUCTION POINTER 283 // PUSH INSTRUCTION POINTER
287 break; 284 break;
@@ -293,17 +290,17 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
293 break; 290 break;
294 291
295 292
296 // LONG 293 // LONG
297 case LSO_Enums.Operation_Table.JUMP: 294 case LSO_Enums.Operation_Table.JUMP:
298 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); 295 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
299 break; 296 break;
300 // BYTE, LONG 297 // BYTE, LONG
301 case LSO_Enums.Operation_Table.JUMPIF: 298 case LSO_Enums.Operation_Table.JUMPIF:
302 case LSO_Enums.Operation_Table.JUMPNIF: 299 case LSO_Enums.Operation_Table.JUMPNIF:
303 Common.SendToDebug("Param1: " + br_read(1)[0]); 300 Common.SendToDebug("Param1: " + br_read(1)[0]);
304 Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); 301 Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0));
305 break; 302 break;
306 // LONG 303 // LONG
307 case LSO_Enums.Operation_Table.STATE: 304 case LSO_Enums.Operation_Table.STATE:
308 bp1 = br_read(1)[0]; 305 bp1 = br_read(1)[0];
309 //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack 306 //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack
@@ -315,12 +312,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
315 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); 312 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
316 Common.SendToDebug("ERROR: Function CALL not implemented yet."); 313 Common.SendToDebug("ERROR: Function CALL not implemented yet.");
317 break; 314 break;
318 // BYTE 315 // BYTE
319 case LSO_Enums.Operation_Table.CAST: 316 case LSO_Enums.Operation_Table.CAST:
320 bp1 = br_read(1)[0]; 317 bp1 = br_read(1)[0];
321 Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); 318 Common.SendToDebug("Instruction " + idesc + ": Cast to type: " +
319 ((LSO_Enums.OpCode_Cast_TypeDefs) bp1));
322 Common.SendToDebug("Param1: " + bp1); 320 Common.SendToDebug("Param1: " + bp1);
323 switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) 321 switch ((LSO_Enums.OpCode_Cast_TypeDefs) bp1)
324 { 322 {
325 case LSO_Enums.OpCode_Cast_TypeDefs.String: 323 case LSO_Enums.OpCode_Cast_TypeDefs.String:
326 Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); 324 Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());");
@@ -330,12 +328,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
330 break; 328 break;
331 } 329 }
332 break; 330 break;
333 // LONG 331 // LONG
334 case LSO_Enums.Operation_Table.STACKTOS: 332 case LSO_Enums.Operation_Table.STACKTOS:
335 case LSO_Enums.Operation_Table.STACKTOL: 333 case LSO_Enums.Operation_Table.STACKTOL:
336 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); 334 Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
337 break; 335 break;
338 // BYTE 336 // BYTE
339 case LSO_Enums.Operation_Table.PRINT: 337 case LSO_Enums.Operation_Table.PRINT:
340 case LSO_Enums.Operation_Table.CALLLIB: 338 case LSO_Enums.Operation_Table.CALLLIB:
341 Common.SendToDebug("Param1: " + br_read(1)[0]); 339 Common.SendToDebug("Param1: " + br_read(1)[0]);
@@ -348,6 +346,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
348 { 346 {
349 IL_PopToStack(il, 1); 347 IL_PopToStack(il, 1);
350 } 348 }
349
351 private void IL_PopToStack(ILGenerator il, int count) 350 private void IL_PopToStack(ILGenerator il, int count)
352 { 351 {
353 Common.SendToDebug("IL_PopToStack();"); 352 Common.SendToDebug("IL_PopToStack();");
@@ -360,31 +359,35 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
360 // new Type[] { })); 359 // new Type[] { }));
361 } 360 }
362 } 361 }
362
363 private void IL_Pop(ILGenerator il) 363 private void IL_Pop(ILGenerator il)
364 { 364 {
365 Common.SendToDebug("IL_Pop();"); 365 Common.SendToDebug("IL_Pop();");
366 IL_CallBaseFunction(il, "POP"); 366 IL_CallBaseFunction(il, "POP");
367 } 367 }
368
368 private void IL_Debug(ILGenerator il, string text) 369 private void IL_Debug(ILGenerator il, string text)
369 { 370 {
370 il.Emit(OpCodes.Ldstr, text); 371 il.Emit(OpCodes.Ldstr, text);
371 il.Emit(OpCodes.Call, typeof(Common).GetMethod("SendToDebug", 372 il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug",
372 new Type[] { typeof(string) } 373 new Type[] {typeof (string)}
373 )); 374 ));
374 } 375 }
376
375 private void IL_CallBaseFunction(ILGenerator il, string methodname) 377 private void IL_CallBaseFunction(ILGenerator il, string methodname)
376 { 378 {
377 il.Emit(OpCodes.Ldarg_0); 379 il.Emit(OpCodes.Ldarg_0);
378 il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { })); 380 il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {}));
379 } 381 }
382
380 private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) 383 private void IL_CallBaseFunction(ILGenerator il, string methodname, object data)
381 { 384 {
382 il.Emit(OpCodes.Ldarg_0); 385 il.Emit(OpCodes.Ldarg_0);
383 if (data.GetType() == typeof(string)) 386 if (data.GetType() == typeof (string))
384 il.Emit(OpCodes.Ldstr, (string)data); 387 il.Emit(OpCodes.Ldstr, (string) data);
385 if (data.GetType() == typeof(UInt32)) 388 if (data.GetType() == typeof (UInt32))
386 il.Emit(OpCodes.Ldc_I4, (UInt32)data); 389 il.Emit(OpCodes.Ldc_I4, (UInt32) data);
387 il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { data.GetType() })); 390 il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {data.GetType()}));
388 } 391 }
389 392
390 private void IL_Push(ILGenerator il, object data) 393 private void IL_Push(ILGenerator il, object data)
@@ -394,43 +397,39 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
394 397
395 IL_PushDataTypeToILStack(il, data); 398 IL_PushDataTypeToILStack(il, data);
396 399
397 il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("PUSH", new Type[] { data.GetType() })); 400 il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()}));
398
399 } 401 }
400 402
401 private void IL_PushDataTypeToILStack(ILGenerator il, object data) 403 private void IL_PushDataTypeToILStack(ILGenerator il, object data)
402 { 404 {
403 if (data.GetType() == typeof(UInt16)) 405 if (data.GetType() == typeof (UInt16))
404 { 406 {
405 il.Emit(OpCodes.Ldc_I4, (UInt16)data); 407 il.Emit(OpCodes.Ldc_I4, (UInt16) data);
406 il.Emit(OpCodes.Box, data.GetType()); 408 il.Emit(OpCodes.Box, data.GetType());
407 } 409 }
408 if (data.GetType() == typeof(UInt32)) 410 if (data.GetType() == typeof (UInt32))
409 { 411 {
410 il.Emit(OpCodes.Ldc_I4, (UInt32)data); 412 il.Emit(OpCodes.Ldc_I4, (UInt32) data);
411 il.Emit(OpCodes.Box, data.GetType()); 413 il.Emit(OpCodes.Box, data.GetType());
412 } 414 }
413 if (data.GetType() == typeof(Int32)) 415 if (data.GetType() == typeof (Int32))
414 { 416 {
415 il.Emit(OpCodes.Ldc_I4, (Int32)data); 417 il.Emit(OpCodes.Ldc_I4, (Int32) data);
416 il.Emit(OpCodes.Box, data.GetType()); 418 il.Emit(OpCodes.Box, data.GetType());
417 } 419 }
418 if (data.GetType() == typeof(float)) 420 if (data.GetType() == typeof (float))
419 { 421 {
420 il.Emit(OpCodes.Ldc_I4, (float)data); 422 il.Emit(OpCodes.Ldc_I4, (float) data);
421 il.Emit(OpCodes.Box, data.GetType()); 423 il.Emit(OpCodes.Box, data.GetType());
422 } 424 }
423 if (data.GetType() == typeof(string)) 425 if (data.GetType() == typeof (string))
424 il.Emit(OpCodes.Ldstr, (string)data); 426 il.Emit(OpCodes.Ldstr, (string) data);
425 //if (data.GetType() == typeof(LSO_Enums.Rotation)) 427 //if (data.GetType() == typeof(LSO_Enums.Rotation))
426 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); 428 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data);
427 //if (data.GetType() == typeof(LSO_Enums.Vector)) 429 //if (data.GetType() == typeof(LSO_Enums.Vector))
428 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); 430 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data);
429 //if (data.GetType() == typeof(LSO_Enums.Key)) 431 //if (data.GetType() == typeof(LSO_Enums.Key))
430 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); 432 // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data);
431
432 } 433 }
433
434
435 } 434 }
436} 435} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs
index 3de2a36..fef9ad2 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 31namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
34{ 32{
@@ -47,6 +45,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
47 String = 51, 45 String = 51,
48 UInt32 = 17 46 UInt32 = 17
49 } 47 }
48
50 [Serializable] 49 [Serializable]
51 public enum OpCode_Cast_TypeDefs 50 public enum OpCode_Cast_TypeDefs
52 { 51 {
@@ -66,6 +65,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
66 public UInt32 Y; 65 public UInt32 Y;
67 public UInt32 X; 66 public UInt32 X;
68 } 67 }
68
69 [Serializable] 69 [Serializable]
70 public struct Rotation 70 public struct Rotation
71 { 71 {
@@ -74,6 +74,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
74 public UInt32 Y; 74 public UInt32 Y;
75 public UInt32 X; 75 public UInt32 X;
76 } 76 }
77
77 [Serializable] 78 [Serializable]
78 public enum Variable_Type_Codes 79 public enum Variable_Type_Codes
79 { 80 {
@@ -87,6 +88,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
87 List = 7, 88 List = 7,
88 Null = 8 89 Null = 8
89 } 90 }
91
90 [Serializable] 92 [Serializable]
91 public enum Event_Mask_Values 93 public enum Event_Mask_Values
92 { 94 {
@@ -124,6 +126,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
124 remote_data = 31, 126 remote_data = 31,
125 http_response = 32 127 http_response = 32
126 } 128 }
129
127 [Serializable] 130 [Serializable]
128 public enum Operation_Table 131 public enum Operation_Table
129 { 132 {
@@ -220,6 +223,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
220 SHL = 0xe0, 223 SHL = 0xe0,
221 SHR = 0xe1 224 SHR = 0xe1
222 } 225 }
226
223 [Serializable] 227 [Serializable]
224 public enum BuiltIn_Functions 228 public enum BuiltIn_Functions
225 { 229 {
@@ -552,6 +556,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
552 llGetParcelMaxPrims = 326, 556 llGetParcelMaxPrims = 326,
553 llGetParcelDetails = 327 557 llGetParcelDetails = 327
554 } 558 }
555
556 } 559 }
557} 560} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs
index 8b24e68..11c51c5 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs
@@ -27,15 +27,16 @@
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.Text;
32using System.IO; 32using System.IO;
33using System.Reflection; 33using System.Reflection;
34using System.Reflection.Emit; 34using System.Reflection.Emit;
35using System.Text;
35 36
36namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 37namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
37{ 38{
38 partial class LSO_Parser 39 internal partial class LSO_Parser
39 { 40 {
40 private string FileName; 41 private string FileName;
41 private FileStream fs; 42 private FileStream fs;
@@ -45,7 +46,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
45 //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable(); 46 //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable();
46 47
47 private TypeBuilder typeBuilder; 48 private TypeBuilder typeBuilder;
48 private System.Collections.Generic.List<string> EventList = new System.Collections.Generic.List<string>(); 49 private List<string> EventList = new List<string>();
49 50
50 public LSO_Parser(string _FileName, TypeBuilder _typeBuilder) 51 public LSO_Parser(string _FileName, TypeBuilder _typeBuilder)
51 { 52 {
@@ -59,11 +60,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
59 Common.SendToDebug("Opening filename: " + FileName); 60 Common.SendToDebug("Opening filename: " + FileName);
60 fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); 61 fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
61 br = new BinaryReader(fs, Encoding.BigEndianUnicode); 62 br = new BinaryReader(fs, Encoding.BigEndianUnicode);
62
63 } 63 }
64
64 internal void CloseFile() 65 internal void CloseFile()
65 { 66 {
66
67 // Close 67 // Close
68 br.Close(); 68 br.Close();
69 fs.Close(); 69 fs.Close();
@@ -75,9 +75,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
75 /// </summary> 75 /// </summary>
76 public void Parse() 76 public void Parse()
77 { 77 {
78
79
80
81 // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. 78 // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack.
82 79
83 80
@@ -148,14 +145,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
148 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); 145 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock();
149 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); 146 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0);
150 myStaticBlock.ObjectType = br_read(1)[0]; 147 myStaticBlock.ObjectType = br_read(1)[0];
151 Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); 148 Common.SendToDebug("Static Block ObjectType: " +
149 ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString());
152 myStaticBlock.Unknown = br_read(1)[0]; 150 myStaticBlock.Unknown = br_read(1)[0];
153 // Size of datatype varies -- what about strings? 151 // Size of datatype varies -- what about strings?
154 if (myStaticBlock.ObjectType != 0) 152 if (myStaticBlock.ObjectType != 0)
155 myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); 153 myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType));
156 154
157 StaticBlocks.Add((UInt32)startReadPos, myStaticBlock); 155 StaticBlocks.Add((UInt32) startReadPos, myStaticBlock);
158
159 } 156 }
160 Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); 157 Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount);
161 158
@@ -183,7 +180,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
183 // TODO: ADD TO FUNCTION LIST (How do we identify it later?) 180 // TODO: ADD TO FUNCTION LIST (How do we identify it later?)
184 // Note! Absolute position 181 // Note! Absolute position
185 myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; 182 myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR;
186 Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); 183 Common.SendToDebug("Fuction " + i + " code chunk position: " +
184 myFunctionBlock.CodeChunkPointer[i]);
187 } 185 }
188 } 186 }
189 } 187 }
@@ -204,14 +202,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
204 Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); 202 Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position);
205 // Position is relative to state frame 203 // Position is relative to state frame
206 myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); 204 myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0);
207 myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); 205 myStateFrameBlock.StatePointer[i].EventMask = new BitArray(br_read(8));
208 Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); 206 Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location);
209 Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); 207 Common.SendToDebug("Total potential EventMask bits: " +
208 myStateFrameBlock.StatePointer[i].EventMask.Count);
210 209
211 //// Read STATE BLOCK 210 //// Read STATE BLOCK
212 //long CurPos = fs.Position; 211 //long CurPos = fs.Position;
213 //fs.Seek(CurPos, SeekOrigin.Begin); 212 //fs.Seek(CurPos, SeekOrigin.Begin);
214
215 } 213 }
216 } 214 }
217 215
@@ -224,19 +222,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
224 // Go through all State Frame Pointers found 222 // Go through all State Frame Pointers found
225 for (int i = 0; i < myStateFrameBlock.StateCount; i++) 223 for (int i = 0; i < myStateFrameBlock.StateCount; i++)
226 { 224 {
227
228 fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); 225 fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin);
229 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); 226 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position);
230 227
231 // READ: STATE BLOCK HEADER 228 // READ: STATE BLOCK HEADER
232 myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); 229 myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock();
233 myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note 230 myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32) fs.Position; // Note
234 myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); 231 myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0);
235 myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; 232 myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0];
236 myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note 233 myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32) fs.Position; // Note
237 Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); 234 Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos);
238 Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); 235 Common.SendToDebug("State block Header Size: " +
239 Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); 236 myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize);
237 Common.SendToDebug("State block Header End Pos: " +
238 myStateFrameBlock.StatePointer[i].StateBlock.EndPos);
240 239
241 // We need to count number of bits flagged in EventMask? 240 // We need to count number of bits flagged in EventMask?
242 241
@@ -245,27 +244,36 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
245 244
246 // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE 245 // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE
247 //TODO: Create event hooks 246 //TODO: Create event hooks
248 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; 247 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers =
248 new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1];
249 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) 249 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++)
250 { 250 {
251
252 if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) 251 if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true)
253 { 252 {
254 // We got an event 253 // We got an event
255 // READ: STATE BLOCK HANDLER 254 // READ: STATE BLOCK HANDLER
256 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); 255 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii +
257 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); 256 " (" + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") at: " +
258 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); 257 fs.Position);
259 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); 258 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer =
260 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize); 259 myStateFrameBlock.StatePointer[i].StateBlock.EndPos +
260 BitConverter.ToUInt32(br_read(4), 0);
261 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize =
262 BitConverter.ToUInt32(br_read(4), 0);
263 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" +
264 ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Code Chunk Pointer: " +
265 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].
266 CodeChunkPointer);
267 Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" +
268 ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Call Frame Size: " +
269 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].
270 CallFrameSize);
261 } 271 }
262 } 272 }
263 } 273 }
264 } 274 }
265 275
266 276
267
268
269 //// READ FUNCTION CODE CHUNKS 277 //// READ FUNCTION CODE CHUNKS
270 //// Functions + Function start pos (GFR) 278 //// Functions + Function start pos (GFR)
271 //// TODO: Somehow be able to identify and reference this 279 //// TODO: Somehow be able to identify and reference this
@@ -291,37 +299,32 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
291 // two level search ain't no good 299 // two level search ain't no good
292 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) 300 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++)
293 { 301 {
294
295
296 if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) 302 if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0)
297 { 303 {
298 Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); 304 Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " +
305 (LSO_Enums.Event_Mask_Values) ii);
299 306
300 307
301 // Override a Method / Function 308 // Override a Method / Function
302 string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii; 309 string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values) ii;
303 Common.SendToDebug("Event Name: " + eventname); 310 Common.SendToDebug("Event Name: " + eventname);
304 if (Common.IL_ProcessCodeChunks) 311 if (Common.IL_ProcessCodeChunks)
305 { 312 {
306 EventList.Add(eventname); 313 EventList.Add(eventname);
307 314
308 // JUMP TO CODE PROCESSOR 315 // JUMP TO CODE PROCESSOR
309 ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname); 316 ProcessCodeChunk(
317 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer,
318 typeBuilder, eventname);
310 } 319 }
311 } 320 }
312
313 } 321 }
314
315 } 322 }
316
317 } 323 }
318 324
319 325
320
321
322 if (Common.IL_CreateFunctionList) 326 if (Common.IL_CreateFunctionList)
323 IL_INSERT_FUNCTIONLIST(); 327 IL_INSERT_FUNCTIONLIST();
324
325 } 328 }
326 329
327 internal LSO_Struct.HeapBlock GetHeap(UInt32 pos) 330 internal LSO_Struct.HeapBlock GetHeap(UInt32 pos)
@@ -342,11 +345,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
342 345
343 346
344 Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); 347 Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize);
345 Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); 348 Common.SendToDebug("Heap Block ObjectType: " +
349 ((LSO_Enums.Variable_Type_Codes) myHeapBlock.ObjectType).ToString());
346 Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); 350 Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount);
347 351
348 return myHeapBlock; 352 return myHeapBlock;
349 } 353 }
354
350 private byte[] br_read(int len) 355 private byte[] br_read(int len)
351 { 356 {
352 if (len <= 0) 357 if (len <= 0)
@@ -365,6 +370,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
365 throw (e); 370 throw (e);
366 } 371 }
367 } 372 }
373
368 //private byte[] br_read_smallendian(int len) 374 //private byte[] br_read_smallendian(int len)
369 //{ 375 //{
370 // byte[] bytes = new byte[len]; 376 // byte[] bytes = new byte[len];
@@ -373,29 +379,38 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
373 //} 379 //}
374 private Type getLLObjectType(byte objectCode) 380 private Type getLLObjectType(byte objectCode)
375 { 381 {
376 switch ((LSO_Enums.Variable_Type_Codes)objectCode) 382 switch ((LSO_Enums.Variable_Type_Codes) objectCode)
377 { 383 {
378 case LSO_Enums.Variable_Type_Codes.Void: return typeof(void); 384 case LSO_Enums.Variable_Type_Codes.Void:
379 case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32); 385 return typeof (void);
380 case LSO_Enums.Variable_Type_Codes.Float: return typeof(float); 386 case LSO_Enums.Variable_Type_Codes.Integer:
381 case LSO_Enums.Variable_Type_Codes.String: return typeof(string); 387 return typeof (UInt32);
382 case LSO_Enums.Variable_Type_Codes.Key: return typeof(string); 388 case LSO_Enums.Variable_Type_Codes.Float:
383 case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector); 389 return typeof (float);
384 case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation); 390 case LSO_Enums.Variable_Type_Codes.String:
391 return typeof (string);
392 case LSO_Enums.Variable_Type_Codes.Key:
393 return typeof (string);
394 case LSO_Enums.Variable_Type_Codes.Vector:
395 return typeof (LSO_Enums.Vector);
396 case LSO_Enums.Variable_Type_Codes.Rotation:
397 return typeof (LSO_Enums.Rotation);
385 case LSO_Enums.Variable_Type_Codes.List: 398 case LSO_Enums.Variable_Type_Codes.List:
386 Common.SendToDebug("TODO: List datatype not implemented yet!"); 399 Common.SendToDebug("TODO: List datatype not implemented yet!");
387 return typeof(System.Collections.ArrayList); 400 return typeof (ArrayList);
388 case LSO_Enums.Variable_Type_Codes.Null: 401 case LSO_Enums.Variable_Type_Codes.Null:
389 Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!"); 402 Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!");
390 return typeof(string); 403 return typeof (string);
391 default: 404 default:
392 Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); 405 Common.SendToDebug("Lookup of LSL datatype " + objectCode +
393 return typeof(object); 406 " to .Net datatype failed: Unknown LSL datatype. Defaulting to object.");
407 return typeof (object);
394 } 408 }
395 } 409 }
410
396 private int getObjectSize(byte ObjectType) 411 private int getObjectSize(byte ObjectType)
397 { 412 {
398 switch ((LSO_Enums.Variable_Type_Codes)ObjectType) 413 switch ((LSO_Enums.Variable_Type_Codes) ObjectType)
399 { 414 {
400 case LSO_Enums.Variable_Type_Codes.Integer: 415 case LSO_Enums.Variable_Type_Codes.Integer:
401 case LSO_Enums.Variable_Type_Codes.Float: 416 case LSO_Enums.Variable_Type_Codes.Float:
@@ -411,13 +426,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
411 return 0; 426 return 0;
412 } 427 }
413 } 428 }
429
414 private string Read_String() 430 private string Read_String()
415 { 431 {
416 string ret = ""; 432 string ret = "";
417 byte reader = br_read(1)[0]; 433 byte reader = br_read(1)[0];
418 while (reader != 0x000) 434 while (reader != 0x000)
419 { 435 {
420 ret += (char)reader; 436 ret += (char) reader;
421 reader = br_read(1)[0]; 437 reader = br_read(1)[0];
422 } 438 }
423 return ret; 439 return ret;
@@ -431,7 +447,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
431 /// <param name="eventname">Name of event (function) to generate</param> 447 /// <param name="eventname">Name of event (function) to generate</param>
432 private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) 448 private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname)
433 { 449 {
434
435 LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); 450 LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk();
436 451
437 Common.SendToDebug("Reading Function Code Chunk at: " + pos); 452 Common.SendToDebug("Reading Function Code Chunk at: " + pos);
@@ -442,12 +457,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
442 myCodeChunk.Comment = Read_String(); 457 myCodeChunk.Comment = Read_String();
443 Common.SendToDebug("Function comment: " + myCodeChunk.Comment); 458 Common.SendToDebug("Function comment: " + myCodeChunk.Comment);
444 myCodeChunk.ReturnTypePos = br_read(1)[0]; 459 myCodeChunk.ReturnTypePos = br_read(1)[0];
445 myCodeChunk.ReturnType = GetStaticBlock((long)myCodeChunk.ReturnTypePos + (long)myHeader.GVR); 460 myCodeChunk.ReturnType = GetStaticBlock((long) myCodeChunk.ReturnTypePos + (long) myHeader.GVR);
446 Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + ((LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType.ObjectType).ToString()); 461 Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " +
462 ((LSO_Enums.Variable_Type_Codes) myCodeChunk.ReturnType.ObjectType).ToString());
447 463
448 464
449 // TODO: How to determine number of codechunks -- does this method work? 465 // TODO: How to determine number of codechunks -- does this method work?
450 myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); 466 myCodeChunk.CodeChunkArguments = new List<LSO_Struct.CodeChunkArgument>();
451 byte reader = br_read(1)[0]; 467 byte reader = br_read(1)[0];
452 reader = br_read(1)[0]; 468 reader = br_read(1)[0];
453 469
@@ -464,14 +480,17 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
464 CCA.NullString = reader; 480 CCA.NullString = reader;
465 CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR); 481 CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR);
466 myCodeChunk.CodeChunkArguments.Add(CCA); 482 myCodeChunk.CodeChunkArguments.Add(CCA);
467 Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + ": " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType.ObjectType); 483 Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType +
484 ": " + (LSO_Enums.Variable_Type_Codes) CCA.FunctionReturnType.ObjectType);
468 } 485 }
469 // Create string array 486 // Create string array
470 Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; 487 Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count];
471 for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) 488 for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++)
472 { 489 {
473 MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType); 490 MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType);
474 Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType).ToString()); 491 Common.SendToDebug("Method argument " + _ic + ": " +
492 getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType).
493 ToString());
475 } 494 }
476 // End marker is 0x000 495 // End marker is 0x000
477 myCodeChunk.EndMarker = reader; 496 myCodeChunk.EndMarker = reader;
@@ -483,9 +502,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
483 502
484 Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); 503 Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod...");
485 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, 504 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
486 MethodAttributes.Public, 505 MethodAttributes.Public,
487 typeof(void), 506 typeof (void),
488 new Type[] { typeof(object) }); 507 new Type[] {typeof (object)});
489 //MethodArgs); 508 //MethodArgs);
490 //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), 509 //typeof(void), //getLLObjectType(myCodeChunk.ReturnType),
491 // new Type[] { typeof(object) }, //); 510 // new Type[] { typeof(object) }, //);
@@ -504,7 +523,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
504 IL_INSERT_TRY(il, eventname); 523 IL_INSERT_TRY(il, eventname);
505 524
506 525
507
508 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); 526 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
509 //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 527 //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
510 //il.Emit(OpCodes.Call, typeof(Console).GetMethod 528 //il.Emit(OpCodes.Call, typeof(Console).GetMethod
@@ -520,7 +538,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
520 } 538 }
521 539
522 540
523
524 // 541 //
525 // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL 542 // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL
526 // 543 //
@@ -538,12 +555,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
538 il.Emit(OpCodes.Ret); 555 il.Emit(OpCodes.Ret);
539 556
540 return; 557 return;
541
542 } 558 }
543 559
544 private void IL_INSERT_FUNCTIONLIST() 560 private void IL_INSERT_FUNCTIONLIST()
545 { 561 {
546
547 Common.SendToDebug("Creating function list"); 562 Common.SendToDebug("Creating function list");
548 563
549 564
@@ -557,11 +572,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
557 //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); 572 //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private);
558 573
559 574
560
561 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, 575 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
562 MethodAttributes.Public, 576 MethodAttributes.Public,
563 typeof(string[]), 577 typeof (string[]),
564 null); 578 null);
565 579
566 //typeBuilder.DefineMethodOverride(methodBuilder, 580 //typeBuilder.DefineMethodOverride(methodBuilder,
567 // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); 581 // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname));
@@ -569,8 +583,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
569 ILGenerator il = methodBuilder.GetILGenerator(); 583 ILGenerator il = methodBuilder.GetILGenerator();
570 584
571 585
572
573
574 // IL_INSERT_TRY(il, eventname); 586 // IL_INSERT_TRY(il, eventname);
575 587
576 // // Push string to stack 588 // // Push string to stack
@@ -586,37 +598,34 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
586 598
587 ////il.Emit(OpCodes.Ldarg_0); 599 ////il.Emit(OpCodes.Ldarg_0);
588 600
589 il.DeclareLocal(typeof(string[])); 601 il.DeclareLocal(typeof (string[]));
590 602
591 ////il.Emit(OpCodes.Ldarg_0); 603 ////il.Emit(OpCodes.Ldarg_0);
592 il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length 604 il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length
593 il.Emit(OpCodes.Newarr, typeof(String)); // create new string array 605 il.Emit(OpCodes.Newarr, typeof (String)); // create new string array
594 il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack 606 il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack
595 ////SetFunctionList 607 ////SetFunctionList
596 608
597 for (int lv = 0; lv < EventList.Count; lv++) 609 for (int lv = 0; lv < EventList.Count; lv++)
598 { 610 {
599 il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack 611 il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack
600 il.Emit(OpCodes.Ldc_I4, lv); // Push index position 612 il.Emit(OpCodes.Ldc_I4, lv); // Push index position
601 il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value 613 il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value
602 il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value 614 il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value
603 615
604 //il.Emit(OpCodes.Ldarg_0); 616 //il.Emit(OpCodes.Ldarg_0);
605 //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value 617 //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value
606 //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) })); 618 //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) }));
607
608 } 619 }
609 620
610 621
611
612 // IL_INSERT_END_TRY(il, eventname); 622 // IL_INSERT_END_TRY(il, eventname);
613 623
614 624
615 il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack 625 il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack
616 // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) })); 626 // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) }));
617 627
618 il.Emit(OpCodes.Ret); // Return 628 il.Emit(OpCodes.Ret); // Return
619
620 } 629 }
621 630
622 631
@@ -631,7 +640,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
631 // Push "Hello World!" string to stack 640 // Push "Hello World!" string to stack
632 //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); 641 //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
633 //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); 642 //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname);
634
635 } 643 }
636 644
637 private void IL_INSERT_END_TRY(ILGenerator il, string eventname) 645 private void IL_INSERT_END_TRY(ILGenerator il, string eventname)
@@ -640,7 +648,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
640 * CATCH 648 * CATCH
641 */ 649 */
642 Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); 650 Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));");
643 il.BeginCatchBlock(typeof(Exception)); 651 il.BeginCatchBlock(typeof (Exception));
644 652
645 // Push "Hello World!" string to stack 653 // Push "Hello World!" string to stack
646 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); 654 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
@@ -648,18 +656,18 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
648 656
649 //call void [mscorlib]System.Console::WriteLine(string) 657 //call void [mscorlib]System.Console::WriteLine(string)
650 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 658 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
651 il.Emit(OpCodes.Call, typeof(Console).GetMethod 659 il.Emit(OpCodes.Call, typeof (Console).GetMethod
652 ("Write", new Type[] { typeof(string) })); 660 ("Write", new Type[] {typeof (string)}));
653 661
654 //callvirt instance string [mscorlib]System.Exception::get_Message() 662 //callvirt instance string [mscorlib]System.Exception::get_Message()
655 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); 663 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt...");
656 il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod 664 il.Emit(OpCodes.Callvirt, typeof (Exception).GetMethod
657 ("get_Message")); 665 ("get_Message"));
658 666
659 //call void [mscorlib]System.Console::WriteLine(string) 667 //call void [mscorlib]System.Console::WriteLine(string)
660 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 668 Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
661 il.Emit(OpCodes.Call, typeof(Console).GetMethod 669 il.Emit(OpCodes.Call, typeof (Console).GetMethod
662 ("WriteLine", new Type[] { typeof(string) })); 670 ("WriteLine", new Type[] {typeof (string)}));
663 671
664 /* 672 /*
665 * CLR END TRY 673 * CLR END TRY
@@ -673,7 +681,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
673 long FirstPos = fs.Position; 681 long FirstPos = fs.Position;
674 try 682 try
675 { 683 {
676 UInt32 position = (UInt32)pos; 684 UInt32 position = (UInt32) pos;
677 // STATIC BLOCK 685 // STATIC BLOCK
678 Common.SendToDebug("Reading STATIC BLOCK at: " + position); 686 Common.SendToDebug("Reading STATIC BLOCK at: " + position);
679 fs.Seek(position, SeekOrigin.Begin); 687 fs.Seek(position, SeekOrigin.Begin);
@@ -683,7 +691,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
683 Common.SendToDebug("Found cached STATIC BLOCK"); 691 Common.SendToDebug("Found cached STATIC BLOCK");
684 692
685 693
686
687 return StaticBlocks[pos]; 694 return StaticBlocks[pos];
688 } 695 }
689 696
@@ -699,7 +706,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
699 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); 706 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock();
700 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); 707 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0);
701 myStaticBlock.ObjectType = br_read(1)[0]; 708 myStaticBlock.ObjectType = br_read(1)[0];
702 Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); 709 Common.SendToDebug("Static Block ObjectType: " +
710 ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString());
703 myStaticBlock.Unknown = br_read(1)[0]; 711 myStaticBlock.Unknown = br_read(1)[0];
704 // Size of datatype varies 712 // Size of datatype varies
705 if (myStaticBlock.ObjectType != 0) 713 if (myStaticBlock.ObjectType != 0)
@@ -715,8 +723,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
715 // Go back to original read pos 723 // Go back to original read pos
716 fs.Seek(FirstPos, SeekOrigin.Begin); 724 fs.Seek(FirstPos, SeekOrigin.Begin);
717 } 725 }
718
719 } 726 }
720
721 } 727 }
722} 728} \ No newline at end of file
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs
index f0203b3..2bb2c38 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs
@@ -28,14 +28,13 @@
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29 29
30using System; 30using System;
31using System.Collections;
31using System.Collections.Generic; 32using System.Collections.Generic;
32using System.Text;
33 33
34namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO 34namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
35{ 35{
36 static class LSO_Struct 36 internal static class LSO_Struct
37 { 37 {
38
39 public struct Header 38 public struct Header
40 { 39 {
41 public UInt32 TM; 40 public UInt32 TM;
@@ -69,6 +68,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
69 public byte Unknown; 68 public byte Unknown;
70 public byte[] BlockVariable; 69 public byte[] BlockVariable;
71 } 70 }
71
72 /* Not actually a structure 72 /* Not actually a structure
73 public struct StaticBlockVariable 73 public struct StaticBlockVariable
74 { 74 {
@@ -80,6 +80,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
80 public byte[] Rotation_16; 80 public byte[] Rotation_16;
81 public UInt32 Pointer_List_Structure; 81 public UInt32 Pointer_List_Structure;
82 } */ 82 } */
83
83 public struct HeapBlock 84 public struct HeapBlock
84 { 85 {
85 public Int32 DataBlockSize; 86 public Int32 DataBlockSize;
@@ -87,17 +88,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
87 public UInt16 ReferenceCount; 88 public UInt16 ReferenceCount;
88 public byte[] Data; 89 public byte[] Data;
89 } 90 }
91
90 public struct StateFrameBlock 92 public struct StateFrameBlock
91 { 93 {
92 public UInt32 StateCount; 94 public UInt32 StateCount;
93 public StatePointerBlock[] StatePointer; 95 public StatePointerBlock[] StatePointer;
94 } 96 }
97
95 public struct StatePointerBlock 98 public struct StatePointerBlock
96 { 99 {
97 public UInt32 Location; 100 public UInt32 Location;
98 public System.Collections.BitArray EventMask; 101 public BitArray EventMask;
99 public StateBlock StateBlock; 102 public StateBlock StateBlock;
100 } 103 }
104
101 public struct StateBlock 105 public struct StateBlock
102 { 106 {
103 public UInt32 StartPos; 107 public UInt32 StartPos;
@@ -106,25 +110,29 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
106 public byte Unknown; 110 public byte Unknown;
107 public StateBlockHandler[] StateBlockHandlers; 111 public StateBlockHandler[] StateBlockHandlers;
108 } 112 }
113
109 public struct StateBlockHandler 114 public struct StateBlockHandler
110 { 115 {
111 public UInt32 CodeChunkPointer; 116 public UInt32 CodeChunkPointer;
112 public UInt32 CallFrameSize; 117 public UInt32 CallFrameSize;
113 } 118 }
119
114 public struct FunctionBlock 120 public struct FunctionBlock
115 { 121 {
116 public UInt32 FunctionCount; 122 public UInt32 FunctionCount;
117 public UInt32[] CodeChunkPointer; 123 public UInt32[] CodeChunkPointer;
118 } 124 }
125
119 public struct CodeChunk 126 public struct CodeChunk
120 { 127 {
121 public UInt32 CodeChunkHeaderSize; 128 public UInt32 CodeChunkHeaderSize;
122 public string Comment; 129 public string Comment;
123 public System.Collections.Generic.List<CodeChunkArgument> CodeChunkArguments; 130 public List<CodeChunkArgument> CodeChunkArguments;
124 public byte EndMarker; 131 public byte EndMarker;
125 public byte ReturnTypePos; 132 public byte ReturnTypePos;
126 public StaticBlock ReturnType; 133 public StaticBlock ReturnType;
127 } 134 }
135
128 public struct CodeChunkArgument 136 public struct CodeChunkArgument
129 { 137 {
130 public byte FunctionReturnTypePos; 138 public byte FunctionReturnTypePos;
@@ -132,4 +140,4 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
132 public StaticBlock FunctionReturnType; 140 public StaticBlock FunctionReturnType;
133 } 141 }
134 } 142 }
135} 143} \ No newline at end of file