diff options
author | MW | 2007-08-01 20:11:42 +0000 |
---|---|---|
committer | MW | 2007-08-01 20:11:42 +0000 |
commit | 1d5544a23a79c981cde44e6d49b73e07db407535 (patch) | |
tree | 2df15f3341c78dd3e6156c27afcc5bb706e779dd /OpenSim/Region | |
parent | Assume White as a console color just means "default", and don't use it. (diff) | |
download | opensim-SC-1d5544a23a79c981cde44e6d49b73e07db407535.zip opensim-SC-1d5544a23a79c981cde44e6d49b73e07db407535.tar.gz opensim-SC-1d5544a23a79c981cde44e6d49b73e07db407535.tar.bz2 opensim-SC-1d5544a23a79c981cde44e6d49b73e07db407535.tar.xz |
Little bit more work on AllNewSceneObjectPart2
Diffstat (limited to 'OpenSim/Region')
9 files changed, 1061 insertions, 1024 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs index cf511ae..3552f33 100644 --- a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs +++ b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs | |||
@@ -32,10 +32,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
32 | public uint BaseMask = FULL_MASK_PERMISSIONS; | 32 | public uint BaseMask = FULL_MASK_PERMISSIONS; |
33 | 33 | ||
34 | protected PrimitiveBaseShape m_Shape; | 34 | protected PrimitiveBaseShape m_Shape; |
35 | protected byte[] m_particleSystem = new byte[0]; | ||
35 | 36 | ||
36 | protected AllNewSceneObjectGroup2 m_parentGroup; | 37 | protected AllNewSceneObjectGroup2 m_parentGroup; |
37 | 38 | ||
38 | |||
39 | #region Properties | 39 | #region Properties |
40 | 40 | ||
41 | protected LLUUID m_uuid; | 41 | protected LLUUID m_uuid; |
@@ -271,6 +271,35 @@ namespace OpenSim.Region.Environment.Scenes | |||
271 | } | 271 | } |
272 | #endregion | 272 | #endregion |
273 | 273 | ||
274 | #region Inventory | ||
275 | public void GetInventory(IClientAPI client, uint localID) | ||
276 | { | ||
277 | if (localID == this.m_localID) | ||
278 | { | ||
279 | client.SendTaskInventory(this.m_uuid, 0, new byte[0]); | ||
280 | } | ||
281 | } | ||
282 | #endregion | ||
283 | |||
284 | public void UpdateExtraParam(ushort type, bool inUse, byte[] data) | ||
285 | { | ||
286 | this.m_Shape.ExtraParams = new byte[data.Length + 7]; | ||
287 | int i = 0; | ||
288 | uint length = (uint)data.Length; | ||
289 | this.m_Shape.ExtraParams[i++] = 1; | ||
290 | this.m_Shape.ExtraParams[i++] = (byte)(type % 256); | ||
291 | this.m_Shape.ExtraParams[i++] = (byte)((type >> 8) % 256); | ||
292 | |||
293 | this.m_Shape.ExtraParams[i++] = (byte)(length % 256); | ||
294 | this.m_Shape.ExtraParams[i++] = (byte)((length >> 8) % 256); | ||
295 | this.m_Shape.ExtraParams[i++] = (byte)((length >> 16) % 256); | ||
296 | this.m_Shape.ExtraParams[i++] = (byte)((length >> 24) % 256); | ||
297 | Array.Copy(data, 0, this.m_Shape.ExtraParams, i, data.Length); | ||
298 | |||
299 | //this.ScheduleFullUpdate(); | ||
300 | } | ||
301 | |||
302 | |||
274 | #region Texture | 303 | #region Texture |
275 | /// <summary> | 304 | /// <summary> |
276 | /// | 305 | /// |
@@ -282,6 +311,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
282 | } | 311 | } |
283 | #endregion | 312 | #endregion |
284 | 313 | ||
314 | public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) | ||
315 | { | ||
316 | this.m_particleSystem = pSystem.GetBytes(); | ||
317 | } | ||
318 | |||
319 | |||
285 | #region Position | 320 | #region Position |
286 | /// <summary> | 321 | /// <summary> |
287 | /// | 322 | /// |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs index be29ee9..4b734a3 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs | |||
@@ -34,7 +34,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
34 | { | 34 | { |
35 | public class ClassInstance : Object | 35 | public class ClassInstance : Object |
36 | { | 36 | { |
37 | public int size; | 37 | public int Size; |
38 | public ClassRecord ClassRec; | 38 | public ClassRecord ClassRec; |
39 | public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>(); | 39 | public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>(); |
40 | 40 | ||
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs index a609a40..4b2aec3 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs | |||
@@ -36,23 +36,23 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
36 | { | 36 | { |
37 | public class ClassRecord | 37 | public class ClassRecord |
38 | { | 38 | { |
39 | private ushort _majorVersion; | 39 | private ushort m_majorVersion; |
40 | private ushort _minorVersion; | 40 | private ushort m_minorVersion; |
41 | private ushort _constantPoolCount; | 41 | private ushort m_constantPoolCount; |
42 | private ushort _accessFlags; | 42 | private ushort m_accessFlags; |
43 | private ushort _thisClass; | 43 | private ushort m_thisClass; |
44 | private ushort _supperClass; | 44 | private ushort m_supperClass; |
45 | private ushort _interfaceCount; | 45 | private ushort m_interfaceCount; |
46 | private ushort _fieldCount; | 46 | private ushort m_fieldCount; |
47 | private ushort _methodCount; | 47 | private ushort m_methodCount; |
48 | //private ushort _attributeCount; | 48 | //private ushort _attributeCount; |
49 | //private string _name; | 49 | //private string _name; |
50 | public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>(); | 50 | public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>(); |
51 | public PoolClass mClass; | 51 | public PoolClass MClass; |
52 | 52 | ||
53 | public List<PoolItem> _constantsPool = new List<PoolItem>(); | 53 | public List<PoolItem> m_constantsPool = new List<PoolItem>(); |
54 | private List<MethodInfo> _methodsList = new List<MethodInfo>(); | 54 | private List<MethodInfo> m_methodsList = new List<MethodInfo>(); |
55 | private List<FieldInfo> _fieldList = new List<FieldInfo>(); | 55 | private List<FieldInfo> m_fieldList = new List<FieldInfo>(); |
56 | 56 | ||
57 | public ClassRecord() | 57 | public ClassRecord() |
58 | { | 58 | { |
@@ -80,11 +80,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
80 | { | 80 | { |
81 | int i = 0; | 81 | int i = 0; |
82 | i += 4; | 82 | i += 4; |
83 | _minorVersion = (ushort)((data[i++] << 8) + data[i++]); | 83 | m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); |
84 | _majorVersion = (ushort)((data[i++] << 8) + data[i++]); | 84 | m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); |
85 | _constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); | 85 | m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); |
86 | Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); | 86 | Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); |
87 | for (int count = 0; count < (_constantPoolCount - 1); count++) | 87 | for (int count = 0; count < (m_constantPoolCount - 1); count++) |
88 | { | 88 | { |
89 | //read in the constant pool | 89 | //read in the constant pool |
90 | byte pooltype = data[i++]; | 90 | byte pooltype = data[i++]; |
@@ -98,7 +98,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
98 | // Console.WriteLine("new utf8 type, length is " + uLength); | 98 | // Console.WriteLine("new utf8 type, length is " + uLength); |
99 | PoolUtf8 utf8 = new PoolUtf8(); | 99 | PoolUtf8 utf8 = new PoolUtf8(); |
100 | utf8.readValue(data, ref i, uLength); | 100 | utf8.readValue(data, ref i, uLength); |
101 | this._constantsPool.Add(utf8); | 101 | this.m_constantsPool.Add(utf8); |
102 | break; | 102 | break; |
103 | case 3: //Int | 103 | case 3: //Int |
104 | break; | 104 | break; |
@@ -107,74 +107,74 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
107 | case 7: //Class | 107 | case 7: //Class |
108 | PoolClass pClass = new PoolClass(this); | 108 | PoolClass pClass = new PoolClass(this); |
109 | pClass.readValue(data, ref i); | 109 | pClass.readValue(data, ref i); |
110 | this._constantsPool.Add(pClass); | 110 | this.m_constantsPool.Add(pClass); |
111 | break; | 111 | break; |
112 | case 9: //FieldRef | 112 | case 9: //FieldRef |
113 | PoolFieldRef pField = new PoolFieldRef(this); | 113 | PoolFieldRef pField = new PoolFieldRef(this); |
114 | pField.readValue(data, ref i); | 114 | pField.readValue(data, ref i); |
115 | this._constantsPool.Add(pField); | 115 | this.m_constantsPool.Add(pField); |
116 | break; | 116 | break; |
117 | case 10: //Method | 117 | case 10: //Method |
118 | PoolMethodRef pMeth = new PoolMethodRef(this); | 118 | PoolMethodRef pMeth = new PoolMethodRef(this); |
119 | pMeth.readValue(data, ref i); | 119 | pMeth.readValue(data, ref i); |
120 | this._constantsPool.Add(pMeth); | 120 | this.m_constantsPool.Add(pMeth); |
121 | break; | 121 | break; |
122 | case 12: //NamedType | 122 | case 12: //NamedType |
123 | PoolNamedType pNamed = new PoolNamedType(this); | 123 | PoolNamedType pNamed = new PoolNamedType(this); |
124 | pNamed.readValue(data, ref i); | 124 | pNamed.readValue(data, ref i); |
125 | this._constantsPool.Add(pNamed); | 125 | this.m_constantsPool.Add(pNamed); |
126 | break; | 126 | break; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | _accessFlags = (ushort)((data[i++] << 8) + data[i++]); | 130 | m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); |
131 | _thisClass = (ushort)((data[i++] << 8) + data[i++]); | 131 | m_thisClass = (ushort)((data[i++] << 8) + data[i++]); |
132 | _supperClass = (ushort)((data[i++] << 8) + data[i++]); | 132 | m_supperClass = (ushort)((data[i++] << 8) + data[i++]); |
133 | 133 | ||
134 | if (this._constantsPool[this._thisClass - 1] is PoolClass) | 134 | if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) |
135 | { | 135 | { |
136 | this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); | 136 | this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); |
137 | } | 137 | } |
138 | 138 | ||
139 | _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); | 139 | m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); |
140 | //should now read in the info for each interface | 140 | //should now read in the info for each interface |
141 | 141 | ||
142 | _fieldCount = (ushort)((data[i++] << 8) + data[i++]); | 142 | m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); |
143 | //should now read in the info for each field | 143 | //should now read in the info for each field |
144 | for (int count = 0; count < _fieldCount; count++) | 144 | for (int count = 0; count < m_fieldCount; count++) |
145 | { | 145 | { |
146 | FieldInfo fieldInf = new FieldInfo(this); | 146 | FieldInfo fieldInf = new FieldInfo(this); |
147 | fieldInf.ReadData(data, ref i); | 147 | fieldInf.ReadData(data, ref i); |
148 | this._fieldList.Add(fieldInf); | 148 | this.m_fieldList.Add(fieldInf); |
149 | } | 149 | } |
150 | 150 | ||
151 | _methodCount = (ushort)((data[i++] << 8) + data[i++]); | 151 | m_methodCount = (ushort)((data[i++] << 8) + data[i++]); |
152 | for (int count = 0; count < _methodCount; count++) | 152 | for (int count = 0; count < m_methodCount; count++) |
153 | { | 153 | { |
154 | MethodInfo methInf = new MethodInfo(this); | 154 | MethodInfo methInf = new MethodInfo(this); |
155 | methInf.ReadData(data, ref i); | 155 | methInf.ReadData(data, ref i); |
156 | this._methodsList.Add(methInf); | 156 | this.m_methodsList.Add(methInf); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | public void AddMethodsToMemory(MethodMemory memory) | 160 | public void AddMethodsToMemory(MethodMemory memory) |
161 | { | 161 | { |
162 | for (int count = 0; count < _methodCount; count++) | 162 | for (int count = 0; count < m_methodCount; count++) |
163 | { | 163 | { |
164 | this._methodsList[count].AddMethodCode(memory); | 164 | this.m_methodsList[count].AddMethodCode(memory); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | public bool StartMethod(Thread thread, string methodName) | 168 | public bool StartMethod(Thread thread, string methodName) |
169 | { | 169 | { |
170 | for (int count = 0; count < _methodCount; count++) | 170 | for (int count = 0; count < m_methodCount; count++) |
171 | { | 171 | { |
172 | if (this._constantsPool[this._methodsList[count].NameIndex - 1] is PoolUtf8) | 172 | if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) |
173 | { | 173 | { |
174 | if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value == methodName) | 174 | if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) |
175 | { | 175 | { |
176 | //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); | 176 | //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); |
177 | thread.SetPC(this._methodsList[count].CodePointer); | 177 | thread.SetPC(this.m_methodsList[count].CodePointer); |
178 | return true; | 178 | return true; |
179 | } | 179 | } |
180 | } | 180 | } |
@@ -185,32 +185,32 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
185 | public void PrintToConsole() | 185 | public void PrintToConsole() |
186 | { | 186 | { |
187 | Console.WriteLine("Class File:"); | 187 | Console.WriteLine("Class File:"); |
188 | Console.WriteLine("Major version: " + _majorVersion); | 188 | Console.WriteLine("Major version: " + m_majorVersion); |
189 | Console.WriteLine("Minor version: " + _minorVersion); | 189 | Console.WriteLine("Minor version: " + m_minorVersion); |
190 | Console.WriteLine("Pool size: " + _constantPoolCount); | 190 | Console.WriteLine("Pool size: " + m_constantPoolCount); |
191 | 191 | ||
192 | for (int i = 0; i < _constantsPool.Count; i++) | 192 | for (int i = 0; i < m_constantsPool.Count; i++) |
193 | { | 193 | { |
194 | this._constantsPool[i].Print(); | 194 | this.m_constantsPool[i].Print(); |
195 | } | 195 | } |
196 | 196 | ||
197 | Console.WriteLine("Access flags: " + _accessFlags); | 197 | Console.WriteLine("Access flags: " + m_accessFlags); |
198 | Console.WriteLine("This class: " + _thisClass); | 198 | Console.WriteLine("This class: " + m_thisClass); |
199 | Console.WriteLine("Super class: " + _supperClass); | 199 | Console.WriteLine("Super class: " + m_supperClass); |
200 | 200 | ||
201 | for (int count = 0; count < _fieldCount; count++) | 201 | for (int count = 0; count < m_fieldCount; count++) |
202 | { | 202 | { |
203 | Console.WriteLine(); | 203 | Console.WriteLine(); |
204 | this._fieldList[count].Print(); | 204 | this.m_fieldList[count].Print(); |
205 | } | 205 | } |
206 | 206 | ||
207 | for (int count = 0; count < _methodCount; count++) | 207 | for (int count = 0; count < m_methodCount; count++) |
208 | { | 208 | { |
209 | Console.WriteLine(); | 209 | Console.WriteLine(); |
210 | this._methodsList[count].Print(); | 210 | this.m_methodsList[count].Print(); |
211 | } | 211 | } |
212 | 212 | ||
213 | Console.WriteLine("class name is " + this.mClass.Name.Value); | 213 | Console.WriteLine("class name is " + this.MClass.Name.Value); |
214 | } | 214 | } |
215 | 215 | ||
216 | public static byte[] ReadFully(Stream stream) | 216 | public static byte[] ReadFully(Stream stream) |
@@ -294,9 +294,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
294 | 294 | ||
295 | public override void Print() | 295 | public override void Print() |
296 | { | 296 | { |
297 | this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); | 297 | this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); |
298 | Console.Write("Class type: " + namePointer); | 298 | Console.Write("Class type: " + namePointer); |
299 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); | 299 | Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); |
300 | 300 | ||
301 | } | 301 | } |
302 | } | 302 | } |
@@ -322,8 +322,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
322 | 322 | ||
323 | public override void Print() | 323 | public override void Print() |
324 | { | 324 | { |
325 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); | 325 | this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); |
326 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); | 326 | this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); |
327 | Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); | 327 | Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); |
328 | } | 328 | } |
329 | } | 329 | } |
@@ -349,8 +349,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
349 | 349 | ||
350 | public override void Print() | 350 | public override void Print() |
351 | { | 351 | { |
352 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); | 352 | this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); |
353 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); | 353 | this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); |
354 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); | 354 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); |
355 | } | 355 | } |
356 | } | 356 | } |
@@ -376,10 +376,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
376 | 376 | ||
377 | public override void Print() | 377 | public override void Print() |
378 | { | 378 | { |
379 | Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); | 379 | Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); |
380 | Type = ((PoolUtf8)this.parent._constantsPool[typePointer - 1]); | 380 | Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); |
381 | Console.Write("Named type: " + namePointer + " , " + typePointer); | 381 | Console.Write("Named type: " + namePointer + " , " + typePointer); |
382 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); | 382 | Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
@@ -426,8 +426,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
426 | { | 426 | { |
427 | Console.WriteLine("Method Info Struct: "); | 427 | Console.WriteLine("Method Info Struct: "); |
428 | Console.WriteLine("AccessFlags: " + AccessFlags); | 428 | Console.WriteLine("AccessFlags: " + AccessFlags); |
429 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 429 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); |
430 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value); | 430 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); |
431 | Console.WriteLine("Attribute Count:" + AttributeCount); | 431 | Console.WriteLine("Attribute Count:" + AttributeCount); |
432 | for (int i = 0; i < AttributeCount; i++) | 432 | for (int i = 0; i < AttributeCount; i++) |
433 | { | 433 | { |
@@ -480,7 +480,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
480 | public void Print() | 480 | public void Print() |
481 | { | 481 | { |
482 | Console.WriteLine("Method Attribute: "); | 482 | Console.WriteLine("Method Attribute: "); |
483 | Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 483 | Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); |
484 | Console.WriteLine("Length: " + Length); | 484 | Console.WriteLine("Length: " + Length); |
485 | Console.WriteLine("MaxStack: " + MaxStack); | 485 | Console.WriteLine("MaxStack: " + MaxStack); |
486 | Console.WriteLine("MaxLocals: " + MaxLocals); | 486 | Console.WriteLine("MaxLocals: " + MaxLocals); |
@@ -522,7 +522,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
522 | 522 | ||
523 | public void Print() | 523 | public void Print() |
524 | { | 524 | { |
525 | Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 525 | Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); |
526 | } | 526 | } |
527 | 527 | ||
528 | } | 528 | } |
@@ -570,22 +570,22 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
570 | { | 570 | { |
571 | Console.WriteLine("Field Info Struct: "); | 571 | Console.WriteLine("Field Info Struct: "); |
572 | Console.WriteLine("AccessFlags: " + AccessFlags); | 572 | Console.WriteLine("AccessFlags: " + AccessFlags); |
573 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 573 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); |
574 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value); | 574 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); |
575 | Console.WriteLine("Attribute Count:" + AttributeCount); | 575 | Console.WriteLine("Attribute Count:" + AttributeCount); |
576 | //if static, add to static field list | 576 | //if static, add to static field list |
577 | // if (this.AccessFlags == 9) //public and static | 577 | // if (this.AccessFlags == 9) //public and static |
578 | if ((this.AccessFlags & 0x08) != 0) | 578 | if ((this.AccessFlags & 0x08) != 0) |
579 | { | 579 | { |
580 | switch (((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value) | 580 | switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) |
581 | { | 581 | { |
582 | case "I": | 582 | case "I": |
583 | Int newin = new Int(); | 583 | Int newin = new Int(); |
584 | this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newin); | 584 | this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); |
585 | break; | 585 | break; |
586 | case "F": | 586 | case "F": |
587 | Float newfl = new Float(); | 587 | Float newfl = new Float(); |
588 | this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newfl); | 588 | this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); |
589 | break; | 589 | break; |
590 | } | 590 | } |
591 | 591 | ||
@@ -622,7 +622,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
622 | 622 | ||
623 | public void Print() | 623 | public void Print() |
624 | { | 624 | { |
625 | Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 625 | Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); |
626 | } | 626 | } |
627 | } | 627 | } |
628 | } | 628 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs index 6f8d70c..ef6570d 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs | |||
@@ -45,293 +45,293 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
45 | case (byte)(byte)OpCode.iconst_m1: | 45 | case (byte)(byte)OpCode.iconst_m1: |
46 | Int m_int = new Int(); | 46 | Int m_int = new Int(); |
47 | m_int.mValue = -1; | 47 | m_int.mValue = -1; |
48 | this._mThread.currentFrame.OpStack.Push(m_int); | 48 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
49 | result = true; | 49 | result = true; |
50 | break; | 50 | break; |
51 | case (byte)(byte)OpCode.iconst_0: | 51 | case (byte)(byte)OpCode.iconst_0: |
52 | m_int = new Int(); | 52 | m_int = new Int(); |
53 | m_int.mValue = 0; | 53 | m_int.mValue = 0; |
54 | this._mThread.currentFrame.OpStack.Push(m_int); | 54 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
55 | result = true; | 55 | result = true; |
56 | break; | 56 | break; |
57 | case (byte)(byte)OpCode.iconst_1: | 57 | case (byte)(byte)OpCode.iconst_1: |
58 | m_int = new Int(); | 58 | m_int = new Int(); |
59 | m_int.mValue = 1; | 59 | m_int.mValue = 1; |
60 | this._mThread.currentFrame.OpStack.Push(m_int); | 60 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
61 | result = true; | 61 | result = true; |
62 | break; | 62 | break; |
63 | case (byte)(byte)OpCode.iconst_2: | 63 | case (byte)(byte)OpCode.iconst_2: |
64 | m_int = new Int(); | 64 | m_int = new Int(); |
65 | m_int.mValue = 2; | 65 | m_int.mValue = 2; |
66 | this._mThread.currentFrame.OpStack.Push(m_int); | 66 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
67 | result = true; | 67 | result = true; |
68 | break; | 68 | break; |
69 | case (byte)(byte)OpCode.iconst_3: | 69 | case (byte)(byte)OpCode.iconst_3: |
70 | m_int = new Int(); | 70 | m_int = new Int(); |
71 | m_int.mValue = 3; | 71 | m_int.mValue = 3; |
72 | this._mThread.currentFrame.OpStack.Push(m_int); | 72 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
73 | break; | 73 | break; |
74 | case (byte)(byte)OpCode.iconst_4: | 74 | case (byte)(byte)OpCode.iconst_4: |
75 | m_int = new Int(); | 75 | m_int = new Int(); |
76 | m_int.mValue = 4; | 76 | m_int.mValue = 4; |
77 | this._mThread.currentFrame.OpStack.Push(m_int); | 77 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
78 | result = true; | 78 | result = true; |
79 | break; | 79 | break; |
80 | case (byte)OpCode.iconst_5: | 80 | case (byte)OpCode.iconst_5: |
81 | m_int = new Int(); | 81 | m_int = new Int(); |
82 | m_int.mValue = 5; | 82 | m_int.mValue = 5; |
83 | this._mThread.currentFrame.OpStack.Push(m_int); | 83 | this.m_thread.m_currentFrame.OpStack.Push(m_int); |
84 | result = true; | 84 | result = true; |
85 | break; | 85 | break; |
86 | case (byte)OpCode.fconst_0: | 86 | case (byte)OpCode.fconst_0: |
87 | Float m_float = new Float(); | 87 | Float m_float = new Float(); |
88 | m_float.mValue = 0.0f; | 88 | m_float.mValue = 0.0f; |
89 | this._mThread.currentFrame.OpStack.Push(m_float); | 89 | this.m_thread.m_currentFrame.OpStack.Push(m_float); |
90 | result = true; | 90 | result = true; |
91 | break; | 91 | break; |
92 | case (byte)OpCode.fconst_1: | 92 | case (byte)OpCode.fconst_1: |
93 | m_float = new Float(); | 93 | m_float = new Float(); |
94 | m_float.mValue = 1.0f; | 94 | m_float.mValue = 1.0f; |
95 | this._mThread.currentFrame.OpStack.Push(m_float); | 95 | this.m_thread.m_currentFrame.OpStack.Push(m_float); |
96 | result = true; | 96 | result = true; |
97 | break; | 97 | break; |
98 | case (byte)OpCode.fconst_2: | 98 | case (byte)OpCode.fconst_2: |
99 | m_float = new Float(); | 99 | m_float = new Float(); |
100 | m_float.mValue = 2.0f; | 100 | m_float.mValue = 2.0f; |
101 | this._mThread.currentFrame.OpStack.Push(m_float); | 101 | this.m_thread.m_currentFrame.OpStack.Push(m_float); |
102 | result = true; | 102 | result = true; |
103 | break; | 103 | break; |
104 | case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? | 104 | case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? |
105 | int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; | 105 | int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; |
106 | Int pushInt = new Int(); | 106 | Int pushInt = new Int(); |
107 | pushInt.mValue = pushvalue; | 107 | pushInt.mValue = pushvalue; |
108 | this._mThread.currentFrame.OpStack.Push(pushInt); | 108 | this.m_thread.m_currentFrame.OpStack.Push(pushInt); |
109 | this._mThread.PC++; | 109 | this.m_thread.PC++; |
110 | result = true; | 110 | result = true; |
111 | break; | 111 | break; |
112 | case (byte)OpCode.sipush: | 112 | case (byte)OpCode.sipush: |
113 | short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 113 | short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
114 | Int pushInt2 = new Int(); | 114 | Int pushInt2 = new Int(); |
115 | pushInt2.mValue = pushvalue2; | 115 | pushInt2.mValue = pushvalue2; |
116 | this._mThread.currentFrame.OpStack.Push(pushInt2); | 116 | this.m_thread.m_currentFrame.OpStack.Push(pushInt2); |
117 | this._mThread.PC += 2; | 117 | this.m_thread.PC += 2; |
118 | result = true; | 118 | result = true; |
119 | break; | 119 | break; |
120 | case (byte)OpCode.fload: | 120 | case (byte)OpCode.fload: |
121 | short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); | 121 | short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); |
122 | Float fload = new Float(); | 122 | Float fload = new Float(); |
123 | if (this._mThread.currentFrame.LocalVariables[findex1] != null) | 123 | if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) |
124 | { | 124 | { |
125 | if (this._mThread.currentFrame.LocalVariables[findex1] is Float) | 125 | if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) |
126 | { | 126 | { |
127 | fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; | 127 | fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; |
128 | this._mThread.currentFrame.OpStack.Push(fload); | 128 | this.m_thread.m_currentFrame.OpStack.Push(fload); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | this._mThread.PC++; | 131 | this.m_thread.PC++; |
132 | result = true; | 132 | result = true; |
133 | break; | 133 | break; |
134 | case (byte)OpCode.iload_0: | 134 | case (byte)OpCode.iload_0: |
135 | if (this._mThread.currentFrame.LocalVariables[0] != null) | 135 | if (this.m_thread.m_currentFrame.LocalVariables[0] != null) |
136 | { | 136 | { |
137 | if (this._mThread.currentFrame.LocalVariables[0] is Int) | 137 | if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) |
138 | { | 138 | { |
139 | Int newInt = new Int(); | 139 | Int newInt = new Int(); |
140 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; | 140 | newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; |
141 | this._mThread.currentFrame.OpStack.Push(newInt); | 141 | this.m_thread.m_currentFrame.OpStack.Push(newInt); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | result = true; | 144 | result = true; |
145 | break; | 145 | break; |
146 | case (byte)OpCode.iload_1: | 146 | case (byte)OpCode.iload_1: |
147 | if (this._mThread.currentFrame.LocalVariables[1] != null) | 147 | if (this.m_thread.m_currentFrame.LocalVariables[1] != null) |
148 | { | 148 | { |
149 | if (this._mThread.currentFrame.LocalVariables[1] is Int) | 149 | if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) |
150 | { | 150 | { |
151 | Int newInt = new Int(); | 151 | Int newInt = new Int(); |
152 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; | 152 | newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; |
153 | this._mThread.currentFrame.OpStack.Push(newInt); | 153 | this.m_thread.m_currentFrame.OpStack.Push(newInt); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | result = true; | 156 | result = true; |
157 | break; | 157 | break; |
158 | case (byte)OpCode.fload_0: | 158 | case (byte)OpCode.fload_0: |
159 | if (this._mThread.currentFrame.LocalVariables[0] != null) | 159 | if (this.m_thread.m_currentFrame.LocalVariables[0] != null) |
160 | { | 160 | { |
161 | if (this._mThread.currentFrame.LocalVariables[0] is Float) | 161 | if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) |
162 | { | 162 | { |
163 | Float newfloat = new Float(); | 163 | Float newfloat = new Float(); |
164 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; | 164 | newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; |
165 | this._mThread.currentFrame.OpStack.Push(newfloat); | 165 | this.m_thread.m_currentFrame.OpStack.Push(newfloat); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | result = true; | 168 | result = true; |
169 | break; | 169 | break; |
170 | case (byte)OpCode.fload_1: | 170 | case (byte)OpCode.fload_1: |
171 | if (this._mThread.currentFrame.LocalVariables[1] != null) | 171 | if (this.m_thread.m_currentFrame.LocalVariables[1] != null) |
172 | { | 172 | { |
173 | if (this._mThread.currentFrame.LocalVariables[1] is Float) | 173 | if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) |
174 | { | 174 | { |
175 | Float newfloat = new Float(); | 175 | Float newfloat = new Float(); |
176 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; | 176 | newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; |
177 | this._mThread.currentFrame.OpStack.Push(newfloat); | 177 | this.m_thread.m_currentFrame.OpStack.Push(newfloat); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | result = true; | 180 | result = true; |
181 | break; | 181 | break; |
182 | case (byte)OpCode.fload_2: | 182 | case (byte)OpCode.fload_2: |
183 | if (this._mThread.currentFrame.LocalVariables[2] != null) | 183 | if (this.m_thread.m_currentFrame.LocalVariables[2] != null) |
184 | { | 184 | { |
185 | if (this._mThread.currentFrame.LocalVariables[2] is Float) | 185 | if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) |
186 | { | 186 | { |
187 | Float newfloat = new Float(); | 187 | Float newfloat = new Float(); |
188 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; | 188 | newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; |
189 | this._mThread.currentFrame.OpStack.Push(newfloat); | 189 | this.m_thread.m_currentFrame.OpStack.Push(newfloat); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | result = true; | 192 | result = true; |
193 | break; | 193 | break; |
194 | case (byte)OpCode.fload_3: | 194 | case (byte)OpCode.fload_3: |
195 | if (this._mThread.currentFrame.LocalVariables[3] != null) | 195 | if (this.m_thread.m_currentFrame.LocalVariables[3] != null) |
196 | { | 196 | { |
197 | if (this._mThread.currentFrame.LocalVariables[3] is Float) | 197 | if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) |
198 | { | 198 | { |
199 | Float newfloat = new Float(); | 199 | Float newfloat = new Float(); |
200 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; | 200 | newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; |
201 | this._mThread.currentFrame.OpStack.Push(newfloat); | 201 | this.m_thread.m_currentFrame.OpStack.Push(newfloat); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | result = true; | 204 | result = true; |
205 | break; | 205 | break; |
206 | case (byte)OpCode.istore: | 206 | case (byte)OpCode.istore: |
207 | short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); | 207 | short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); |
208 | BaseType istor = this._mThread.currentFrame.OpStack.Pop(); | 208 | BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); |
209 | if (istor is Int) | 209 | if (istor is Int) |
210 | { | 210 | { |
211 | this._mThread.currentFrame.LocalVariables[findex3] = (Int)istor; | 211 | this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; |
212 | } | 212 | } |
213 | this._mThread.PC++; | 213 | this.m_thread.PC++; |
214 | result = true; | 214 | result = true; |
215 | break; | 215 | break; |
216 | case (byte)OpCode.fstore: | 216 | case (byte)OpCode.fstore: |
217 | short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); | 217 | short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); |
218 | BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); | 218 | BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); |
219 | if (fstor is Float) | 219 | if (fstor is Float) |
220 | { | 220 | { |
221 | this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; | 221 | this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; |
222 | } | 222 | } |
223 | this._mThread.PC++; | 223 | this.m_thread.PC++; |
224 | result = true; | 224 | result = true; |
225 | break; | 225 | break; |
226 | case (byte)OpCode.istore_0: | 226 | case (byte)OpCode.istore_0: |
227 | BaseType baset = this._mThread.currentFrame.OpStack.Pop(); | 227 | BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
228 | if (baset is Int) | 228 | if (baset is Int) |
229 | { | 229 | { |
230 | this._mThread.currentFrame.LocalVariables[0] = (Int)baset; | 230 | this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; |
231 | } | 231 | } |
232 | result = true; | 232 | result = true; |
233 | break; | 233 | break; |
234 | case (byte)OpCode.istore_1: | 234 | case (byte)OpCode.istore_1: |
235 | baset = this._mThread.currentFrame.OpStack.Pop(); | 235 | baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
236 | if (baset is Int) | 236 | if (baset is Int) |
237 | { | 237 | { |
238 | this._mThread.currentFrame.LocalVariables[1] = (Int)baset; | 238 | this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; |
239 | } | 239 | } |
240 | result = true; | 240 | result = true; |
241 | break; | 241 | break; |
242 | case (byte)OpCode.fstore_0: | 242 | case (byte)OpCode.fstore_0: |
243 | baset = this._mThread.currentFrame.OpStack.Pop(); | 243 | baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
244 | if (baset is Float) | 244 | if (baset is Float) |
245 | { | 245 | { |
246 | this._mThread.currentFrame.LocalVariables[0] = (Float)baset; | 246 | this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; |
247 | } | 247 | } |
248 | result = true; | 248 | result = true; |
249 | break; | 249 | break; |
250 | case (byte)OpCode.fstore_1: | 250 | case (byte)OpCode.fstore_1: |
251 | baset = this._mThread.currentFrame.OpStack.Pop(); | 251 | baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
252 | if (baset is Float) | 252 | if (baset is Float) |
253 | { | 253 | { |
254 | this._mThread.currentFrame.LocalVariables[1] = (Float)baset; | 254 | this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; |
255 | } | 255 | } |
256 | result = true; | 256 | result = true; |
257 | break; | 257 | break; |
258 | case (byte)OpCode.fstore_2: | 258 | case (byte)OpCode.fstore_2: |
259 | baset = this._mThread.currentFrame.OpStack.Pop(); | 259 | baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
260 | if (baset is Float) | 260 | if (baset is Float) |
261 | { | 261 | { |
262 | this._mThread.currentFrame.LocalVariables[2] = (Float)baset; | 262 | this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; |
263 | } | 263 | } |
264 | result = true; | 264 | result = true; |
265 | break; | 265 | break; |
266 | case (byte)OpCode.fstore_3: | 266 | case (byte)OpCode.fstore_3: |
267 | baset = this._mThread.currentFrame.OpStack.Pop(); | 267 | baset = this.m_thread.m_currentFrame.OpStack.Pop(); |
268 | if (baset is Float) | 268 | if (baset is Float) |
269 | { | 269 | { |
270 | this._mThread.currentFrame.LocalVariables[3] = (Float)baset; | 270 | this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; |
271 | } | 271 | } |
272 | result = true; | 272 | result = true; |
273 | break; | 273 | break; |
274 | case (byte)OpCode.pop: | 274 | case (byte)OpCode.pop: |
275 | this._mThread.currentFrame.OpStack.Pop(); | 275 | this.m_thread.m_currentFrame.OpStack.Pop(); |
276 | result = true; | 276 | result = true; |
277 | break; | 277 | break; |
278 | case (byte)OpCode.fadd: | 278 | case (byte)OpCode.fadd: |
279 | BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); | 279 | BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
280 | BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); | 280 | BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
281 | if (bf1 is Float && bf2 is Float) | 281 | if (bf1 is Float && bf2 is Float) |
282 | { | 282 | { |
283 | Float nflt = new Float(); | 283 | Float nflt = new Float(); |
284 | nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; | 284 | nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; |
285 | this._mThread.currentFrame.OpStack.Push(nflt); | 285 | this.m_thread.m_currentFrame.OpStack.Push(nflt); |
286 | } | 286 | } |
287 | result = true; | 287 | result = true; |
288 | break; | 288 | break; |
289 | case (byte)OpCode.fsub: | 289 | case (byte)OpCode.fsub: |
290 | BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); | 290 | BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
291 | BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); | 291 | BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
292 | if (bsf1 is Float && bsf2 is Float) | 292 | if (bsf1 is Float && bsf2 is Float) |
293 | { | 293 | { |
294 | Float resf = new Float(); | 294 | Float resf = new Float(); |
295 | resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; | 295 | resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; |
296 | this._mThread.currentFrame.OpStack.Push(resf); | 296 | this.m_thread.m_currentFrame.OpStack.Push(resf); |
297 | } | 297 | } |
298 | result = true; | 298 | result = true; |
299 | break; | 299 | break; |
300 | case (byte)OpCode.imul: //check the order of the two values off the stack is correct | 300 | case (byte)OpCode.imul: //check the order of the two values off the stack is correct |
301 | BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); | 301 | BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
302 | BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); | 302 | BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
303 | if (bs1 is Int && bs2 is Int) | 303 | if (bs1 is Int && bs2 is Int) |
304 | { | 304 | { |
305 | Int nInt = new Int(); | 305 | Int nInt = new Int(); |
306 | nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; | 306 | nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; |
307 | this._mThread.currentFrame.OpStack.Push(nInt); | 307 | this.m_thread.m_currentFrame.OpStack.Push(nInt); |
308 | } | 308 | } |
309 | result = true; | 309 | result = true; |
310 | break; | 310 | break; |
311 | case (byte)OpCode.iinc: | 311 | case (byte)OpCode.iinc: |
312 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) | 312 | if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) |
313 | { | 313 | { |
314 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) | 314 | if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) |
315 | { | 315 | { |
316 | ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; | 316 | ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | this._mThread.PC += 2; | 319 | this.m_thread.PC += 2; |
320 | result = true; | 320 | result = true; |
321 | break; | 321 | break; |
322 | case (byte)OpCode.f2i: | 322 | case (byte)OpCode.f2i: |
323 | BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); | 323 | BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
324 | if (conv1 is Float) | 324 | if (conv1 is Float) |
325 | { | 325 | { |
326 | Int newconv = new Int(); | 326 | Int newconv = new Int(); |
327 | newconv.mValue = (int)((Float)conv1).mValue; | 327 | newconv.mValue = (int)((Float)conv1).mValue; |
328 | this._mThread.currentFrame.OpStack.Push(newconv); | 328 | this.m_thread.m_currentFrame.OpStack.Push(newconv); |
329 | } | 329 | } |
330 | result = true; | 330 | result = true; |
331 | break; | 331 | break; |
332 | case (byte)OpCode.fcmpl: | 332 | case (byte)OpCode.fcmpl: |
333 | BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); | 333 | BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
334 | BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); | 334 | BaseType flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
335 | if (flcom1 is Float && flcom2 is Float) | 335 | if (flcom1 is Float && flcom2 is Float) |
336 | { | 336 | { |
337 | Int compres = new Int(); | 337 | Int compres = new Int(); |
@@ -347,13 +347,13 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
347 | { | 347 | { |
348 | compres.mValue = 0; | 348 | compres.mValue = 0; |
349 | } | 349 | } |
350 | this._mThread.currentFrame.OpStack.Push(compres); | 350 | this.m_thread.m_currentFrame.OpStack.Push(compres); |
351 | } | 351 | } |
352 | result = true; | 352 | result = true; |
353 | break; | 353 | break; |
354 | case (byte)OpCode.fcmpg: | 354 | case (byte)OpCode.fcmpg: |
355 | flcom2 = this._mThread.currentFrame.OpStack.Pop(); | 355 | flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
356 | flcom1 = this._mThread.currentFrame.OpStack.Pop(); | 356 | flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
357 | if (flcom1 is Float && flcom2 is Float) | 357 | if (flcom1 is Float && flcom2 is Float) |
358 | { | 358 | { |
359 | Int compres = new Int(); | 359 | Int compres = new Int(); |
@@ -369,54 +369,54 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
369 | { | 369 | { |
370 | compres.mValue = 0; | 370 | compres.mValue = 0; |
371 | } | 371 | } |
372 | this._mThread.currentFrame.OpStack.Push(compres); | 372 | this.m_thread.m_currentFrame.OpStack.Push(compres); |
373 | } | 373 | } |
374 | result = true; | 374 | result = true; |
375 | break; | 375 | break; |
376 | case (byte)OpCode.ifge: | 376 | case (byte)OpCode.ifge: |
377 | short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 377 | short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
378 | BaseType compe1 = this._mThread.currentFrame.OpStack.Pop(); | 378 | BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
379 | if (compe1 is Int) | 379 | if (compe1 is Int) |
380 | { | 380 | { |
381 | if (((Int)compe1).mValue >= 0) | 381 | if (((Int)compe1).mValue >= 0) |
382 | { | 382 | { |
383 | this._mThread.PC += -1 + compareoffset2; | 383 | this.m_thread.PC += -1 + compareoffset2; |
384 | } | 384 | } |
385 | else | 385 | else |
386 | { | 386 | { |
387 | this._mThread.PC += 2; | 387 | this.m_thread.PC += 2; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | else | 390 | else |
391 | { | 391 | { |
392 | this._mThread.PC += 2; | 392 | this.m_thread.PC += 2; |
393 | } | 393 | } |
394 | result = true; | 394 | result = true; |
395 | break; | 395 | break; |
396 | case (byte)OpCode.ifle: | 396 | case (byte)OpCode.ifle: |
397 | short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 397 | short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
398 | BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); | 398 | BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
399 | if (comp1 is Int) | 399 | if (comp1 is Int) |
400 | { | 400 | { |
401 | if (((Int)comp1).mValue <= 0) | 401 | if (((Int)comp1).mValue <= 0) |
402 | { | 402 | { |
403 | this._mThread.PC += -1 + compareoffset1; | 403 | this.m_thread.PC += -1 + compareoffset1; |
404 | } | 404 | } |
405 | else | 405 | else |
406 | { | 406 | { |
407 | this._mThread.PC += 2; | 407 | this.m_thread.PC += 2; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | else | 410 | else |
411 | { | 411 | { |
412 | this._mThread.PC += 2; | 412 | this.m_thread.PC += 2; |
413 | } | 413 | } |
414 | result = true; | 414 | result = true; |
415 | break; | 415 | break; |
416 | case (byte)OpCode.if_icmpge: | 416 | case (byte)OpCode.if_icmpge: |
417 | short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 417 | short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
418 | BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); | 418 | BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
419 | BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); | 419 | BaseType bc1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
420 | if (bc1 is Int && bc2 is Int) | 420 | if (bc1 is Int && bc2 is Int) |
421 | { | 421 | { |
422 | //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); | 422 | //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); |
@@ -424,25 +424,25 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
424 | { | 424 | { |
425 | // Console.WriteLine("branch compare true , offset is " +compareoffset); | 425 | // Console.WriteLine("branch compare true , offset is " +compareoffset); |
426 | // Console.WriteLine("current PC is " + this._mThread.PC); | 426 | // Console.WriteLine("current PC is " + this._mThread.PC); |
427 | this._mThread.PC += -1 + compareoffset; | 427 | this.m_thread.PC += -1 + compareoffset; |
428 | //Console.WriteLine("new PC is " + this._mThread.PC); | 428 | //Console.WriteLine("new PC is " + this._mThread.PC); |
429 | } | 429 | } |
430 | else | 430 | else |
431 | { | 431 | { |
432 | //Console.WriteLine("branch compare false"); | 432 | //Console.WriteLine("branch compare false"); |
433 | this._mThread.PC += 2; | 433 | this.m_thread.PC += 2; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | else | 436 | else |
437 | { | 437 | { |
438 | this._mThread.PC += 2; | 438 | this.m_thread.PC += 2; |
439 | } | 439 | } |
440 | result = true; | 440 | result = true; |
441 | break; | 441 | break; |
442 | case (byte)OpCode.if_icmple: | 442 | case (byte)OpCode.if_icmple: |
443 | short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 443 | short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
444 | BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); | 444 | BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); |
445 | BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); | 445 | BaseType bcl1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
446 | if (bcl1 is Int && bcl2 is Int) | 446 | if (bcl1 is Int && bcl2 is Int) |
447 | { | 447 | { |
448 | //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); | 448 | //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); |
@@ -450,47 +450,47 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
450 | { | 450 | { |
451 | // Console.WriteLine("branch compare true , offset is " + compareloffset); | 451 | // Console.WriteLine("branch compare true , offset is " + compareloffset); |
452 | // Console.WriteLine("current PC is " + this._mThread.PC); | 452 | // Console.WriteLine("current PC is " + this._mThread.PC); |
453 | this._mThread.PC += -1 + compareloffset; | 453 | this.m_thread.PC += -1 + compareloffset; |
454 | // Console.WriteLine("new PC is " + this._mThread.PC); | 454 | // Console.WriteLine("new PC is " + this._mThread.PC); |
455 | } | 455 | } |
456 | else | 456 | else |
457 | { | 457 | { |
458 | //Console.WriteLine("branch compare false"); | 458 | //Console.WriteLine("branch compare false"); |
459 | this._mThread.PC += 2; | 459 | this.m_thread.PC += 2; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | else | 462 | else |
463 | { | 463 | { |
464 | this._mThread.PC += 2; | 464 | this.m_thread.PC += 2; |
465 | } | 465 | } |
466 | result = true; | 466 | result = true; |
467 | break; | 467 | break; |
468 | case (byte)OpCode._goto: | 468 | case (byte)OpCode._goto: |
469 | short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 469 | short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
470 | this._mThread.PC += -1 + offset; | 470 | this.m_thread.PC += -1 + offset; |
471 | result = true; | 471 | result = true; |
472 | break; | 472 | break; |
473 | case (byte)OpCode.getstatic: | 473 | case (byte)OpCode.getstatic: |
474 | short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 474 | short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
475 | if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) | 475 | if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) |
476 | { | 476 | { |
477 | if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) | 477 | if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) |
478 | { | 478 | { |
479 | //from this class | 479 | //from this class |
480 | if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) | 480 | if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) |
481 | { | 481 | { |
482 | if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) | 482 | if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) |
483 | { | 483 | { |
484 | Float retFloat = new Float(); | 484 | Float retFloat = new Float(); |
485 | retFloat.mValue = ((Float)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; | 485 | retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; |
486 | this._mThread.currentFrame.OpStack.Push(retFloat); | 486 | this.m_thread.m_currentFrame.OpStack.Push(retFloat); |
487 | } | 487 | } |
488 | else if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) | 488 | else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) |
489 | { | 489 | { |
490 | Int retInt = new Int(); | 490 | Int retInt = new Int(); |
491 | retInt.mValue = ((Int)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; | 491 | retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; |
492 | // Console.WriteLine("getting static field, " + retInt.mValue); | 492 | // Console.WriteLine("getting static field, " + retInt.mValue); |
493 | this._mThread.currentFrame.OpStack.Push(retInt); | 493 | this.m_thread.m_currentFrame.OpStack.Push(retInt); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
@@ -499,36 +499,36 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
499 | //get from a different class | 499 | //get from a different class |
500 | } | 500 | } |
501 | } | 501 | } |
502 | this._mThread.PC += 2; | 502 | this.m_thread.PC += 2; |
503 | result = true; | 503 | result = true; |
504 | break; | 504 | break; |
505 | case (byte)OpCode.putstatic: | 505 | case (byte)OpCode.putstatic: |
506 | fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 506 | fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); |
507 | BaseType addstatic = this._mThread.currentFrame.OpStack.Pop(); | 507 | BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); |
508 | if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) | 508 | if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) |
509 | { | 509 | { |
510 | if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) | 510 | if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) |
511 | { | 511 | { |
512 | // this class | 512 | // this class |
513 | if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) | 513 | if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) |
514 | { | 514 | { |
515 | if (addstatic is Float) | 515 | if (addstatic is Float) |
516 | { | 516 | { |
517 | if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) | 517 | if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) |
518 | { | 518 | { |
519 | Float newf = new Float(); | 519 | Float newf = new Float(); |
520 | newf.mValue = ((Float)addstatic).mValue; | 520 | newf.mValue = ((Float)addstatic).mValue; |
521 | this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; | 521 | this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; |
522 | } | 522 | } |
523 | } | 523 | } |
524 | else if (addstatic is Int) | 524 | else if (addstatic is Int) |
525 | { | 525 | { |
526 | if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) | 526 | if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) |
527 | { | 527 | { |
528 | //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); | 528 | //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); |
529 | Int newi = new Int(); | 529 | Int newi = new Int(); |
530 | newi.mValue = ((Int)addstatic).mValue; | 530 | newi.mValue = ((Int)addstatic).mValue; |
531 | this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; | 531 | this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; |
532 | } | 532 | } |
533 | } | 533 | } |
534 | } | 534 | } |
@@ -538,7 +538,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
538 | // a different class | 538 | // a different class |
539 | } | 539 | } |
540 | } | 540 | } |
541 | this._mThread.PC += 2; | 541 | this.m_thread.PC += 2; |
542 | result = true; | 542 | result = true; |
543 | break; | 543 | break; |
544 | 544 | ||
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs index 6b85fcc..42fd299 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs | |||
@@ -46,10 +46,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
46 | switch (opcode) | 46 | switch (opcode) |
47 | { | 47 | { |
48 | case 184: | 48 | case 184: |
49 | short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); | 49 | short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); |
50 | if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) | 50 | if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) |
51 | { | 51 | { |
52 | string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; | 52 | string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value; |
53 | string typeparam = ""; | 53 | string typeparam = ""; |
54 | string typereturn = ""; | 54 | string typereturn = ""; |
55 | int firstbrak = 0; | 55 | int firstbrak = 0; |
@@ -58,16 +58,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
58 | secondbrak = typ.LastIndexOf(')'); | 58 | secondbrak = typ.LastIndexOf(')'); |
59 | typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); | 59 | typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); |
60 | typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); | 60 | typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); |
61 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) | 61 | if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) |
62 | { | 62 | { |
63 | //calling a method in this class | 63 | //calling a method in this class |
64 | if (typeparam.Length == 0) | 64 | if (typeparam.Length == 0) |
65 | { | 65 | { |
66 | this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); | 66 | this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); |
67 | } | 67 | } |
68 | else | 68 | else |
69 | { | 69 | { |
70 | this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); | 70 | this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | else | 73 | else |
@@ -75,15 +75,15 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
75 | //calling a method of a different class | 75 | //calling a method of a different class |
76 | 76 | ||
77 | // OpenSimAPI Class | 77 | // OpenSimAPI Class |
78 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") | 78 | if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") |
79 | { | 79 | { |
80 | this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null); | 80 | this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | else | 84 | else |
85 | { | 85 | { |
86 | this._mThread.PC += 2; | 86 | this.m_thread.PC += 2; |
87 | } | 87 | } |
88 | result = true; | 88 | result = true; |
89 | break; | 89 | break; |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs index 9961cbd..e718328 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs | |||
@@ -37,17 +37,17 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
37 | { | 37 | { |
38 | private partial class Interpreter | 38 | private partial class Interpreter |
39 | { | 39 | { |
40 | private Thread _mThread; | 40 | private Thread m_thread; |
41 | 41 | ||
42 | public Interpreter(Thread parentThread) | 42 | public Interpreter(Thread parentThread) |
43 | { | 43 | { |
44 | _mThread = parentThread; | 44 | m_thread = parentThread; |
45 | } | 45 | } |
46 | 46 | ||
47 | public bool Excute() | 47 | public bool Excute() |
48 | { | 48 | { |
49 | bool run = true; | 49 | bool run = true; |
50 | byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; | 50 | byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++]; |
51 | // Console.WriteLine("opCode is: " + currentOpCode); | 51 | // Console.WriteLine("opCode is: " + currentOpCode); |
52 | bool handled = false; | 52 | bool handled = false; |
53 | 53 | ||
@@ -60,64 +60,64 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
60 | { | 60 | { |
61 | if (currentOpCode == 172) | 61 | if (currentOpCode == 172) |
62 | { | 62 | { |
63 | if (this._mThread.stack.StackFrames.Count > 1) | 63 | if (this.m_thread.stack.StackFrames.Count > 1) |
64 | { | 64 | { |
65 | Console.WriteLine("returning int from function"); | 65 | Console.WriteLine("returning int from function"); |
66 | int retPC1 = this._mThread.currentFrame.ReturnPC; | 66 | int retPC1 = this.m_thread.m_currentFrame.ReturnPC; |
67 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); | 67 | BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
68 | this._mThread.stack.StackFrames.Pop(); | 68 | this.m_thread.stack.StackFrames.Pop(); |
69 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 69 | this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); |
70 | this._mThread.PC = retPC1; | 70 | this.m_thread.PC = retPC1; |
71 | if (bas1 is Int) | 71 | if (bas1 is Int) |
72 | { | 72 | { |
73 | this._mThread.currentFrame.OpStack.Push((Int)bas1); | 73 | this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | else | 76 | else |
77 | { | 77 | { |
78 | // Console.WriteLine("No parent function so ending program"); | 78 | // Console.WriteLine("No parent function so ending program"); |
79 | this._mThread.stack.StackFrames.Pop(); | 79 | this.m_thread.stack.StackFrames.Pop(); |
80 | run = false; | 80 | run = false; |
81 | } | 81 | } |
82 | handled = true; | 82 | handled = true; |
83 | } | 83 | } |
84 | if (currentOpCode == 174) | 84 | if (currentOpCode == 174) |
85 | { | 85 | { |
86 | if (this._mThread.stack.StackFrames.Count > 1) | 86 | if (this.m_thread.stack.StackFrames.Count > 1) |
87 | { | 87 | { |
88 | Console.WriteLine("returning float from function"); | 88 | Console.WriteLine("returning float from function"); |
89 | int retPC1 = this._mThread.currentFrame.ReturnPC; | 89 | int retPC1 = this.m_thread.m_currentFrame.ReturnPC; |
90 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); | 90 | BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); |
91 | this._mThread.stack.StackFrames.Pop(); | 91 | this.m_thread.stack.StackFrames.Pop(); |
92 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 92 | this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); |
93 | this._mThread.PC = retPC1; | 93 | this.m_thread.PC = retPC1; |
94 | if (bas1 is Float) | 94 | if (bas1 is Float) |
95 | { | 95 | { |
96 | this._mThread.currentFrame.OpStack.Push((Float)bas1); | 96 | this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | else | 99 | else |
100 | { | 100 | { |
101 | // Console.WriteLine("No parent function so ending program"); | 101 | // Console.WriteLine("No parent function so ending program"); |
102 | this._mThread.stack.StackFrames.Pop(); | 102 | this.m_thread.stack.StackFrames.Pop(); |
103 | run = false; | 103 | run = false; |
104 | } | 104 | } |
105 | handled = true; | 105 | handled = true; |
106 | } | 106 | } |
107 | if (currentOpCode == 177) | 107 | if (currentOpCode == 177) |
108 | { | 108 | { |
109 | if (this._mThread.stack.StackFrames.Count > 1) | 109 | if (this.m_thread.stack.StackFrames.Count > 1) |
110 | { | 110 | { |
111 | Console.WriteLine("returning from function"); | 111 | Console.WriteLine("returning from function"); |
112 | int retPC = this._mThread.currentFrame.ReturnPC; | 112 | int retPC = this.m_thread.m_currentFrame.ReturnPC; |
113 | this._mThread.stack.StackFrames.Pop(); | 113 | this.m_thread.stack.StackFrames.Pop(); |
114 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 114 | this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); |
115 | this._mThread.PC = retPC; | 115 | this.m_thread.PC = retPC; |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
119 | // Console.WriteLine("No parent function so ending program"); | 119 | // Console.WriteLine("No parent function so ending program"); |
120 | this._mThread.stack.StackFrames.Pop(); | 120 | this.m_thread.stack.StackFrames.Pop(); |
121 | run = false; | 121 | run = false; |
122 | } | 122 | } |
123 | handled = true; | 123 | handled = true; |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs index eda2640..aad1f47 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs | |||
@@ -44,10 +44,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
44 | public static Scene World; | 44 | public static Scene World; |
45 | private int PC = 0; | 45 | private int PC = 0; |
46 | private Stack stack; | 46 | private Stack stack; |
47 | private Interpreter mInterpreter; | 47 | private Interpreter m_Interpreter; |
48 | public ClassRecord currentClass; | 48 | public ClassRecord currentClass; |
49 | public ClassInstance currentInstance; | 49 | public ClassInstance currentInstance; |
50 | private StackFrame currentFrame; | 50 | private StackFrame m_currentFrame; |
51 | public int excutionCounter = 0; | 51 | public int excutionCounter = 0; |
52 | public bool running = false; | 52 | public bool running = false; |
53 | 53 | ||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
55 | 55 | ||
56 | public Thread() | 56 | public Thread() |
57 | { | 57 | { |
58 | this.mInterpreter = new Interpreter(this); | 58 | this.m_Interpreter = new Interpreter(this); |
59 | this.stack = new Stack(); | 59 | this.stack = new Stack(); |
60 | } | 60 | } |
61 | 61 | ||
@@ -67,24 +67,24 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
67 | 67 | ||
68 | public void StartMethod(ClassRecord rec, string methName) | 68 | public void StartMethod(ClassRecord rec, string methName) |
69 | { | 69 | { |
70 | currentFrame = new StackFrame(); | 70 | m_currentFrame = new StackFrame(); |
71 | this.stack.StackFrames.Push(currentFrame); | 71 | this.stack.StackFrames.Push(m_currentFrame); |
72 | this.currentClass = rec; | 72 | this.currentClass = rec; |
73 | currentClass.StartMethod(this, methName); | 73 | currentClass.StartMethod(this, methName); |
74 | } | 74 | } |
75 | 75 | ||
76 | public void StartMethod( string methName) | 76 | public void StartMethod( string methName) |
77 | { | 77 | { |
78 | currentFrame = new StackFrame(); | 78 | m_currentFrame = new StackFrame(); |
79 | this.stack.StackFrames.Push(currentFrame); | 79 | this.stack.StackFrames.Push(m_currentFrame); |
80 | currentClass.StartMethod(this, methName); | 80 | currentClass.StartMethod(this, methName); |
81 | } | 81 | } |
82 | 82 | ||
83 | public void JumpToStaticVoidMethod(string methName, int returnPC) | 83 | public void JumpToStaticVoidMethod(string methName, int returnPC) |
84 | { | 84 | { |
85 | currentFrame = new StackFrame(); | 85 | m_currentFrame = new StackFrame(); |
86 | currentFrame.ReturnPC = returnPC; | 86 | m_currentFrame.ReturnPC = returnPC; |
87 | this.stack.StackFrames.Push(currentFrame); | 87 | this.stack.StackFrames.Push(m_currentFrame); |
88 | currentClass.StartMethod(this, methName); | 88 | currentClass.StartMethod(this, methName); |
89 | } | 89 | } |
90 | 90 | ||
@@ -92,11 +92,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
92 | { | 92 | { |
93 | if (param == "I") | 93 | if (param == "I") |
94 | { | 94 | { |
95 | BaseType bs1 = currentFrame.OpStack.Pop(); | 95 | BaseType bs1 = m_currentFrame.OpStack.Pop(); |
96 | currentFrame = new StackFrame(); | 96 | m_currentFrame = new StackFrame(); |
97 | currentFrame.ReturnPC = returnPC; | 97 | m_currentFrame.ReturnPC = returnPC; |
98 | this.stack.StackFrames.Push(currentFrame); | 98 | this.stack.StackFrames.Push(m_currentFrame); |
99 | currentFrame.LocalVariables[0] = ((Int)bs1); | 99 | m_currentFrame.LocalVariables[0] = ((Int)bs1); |
100 | currentClass.StartMethod(this, methName); | 100 | currentClass.StartMethod(this, methName); |
101 | } | 101 | } |
102 | if (param == "F") | 102 | if (param == "F") |
@@ -113,7 +113,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
113 | public bool Excute() | 113 | public bool Excute() |
114 | { | 114 | { |
115 | excutionCounter++; | 115 | excutionCounter++; |
116 | return this.mInterpreter.Excute(); | 116 | return this.m_Interpreter.Excute(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_OPCODE_IL_processor.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_OPCODE_IL_processor.cs index 46f6845..e85c1d0 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_OPCODE_IL_processor.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_OPCODE_IL_processor.cs | |||
@@ -27,325 +27,325 @@ | |||
27 | */ | 27 | */ |
28 | /* Original code: Tedd Hansen */ | 28 | /* Original code: Tedd Hansen */ |
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Reflection.Emit; | 33 | using System.Reflection.Emit; |
34 | 34 | ||
35 | namespace OpenSim.Region.Scripting.LSL | 35 | namespace OpenSim.Region.Scripting.LSL |
36 | { | ||
37 | partial class LSO_Parser | ||
38 | { | ||
39 | //LSO_Enums MyLSO_Enums = new LSO_Enums(); | ||
40 | |||
41 | internal bool LSL_PROCESS_OPCODE(ILGenerator il) | ||
36 | { | 42 | { |
37 | partial class LSO_Parser | 43 | |
44 | byte bp1; | ||
45 | UInt32 u32p1; | ||
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) | ||
38 | { | 50 | { |
39 | //LSO_Enums MyLSO_Enums = new LSO_Enums(); | ||
40 | 51 | ||
41 | internal bool LSL_PROCESS_OPCODE(ILGenerator il) | 52 | case LSO_Enums.Operation_Table.POP: |
42 | { | 53 | case LSO_Enums.Operation_Table.POPL: |
43 | 54 | case LSO_Enums.Operation_Table.POPV: | |
44 | byte bp1; | 55 | case LSO_Enums.Operation_Table.POPQ: |
45 | UInt32 u32p1; | 56 | case LSO_Enums.Operation_Table.POPIP: |
46 | UInt16 opcode = br_read(1)[0]; | 57 | case LSO_Enums.Operation_Table.POPBP: |
47 | Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); | 58 | case LSO_Enums.Operation_Table.POPSP: |
48 | string idesc = ((LSO_Enums.Operation_Table)opcode).ToString(); | 59 | case LSO_Enums.Operation_Table.POPSLR: |
49 | switch ((LSO_Enums.Operation_Table)opcode) | 60 | // ignore -- builds callframe |
50 | { | 61 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Pop);"); |
62 | il.Emit(OpCodes.Pop); | ||
63 | break; | ||
64 | case LSO_Enums.Operation_Table.POPARG: | ||
65 | Common.SendToDebug("Instruction " + idesc + ": Ignored"); | ||
66 | Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack "); | ||
67 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
68 | break; | ||
51 | 69 | ||
52 | case LSO_Enums.Operation_Table.POP: | 70 | // LONG |
53 | case LSO_Enums.Operation_Table.POPL: | 71 | case LSO_Enums.Operation_Table.STORE: |
54 | case LSO_Enums.Operation_Table.POPV: | 72 | case LSO_Enums.Operation_Table.STORES: |
55 | case LSO_Enums.Operation_Table.POPQ: | 73 | case LSO_Enums.Operation_Table.STOREL: |
56 | case LSO_Enums.Operation_Table.POPIP: | 74 | case LSO_Enums.Operation_Table.STOREV: |
57 | case LSO_Enums.Operation_Table.POPBP: | 75 | case LSO_Enums.Operation_Table.STOREQ: |
58 | case LSO_Enums.Operation_Table.POPSP: | 76 | case LSO_Enums.Operation_Table.STOREG: |
59 | case LSO_Enums.Operation_Table.POPSLR: | 77 | case LSO_Enums.Operation_Table.STOREGS: |
60 | // ignore -- builds callframe | 78 | case LSO_Enums.Operation_Table.STOREGL: |
61 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Pop);"); | 79 | case LSO_Enums.Operation_Table.STOREGV: |
62 | il.Emit(OpCodes.Pop); | 80 | case LSO_Enums.Operation_Table.STOREGQ: |
63 | break; | 81 | case LSO_Enums.Operation_Table.LOADP: |
64 | case LSO_Enums.Operation_Table.POPARG: | 82 | case LSO_Enums.Operation_Table.LOADSP: |
65 | Common.SendToDebug("Instruction " + idesc + ": Ignored"); | 83 | case LSO_Enums.Operation_Table.LOADLP: |
66 | Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack "); | 84 | case LSO_Enums.Operation_Table.LOADVP: |
67 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 85 | case LSO_Enums.Operation_Table.LOADQP: |
68 | break; | 86 | case LSO_Enums.Operation_Table.PUSH: |
87 | case LSO_Enums.Operation_Table.PUSHS: | ||
88 | case LSO_Enums.Operation_Table.PUSHL: | ||
89 | case LSO_Enums.Operation_Table.PUSHV: | ||
90 | case LSO_Enums.Operation_Table.PUSHQ: | ||
91 | case LSO_Enums.Operation_Table.PUSHG: | ||
92 | case LSO_Enums.Operation_Table.PUSHGS: | ||
93 | case LSO_Enums.Operation_Table.PUSHGL: | ||
94 | case LSO_Enums.Operation_Table.PUSHGV: | ||
95 | case LSO_Enums.Operation_Table.PUSHGQ: | ||
96 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
97 | break; | ||
98 | // None | ||
99 | case LSO_Enums.Operation_Table.PUSHIP: | ||
100 | case LSO_Enums.Operation_Table.PUSHBP: | ||
101 | case LSO_Enums.Operation_Table.PUSHSP: | ||
102 | // Push Stack Top (Memory Address) to stack | ||
103 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, " + myHeader.SP + ");"); | ||
104 | Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); | ||
105 | il.Emit(OpCodes.Ldc_I4, myHeader.SP); | ||
106 | break; | ||
107 | // BYTE | ||
108 | case LSO_Enums.Operation_Table.PUSHARGB: | ||
109 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
110 | break; | ||
111 | // INTEGER | ||
112 | case LSO_Enums.Operation_Table.PUSHARGI: | ||
113 | // TODO: What is size of integer? | ||
114 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
115 | Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes.Ldc_I4, " + u32p1 + ");"); | ||
116 | Common.SendToDebug("Param1: " + u32p1); | ||
117 | il.Emit(OpCodes.Ldc_I4, u32p1); | ||
118 | break; | ||
119 | // FLOAT | ||
120 | case LSO_Enums.Operation_Table.PUSHARGF: | ||
121 | // TODO: What is size of float? | ||
122 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
123 | break; | ||
124 | // STRING | ||
125 | case LSO_Enums.Operation_Table.PUSHARGS: | ||
126 | string s = Read_String(); | ||
127 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldstr, \"" + s + "\");"); | ||
128 | Common.SendToDebug("Param1: " + s); | ||
129 | il.Emit(OpCodes.Ldstr, s); | ||
130 | break; | ||
131 | // VECTOR z,y,x | ||
132 | case LSO_Enums.Operation_Table.PUSHARGV: | ||
133 | Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
134 | Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
135 | Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
136 | break; | ||
137 | // ROTATION s,z,y,x | ||
138 | case LSO_Enums.Operation_Table.PUSHARGQ: | ||
139 | Common.SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
140 | Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
141 | Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
142 | Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
143 | break; | ||
144 | // LONG | ||
145 | case LSO_Enums.Operation_Table.PUSHARGE: | ||
146 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
147 | //Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes., " + u32p1 + ");"); | ||
148 | Common.SendToDebug("Instruction " + idesc + ": Ignoring (not in use according to doc)"); | ||
149 | //Common.SendToDebug("Instruction " + idesc + ": Description: Pushes X bytes of $00 onto the stack (used to put space for local variable memory for a call)"); | ||
150 | Common.SendToDebug("Param1: " + u32p1); | ||
151 | //il.Emit(OpCodes.ldc_i4, u32p1); | ||
152 | //if (u32p1 > 0) { | ||
153 | //for (int _ic=0; _ic < u32p1; _ic++) | ||
154 | //{ | ||
155 | // Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldnull);"); | ||
156 | // il.Emit(OpCodes.Ldnull); | ||
157 | //} | ||
158 | break; | ||
159 | // BYTE | ||
160 | case LSO_Enums.Operation_Table.ADD: | ||
161 | bp1 = br_read(1)[0]; | ||
162 | Common.SendToDebug("Instruction " + idesc + ": Add type: " + ((LSO_Enums.OpCode_Add_TypeDefs)bp1).ToString()); | ||
163 | Common.SendToDebug("Param1: " + bp1); | ||
164 | switch ((LSO_Enums.OpCode_Add_TypeDefs)bp1) | ||
165 | { | ||
166 | case LSO_Enums.OpCode_Add_TypeDefs.String: | ||
167 | Common.SendToDebug("Instruction " + idesc | ||
168 | + ": il.Emit(OpCodes.Call, typeof(System.String).GetMethod(\"Concat\", new Type[] { typeof(object), typeof(object) }));"); | ||
169 | il.Emit(OpCodes.Call, typeof(System.String).GetMethod | ||
170 | ("Concat", new Type[] { typeof(object), typeof(object) })); | ||
69 | 171 | ||
70 | // LONG | ||
71 | case LSO_Enums.Operation_Table.STORE: | ||
72 | case LSO_Enums.Operation_Table.STORES: | ||
73 | case LSO_Enums.Operation_Table.STOREL: | ||
74 | case LSO_Enums.Operation_Table.STOREV: | ||
75 | case LSO_Enums.Operation_Table.STOREQ: | ||
76 | case LSO_Enums.Operation_Table.STOREG: | ||
77 | case LSO_Enums.Operation_Table.STOREGS: | ||
78 | case LSO_Enums.Operation_Table.STOREGL: | ||
79 | case LSO_Enums.Operation_Table.STOREGV: | ||
80 | case LSO_Enums.Operation_Table.STOREGQ: | ||
81 | case LSO_Enums.Operation_Table.LOADP: | ||
82 | case LSO_Enums.Operation_Table.LOADSP: | ||
83 | case LSO_Enums.Operation_Table.LOADLP: | ||
84 | case LSO_Enums.Operation_Table.LOADVP: | ||
85 | case LSO_Enums.Operation_Table.LOADQP: | ||
86 | case LSO_Enums.Operation_Table.PUSH: | ||
87 | case LSO_Enums.Operation_Table.PUSHS: | ||
88 | case LSO_Enums.Operation_Table.PUSHL: | ||
89 | case LSO_Enums.Operation_Table.PUSHV: | ||
90 | case LSO_Enums.Operation_Table.PUSHQ: | ||
91 | case LSO_Enums.Operation_Table.PUSHG: | ||
92 | case LSO_Enums.Operation_Table.PUSHGS: | ||
93 | case LSO_Enums.Operation_Table.PUSHGL: | ||
94 | case LSO_Enums.Operation_Table.PUSHGV: | ||
95 | case LSO_Enums.Operation_Table.PUSHGQ: | ||
96 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
97 | break; | ||
98 | // None | ||
99 | case LSO_Enums.Operation_Table.PUSHIP: | ||
100 | case LSO_Enums.Operation_Table.PUSHBP: | ||
101 | case LSO_Enums.Operation_Table.PUSHSP: | ||
102 | // Push Stack Top (Memory Address) to stack | ||
103 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, " + myHeader.SP + ");"); | ||
104 | Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); | ||
105 | il.Emit(OpCodes.Ldc_I4, myHeader.SP); | ||
106 | break; | ||
107 | // BYTE | ||
108 | case LSO_Enums.Operation_Table.PUSHARGB: | ||
109 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
110 | break; | ||
111 | // INTEGER | ||
112 | case LSO_Enums.Operation_Table.PUSHARGI: | ||
113 | // TODO: What is size of integer? | ||
114 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
115 | Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes.Ldc_I4, " + u32p1 + ");"); | ||
116 | Common.SendToDebug("Param1: " + u32p1); | ||
117 | il.Emit(OpCodes.Ldc_I4, u32p1); | ||
118 | break; | ||
119 | // FLOAT | ||
120 | case LSO_Enums.Operation_Table.PUSHARGF: | ||
121 | // TODO: What is size of float? | ||
122 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
123 | break; | ||
124 | // STRING | ||
125 | case LSO_Enums.Operation_Table.PUSHARGS: | ||
126 | string s = Read_String(); | ||
127 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldstr, \"" + s + "\");"); | ||
128 | Common.SendToDebug("Param1: " + s); | ||
129 | il.Emit(OpCodes.Ldstr, s); | ||
130 | break; | 172 | break; |
131 | // VECTOR z,y,x | 173 | case LSO_Enums.OpCode_Add_TypeDefs.UInt32: |
132 | case LSO_Enums.Operation_Table.PUSHARGV: | 174 | default: |
133 | Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0)); | 175 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Add);"); |
134 | Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0)); | 176 | il.Emit(OpCodes.Add); |
135 | Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
136 | break; | 177 | break; |
137 | // ROTATION s,z,y,x | 178 | } |
138 | case LSO_Enums.Operation_Table.PUSHARGQ: | ||
139 | Common.SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
140 | Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
141 | Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
142 | Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
143 | break; | ||
144 | // LONG | ||
145 | case LSO_Enums.Operation_Table.PUSHARGE: | ||
146 | u32p1 = BitConverter.ToUInt32(br_read(4), 0); | ||
147 | //Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes., " + u32p1 + ");"); | ||
148 | Common.SendToDebug("Instruction " + idesc + ": Ignoring (not in use according to doc)"); | ||
149 | //Common.SendToDebug("Instruction " + idesc + ": Description: Pushes X bytes of $00 onto the stack (used to put space for local variable memory for a call)"); | ||
150 | Common.SendToDebug("Param1: " + u32p1); | ||
151 | //il.Emit(OpCodes.ldc_i4, u32p1); | ||
152 | //if (u32p1 > 0) { | ||
153 | //for (int _ic=0; _ic < u32p1; _ic++) | ||
154 | //{ | ||
155 | // Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldnull);"); | ||
156 | // il.Emit(OpCodes.Ldnull); | ||
157 | //} | ||
158 | break; | ||
159 | // BYTE | ||
160 | case LSO_Enums.Operation_Table.ADD: | ||
161 | bp1 = br_read(1)[0]; | ||
162 | Common.SendToDebug("Instruction " + idesc + ": Add type: " + ((LSO_Enums.OpCode_Add_TypeDefs)bp1).ToString()); | ||
163 | Common.SendToDebug("Param1: " + bp1); | ||
164 | switch ((LSO_Enums.OpCode_Add_TypeDefs)bp1) | ||
165 | { | ||
166 | case LSO_Enums.OpCode_Add_TypeDefs.String: | ||
167 | Common.SendToDebug("Instruction " + idesc | ||
168 | + ": il.Emit(OpCodes.Call, typeof(System.String).GetMethod(\"Concat\", new Type[] { typeof(object), typeof(object) }));"); | ||
169 | il.Emit(OpCodes.Call, typeof(System.String).GetMethod | ||
170 | ("Concat", new Type[] { typeof(object), typeof(object) })); | ||
171 | 179 | ||
172 | break; | ||
173 | case LSO_Enums.OpCode_Add_TypeDefs.UInt32: | ||
174 | default: | ||
175 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Add);"); | ||
176 | il.Emit(OpCodes.Add); | ||
177 | break; | ||
178 | } | ||
179 | 180 | ||
180 | 181 | //il.Emit(OpCodes.Add, p1); | |
181 | //il.Emit(OpCodes.Add, p1); | 182 | break; |
182 | break; | 183 | case LSO_Enums.Operation_Table.SUB: |
183 | case LSO_Enums.Operation_Table.SUB: | 184 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Sub);"); |
184 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Sub);"); | ||
185 | bp1 = br_read(1)[0]; | ||
186 | Common.SendToDebug("Param1: " + bp1); | ||
187 | il.Emit(OpCodes.Sub); | ||
188 | //il.Emit(OpCodes.Sub, p1); | ||
189 | break; | ||
190 | case LSO_Enums.Operation_Table.MUL: | ||
191 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Mul);"); | ||
192 | bp1 = br_read(1)[0]; | 185 | bp1 = br_read(1)[0]; |
193 | Common.SendToDebug("Param1: " + bp1); | 186 | Common.SendToDebug("Param1: " + bp1); |
194 | il.Emit(OpCodes.Mul); | 187 | il.Emit(OpCodes.Sub); |
195 | //il.Emit(OpCodes.Mul, p1); | 188 | //il.Emit(OpCodes.Sub, p1); |
196 | break; | 189 | break; |
197 | case LSO_Enums.Operation_Table.DIV: | 190 | case LSO_Enums.Operation_Table.MUL: |
198 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Div);"); | 191 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Mul);"); |
199 | bp1 = br_read(1)[0]; | 192 | bp1 = br_read(1)[0]; |
200 | Common.SendToDebug("Param1: " + bp1); | 193 | Common.SendToDebug("Param1: " + bp1); |
201 | il.Emit(OpCodes.Div); | 194 | il.Emit(OpCodes.Mul); |
202 | //il.Emit(OpCodes.Div, p1); | 195 | //il.Emit(OpCodes.Mul, p1); |
203 | break; | 196 | break; |
204 | case LSO_Enums.Operation_Table.EQ: | 197 | case LSO_Enums.Operation_Table.DIV: |
205 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ceq);"); | 198 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Div);"); |
206 | bp1 = br_read(1)[0]; | 199 | bp1 = br_read(1)[0]; |
207 | Common.SendToDebug("Param1: " + bp1); | 200 | Common.SendToDebug("Param1: " + bp1); |
208 | il.Emit(OpCodes.Ceq); | 201 | il.Emit(OpCodes.Div); |
209 | //il.Emit(OpCodes.Ceq, p1); | 202 | //il.Emit(OpCodes.Div, p1); |
210 | break; | 203 | break; |
211 | case LSO_Enums.Operation_Table.NEQ: | 204 | case LSO_Enums.Operation_Table.EQ: |
212 | case LSO_Enums.Operation_Table.LEQ: | 205 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ceq);"); |
213 | case LSO_Enums.Operation_Table.GEQ: | 206 | bp1 = br_read(1)[0]; |
214 | case LSO_Enums.Operation_Table.LESS: | 207 | Common.SendToDebug("Param1: " + bp1); |
215 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Clt_Un);"); | 208 | il.Emit(OpCodes.Ceq); |
216 | bp1 = br_read(1)[0]; | 209 | //il.Emit(OpCodes.Ceq, p1); |
217 | Common.SendToDebug("Param1: " + bp1); | 210 | break; |
218 | il.Emit(OpCodes.Clt_Un); | 211 | case LSO_Enums.Operation_Table.NEQ: |
219 | //il.Emit(OpCodes.Clt, p1); | 212 | case LSO_Enums.Operation_Table.LEQ: |
220 | break; | 213 | case LSO_Enums.Operation_Table.GEQ: |
221 | case LSO_Enums.Operation_Table.GREATER: | 214 | case LSO_Enums.Operation_Table.LESS: |
222 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Cgt_Un);"); | 215 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Clt_Un);"); |
223 | bp1 = br_read(1)[0]; | 216 | bp1 = br_read(1)[0]; |
224 | Common.SendToDebug("Param1: " + bp1); | 217 | Common.SendToDebug("Param1: " + bp1); |
225 | il.Emit(OpCodes.Cgt_Un); | 218 | il.Emit(OpCodes.Clt_Un); |
226 | //il.Emit(OpCodes.Cgt, p1); | 219 | //il.Emit(OpCodes.Clt, p1); |
227 | break; | 220 | break; |
228 | case LSO_Enums.Operation_Table.MOD: | 221 | case LSO_Enums.Operation_Table.GREATER: |
229 | case LSO_Enums.Operation_Table.BOOLOR: | 222 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Cgt_Un);"); |
230 | bp1 = br_read(1)[0]; | 223 | bp1 = br_read(1)[0]; |
231 | Common.SendToDebug("Param1: " + bp1); | 224 | Common.SendToDebug("Param1: " + bp1); |
232 | break; | 225 | il.Emit(OpCodes.Cgt_Un); |
233 | // LONG | 226 | //il.Emit(OpCodes.Cgt, p1); |
234 | case LSO_Enums.Operation_Table.JUMP: | 227 | break; |
235 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 228 | case LSO_Enums.Operation_Table.MOD: |
236 | break; | 229 | case LSO_Enums.Operation_Table.BOOLOR: |
237 | // BYTE, LONG | 230 | bp1 = br_read(1)[0]; |
238 | case LSO_Enums.Operation_Table.JUMPIF: | 231 | Common.SendToDebug("Param1: " + bp1); |
239 | case LSO_Enums.Operation_Table.JUMPNIF: | 232 | break; |
240 | Common.SendToDebug("Param1: " + br_read(1)[0]); | 233 | // LONG |
241 | Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); | 234 | case LSO_Enums.Operation_Table.JUMP: |
242 | break; | 235 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
243 | // LONG | 236 | break; |
244 | case LSO_Enums.Operation_Table.STATE: | 237 | // BYTE, LONG |
245 | bp1 = br_read(1)[0]; | 238 | case LSO_Enums.Operation_Table.JUMPIF: |
246 | //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack | 239 | case LSO_Enums.Operation_Table.JUMPNIF: |
247 | //il.Emit(OpCodes.Ldc_I4, 0); // Push index position | 240 | Common.SendToDebug("Param1: " + br_read(1)[0]); |
248 | //il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value | 241 | Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); |
249 | //il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value | 242 | break; |
250 | break; | 243 | // LONG |
251 | case LSO_Enums.Operation_Table.CALL: | 244 | case LSO_Enums.Operation_Table.STATE: |
252 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | 245 | bp1 = br_read(1)[0]; |
253 | break; | 246 | //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack |
254 | // BYTE | 247 | //il.Emit(OpCodes.Ldc_I4, 0); // Push index position |
255 | case LSO_Enums.Operation_Table.CAST: | 248 | //il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value |
256 | bp1 = br_read(1)[0]; | 249 | //il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value |
257 | Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); | 250 | break; |
258 | Common.SendToDebug("Param1: " + bp1); | 251 | case LSO_Enums.Operation_Table.CALL: |
259 | switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) | 252 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
260 | { | 253 | break; |
261 | case LSO_Enums.OpCode_Cast_TypeDefs.String: | 254 | // BYTE |
262 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Calli, typeof(System.Convert).GetMethod(\"ToString\", new Type[] { typeof(object) }));"); | 255 | case LSO_Enums.Operation_Table.CAST: |
263 | //il.Emit(OpCodes.Box, typeof (UInt32)); | 256 | bp1 = br_read(1)[0]; |
264 | il.Emit(OpCodes.Calli, typeof(Common).GetMethod | 257 | Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); |
265 | ("Cast_ToString", new Type[] { typeof(object) })); | 258 | Common.SendToDebug("Param1: " + bp1); |
266 | 259 | switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) | |
267 | //il.Emit(OpCodes.Box, typeof(System.UInt32) ); | 260 | { |
268 | //il.Emit(OpCodes.Box, typeof(string)); | 261 | case LSO_Enums.OpCode_Cast_TypeDefs.String: |
262 | Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Calli, typeof(System.Convert).GetMethod(\"ToString\", new Type[] { typeof(object) }));"); | ||
263 | //il.Emit(OpCodes.Box, typeof (UInt32)); | ||
264 | il.Emit(OpCodes.Calli, typeof(Common).GetMethod | ||
265 | ("Cast_ToString", new Type[] { typeof(object) })); | ||
266 | |||
267 | //il.Emit(OpCodes.Box, typeof(System.UInt32) ); | ||
268 | //il.Emit(OpCodes.Box, typeof(string)); | ||
269 | |||
270 | //il.Emit(OpCodes.Conv_R8); | ||
271 | //il.Emit(OpCodes.Call, typeof(System.Convert).GetMethod | ||
272 | // ("ToString", new Type[] { typeof(float) })); | ||
269 | 273 | ||
270 | //il.Emit(OpCodes.Conv_R8); | ||
271 | //il.Emit(OpCodes.Call, typeof(System.Convert).GetMethod | ||
272 | // ("ToString", new Type[] { typeof(float) })); | ||
273 | |||
274 | break; | ||
275 | default: | ||
276 | Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!"); | ||
277 | break; | ||
278 | } | ||
279 | break; | ||
280 | // LONG | ||
281 | case LSO_Enums.Operation_Table.STACKTOS: | ||
282 | case LSO_Enums.Operation_Table.STACKTOL: | ||
283 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); | ||
284 | break; | 274 | break; |
285 | // BYTE | 275 | default: |
286 | case LSO_Enums.Operation_Table.PRINT: | 276 | Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!"); |
287 | case LSO_Enums.Operation_Table.CALLLIB: | ||
288 | Common.SendToDebug("Param1: " + br_read(1)[0]); | ||
289 | break; | 277 | break; |
290 | // SHORT | 278 | } |
291 | case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: | 279 | break; |
292 | // TODO: What is size of short? | 280 | // LONG |
293 | UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); | 281 | case LSO_Enums.Operation_Table.STACKTOS: |
294 | Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); | 282 | case LSO_Enums.Operation_Table.STACKTOL: |
295 | Common.SendToDebug("Param1: " + U16p1); | 283 | Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); |
296 | switch ((LSO_Enums.BuiltIn_Functions)U16p1) | 284 | break; |
297 | { | 285 | // BYTE |
298 | case LSO_Enums.BuiltIn_Functions.llSay: | 286 | case LSO_Enums.Operation_Table.PRINT: |
299 | Common.SendToDebug("Instruction " + idesc + " " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() | 287 | case LSO_Enums.Operation_Table.CALLLIB: |
300 | + ": Mapped to internal function"); | 288 | Common.SendToDebug("Param1: " + br_read(1)[0]); |
301 | 289 | break; | |
302 | //il.Emit(OpCodes.Ldstr, "INTERNAL COMMAND: llSay({0}, \"{1}\""); | 290 | // SHORT |
303 | //il.Emit(OpCodes.Call, typeof(IL_Helper).GetMethod("ReverseFormatString", | 291 | case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: |
304 | // new Type[] { typeof(string), typeof(UInt32), typeof(string) } | 292 | // TODO: What is size of short? |
305 | //)); | 293 | UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); |
294 | Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); | ||
295 | Common.SendToDebug("Param1: " + U16p1); | ||
296 | switch ((LSO_Enums.BuiltIn_Functions)U16p1) | ||
297 | { | ||
298 | case LSO_Enums.BuiltIn_Functions.llSay: | ||
299 | Common.SendToDebug("Instruction " + idesc + " " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() | ||
300 | + ": Mapped to internal function"); | ||
306 | 301 | ||
302 | //il.Emit(OpCodes.Ldstr, "INTERNAL COMMAND: llSay({0}, \"{1}\""); | ||
303 | //il.Emit(OpCodes.Call, typeof(IL_Helper).GetMethod("ReverseFormatString", | ||
304 | // new Type[] { typeof(string), typeof(UInt32), typeof(string) } | ||
305 | //)); | ||
307 | 306 | ||
308 | //il.Emit(OpCodes.Pop); | ||
309 | //il.Emit(OpCodes.Call, | ||
310 | // typeof(Console).GetMethod("WriteLine", | ||
311 | // new Type[] { typeof(string) } | ||
312 | //)); | ||
313 | 307 | ||
308 | //il.Emit(OpCodes.Pop); | ||
309 | //il.Emit(OpCodes.Call, | ||
310 | // typeof(Console).GetMethod("WriteLine", | ||
311 | // new Type[] { typeof(string) } | ||
312 | //)); | ||
314 | 313 | ||
315 | il.Emit(OpCodes.Call, | ||
316 | typeof(Common).GetMethod("SendToLog", | ||
317 | new Type[] { typeof(string) } | ||
318 | )); | ||
319 | 314 | ||
315 | il.Emit(OpCodes.Call, | ||
316 | typeof(Common).GetMethod("SendToLog", | ||
317 | new Type[] { typeof(string) } | ||
318 | )); | ||
320 | 319 | ||
321 | |||
322 | //il.Emit(OpCodes.Pop); | ||
323 | 320 | ||
324 | //il.Emit(OpCodes.Ldind_I2, 0); | ||
325 | 321 | ||
326 | //il.Emit(OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) })); | 322 | //il.Emit(OpCodes.Pop); |
327 | //il.EmitCalli(OpCodes.Calli, | ||
328 | //il.Emit(OpCodes.Call, typeof().GetMethod | ||
329 | // ("llSay", new Type[] { typeof(UInt32), typeof(string) })); | ||
330 | break; | ||
331 | default: | ||
332 | Common.SendToDebug("Instruction " + idesc + ": " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() + ": INTERNAL COMMAND NOT IMPLEMENTED"); | ||
333 | break; | ||
334 | } | ||
335 | |||
336 | //Common.SendToDebug("Instruction " + idesc + ": DEBUG: Faking return code:"); | ||
337 | //Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, 0);"); | ||
338 | //il.Emit(OpCodes.Ldc_I4, 0); | ||
339 | break; | ||
340 | 323 | ||
341 | // RETURN | 324 | //il.Emit(OpCodes.Ldind_I2, 0); |
342 | case LSO_Enums.Operation_Table.RETURN: | ||
343 | 325 | ||
344 | Common.SendToDebug("Last OPCODE was return command. Code chunk execution complete."); | 326 | //il.Emit(OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) })); |
345 | return true; | 327 | //il.EmitCalli(OpCodes.Calli, |
328 | //il.Emit(OpCodes.Call, typeof().GetMethod | ||
329 | // ("llSay", new Type[] { typeof(UInt32), typeof(string) })); | ||
330 | break; | ||
331 | default: | ||
332 | Common.SendToDebug("Instruction " + idesc + ": " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() + ": INTERNAL COMMAND NOT IMPLEMENTED"); | ||
333 | break; | ||
346 | } | 334 | } |
347 | return false; | ||
348 | } | ||
349 | 335 | ||
336 | //Common.SendToDebug("Instruction " + idesc + ": DEBUG: Faking return code:"); | ||
337 | //Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, 0);"); | ||
338 | //il.Emit(OpCodes.Ldc_I4, 0); | ||
339 | break; | ||
340 | |||
341 | // RETURN | ||
342 | case LSO_Enums.Operation_Table.RETURN: | ||
343 | |||
344 | Common.SendToDebug("Last OPCODE was return command. Code chunk execution complete."); | ||
345 | return true; | ||
350 | } | 346 | } |
347 | return false; | ||
351 | } | 348 | } |
349 | |||
350 | } | ||
351 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs index 18dca74..4ad1f83 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs | |||
@@ -27,512 +27,514 @@ | |||
27 | */ | 27 | */ |
28 | /* Original code: Tedd Hansen */ | 28 | /* Original code: Tedd Hansen */ |
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Reflection.Emit; | 34 | using System.Reflection.Emit; |
35 | 35 | ||
36 | namespace OpenSim.Region.Scripting.LSL | 36 | namespace OpenSim.Region.Scripting.LSL |
37 | { | ||
38 | partial class LSO_Parser | ||
37 | { | 39 | { |
38 | partial class LSO_Parser | 40 | private FileStream fs; |
41 | private BinaryReader br; | ||
42 | private LSO_Struct.Header myHeader; | ||
43 | |||
44 | private TypeBuilder typeBuilder; | ||
45 | private System.Collections.Generic.List<string> EventList = new System.Collections.Generic.List<string>(); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Parse LSO file. | ||
49 | /// Reads LSO ByteCode into memory structures. | ||
50 | /// TODO: What else does it do? | ||
51 | /// </summary> | ||
52 | /// <param name="FileName">FileName of LSO ByteCode file</param> | ||
53 | public void ParseFile(string FileName, TypeBuilder _typeBuilder) | ||
39 | { | 54 | { |
40 | private FileStream fs; | 55 | typeBuilder = _typeBuilder; |
41 | private BinaryReader br; | 56 | //WorldAPI = _WorldAPI; |
42 | private LSO_Struct.Header myHeader; | 57 | // Open |
43 | 58 | Common.SendToDebug("Opening filename: " + FileName); | |
44 | private TypeBuilder typeBuilder; | 59 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); |
45 | private System.Collections.Generic.List<string> EventList = new System.Collections.Generic.List<string>(); | 60 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); |
46 | 61 | ||
47 | /// <summary> | 62 | |
48 | /// Parse LSO file. | 63 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. |
49 | /// Reads LSO ByteCode into memory structures. | 64 | |
50 | /// TODO: What else does it do? | 65 | |
51 | /// </summary> | 66 | // HEADER BLOCK |
52 | /// <param name="FileName">FileName of LSO ByteCode file</param> | 67 | Common.SendToDebug("Reading HEADER BLOCK at: 0"); |
53 | public void ParseFile(string FileName, TypeBuilder _typeBuilder) | 68 | fs.Seek(0, SeekOrigin.Begin); |
69 | myHeader = new LSO_Struct.Header(); | ||
70 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); | ||
71 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); | ||
72 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); | ||
73 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); | ||
74 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); | ||
75 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); | ||
76 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); | ||
77 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); | ||
78 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); | ||
79 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); | ||
80 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); | ||
81 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); | ||
82 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); | ||
83 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); | ||
84 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); | ||
85 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); | ||
86 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); | ||
87 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); | ||
88 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); | ||
89 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); | ||
90 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); | ||
91 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); | ||
92 | |||
93 | // Print Header Block to debug | ||
94 | Common.SendToDebug("TM - Top of memory (size): " + myHeader.TM); | ||
95 | Common.SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); | ||
96 | Common.SendToDebug("VN - Version number: " + myHeader.VN); | ||
97 | Common.SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); | ||
98 | Common.SendToDebug("SP - Stack Pointer: " + myHeader.SP); | ||
99 | Common.SendToDebug("HR - Heap Register: " + myHeader.HR); | ||
100 | Common.SendToDebug("HP - Heap Pointer: " + myHeader.HP); | ||
101 | Common.SendToDebug("CS - Current State: " + myHeader.CS); | ||
102 | Common.SendToDebug("NS - Next State: " + myHeader.NS); | ||
103 | Common.SendToDebug("CE - Current Events: " + myHeader.CE); | ||
104 | Common.SendToDebug("IE - In Event: " + myHeader.IE); | ||
105 | Common.SendToDebug("ER - Event Register: " + myHeader.ER); | ||
106 | Common.SendToDebug("FR - Fault Register: " + myHeader.FR); | ||
107 | Common.SendToDebug("SLR - Sleep Register: " + myHeader.SLR); | ||
108 | Common.SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); | ||
109 | Common.SendToDebug("GFR - Global Function Register: " + myHeader.GFR); | ||
110 | Common.SendToDebug("PR - Parameter Register: " + myHeader.PR); | ||
111 | Common.SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); | ||
112 | Common.SendToDebug("SR - State Register: " + myHeader.SR); | ||
113 | Common.SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); | ||
114 | Common.SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); | ||
115 | Common.SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); | ||
116 | Common.SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); | ||
117 | |||
118 | // STATIC BLOCK | ||
119 | Common.SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); | ||
120 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
121 | int StaticBlockCount = 0; | ||
122 | // Read function blocks until we hit GFR | ||
123 | while (fs.Position < myHeader.GFR) | ||
54 | { | 124 | { |
55 | typeBuilder = _typeBuilder; | 125 | StaticBlockCount++; |
56 | //WorldAPI = _WorldAPI; | 126 | Common.SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position); |
57 | // Open | 127 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); |
58 | Common.SendToDebug("Opening filename: " + FileName); | 128 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); |
59 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); | 129 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); |
60 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); | 130 | myStaticBlock.ObjectType = br_read(1)[0]; |
61 | 131 | Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); | |
62 | 132 | myStaticBlock.Unknown = br_read(1)[0]; | |
63 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. | 133 | // Size of datatype varies |
64 | 134 | if (myStaticBlock.ObjectType != 0) | |
65 | 135 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | |
66 | // HEADER BLOCK | 136 | } |
67 | Common.SendToDebug("Reading HEADER BLOCK at: 0"); | 137 | Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); |
68 | fs.Seek(0, SeekOrigin.Begin); | ||
69 | myHeader = new LSO_Struct.Header(); | ||
70 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); | ||
71 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); | ||
72 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); | ||
73 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); | ||
74 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); | ||
75 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); | ||
76 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); | ||
77 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); | ||
78 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); | ||
79 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); | ||
80 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); | ||
81 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); | ||
82 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); | ||
83 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); | ||
84 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); | ||
85 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); | ||
86 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); | ||
87 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); | ||
88 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); | ||
89 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); | ||
90 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); | ||
91 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); | ||
92 | |||
93 | // Print Header Block to debug | ||
94 | Common.SendToDebug("TM - Top of memory (size): " + myHeader.TM); | ||
95 | Common.SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); | ||
96 | Common.SendToDebug("VN - Version number: " + myHeader.VN); | ||
97 | Common.SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); | ||
98 | Common.SendToDebug("SP - Stack Pointer: " + myHeader.SP); | ||
99 | Common.SendToDebug("HR - Heap Register: " + myHeader.HR); | ||
100 | Common.SendToDebug("HP - Heap Pointer: " + myHeader.HP); | ||
101 | Common.SendToDebug("CS - Current State: " + myHeader.CS); | ||
102 | Common.SendToDebug("NS - Next State: " + myHeader.NS); | ||
103 | Common.SendToDebug("CE - Current Events: " + myHeader.CE); | ||
104 | Common.SendToDebug("IE - In Event: " + myHeader.IE); | ||
105 | Common.SendToDebug("ER - Event Register: " + myHeader.ER); | ||
106 | Common.SendToDebug("FR - Fault Register: " + myHeader.FR); | ||
107 | Common.SendToDebug("SLR - Sleep Register: " + myHeader.SLR); | ||
108 | Common.SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); | ||
109 | Common.SendToDebug("GFR - Global Function Register: " + myHeader.GFR); | ||
110 | Common.SendToDebug("PR - Parameter Register: " + myHeader.PR); | ||
111 | Common.SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); | ||
112 | Common.SendToDebug("SR - State Register: " + myHeader.SR); | ||
113 | Common.SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); | ||
114 | Common.SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); | ||
115 | Common.SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); | ||
116 | Common.SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); | ||
117 | |||
118 | // STATIC BLOCK | ||
119 | Common.SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); | ||
120 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
121 | int StaticBlockCount = 0; | ||
122 | // Read function blocks until we hit GFR | ||
123 | while (fs.Position < myHeader.GFR) | ||
124 | { | ||
125 | StaticBlockCount++; | ||
126 | Common.SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position); | ||
127 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | ||
128 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | ||
129 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | ||
130 | myStaticBlock.ObjectType = br_read(1)[0]; | ||
131 | Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); | ||
132 | myStaticBlock.Unknown = br_read(1)[0]; | ||
133 | // Size of datatype varies | ||
134 | if (myStaticBlock.ObjectType != 0) | ||
135 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | ||
136 | } | ||
137 | Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); | ||
138 | 138 | ||
139 | 139 | ||
140 | // FUNCTION BLOCK | 140 | // FUNCTION BLOCK |
141 | // Always right after STATIC BLOCK | 141 | // Always right after STATIC BLOCK |
142 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); | 142 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); |
143 | if (myHeader.GFR == myHeader.SR) | 143 | if (myHeader.GFR == myHeader.SR) |
144 | { | ||
145 | // If GFR and SR are at same position then there is no fuction block | ||
146 | Common.SendToDebug("No FUNCTION BLOCK found"); | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | Common.SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); | ||
151 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); | ||
152 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); | ||
153 | Common.SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); | ||
154 | if (myFunctionBlock.FunctionCount > 0) | ||
144 | { | 155 | { |
145 | // If GFR and SR are at same position then there is no fuction block | 156 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; |
146 | Common.SendToDebug("No FUNCTION BLOCK found"); | 157 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) |
147 | } else { | ||
148 | Common.SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); | ||
149 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); | ||
150 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); | ||
151 | Common.SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); | ||
152 | if (myFunctionBlock.FunctionCount > 0) | ||
153 | { | 158 | { |
154 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; | 159 | Common.SendToDebug("Reading function " + i + " at: " + fs.Position); |
155 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | 160 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) |
156 | { | 161 | // Note! Absolute position |
157 | Common.SendToDebug("Reading function " + i + " at: " + fs.Position); | 162 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; |
158 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) | 163 | Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); |
159 | // Note! Absolute position | ||
160 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; | ||
161 | Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); | ||
162 | } | ||
163 | } | 164 | } |
164 | } | 165 | } |
166 | } | ||
165 | 167 | ||
166 | 168 | ||
167 | // STATE FRAME BLOCK | 169 | // STATE FRAME BLOCK |
168 | // Always right after FUNCTION BLOCK | 170 | // Always right after FUNCTION BLOCK |
169 | Common.SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); | 171 | Common.SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); |
170 | fs.Seek(myHeader.SR, SeekOrigin.Begin); | 172 | fs.Seek(myHeader.SR, SeekOrigin.Begin); |
171 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); | 173 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); |
172 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); | 174 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); |
173 | if (myStateFrameBlock.StateCount > 0) | 175 | if (myStateFrameBlock.StateCount > 0) |
176 | { | ||
177 | // Initialize array | ||
178 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; | ||
179 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
174 | { | 180 | { |
175 | // Initialize array | 181 | Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); |
176 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; | 182 | // Position is relative to state frame |
177 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | 183 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); |
178 | { | 184 | myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); |
179 | Common.SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position); | 185 | Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); |
180 | // Position is relative to state frame | 186 | Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); |
181 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); | ||
182 | myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); | ||
183 | Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); | ||
184 | Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); | ||
185 | 187 | ||
186 | //// Read STATE BLOCK | 188 | //// Read STATE BLOCK |
187 | //long CurPos = fs.Position; | 189 | //long CurPos = fs.Position; |
188 | //fs.Seek(CurPos, SeekOrigin.Begin); | 190 | //fs.Seek(CurPos, SeekOrigin.Begin); |
189 | 191 | ||
190 | } | ||
191 | } | 192 | } |
193 | } | ||
192 | 194 | ||
193 | 195 | ||
194 | // STATE BLOCK | 196 | // STATE BLOCK |
195 | // For each StateFrameBlock there is one StateBlock with multiple event handlers | 197 | // For each StateFrameBlock there is one StateBlock with multiple event handlers |
196 | 198 | ||
197 | if (myStateFrameBlock.StateCount > 0) | 199 | if (myStateFrameBlock.StateCount > 0) |
200 | { | ||
201 | // Go through all State Frame Pointers found | ||
202 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
198 | { | 203 | { |
199 | // Go through all State Frame Pointers found | ||
200 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
201 | { | ||
202 | |||
203 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); | ||
204 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); | ||
205 | 204 | ||
206 | // READ: STATE BLOCK HEADER | 205 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); |
207 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); | 206 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); |
208 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note | 207 | |
209 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); | 208 | // READ: STATE BLOCK HEADER |
210 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; | 209 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); |
211 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note | 210 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note |
212 | Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); | 211 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); |
213 | Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); | 212 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; |
214 | Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); | 213 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note |
214 | Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); | ||
215 | Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); | ||
216 | Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); | ||
215 | 217 | ||
216 | // We need to count number of bits flagged in EventMask? | 218 | // We need to count number of bits flagged in EventMask? |
217 | 219 | ||
218 | 220 | ||
219 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask | 221 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask |
220 | 222 | ||
221 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE | 223 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE |
222 | //TODO: Create event hooks | 224 | //TODO: Create event hooks |
223 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; | 225 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; |
224 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | 226 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) |
227 | { | ||
228 | |||
229 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) | ||
225 | { | 230 | { |
226 | 231 | // We got an event | |
227 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) | 232 | // READ: STATE BLOCK HANDLER |
228 | { | 233 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); |
229 | // We got an event | 234 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); |
230 | // READ: STATE BLOCK HANDLER | 235 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); |
231 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); | 236 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); |
232 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); | 237 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize); |
233 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); | ||
234 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); | ||
235 | Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize ); | ||
236 | } | ||
237 | } | 238 | } |
238 | } | 239 | } |
239 | } | 240 | } |
241 | } | ||
240 | 242 | ||
241 | 243 | ||
242 | 244 | ||
243 | 245 | ||
244 | //// READ FUNCTION CODE CHUNKS | 246 | //// READ FUNCTION CODE CHUNKS |
245 | //// Functions + Function start pos (GFR) | 247 | //// Functions + Function start pos (GFR) |
246 | //// TODO: Somehow be able to identify and reference this | 248 | //// TODO: Somehow be able to identify and reference this |
247 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; | 249 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; |
248 | //if (myFunctionBlock.FunctionCount > 0) | 250 | //if (myFunctionBlock.FunctionCount > 0) |
249 | //{ | 251 | //{ |
250 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; | 252 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; |
251 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | 253 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) |
252 | // { | 254 | // { |
253 | // Common.SendToDebug("Reading Function Code Chunk " + i); | 255 | // Common.SendToDebug("Reading Function Code Chunk " + i); |
254 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); | 256 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); |
255 | // } | 257 | // } |
256 | 258 | ||
257 | //} | 259 | //} |
258 | // READ EVENT CODE CHUNKS | 260 | // READ EVENT CODE CHUNKS |
259 | LSO_Struct.CodeChunk[] myEventCodeChunk; | 261 | LSO_Struct.CodeChunk[] myEventCodeChunk; |
260 | if (myStateFrameBlock.StateCount > 0) | 262 | if (myStateFrameBlock.StateCount > 0) |
263 | { | ||
264 | myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; | ||
265 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | ||
261 | { | 266 | { |
262 | myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; | 267 | // TODO: Somehow organize events and functions so they can be found again, |
263 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | 268 | // two level search ain't no good |
269 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
264 | { | 270 | { |
265 | // TODO: Somehow organize events and functions so they can be found again, | ||
266 | // two level search ain't no good | ||
267 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | ||
268 | { | ||
269 | 271 | ||
270 | 272 | ||
271 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) | 273 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) |
272 | { | 274 | { |
273 | Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); | 275 | Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); |
274 | 276 | ||
275 | 277 | ||
276 | // Override a Method / Function | 278 | // Override a Method / Function |
277 | string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii; | 279 | string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii; |
278 | Common.SendToDebug("Event Name: " + eventname); | 280 | Common.SendToDebug("Event Name: " + eventname); |
279 | if (Common.IL_ProcessCodeChunks) | 281 | if (Common.IL_ProcessCodeChunks) |
280 | { | 282 | { |
281 | EventList.Add(eventname); | 283 | EventList.Add(eventname); |
282 | 284 | ||
283 | // JUMP TO CODE PROCESSOR | 285 | // JUMP TO CODE PROCESSOR |
284 | ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname); | 286 | ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname); |
285 | } | ||
286 | } | 287 | } |
287 | |||
288 | } | 288 | } |
289 | 289 | ||
290 | } | 290 | } |
291 | 291 | ||
292 | } | 292 | } |
293 | 293 | ||
294 | } | ||
294 | 295 | ||
295 | // Close | ||
296 | br.Close(); | ||
297 | fs.Close(); | ||
298 | 296 | ||
299 | if (Common.IL_CreateFunctionList) | 297 | // Close |
300 | IL_INSERT_FUNCTIONLIST(); | 298 | br.Close(); |
299 | fs.Close(); | ||
301 | 300 | ||
302 | } | 301 | if (Common.IL_CreateFunctionList) |
302 | IL_INSERT_FUNCTIONLIST(); | ||
303 | |||
304 | } | ||
305 | |||
306 | private LSO_Struct.HeapBlock GetHeap(UInt32 pos) | ||
307 | { | ||
308 | // HEAP BLOCK | ||
309 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) | ||
310 | Common.SendToDebug("Reading HEAP BLOCK at: " + pos); | ||
311 | fs.Seek(pos, SeekOrigin.Begin); | ||
312 | |||
313 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); | ||
314 | myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0); | ||
315 | myHeapBlock.ObjectType = br_read(1)[0]; | ||
316 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); | ||
317 | myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); | ||
318 | |||
319 | Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); | ||
320 | Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); | ||
321 | Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); | ||
322 | |||
323 | return myHeapBlock; | ||
324 | } | ||
325 | private byte[] br_read(int len) | ||
326 | { | ||
327 | if (len <= 0) | ||
328 | return null; | ||
303 | 329 | ||
304 | private LSO_Struct.HeapBlock GetHeap(UInt32 pos) | 330 | try |
305 | { | 331 | { |
306 | // HEAP BLOCK | 332 | byte[] bytes = new byte[len]; |
307 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) | 333 | for (int i = len - 1; i > -1; i--) |
308 | Common.SendToDebug("Reading HEAP BLOCK at: " + pos); | 334 | bytes[i] = br.ReadByte(); |
309 | fs.Seek(pos, SeekOrigin.Begin); | 335 | return bytes; |
310 | |||
311 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); | ||
312 | myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0); | ||
313 | myHeapBlock.ObjectType = br_read(1)[0]; | ||
314 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); | ||
315 | myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); | ||
316 | |||
317 | Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); | ||
318 | Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); | ||
319 | Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); | ||
320 | |||
321 | return myHeapBlock; | ||
322 | } | 336 | } |
323 | private byte[] br_read(int len) | 337 | catch (Exception e) |
324 | { | 338 | { |
325 | if (len <= 0) | 339 | Common.SendToDebug("Exception: " + e.ToString()); |
326 | return null; | 340 | throw (e); |
327 | |||
328 | try | ||
329 | { | ||
330 | byte[] bytes = new byte[len]; | ||
331 | for (int i = len - 1; i > -1; i--) | ||
332 | bytes[i] = br.ReadByte(); | ||
333 | return bytes; | ||
334 | } | ||
335 | catch (Exception e) | ||
336 | { | ||
337 | Common.SendToDebug("Exception: " + e.ToString()); | ||
338 | throw (e); | ||
339 | } | ||
340 | } | 341 | } |
341 | //private byte[] br_read_smallendian(int len) | 342 | } |
342 | //{ | 343 | //private byte[] br_read_smallendian(int len) |
343 | // byte[] bytes = new byte[len]; | 344 | //{ |
344 | // br.Read(bytes,0, len); | 345 | // byte[] bytes = new byte[len]; |
345 | // return bytes; | 346 | // br.Read(bytes,0, len); |
346 | //} | 347 | // return bytes; |
347 | private Type getLLObjectType(byte objectCode) | 348 | //} |
349 | private Type getLLObjectType(byte objectCode) | ||
350 | { | ||
351 | switch ((LSO_Enums.Variable_Type_Codes)objectCode) | ||
348 | { | 352 | { |
349 | switch ((LSO_Enums.Variable_Type_Codes)objectCode) | 353 | case LSO_Enums.Variable_Type_Codes.Void: return typeof(void); |
350 | { | 354 | case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32); |
351 | case LSO_Enums.Variable_Type_Codes.Void: return typeof(void); | 355 | case LSO_Enums.Variable_Type_Codes.Float: return typeof(float); |
352 | case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32); | 356 | case LSO_Enums.Variable_Type_Codes.String: return typeof(string); |
353 | case LSO_Enums.Variable_Type_Codes.Float: return typeof(float); | 357 | case LSO_Enums.Variable_Type_Codes.Key: return typeof(string); |
354 | case LSO_Enums.Variable_Type_Codes.String: return typeof(string); | 358 | case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector); |
355 | case LSO_Enums.Variable_Type_Codes.Key: return typeof(string); | 359 | case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation); |
356 | case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector); | 360 | case LSO_Enums.Variable_Type_Codes.List: |
357 | case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation); | 361 | Common.SendToDebug("TODO: List datatype not implemented yet!"); |
358 | case LSO_Enums.Variable_Type_Codes.List: | 362 | return typeof(System.Collections.ArrayList); |
359 | Common.SendToDebug("TODO: List datatype not implemented yet!"); | 363 | default: |
360 | return typeof(System.Collections.ArrayList); | 364 | Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); |
361 | default: | 365 | return typeof(object); |
362 | Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); | ||
363 | return typeof(object); | ||
364 | } | ||
365 | } | 366 | } |
366 | private int getObjectSize(byte ObjectType) | 367 | } |
368 | private int getObjectSize(byte ObjectType) | ||
369 | { | ||
370 | switch (ObjectType) | ||
367 | { | 371 | { |
368 | switch (ObjectType) | 372 | case 1: |
369 | { | 373 | case 2: |
370 | case 1: | 374 | case 3: |
371 | case 2: | 375 | case 4: |
372 | case 3: | 376 | case 7: |
373 | case 4: | 377 | return 4; |
374 | case 7: | 378 | case 5: |
375 | return 4; | 379 | return 12; |
376 | case 5: | 380 | case 6: |
377 | return 12; | 381 | return 16; |
378 | case 6: | 382 | default: |
379 | return 16; | 383 | return 0; |
380 | default: | ||
381 | return 0; | ||
382 | } | ||
383 | } | 384 | } |
384 | private string Read_String() | 385 | } |
386 | private string Read_String() | ||
387 | { | ||
388 | string ret = ""; | ||
389 | byte reader = br_read(1)[0]; | ||
390 | while (reader != 0x000) | ||
385 | { | 391 | { |
386 | string ret = ""; | 392 | ret += (char)reader; |
387 | byte reader = br_read(1)[0]; | 393 | reader = br_read(1)[0]; |
388 | while (reader != 0x000) | ||
389 | { | ||
390 | ret += (char)reader; | ||
391 | reader = br_read(1)[0]; | ||
392 | } | ||
393 | return ret; | ||
394 | } | 394 | } |
395 | return ret; | ||
396 | } | ||
397 | |||
398 | /// <summary> | ||
399 | /// Reads a code chunk and creates IL | ||
400 | /// </summary> | ||
401 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> | ||
402 | /// <param name="typeBuilder">TypeBuilder for assembly</param> | ||
403 | /// <param name="eventname">Name of event (function) to generate</param> | ||
404 | private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) | ||
405 | { | ||
395 | 406 | ||
396 | /// <summary> | 407 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); |
397 | /// Reads a code chunk and creates IL | 408 | |
398 | /// </summary> | 409 | Common.SendToDebug("Reading Function Code Chunk at: " + pos); |
399 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> | 410 | fs.Seek(pos, SeekOrigin.Begin); |
400 | /// <param name="typeBuilder">TypeBuilder for assembly</param> | 411 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); |
401 | /// <param name="eventname">Name of event (function) to generate</param> | 412 | Common.SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize); |
402 | private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) | 413 | // Read until null |
414 | myCodeChunk.Comment = Read_String(); | ||
415 | Common.SendToDebug("Function comment: " + myCodeChunk.Comment); | ||
416 | myCodeChunk.ReturnType = br_read(1)[0]; | ||
417 | Common.SendToDebug("Return type #" + myCodeChunk.ReturnType + ": " + (getLLObjectType(myCodeChunk.ReturnType).ToString())); | ||
418 | |||
419 | // TODO: How to determine number of codechunks -- does this method work? | ||
420 | myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); | ||
421 | byte reader = br_read(1)[0]; | ||
422 | reader = br_read(1)[0]; | ||
423 | |||
424 | // NOTE ON CODE CHUNK ARGUMENTS | ||
425 | // This determins type definition | ||
426 | int ccount = 0; | ||
427 | while (reader != 0x000) | ||
403 | { | 428 | { |
404 | 429 | ccount++; | |
405 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); | 430 | Common.SendToDebug("Reading Code Chunk Argument " + ccount); |
406 | 431 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); | |
407 | Common.SendToDebug("Reading Function Code Chunk at: " + pos); | 432 | CCA.FunctionReturnType = reader; |
408 | fs.Seek(pos, SeekOrigin.Begin); | ||
409 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); | ||
410 | Common.SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize ); | ||
411 | // Read until null | ||
412 | myCodeChunk.Comment = Read_String(); | ||
413 | Common.SendToDebug("Function comment: " + myCodeChunk.Comment); | ||
414 | myCodeChunk.ReturnType = br_read(1)[0]; | ||
415 | Common.SendToDebug("Return type #" + myCodeChunk.ReturnType + ": " + (getLLObjectType(myCodeChunk.ReturnType).ToString())); | ||
416 | |||
417 | // TODO: How to determine number of codechunks -- does this method work? | ||
418 | myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); | ||
419 | byte reader = br_read(1)[0]; | ||
420 | reader = br_read(1)[0]; | 433 | reader = br_read(1)[0]; |
421 | 434 | CCA.NullString = reader; | |
422 | // NOTE ON CODE CHUNK ARGUMENTS | 435 | myCodeChunk.CodeChunkArguments.Add(CCA); |
423 | // This determins type definition | 436 | Common.SendToDebug("Code Chunk Argument " + ccount + " type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType); |
424 | int ccount = 0; | 437 | } |
425 | while (reader != 0x000) | 438 | // Create string array |
426 | { | 439 | Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; |
427 | ccount++; | 440 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) |
428 | Common.SendToDebug("Reading Code Chunk Argument " + ccount); | 441 | { |
429 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); | 442 | MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType); |
430 | CCA.FunctionReturnType = reader; | 443 | Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType).ToString()); |
431 | reader = br_read(1)[0]; | 444 | } |
432 | CCA.NullString = reader; | 445 | // End marker is 0x000 |
433 | myCodeChunk.CodeChunkArguments.Add(CCA); | 446 | myCodeChunk.EndMarker = reader; |
434 | Common.SendToDebug("Code Chunk Argument " + ccount + " type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType); | ||
435 | } | ||
436 | // Create string array | ||
437 | Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; | ||
438 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | ||
439 | { | ||
440 | MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType); | ||
441 | Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType).ToString()); | ||
442 | } | ||
443 | // End marker is 0x000 | ||
444 | myCodeChunk.EndMarker = reader; | ||
445 | 447 | ||
446 | 448 | ||
447 | // | 449 | // |
448 | // Emit: START OF METHOD (FUNCTION) | 450 | // Emit: START OF METHOD (FUNCTION) |
449 | // | 451 | // |
450 | 452 | ||
451 | Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); | 453 | Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); |
452 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | 454 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, |
453 | MethodAttributes.Public, | 455 | MethodAttributes.Public, |
454 | typeof(void), | 456 | typeof(void), |
455 | MethodArgs); | 457 | MethodArgs); |
456 | //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), | 458 | //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), |
457 | // new Type[] { typeof(object) }, //); | 459 | // new Type[] { typeof(object) }, //); |
458 | 460 | ||
459 | //Common.SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); | 461 | //Common.SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); |
460 | //typeBuilder.DefineMethodOverride(methodBuilder, | 462 | //typeBuilder.DefineMethodOverride(methodBuilder, |
461 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | 463 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); |
462 | 464 | ||
463 | // Create the IL generator | 465 | // Create the IL generator |
464 | 466 | ||
465 | Common.SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); | 467 | Common.SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); |
466 | ILGenerator il = methodBuilder.GetILGenerator(); | 468 | ILGenerator il = methodBuilder.GetILGenerator(); |
467 | 469 | ||
468 | 470 | ||
469 | if (Common.IL_UseTryCatch) | 471 | if (Common.IL_UseTryCatch) |
470 | IL_INSERT_TRY(il, eventname); | 472 | IL_INSERT_TRY(il, eventname); |
471 | 473 | ||
472 | 474 | ||
473 | 475 | ||
474 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | 476 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); |
475 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 477 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
476 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod | 478 | //il.Emit(OpCodes.Call, typeof(Console).GetMethod |
477 | // ("WriteLine", new Type[] { typeof(string) })); | 479 | // ("WriteLine", new Type[] { typeof(string) })); |
478 | 480 | ||
479 | //Common.SendToDebug("STARTUP: il.Emit(OpCodes.Ldc_I4_S, 0);"); | 481 | //Common.SendToDebug("STARTUP: il.Emit(OpCodes.Ldc_I4_S, 0);"); |
480 | 482 | ||
481 | //il.Emit(OpCodes.Ldc_I4_S, 0); | 483 | //il.Emit(OpCodes.Ldc_I4_S, 0); |
482 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) | 484 | for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) |
483 | { | 485 | { |
484 | Common.SendToDebug("PARAMS: il.Emit(OpCodes.Ldarg, " + _ic + ");"); | 486 | Common.SendToDebug("PARAMS: il.Emit(OpCodes.Ldarg, " + _ic + ");"); |
485 | il.Emit(OpCodes.Ldarg, _ic); | 487 | il.Emit(OpCodes.Ldarg, _ic); |
486 | } | 488 | } |
487 | 489 | ||
488 | 490 | ||
489 | 491 | ||
490 | // | 492 | // |
491 | // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL | 493 | // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL |
492 | // | 494 | // |
493 | bool FoundRet = false; | 495 | bool FoundRet = false; |
494 | while (FoundRet == false) | 496 | while (FoundRet == false) |
495 | { | 497 | { |
496 | FoundRet = LSL_PROCESS_OPCODE(il); | 498 | FoundRet = LSL_PROCESS_OPCODE(il); |
497 | } | 499 | } |
498 | 500 | ||
499 | 501 | ||
500 | if (Common.IL_UseTryCatch) | 502 | if (Common.IL_UseTryCatch) |
501 | IL_INSERT_END_TRY(il, eventname); | 503 | IL_INSERT_END_TRY(il, eventname); |
502 | 504 | ||
503 | // Emit: RETURN FROM METHOD | 505 | // Emit: RETURN FROM METHOD |
504 | il.Emit(OpCodes.Ret); | 506 | il.Emit(OpCodes.Ret); |
505 | 507 | ||
506 | return; | 508 | return; |
507 | 509 | ||
508 | } | 510 | } |
509 | 511 | ||
510 | private void IL_INSERT_FUNCTIONLIST() | 512 | private void IL_INSERT_FUNCTIONLIST() |
511 | { | 513 | { |
512 | 514 | ||
513 | Common.SendToDebug("Creating function list"); | 515 | Common.SendToDebug("Creating function list"); |
514 | 516 | ||
515 | 517 | ||
516 | string eventname = "GetFunctions"; | 518 | string eventname = "GetFunctions"; |
517 | 519 | ||
518 | Common.SendToDebug("Creating IL " + eventname); | 520 | Common.SendToDebug("Creating IL " + eventname); |
519 | // Define a private String field. | 521 | // Define a private String field. |
520 | //FieldBuilder myField = myTypeBuilder.DefineField("EventList", typeof(String[]), FieldAttributes.Public); | 522 | //FieldBuilder myField = myTypeBuilder.DefineField("EventList", typeof(String[]), FieldAttributes.Public); |
521 | 523 | ||
522 | 524 | ||
523 | //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); | 525 | //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); |
524 | 526 | ||
525 | 527 | ||
526 | 528 | ||
527 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | 529 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, |
528 | MethodAttributes.Public, | 530 | MethodAttributes.Public, |
529 | typeof(string[]), | 531 | typeof(string[]), |
530 | null); | 532 | null); |
531 | 533 | ||
532 | //typeBuilder.DefineMethodOverride(methodBuilder, | 534 | //typeBuilder.DefineMethodOverride(methodBuilder, |
533 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | 535 | // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); |
534 | 536 | ||
535 | ILGenerator il = methodBuilder.GetILGenerator(); | 537 | ILGenerator il = methodBuilder.GetILGenerator(); |
536 | 538 | ||
537 | 539 | ||
538 | 540 | ||
@@ -548,80 +550,80 @@ using System; | |||
548 | 550 | ||
549 | //initIL.Emit(OpCodes.Newobj, typeof(string[])); | 551 | //initIL.Emit(OpCodes.Newobj, typeof(string[])); |
550 | 552 | ||
551 | //string[] MyArray = new string[2] { "TestItem1" , "TestItem2" }; | 553 | //string[] MyArray = new string[2] { "TestItem1" , "TestItem2" }; |
552 | 554 | ||
553 | il.DeclareLocal(typeof(string[])); | 555 | il.DeclareLocal(typeof(string[])); |
554 | 556 | ||
555 | //il.Emit(OpCodes.Ldarg_0); | 557 | //il.Emit(OpCodes.Ldarg_0); |
556 | il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length | 558 | il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length |
557 | il.Emit(OpCodes.Newarr, typeof(String)); // create new string array | 559 | il.Emit(OpCodes.Newarr, typeof(String)); // create new string array |
558 | il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack | 560 | il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack |
559 | 561 | ||
560 | for (int lv = 0; lv < EventList.Count; lv++) | 562 | for (int lv = 0; lv < EventList.Count; lv++) |
561 | { | 563 | { |
562 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | 564 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack |
563 | il.Emit(OpCodes.Ldc_I4, lv); // Push index position | 565 | il.Emit(OpCodes.Ldc_I4, lv); // Push index position |
564 | il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value | 566 | il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value |
565 | il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value | 567 | il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value |
566 | } | 568 | } |
567 | 569 | ||
568 | |||
569 | 570 | ||
570 | // IL_INSERT_END_TRY(il, eventname); | ||
571 | 571 | ||
572 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack | 572 | // IL_INSERT_END_TRY(il, eventname); |
573 | il.Emit(OpCodes.Ret); // Return | ||
574 | 573 | ||
575 | } | 574 | il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack |
575 | il.Emit(OpCodes.Ret); // Return | ||
576 | 576 | ||
577 | } | ||
577 | 578 | ||
578 | private void IL_INSERT_TRY(ILGenerator il, string eventname) | ||
579 | { | ||
580 | /* | ||
581 | * CLR TRY | ||
582 | */ | ||
583 | //Common.SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); | ||
584 | il.BeginExceptionBlock(); | ||
585 | 579 | ||
586 | // Push "Hello World!" string to stack | 580 | private void IL_INSERT_TRY(ILGenerator il, string eventname) |
587 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | 581 | { |
588 | il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); | 582 | /* |
583 | * CLR TRY | ||
584 | */ | ||
585 | //Common.SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); | ||
586 | il.BeginExceptionBlock(); | ||
589 | 587 | ||
590 | } | 588 | // Push "Hello World!" string to stack |
591 | 589 | //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | |
592 | private void IL_INSERT_END_TRY(ILGenerator il, string eventname) | 590 | il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); |
593 | { | 591 | |
594 | /* | 592 | } |
595 | * CATCH | 593 | |
596 | */ | 594 | private void IL_INSERT_END_TRY(ILGenerator il, string eventname) |
597 | Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); | 595 | { |
598 | il.BeginCatchBlock(typeof(Exception)); | 596 | /* |
599 | 597 | * CATCH | |
600 | // Push "Hello World!" string to stack | 598 | */ |
601 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | 599 | Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); |
602 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); | 600 | il.BeginCatchBlock(typeof(Exception)); |
603 | 601 | ||
604 | //call void [mscorlib]System.Console::WriteLine(string) | 602 | // Push "Hello World!" string to stack |
605 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 603 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); |
606 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 604 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); |
607 | ("Write", new Type[] { typeof(string) })); | 605 | |
608 | 606 | //call void [mscorlib]System.Console::WriteLine(string) | |
609 | //callvirt instance string [mscorlib]System.Exception::get_Message() | 607 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
610 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); | 608 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
611 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod | 609 | ("Write", new Type[] { typeof(string) })); |
612 | ("get_Message")); | 610 | |
613 | 611 | //callvirt instance string [mscorlib]System.Exception::get_Message() | |
614 | //call void [mscorlib]System.Console::WriteLine(string) | 612 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); |
615 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 613 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod |
616 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 614 | ("get_Message")); |
617 | ("WriteLine", new Type[] { typeof(string) })); | 615 | |
618 | 616 | //call void [mscorlib]System.Console::WriteLine(string) | |
619 | /* | 617 | Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
620 | * CLR END TRY | 618 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
621 | */ | 619 | ("WriteLine", new Type[] { typeof(string) })); |
622 | //Common.SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); | 620 | |
623 | il.EndExceptionBlock(); | 621 | /* |
624 | } | 622 | * CLR END TRY |
623 | */ | ||
624 | //Common.SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); | ||
625 | il.EndExceptionBlock(); | ||
626 | } | ||
625 | 627 | ||
626 | } | 628 | } |
627 | } | 629 | } |