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