aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-01-12 15:52:34 +0000
committerTedd Hansen2008-01-12 15:52:34 +0000
commitf9c981007db13d86342f5a68168e012b4026c78c (patch)
tree557e208bc079a02d47857fa59f6dfa40469b0fe4 /OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs
parentWelcome back LSO. (diff)
downloadopensim-SC_OLD-f9c981007db13d86342f5a68168e012b4026c78c.zip
opensim-SC_OLD-f9c981007db13d86342f5a68168e012b4026c78c.tar.gz
opensim-SC_OLD-f9c981007db13d86342f5a68168e012b4026c78c.tar.bz2
opensim-SC_OLD-f9c981007db13d86342f5a68168e012b4026c78c.tar.xz
Set eol
Diffstat (limited to 'OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs584
1 files changed, 292 insertions, 292 deletions
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs
index 27acc9c..6dde3e5 100644
--- a/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs
+++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSO/Engine.cs
@@ -1,293 +1,293 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Reflection.Emit; 32using System.Reflection.Emit;
33using System.Text; 33using System.Text;
34using System.Threading; 34using System.Threading;
35using OpenSim.Region.ScriptEngine.Common; 35using OpenSim.Region.ScriptEngine.Common;
36using OpenSim.Region.ScriptEngine.LSOEngine.LSO; 36using OpenSim.Region.ScriptEngine.LSOEngine.LSO;
37 37
38namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO 38namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO
39{ 39{
40 public class Engine 40 public class Engine
41 { 41 {
42 //private string LSO_FileName = @"LSO\AdditionTest.lso"; 42 //private string LSO_FileName = @"LSO\AdditionTest.lso";
43 private string LSO_FileName; // = @"LSO\CloseToDefault.lso"; 43 private string LSO_FileName; // = @"LSO\CloseToDefault.lso";
44 private AppDomain appDomain; 44 private AppDomain appDomain;
45 45
46 public string Compile(string LSOFileName) 46 public string Compile(string LSOFileName)
47 { 47 {
48 LSO_FileName = LSOFileName; 48 LSO_FileName = LSOFileName;
49 49
50 50
51 //appDomain = AppDomain.CreateDomain("AlternateAppDomain"); 51 //appDomain = AppDomain.CreateDomain("AlternateAppDomain");
52 appDomain = Thread.GetDomain(); 52 appDomain = Thread.GetDomain();
53 53
54 // Create Assembly Name 54 // Create Assembly Name
55 AssemblyName asmName = new AssemblyName(); 55 AssemblyName asmName = new AssemblyName();
56 asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName); 56 asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName);
57 //asmName.Name = "TestAssembly"; 57 //asmName.Name = "TestAssembly";
58 58
59 string DLL_FileName = asmName.Name + ".dll"; 59 string DLL_FileName = asmName.Name + ".dll";
60 string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; 60 string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName;
61 61
62 LSOEngine.LSO.Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName)); 62 LSOEngine.LSO.Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName));
63 LSOEngine.LSO.Common.SendToLog("Assembly name: " + asmName.Name); 63 LSOEngine.LSO.Common.SendToLog("Assembly name: " + asmName.Name);
64 LSOEngine.LSO.Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); 64 LSOEngine.LSO.Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll");
65 LSOEngine.LSO.Common.SendToLog("Starting processing of LSL ByteCode..."); 65 LSOEngine.LSO.Common.SendToLog("Starting processing of LSL ByteCode...");
66 LSOEngine.LSO.Common.SendToLog(""); 66 LSOEngine.LSO.Common.SendToLog("");
67 67
68 68
69 // Create Assembly 69 // Create Assembly
70 AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( 70 AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly(
71 asmName, 71 asmName,
72 AssemblyBuilderAccess.RunAndSave 72 AssemblyBuilderAccess.RunAndSave
73 ); 73 );
74 //// Create Assembly 74 //// Create Assembly
75 //AssemblyBuilder asmBuilder = 75 //AssemblyBuilder asmBuilder =
76 // Thread.GetDomain().DefineDynamicAssembly 76 // Thread.GetDomain().DefineDynamicAssembly
77 //(asmName, AssemblyBuilderAccess.RunAndSave); 77 //(asmName, AssemblyBuilderAccess.RunAndSave);
78 78
79 // Create a module (and save to disk) 79 // Create a module (and save to disk)
80 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule 80 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule
81 (asmName.Name, 81 (asmName.Name,
82 DLL_FileName); 82 DLL_FileName);
83 83
84 //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\""); 84 //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\"");
85 // Create a Class (/Type) 85 // Create a Class (/Type)
86 TypeBuilder typeBuilder = modBuilder.DefineType( 86 TypeBuilder typeBuilder = modBuilder.DefineType(
87 "LSL_ScriptObject", 87 "LSL_ScriptObject",
88 TypeAttributes.Public | TypeAttributes.BeforeFieldInit, 88 TypeAttributes.Public | TypeAttributes.BeforeFieldInit,
89 typeof (LSL_BaseClass)); 89 typeof (LSL_BaseClass));
90 //, 90 //,
91 // typeof()); 91 // typeof());
92 //, typeof(LSL_BuiltIn_Commands_Interface)); 92 //, typeof(LSL_BuiltIn_Commands_Interface));
93 //, 93 //,
94 // typeof(object), 94 // typeof(object),
95 // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); 95 // new Type[] { typeof(LSL_CLRInterface.LSLScript) });
96 96
97 97
98 /* 98 /*
99 * Generate the IL itself 99 * Generate the IL itself
100 */ 100 */
101 101
102 LSO_Parser LSOP = new LSO_Parser(LSO_FileName, typeBuilder); 102 LSO_Parser LSOP = new LSO_Parser(LSO_FileName, typeBuilder);
103 LSOP.OpenFile(); 103 LSOP.OpenFile();
104 LSOP.Parse(); 104 LSOP.Parse();
105 105
106 // Constructor has to be created AFTER LSO_Parser because of accumulated variables 106 // Constructor has to be created AFTER LSO_Parser because of accumulated variables
107 if (LSOEngine.LSO.Common.IL_CreateConstructor) 107 if (LSOEngine.LSO.Common.IL_CreateConstructor)
108 IL_CREATE_CONSTRUCTOR(typeBuilder, LSOP); 108 IL_CREATE_CONSTRUCTOR(typeBuilder, LSOP);
109 109
110 LSOP.CloseFile(); 110 LSOP.CloseFile();
111 /* 111 /*
112 * Done generating. Create a type and run it. 112 * Done generating. Create a type and run it.
113 */ 113 */
114 114
115 115
116 LSOEngine.LSO.Common.SendToLog("Attempting to compile assembly..."); 116 LSOEngine.LSO.Common.SendToLog("Attempting to compile assembly...");
117 // Compile it 117 // Compile it
118 Type type = typeBuilder.CreateType(); 118 Type type = typeBuilder.CreateType();
119 LSOEngine.LSO.Common.SendToLog("Compilation successful!"); 119 LSOEngine.LSO.Common.SendToLog("Compilation successful!");
120 120
121 LSOEngine.LSO.Common.SendToLog("Saving assembly: " + DLL_FileName); 121 LSOEngine.LSO.Common.SendToLog("Saving assembly: " + DLL_FileName);
122 asmBuilder.Save(DLL_FileName); 122 asmBuilder.Save(DLL_FileName);
123 123
124 LSOEngine.LSO.Common.SendToLog("Returning assembly filename: " + DLL_FileName); 124 LSOEngine.LSO.Common.SendToLog("Returning assembly filename: " + DLL_FileName);
125 125
126 126
127 return DLL_FileName; 127 return DLL_FileName;
128 128
129 129
130 //Common.SendToLog("Creating an instance of new assembly..."); 130 //Common.SendToLog("Creating an instance of new assembly...");
131 //// Create an instance we can play with 131 //// Create an instance we can play with
132 ////LSLScript hello = (LSLScript)Activator.CreateInstance(type); 132 ////LSLScript hello = (LSLScript)Activator.CreateInstance(type);
133 ////LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); 133 ////LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type);
134 //object MyScript = (object)Activator.CreateInstance(type); 134 //object MyScript = (object)Activator.CreateInstance(type);
135 135
136 136
137 //System.Reflection.MemberInfo[] Members = type.GetMembers(); 137 //System.Reflection.MemberInfo[] Members = type.GetMembers();
138 138
139 //Common.SendToLog("Members of assembly " + type.ToString() + ":"); 139 //Common.SendToLog("Members of assembly " + type.ToString() + ":");
140 //foreach (MemberInfo member in Members) 140 //foreach (MemberInfo member in Members)
141 // Common.SendToLog(member.ToString()); 141 // Common.SendToLog(member.ToString());
142 142
143 143
144 //// Play with it 144 //// Play with it
145 ////MyScript.event_state_entry("Test"); 145 ////MyScript.event_state_entry("Test");
146 //object[] args = { null }; 146 //object[] args = { null };
147 ////System.Collections.Generic.List<string> Functions = (System.Collections.Generic.List<string>)type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); 147 ////System.Collections.Generic.List<string> Functions = (System.Collections.Generic.List<string>)type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null);
148 148
149 //string[] ret = { }; 149 //string[] ret = { };
150 //if (Common.IL_CreateFunctionList) 150 //if (Common.IL_CreateFunctionList)
151 // ret = (string[])type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null); 151 // ret = (string[])type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null);
152 152
153 //foreach (string s in ret) 153 //foreach (string s in ret)
154 //{ 154 //{
155 // Common.SendToLog(""); 155 // Common.SendToLog("");
156 // Common.SendToLog("*** Executing LSL Server Event: " + s); 156 // Common.SendToLog("*** Executing LSL Server Event: " + s);
157 // //object test = type.GetMember(s); 157 // //object test = type.GetMember(s);
158 // //object runner = type.InvokeMember(s, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, MyScript, args); 158 // //object runner = type.InvokeMember(s, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, MyScript, args);
159 // //runner(); 159 // //runner();
160 // //objBooks_Late = type.InvokeMember(s, BindingFlags.CreateInstance, null, objApp_Late, null); 160 // //objBooks_Late = type.InvokeMember(s, BindingFlags.CreateInstance, null, objApp_Late, null);
161 // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); 161 // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" });
162 162
163 //} 163 //}
164 } 164 }
165 165
166 166
167 private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) 167 private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP)
168 { 168 {
169 LSOEngine.LSO.Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); 169 LSOEngine.LSO.Common.SendToDebug("IL_CREATE_CONSTRUCTOR()");
170 //ConstructorBuilder constructor = typeBuilder.DefineConstructor( 170 //ConstructorBuilder constructor = typeBuilder.DefineConstructor(
171 // MethodAttributes.Public, 171 // MethodAttributes.Public,
172 // CallingConventions.Standard, 172 // CallingConventions.Standard,
173 // new Type[0]); 173 // new Type[0]);
174 ConstructorBuilder constructor = typeBuilder.DefineConstructor( 174 ConstructorBuilder constructor = typeBuilder.DefineConstructor(
175 MethodAttributes.Public | 175 MethodAttributes.Public |
176 MethodAttributes.SpecialName | 176 MethodAttributes.SpecialName |
177 MethodAttributes.RTSpecialName, 177 MethodAttributes.RTSpecialName,
178 CallingConventions.Standard, 178 CallingConventions.Standard,
179 new Type[0]); 179 new Type[0]);
180 180
181 //Define the reflection ConstructorInfor for System.Object 181 //Define the reflection ConstructorInfor for System.Object
182 ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]); 182 ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]);
183 183
184 //call constructor of base object 184 //call constructor of base object
185 ILGenerator il = constructor.GetILGenerator(); 185 ILGenerator il = constructor.GetILGenerator();
186 186
187 il.Emit(OpCodes.Ldarg_0); 187 il.Emit(OpCodes.Ldarg_0);
188 il.Emit(OpCodes.Call, conObj); 188 il.Emit(OpCodes.Call, conObj);
189 189
190 190
191 //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: UInt32 State = 0;"); 191 //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: UInt32 State = 0;");
192 //string FieldName; 192 //string FieldName;
193 //// Create state object 193 //// Create state object
194 //FieldName = "State"; 194 //FieldName = "State";
195 //FieldBuilder State_fb = typeBuilder.DefineField( 195 //FieldBuilder State_fb = typeBuilder.DefineField(
196 // FieldName, 196 // FieldName,
197 // typeof(UInt32), 197 // typeof(UInt32),
198 // FieldAttributes.Public); 198 // FieldAttributes.Public);
199 //il.Emit(OpCodes.Ldarg_0); 199 //il.Emit(OpCodes.Ldarg_0);
200 //il.Emit(OpCodes.Ldc_I4, 0); 200 //il.Emit(OpCodes.Ldc_I4, 0);
201 //il.Emit(OpCodes.Stfld, State_fb); 201 //il.Emit(OpCodes.Stfld, State_fb);
202 202
203 203
204 //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: LSL_BuiltIn_Commands_TestImplementation LSL_BuiltIns = New LSL_BuiltIn_Commands_TestImplementation();"); 204 //Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: LSL_BuiltIn_Commands_TestImplementation LSL_BuiltIns = New LSL_BuiltIn_Commands_TestImplementation();");
205 ////Type objType1 = typeof(object); 205 ////Type objType1 = typeof(object);
206 //Type objType1 = typeof(LSL_BuiltIn_Commands_TestImplementation); 206 //Type objType1 = typeof(LSL_BuiltIn_Commands_TestImplementation);
207 207
208 //FieldName = "LSL_BuiltIns"; 208 //FieldName = "LSL_BuiltIns";
209 //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField( 209 //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField(
210 // FieldName, 210 // FieldName,
211 // objType1, 211 // objType1,
212 // FieldAttributes.Public); 212 // FieldAttributes.Public);
213 213
214 ////LSL_BuiltIn_Commands_TestImplementation _ti = new LSL_BuiltIn_Commands_TestImplementation(); 214 ////LSL_BuiltIn_Commands_TestImplementation _ti = new LSL_BuiltIn_Commands_TestImplementation();
215 //il.Emit(OpCodes.Ldarg_0); 215 //il.Emit(OpCodes.Ldarg_0);
216 ////il.Emit(OpCodes.Ldstr, "Test 123"); 216 ////il.Emit(OpCodes.Ldstr, "Test 123");
217 //il.Emit(OpCodes.Newobj, objType1.GetConstructor(new Type[] { })); 217 //il.Emit(OpCodes.Newobj, objType1.GetConstructor(new Type[] { }));
218 //il.Emit(OpCodes.Stfld, LSL_BuiltIns_fb); 218 //il.Emit(OpCodes.Stfld, LSL_BuiltIns_fb);
219 219
220 foreach (UInt32 pos in LSOP.StaticBlocks.Keys) 220 foreach (UInt32 pos in LSOP.StaticBlocks.Keys)
221 { 221 {
222 LSO_Struct.StaticBlock sb; 222 LSO_Struct.StaticBlock sb;
223 LSOP.StaticBlocks.TryGetValue(pos, out sb); 223 LSOP.StaticBlocks.TryGetValue(pos, out sb);
224 224
225 if (sb.ObjectType > 0 && sb.ObjectType < 8) 225 if (sb.ObjectType > 0 && sb.ObjectType < 8)
226 { 226 {
227 // We don't want void or null's 227 // We don't want void or null's
228 228
229 il.Emit(OpCodes.Ldarg_0); 229 il.Emit(OpCodes.Ldarg_0);
230 // Push position to stack 230 // Push position to stack
231 il.Emit(OpCodes.Ldc_I4, pos); 231 il.Emit(OpCodes.Ldc_I4, pos);
232 //il.Emit(OpCodes.Box, typeof(UInt32)); 232 //il.Emit(OpCodes.Box, typeof(UInt32));
233 233
234 234
235 Type datatype = null; 235 Type datatype = null;
236 236
237 // Push data to stack 237 // Push data to stack
238 LSOEngine.LSO.Common.SendToDebug("Adding to static (" + pos + ") type: " + 238 LSOEngine.LSO.Common.SendToDebug("Adding to static (" + pos + ") type: " +
239 ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType + 239 ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType +
240 ")"); 240 ")");
241 switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType) 241 switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType)
242 { 242 {
243 case LSO_Enums.Variable_Type_Codes.Float: 243 case LSO_Enums.Variable_Type_Codes.Float:
244 case LSO_Enums.Variable_Type_Codes.Integer: 244 case LSO_Enums.Variable_Type_Codes.Integer:
245 //UInt32 245 //UInt32
246 il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); 246 il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0));
247 datatype = typeof (UInt32); 247 datatype = typeof (UInt32);
248 il.Emit(OpCodes.Box, datatype); 248 il.Emit(OpCodes.Box, datatype);
249 break; 249 break;
250 case LSO_Enums.Variable_Type_Codes.String: 250 case LSO_Enums.Variable_Type_Codes.String:
251 case LSO_Enums.Variable_Type_Codes.Key: 251 case LSO_Enums.Variable_Type_Codes.Key:
252 //String 252 //String
253 LSO_Struct.HeapBlock hb = 253 LSO_Struct.HeapBlock hb =
254 LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); 254 LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1);
255 il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data)); 255 il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data));
256 datatype = typeof (string); 256 datatype = typeof (string);
257 break; 257 break;
258 case LSO_Enums.Variable_Type_Codes.Vector: 258 case LSO_Enums.Variable_Type_Codes.Vector:
259 datatype = typeof (LSO_Enums.Vector); 259 datatype = typeof (LSO_Enums.Vector);
260 //TODO: Not implemented 260 //TODO: Not implemented
261 break; 261 break;
262 case LSO_Enums.Variable_Type_Codes.Rotation: 262 case LSO_Enums.Variable_Type_Codes.Rotation:
263 //Object 263 //Object
264 //TODO: Not implemented 264 //TODO: Not implemented
265 datatype = typeof (LSO_Enums.Rotation); 265 datatype = typeof (LSO_Enums.Rotation);
266 break; 266 break;
267 default: 267 default:
268 datatype = typeof (object); 268 datatype = typeof (object);
269 break; 269 break;
270 } 270 }
271 271
272 272
273 // Make call 273 // Make call
274 il.Emit(OpCodes.Call, 274 il.Emit(OpCodes.Call,
275 typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype})); 275 typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype}));
276 } 276 }
277 } 277 }
278 278
279 279
280 ////il.Emit(OpCodes.Newobj, typeof(UInt32)); 280 ////il.Emit(OpCodes.Newobj, typeof(UInt32));
281 //il.Emit(OpCodes.Starg_0); 281 //il.Emit(OpCodes.Starg_0);
282 //// Create LSL function library 282 //// Create LSL function library
283 //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField("LSL_BuiltIns", typeof(LSL_BuiltIn_Commands_Interface), FieldAttributes.Public); 283 //FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField("LSL_BuiltIns", typeof(LSL_BuiltIn_Commands_Interface), FieldAttributes.Public);
284 //il.Emit(OpCodes.Newobj, typeof(LSL_BuiltIn_Commands_Interface)); 284 //il.Emit(OpCodes.Newobj, typeof(LSL_BuiltIn_Commands_Interface));
285 //il.Emit(OpCodes.Stloc_1); 285 //il.Emit(OpCodes.Stloc_1);
286 286
287 il.Emit(OpCodes.Ret); 287 il.Emit(OpCodes.Ret);
288 } 288 }
289 289
290 290
291 // End of class 291 // End of class
292 } 292 }
293} \ No newline at end of file 293} \ No newline at end of file