diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs | 135 |
1 files changed, 67 insertions, 68 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs index 45cca25..d25644c 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs | |||
@@ -27,32 +27,28 @@ | |||
27 | */ | 27 | */ |
28 | /* Original code: Tedd Hansen */ | 28 | /* Original code: Tedd Hansen */ |
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Reflection; | 30 | using System.Reflection; |
33 | using System.Reflection.Emit; | 31 | using System.Reflection.Emit; |
34 | using OpenSim.Region.ScriptEngine.Common; | 32 | using OpenSim.Region.ScriptEngine.Common; |
35 | 33 | ||
36 | namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | 34 | namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO |
37 | { | 35 | { |
38 | partial class LSO_Parser | 36 | internal partial class LSO_Parser |
39 | { | 37 | { |
40 | //internal Stack<Type> ILStack = new Stack<Type>(); | 38 | //internal Stack<Type> ILStack = new Stack<Type>(); |
41 | //LSO_Enums MyLSO_Enums = new LSO_Enums(); | 39 | //LSO_Enums MyLSO_Enums = new LSO_Enums(); |
42 | 40 | ||
43 | internal bool LSL_PROCESS_OPCODE(ILGenerator il) | 41 | internal bool LSL_PROCESS_OPCODE(ILGenerator il) |
44 | { | 42 | { |
45 | |||
46 | byte bp1; | 43 | byte bp1; |
47 | UInt32 u32p1; | 44 | UInt32 u32p1; |
48 | float fp1; | 45 | float fp1; |
49 | UInt16 opcode = br_read(1)[0]; | 46 | UInt16 opcode = br_read(1)[0]; |
50 | Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); | 47 | Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table) opcode).ToString()); |
51 | string idesc = ((LSO_Enums.Operation_Table)opcode).ToString(); | 48 | string idesc = ((LSO_Enums.Operation_Table) opcode).ToString(); |
52 | switch ((LSO_Enums.Operation_Table)opcode) | 49 | switch ((LSO_Enums.Operation_Table) opcode) |
53 | { | 50 | { |
54 | 51 | /*************** | |
55 | /*************** | ||
56 | * IMPLEMENTED * | 52 | * IMPLEMENTED * |
57 | ***************/ | 53 | ***************/ |
58 | case LSO_Enums.Operation_Table.NOOP: | 54 | case LSO_Enums.Operation_Table.NOOP: |
@@ -60,33 +56,34 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
60 | case LSO_Enums.Operation_Table.PUSHSP: | 56 | case LSO_Enums.Operation_Table.PUSHSP: |
61 | // Push Stack Top (Memory Address) to stack | 57 | // Push Stack Top (Memory Address) to stack |
62 | Common.SendToDebug("Instruction " + idesc); | 58 | Common.SendToDebug("Instruction " + idesc); |
63 | Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); | 59 | Common.SendToDebug("Instruction " + idesc + |
64 | IL_Push(il, (UInt32)myHeader.SP); | 60 | ": Description: Pushing Stack Top (Memory Address from header) to stack"); |
61 | IL_Push(il, (UInt32) myHeader.SP); | ||
65 | break; | 62 | break; |
66 | // BYTE | 63 | // BYTE |
67 | case LSO_Enums.Operation_Table.PUSHARGB: | 64 | case LSO_Enums.Operation_Table.PUSHARGB: |
68 | Common.SendToDebug("Param1: " + br_read(1)[0]); | 65 | Common.SendToDebug("Param1: " + br_read(1)[0]); |
69 | break; | 66 | break; |
70 | // INTEGER | 67 | // INTEGER |
71 | case LSO_Enums.Operation_Table.PUSHARGI: | 68 | case LSO_Enums.Operation_Table.PUSHARGI: |
72 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | 69 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); |
73 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); | 70 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); |
74 | IL_Push(il, u32p1); | 71 | IL_Push(il, u32p1); |
75 | break; | 72 | break; |
76 | // FLOAT | 73 | // FLOAT |
77 | case LSO_Enums.Operation_Table.PUSHARGF: | 74 | case LSO_Enums.Operation_Table.PUSHARGF: |
78 | fp1 = BitConverter.ToUInt32(br_read(4), 0); | 75 | fp1 = BitConverter.ToUInt32(br_read(4), 0); |
79 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); | 76 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); |
80 | IL_Push(il, fp1); | 77 | IL_Push(il, fp1); |
81 | break; | 78 | break; |
82 | // STRING | 79 | // STRING |
83 | case LSO_Enums.Operation_Table.PUSHARGS: | 80 | case LSO_Enums.Operation_Table.PUSHARGS: |
84 | string s = Read_String(); | 81 | string s = Read_String(); |
85 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); | 82 | Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); |
86 | IL_Debug(il, "OPCODE: " + idesc + ":" + s); | 83 | IL_Debug(il, "OPCODE: " + idesc + ":" + s); |
87 | IL_Push(il, s); | 84 | IL_Push(il, s); |
88 | break; | 85 | break; |
89 | // VECTOR z,y,x | 86 | // VECTOR z,y,x |
90 | case LSO_Enums.Operation_Table.PUSHARGV: | 87 | case LSO_Enums.Operation_Table.PUSHARGV: |
91 | LSO_Enums.Vector v = new LSO_Enums.Vector(); | 88 | LSO_Enums.Vector v = new LSO_Enums.Vector(); |
92 | v.Z = BitConverter.ToUInt32(br_read(4), 0); | 89 | v.Z = BitConverter.ToUInt32(br_read(4), 0); |
@@ -97,7 +94,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
97 | Common.SendToDebug("Param1 X: " + v.X); | 94 | Common.SendToDebug("Param1 X: " + v.X); |
98 | IL_Push(il, v); | 95 | IL_Push(il, v); |
99 | break; | 96 | break; |
100 | // ROTATION s,z,y,x | 97 | // ROTATION s,z,y,x |
101 | case LSO_Enums.Operation_Table.PUSHARGQ: | 98 | case LSO_Enums.Operation_Table.PUSHARGQ: |
102 | LSO_Enums.Rotation r = new LSO_Enums.Rotation(); | 99 | LSO_Enums.Rotation r = new LSO_Enums.Rotation(); |
103 | r.S = BitConverter.ToUInt32(br_read(4), 0); | 100 | r.S = BitConverter.ToUInt32(br_read(4), 0); |
@@ -112,7 +109,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
112 | break; | 109 | break; |
113 | 110 | ||
114 | case LSO_Enums.Operation_Table.PUSHE: | 111 | case LSO_Enums.Operation_Table.PUSHE: |
115 | IL_Push(il, (UInt32)0); | 112 | IL_Push(il, (UInt32) 0); |
116 | break; | 113 | break; |
117 | 114 | ||
118 | case LSO_Enums.Operation_Table.PUSHARGE: | 115 | case LSO_Enums.Operation_Table.PUSHARGE: |
@@ -121,7 +118,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
121 | //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); | 118 | //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); |
122 | IL_Push(il, u32p1); | 119 | IL_Push(il, u32p1); |
123 | break; | 120 | break; |
124 | // BYTE | 121 | // BYTE |
125 | case LSO_Enums.Operation_Table.ADD: | 122 | case LSO_Enums.Operation_Table.ADD: |
126 | case LSO_Enums.Operation_Table.SUB: | 123 | case LSO_Enums.Operation_Table.SUB: |
127 | case LSO_Enums.Operation_Table.MUL: | 124 | case LSO_Enums.Operation_Table.MUL: |
@@ -136,10 +133,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
136 | case LSO_Enums.Operation_Table.MOD: | 133 | case LSO_Enums.Operation_Table.MOD: |
137 | bp1 = br_read(1)[0]; | 134 | bp1 = br_read(1)[0]; |
138 | Common.SendToDebug("Param1: " + bp1); | 135 | Common.SendToDebug("Param1: " + bp1); |
139 | IL_CallBaseFunction(il, idesc, (UInt32)bp1); | 136 | IL_CallBaseFunction(il, idesc, (UInt32) bp1); |
140 | break; | 137 | break; |
141 | 138 | ||
142 | // NO ARGUMENTS | 139 | // NO ARGUMENTS |
143 | case LSO_Enums.Operation_Table.BITAND: | 140 | case LSO_Enums.Operation_Table.BITAND: |
144 | case LSO_Enums.Operation_Table.BITOR: | 141 | case LSO_Enums.Operation_Table.BITOR: |
145 | case LSO_Enums.Operation_Table.BITXOR: | 142 | case LSO_Enums.Operation_Table.BITXOR: |
@@ -149,22 +146,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
149 | case LSO_Enums.Operation_Table.BOOLNOT: | 146 | case LSO_Enums.Operation_Table.BOOLNOT: |
150 | IL_CallBaseFunction(il, idesc); | 147 | IL_CallBaseFunction(il, idesc); |
151 | break; | 148 | break; |
152 | // SHORT | 149 | // SHORT |
153 | case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: | 150 | case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: |
154 | // TODO: What is size of short? | 151 | // TODO: What is size of short? |
155 | UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); | 152 | UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); |
156 | Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); | 153 | Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + |
154 | ((LSO_Enums.BuiltIn_Functions) U16p1).ToString()); | ||
157 | //Common.SendToDebug("Param1: " + U16p1); | 155 | //Common.SendToDebug("Param1: " + U16p1); |
158 | string fname = ((LSO_Enums.BuiltIn_Functions)U16p1).ToString(); | 156 | string fname = ((LSO_Enums.BuiltIn_Functions) U16p1).ToString(); |
159 | 157 | ||
160 | bool cmdFound = false; | 158 | bool cmdFound = false; |
161 | foreach (MethodInfo mi in typeof(LSL_BuiltIn_Commands_Interface).GetMethods()) | 159 | foreach (MethodInfo mi in typeof (LSL_BuiltIn_Commands_Interface).GetMethods()) |
162 | { | 160 | { |
163 | // Found command | 161 | // Found command |
164 | if (mi.Name == fname) | 162 | if (mi.Name == fname) |
165 | { | 163 | { |
166 | il.Emit(OpCodes.Ldarg_0); | 164 | il.Emit(OpCodes.Ldarg_0); |
167 | il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] { })); | 165 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] {})); |
168 | // Pop required number of items from my stack to .Net stack | 166 | // Pop required number of items from my stack to .Net stack |
169 | IL_PopToStack(il, mi.GetParameters().Length); | 167 | IL_PopToStack(il, mi.GetParameters().Length); |
170 | il.Emit(OpCodes.Callvirt, mi); | 168 | il.Emit(OpCodes.Callvirt, mi); |
@@ -179,7 +177,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
179 | 177 | ||
180 | break; | 178 | break; |
181 | 179 | ||
182 | // RETURN | 180 | // RETURN |
183 | case LSO_Enums.Operation_Table.RETURN: | 181 | case LSO_Enums.Operation_Table.RETURN: |
184 | 182 | ||
185 | Common.SendToDebug("OPCODE: RETURN"); | 183 | Common.SendToDebug("OPCODE: RETURN"); |
@@ -195,7 +193,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
195 | IL_Pop(il); | 193 | IL_Pop(il); |
196 | break; | 194 | break; |
197 | 195 | ||
198 | // LONG | 196 | // LONG |
199 | case LSO_Enums.Operation_Table.STORE: | 197 | case LSO_Enums.Operation_Table.STORE: |
200 | case LSO_Enums.Operation_Table.STORES: | 198 | case LSO_Enums.Operation_Table.STORES: |
201 | case LSO_Enums.Operation_Table.STOREL: | 199 | case LSO_Enums.Operation_Table.STOREL: |
@@ -238,7 +236,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
238 | IL_Pop(il); | 236 | IL_Pop(il); |
239 | break; | 237 | break; |
240 | 238 | ||
241 | // PUSH FROM LOCAL FRAME | 239 | // PUSH FROM LOCAL FRAME |
242 | case LSO_Enums.Operation_Table.PUSH: | 240 | case LSO_Enums.Operation_Table.PUSH: |
243 | case LSO_Enums.Operation_Table.PUSHS: | 241 | case LSO_Enums.Operation_Table.PUSHS: |
244 | case LSO_Enums.Operation_Table.PUSHL: | 242 | case LSO_Enums.Operation_Table.PUSHL: |
@@ -250,7 +248,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
250 | 248 | ||
251 | break; | 249 | break; |
252 | 250 | ||
253 | // PUSH FROM STATIC FRAME | 251 | // PUSH FROM STATIC FRAME |
254 | case LSO_Enums.Operation_Table.PUSHG: | 252 | case LSO_Enums.Operation_Table.PUSHG: |
255 | case LSO_Enums.Operation_Table.PUSHGS: | 253 | case LSO_Enums.Operation_Table.PUSHGS: |
256 | case LSO_Enums.Operation_Table.PUSHGL: | 254 | case LSO_Enums.Operation_Table.PUSHGL: |
@@ -262,26 +260,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
262 | break; | 260 | break; |
263 | 261 | ||
264 | 262 | ||
265 | /*********************** | 263 | /*********************** |
266 | * NOT IMPLEMENTED YET * | 264 | * NOT IMPLEMENTED YET * |
267 | ***********************/ | 265 | ***********************/ |
268 | 266 | ||
269 | 267 | ||
270 | |||
271 | case LSO_Enums.Operation_Table.POPIP: | 268 | case LSO_Enums.Operation_Table.POPIP: |
272 | case LSO_Enums.Operation_Table.POPSP: | 269 | case LSO_Enums.Operation_Table.POPSP: |
273 | case LSO_Enums.Operation_Table.POPSLR: | 270 | case LSO_Enums.Operation_Table.POPSLR: |
274 | case LSO_Enums.Operation_Table.POPARG: | 271 | case LSO_Enums.Operation_Table.POPARG: |
275 | case LSO_Enums.Operation_Table.POPBP: | 272 | case LSO_Enums.Operation_Table.POPBP: |
276 | //Common.SendToDebug("Instruction " + idesc + ": Ignored"); | 273 | //Common.SendToDebug("Instruction " + idesc + ": Ignored"); |
277 | Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); | 274 | Common.SendToDebug("Instruction " + idesc + |
275 | ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); | ||
278 | //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 276 | //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
279 | IL_Pop(il); | 277 | IL_Pop(il); |
280 | break; | 278 | break; |
281 | 279 | ||
282 | 280 | ||
283 | 281 | // None | |
284 | // None | ||
285 | case LSO_Enums.Operation_Table.PUSHIP: | 282 | case LSO_Enums.Operation_Table.PUSHIP: |
286 | // PUSH INSTRUCTION POINTER | 283 | // PUSH INSTRUCTION POINTER |
287 | break; | 284 | break; |
@@ -293,17 +290,17 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
293 | break; | 290 | break; |
294 | 291 | ||
295 | 292 | ||
296 | // LONG | 293 | // LONG |
297 | case LSO_Enums.Operation_Table.JUMP: | 294 | case LSO_Enums.Operation_Table.JUMP: |
298 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 295 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
299 | break; | 296 | break; |
300 | // BYTE, LONG | 297 | // BYTE, LONG |
301 | case LSO_Enums.Operation_Table.JUMPIF: | 298 | case LSO_Enums.Operation_Table.JUMPIF: |
302 | case LSO_Enums.Operation_Table.JUMPNIF: | 299 | case LSO_Enums.Operation_Table.JUMPNIF: |
303 | Common.SendToDebug("Param1: " + br_read(1)[0]); | 300 | Common.SendToDebug("Param1: " + br_read(1)[0]); |
304 | Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); | 301 | Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); |
305 | break; | 302 | break; |
306 | // LONG | 303 | // LONG |
307 | case LSO_Enums.Operation_Table.STATE: | 304 | case LSO_Enums.Operation_Table.STATE: |
308 | bp1 = br_read(1)[0]; | 305 | bp1 = br_read(1)[0]; |
309 | //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack | 306 | //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack |
@@ -315,12 +312,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
315 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 312 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
316 | Common.SendToDebug("ERROR: Function CALL not implemented yet."); | 313 | Common.SendToDebug("ERROR: Function CALL not implemented yet."); |
317 | break; | 314 | break; |
318 | // BYTE | 315 | // BYTE |
319 | case LSO_Enums.Operation_Table.CAST: | 316 | case LSO_Enums.Operation_Table.CAST: |
320 | bp1 = br_read(1)[0]; | 317 | bp1 = br_read(1)[0]; |
321 | Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); | 318 | Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + |
319 | ((LSO_Enums.OpCode_Cast_TypeDefs) bp1)); | ||
322 | Common.SendToDebug("Param1: " + bp1); | 320 | Common.SendToDebug("Param1: " + bp1); |
323 | switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) | 321 | switch ((LSO_Enums.OpCode_Cast_TypeDefs) bp1) |
324 | { | 322 | { |
325 | case LSO_Enums.OpCode_Cast_TypeDefs.String: | 323 | case LSO_Enums.OpCode_Cast_TypeDefs.String: |
326 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); | 324 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); |
@@ -330,12 +328,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
330 | break; | 328 | break; |
331 | } | 329 | } |
332 | break; | 330 | break; |
333 | // LONG | 331 | // LONG |
334 | case LSO_Enums.Operation_Table.STACKTOS: | 332 | case LSO_Enums.Operation_Table.STACKTOS: |
335 | case LSO_Enums.Operation_Table.STACKTOL: | 333 | case LSO_Enums.Operation_Table.STACKTOL: |
336 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 334 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
337 | break; | 335 | break; |
338 | // BYTE | 336 | // BYTE |
339 | case LSO_Enums.Operation_Table.PRINT: | 337 | case LSO_Enums.Operation_Table.PRINT: |
340 | case LSO_Enums.Operation_Table.CALLLIB: | 338 | case LSO_Enums.Operation_Table.CALLLIB: |
341 | Common.SendToDebug("Param1: " + br_read(1)[0]); | 339 | Common.SendToDebug("Param1: " + br_read(1)[0]); |
@@ -348,6 +346,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
348 | { | 346 | { |
349 | IL_PopToStack(il, 1); | 347 | IL_PopToStack(il, 1); |
350 | } | 348 | } |
349 | |||
351 | private void IL_PopToStack(ILGenerator il, int count) | 350 | private void IL_PopToStack(ILGenerator il, int count) |
352 | { | 351 | { |
353 | Common.SendToDebug("IL_PopToStack();"); | 352 | Common.SendToDebug("IL_PopToStack();"); |
@@ -360,31 +359,35 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
360 | // new Type[] { })); | 359 | // new Type[] { })); |
361 | } | 360 | } |
362 | } | 361 | } |
362 | |||
363 | private void IL_Pop(ILGenerator il) | 363 | private void IL_Pop(ILGenerator il) |
364 | { | 364 | { |
365 | Common.SendToDebug("IL_Pop();"); | 365 | Common.SendToDebug("IL_Pop();"); |
366 | IL_CallBaseFunction(il, "POP"); | 366 | IL_CallBaseFunction(il, "POP"); |
367 | } | 367 | } |
368 | |||
368 | private void IL_Debug(ILGenerator il, string text) | 369 | private void IL_Debug(ILGenerator il, string text) |
369 | { | 370 | { |
370 | il.Emit(OpCodes.Ldstr, text); | 371 | il.Emit(OpCodes.Ldstr, text); |
371 | il.Emit(OpCodes.Call, typeof(Common).GetMethod("SendToDebug", | 372 | il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug", |
372 | new Type[] { typeof(string) } | 373 | new Type[] {typeof (string)} |
373 | )); | 374 | )); |
374 | } | 375 | } |
376 | |||
375 | private void IL_CallBaseFunction(ILGenerator il, string methodname) | 377 | private void IL_CallBaseFunction(ILGenerator il, string methodname) |
376 | { | 378 | { |
377 | il.Emit(OpCodes.Ldarg_0); | 379 | il.Emit(OpCodes.Ldarg_0); |
378 | il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { })); | 380 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {})); |
379 | } | 381 | } |
382 | |||
380 | private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) | 383 | private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) |
381 | { | 384 | { |
382 | il.Emit(OpCodes.Ldarg_0); | 385 | il.Emit(OpCodes.Ldarg_0); |
383 | if (data.GetType() == typeof(string)) | 386 | if (data.GetType() == typeof (string)) |
384 | il.Emit(OpCodes.Ldstr, (string)data); | 387 | il.Emit(OpCodes.Ldstr, (string) data); |
385 | if (data.GetType() == typeof(UInt32)) | 388 | if (data.GetType() == typeof (UInt32)) |
386 | il.Emit(OpCodes.Ldc_I4, (UInt32)data); | 389 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); |
387 | il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { data.GetType() })); | 390 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {data.GetType()})); |
388 | } | 391 | } |
389 | 392 | ||
390 | private void IL_Push(ILGenerator il, object data) | 393 | private void IL_Push(ILGenerator il, object data) |
@@ -394,43 +397,39 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO | |||
394 | 397 | ||
395 | IL_PushDataTypeToILStack(il, data); | 398 | IL_PushDataTypeToILStack(il, data); |
396 | 399 | ||
397 | il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("PUSH", new Type[] { data.GetType() })); | 400 | il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()})); |
398 | |||
399 | } | 401 | } |
400 | 402 | ||
401 | private void IL_PushDataTypeToILStack(ILGenerator il, object data) | 403 | private void IL_PushDataTypeToILStack(ILGenerator il, object data) |
402 | { | 404 | { |
403 | if (data.GetType() == typeof(UInt16)) | 405 | if (data.GetType() == typeof (UInt16)) |
404 | { | 406 | { |
405 | il.Emit(OpCodes.Ldc_I4, (UInt16)data); | 407 | il.Emit(OpCodes.Ldc_I4, (UInt16) data); |
406 | il.Emit(OpCodes.Box, data.GetType()); | 408 | il.Emit(OpCodes.Box, data.GetType()); |
407 | } | 409 | } |
408 | if (data.GetType() == typeof(UInt32)) | 410 | if (data.GetType() == typeof (UInt32)) |
409 | { | 411 | { |
410 | il.Emit(OpCodes.Ldc_I4, (UInt32)data); | 412 | il.Emit(OpCodes.Ldc_I4, (UInt32) data); |
411 | il.Emit(OpCodes.Box, data.GetType()); | 413 | il.Emit(OpCodes.Box, data.GetType()); |
412 | } | 414 | } |
413 | if (data.GetType() == typeof(Int32)) | 415 | if (data.GetType() == typeof (Int32)) |
414 | { | 416 | { |
415 | il.Emit(OpCodes.Ldc_I4, (Int32)data); | 417 | il.Emit(OpCodes.Ldc_I4, (Int32) data); |
416 | il.Emit(OpCodes.Box, data.GetType()); | 418 | il.Emit(OpCodes.Box, data.GetType()); |
417 | } | 419 | } |
418 | if (data.GetType() == typeof(float)) | 420 | if (data.GetType() == typeof (float)) |
419 | { | 421 | { |
420 | il.Emit(OpCodes.Ldc_I4, (float)data); | 422 | il.Emit(OpCodes.Ldc_I4, (float) data); |
421 | il.Emit(OpCodes.Box, data.GetType()); | 423 | il.Emit(OpCodes.Box, data.GetType()); |
422 | } | 424 | } |
423 | if (data.GetType() == typeof(string)) | 425 | if (data.GetType() == typeof (string)) |
424 | il.Emit(OpCodes.Ldstr, (string)data); | 426 | il.Emit(OpCodes.Ldstr, (string) data); |
425 | //if (data.GetType() == typeof(LSO_Enums.Rotation)) | 427 | //if (data.GetType() == typeof(LSO_Enums.Rotation)) |
426 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); | 428 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); |
427 | //if (data.GetType() == typeof(LSO_Enums.Vector)) | 429 | //if (data.GetType() == typeof(LSO_Enums.Vector)) |
428 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); | 430 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); |
429 | //if (data.GetType() == typeof(LSO_Enums.Key)) | 431 | //if (data.GetType() == typeof(LSO_Enums.Key)) |
430 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); | 432 | // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); |
431 | |||
432 | } | 433 | } |
433 | |||
434 | |||
435 | } | 434 | } |
436 | } | 435 | } \ No newline at end of file |