diff options
Some more work on SceneObject/primitive rewrites (AllNewSceneObjectGroup2 /Part2).
Updated the JavaVM to a later version I did (basically some clean up and a little bit more functional).
Added SendLoadURL method to IClientAPI.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs | 239 |
1 files changed, 188 insertions, 51 deletions
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 f151b7e..a609a40 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
33 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 35 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
35 | { | 36 | { |
@@ -60,7 +61,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
60 | 61 | ||
61 | public ClassInstance CreateNewInstance() | 62 | public ClassInstance CreateNewInstance() |
62 | { | 63 | { |
63 | return new ClassInstance(); | 64 | ClassInstance classInst = new ClassInstance(); |
65 | classInst.ClassRec = this; | ||
66 | //TODO: set fields | ||
67 | |||
68 | return classInst; | ||
64 | } | 69 | } |
65 | 70 | ||
66 | public void LoadClassFromFile(string fileName) | 71 | public void LoadClassFromFile(string fileName) |
@@ -75,33 +80,40 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
75 | { | 80 | { |
76 | int i = 0; | 81 | int i = 0; |
77 | i += 4; | 82 | i += 4; |
78 | _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); | 83 | _minorVersion = (ushort)((data[i++] << 8) + data[i++]); |
79 | _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); | 84 | _majorVersion = (ushort)((data[i++] << 8) + data[i++]); |
80 | _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); | 85 | _constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); |
81 | // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); | 86 | Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); |
82 | for (int count = 0; count < _constantPoolCount -1 ; count++) | 87 | for (int count = 0; count < (_constantPoolCount - 1); count++) |
83 | { | 88 | { |
84 | //read in the constant pool | 89 | //read in the constant pool |
85 | byte pooltype = data[i++]; | 90 | byte pooltype = data[i++]; |
86 | //Console.WriteLine("#" +count +": new constant type = " +pooltype); | 91 | Console.WriteLine("#" + count + ": new constant type = " + pooltype); |
87 | //Console.WriteLine("start position is: " + i); | 92 | //Console.WriteLine("start position is: " + i); |
88 | switch (pooltype) | 93 | switch (pooltype) |
89 | { | 94 | { |
90 | case 1: //Utf8 | 95 | case 1: //Utf8 |
91 | ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); | 96 | ushort uLength = (ushort)((data[i++] << 8) + data[i++]); |
92 | 97 | ||
93 | // Console.WriteLine("new utf8 type, length is " + uLength); | 98 | // Console.WriteLine("new utf8 type, length is " + uLength); |
94 | PoolUtf8 utf8 = new PoolUtf8(); | 99 | PoolUtf8 utf8 = new PoolUtf8(); |
95 | utf8.readValue(data, ref i, uLength); | 100 | utf8.readValue(data, ref i, uLength); |
96 | this._constantsPool.Add(utf8); | 101 | this._constantsPool.Add(utf8); |
97 | break; | 102 | break; |
98 | case 3: //Int | 103 | case 3: //Int |
99 | break; | 104 | break; |
105 | case 4: //Float | ||
106 | break; | ||
100 | case 7: //Class | 107 | case 7: //Class |
101 | PoolClass pClass = new PoolClass(this); | 108 | PoolClass pClass = new PoolClass(this); |
102 | pClass.readValue(data, ref i); | 109 | pClass.readValue(data, ref i); |
103 | this._constantsPool.Add(pClass); | 110 | this._constantsPool.Add(pClass); |
104 | break; | 111 | break; |
112 | case 9: //FieldRef | ||
113 | PoolFieldRef pField = new PoolFieldRef(this); | ||
114 | pField.readValue(data, ref i); | ||
115 | this._constantsPool.Add(pField); | ||
116 | break; | ||
105 | case 10: //Method | 117 | case 10: //Method |
106 | PoolMethodRef pMeth = new PoolMethodRef(this); | 118 | PoolMethodRef pMeth = new PoolMethodRef(this); |
107 | pMeth.readValue(data, ref i); | 119 | pMeth.readValue(data, ref i); |
@@ -115,9 +127,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
115 | } | 127 | } |
116 | } | 128 | } |
117 | 129 | ||
118 | _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); | 130 | _accessFlags = (ushort)((data[i++] << 8) + data[i++]); |
119 | _thisClass = (ushort)((data[i++] << 8) + data[i++] ); | 131 | _thisClass = (ushort)((data[i++] << 8) + data[i++]); |
120 | _supperClass = (ushort)((data[i++] << 8) + data[i++] ); | 132 | _supperClass = (ushort)((data[i++] << 8) + data[i++]); |
121 | 133 | ||
122 | if (this._constantsPool[this._thisClass - 1] is PoolClass) | 134 | if (this._constantsPool[this._thisClass - 1] is PoolClass) |
123 | { | 135 | { |
@@ -126,8 +138,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
126 | 138 | ||
127 | _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); | 139 | _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); |
128 | //should now read in the info for each interface | 140 | //should now read in the info for each interface |
141 | |||
129 | _fieldCount = (ushort)((data[i++] << 8) + data[i++]); | 142 | _fieldCount = (ushort)((data[i++] << 8) + data[i++]); |
130 | //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++) | ||
145 | { | ||
146 | FieldInfo fieldInf = new FieldInfo(this); | ||
147 | fieldInf.ReadData(data, ref i); | ||
148 | this._fieldList.Add(fieldInf); | ||
149 | } | ||
150 | |||
131 | _methodCount = (ushort)((data[i++] << 8) + data[i++]); | 151 | _methodCount = (ushort)((data[i++] << 8) + data[i++]); |
132 | for (int count = 0; count < _methodCount; count++) | 152 | for (int count = 0; count < _methodCount; count++) |
133 | { | 153 | { |
@@ -149,9 +169,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
149 | { | 169 | { |
150 | for (int count = 0; count < _methodCount; count++) | 170 | for (int count = 0; count < _methodCount; count++) |
151 | { | 171 | { |
152 | if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) | 172 | if (this._constantsPool[this._methodsList[count].NameIndex - 1] is PoolUtf8) |
153 | { | 173 | { |
154 | if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) | 174 | if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value == methodName) |
155 | { | 175 | { |
156 | //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); |
157 | thread.SetPC(this._methodsList[count].CodePointer); | 177 | thread.SetPC(this._methodsList[count].CodePointer); |
@@ -165,8 +185,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
165 | public void PrintToConsole() | 185 | public void PrintToConsole() |
166 | { | 186 | { |
167 | Console.WriteLine("Class File:"); | 187 | Console.WriteLine("Class File:"); |
168 | Console.WriteLine("Major version: " + _majorVersion); | 188 | Console.WriteLine("Major version: " + _majorVersion); |
169 | Console.WriteLine("Minor version: " + _minorVersion); | 189 | Console.WriteLine("Minor version: " + _minorVersion); |
170 | Console.WriteLine("Pool size: " + _constantPoolCount); | 190 | Console.WriteLine("Pool size: " + _constantPoolCount); |
171 | 191 | ||
172 | for (int i = 0; i < _constantsPool.Count; i++) | 192 | for (int i = 0; i < _constantsPool.Count; i++) |
@@ -174,9 +194,15 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
174 | this._constantsPool[i].Print(); | 194 | this._constantsPool[i].Print(); |
175 | } | 195 | } |
176 | 196 | ||
177 | Console.WriteLine("Access flags: " + _accessFlags); | 197 | Console.WriteLine("Access flags: " + _accessFlags); |
178 | Console.WriteLine("This class: " + _thisClass ); | 198 | Console.WriteLine("This class: " + _thisClass); |
179 | Console.WriteLine("Super class: " + _supperClass); | 199 | Console.WriteLine("Super class: " + _supperClass); |
200 | |||
201 | for (int count = 0; count < _fieldCount; count++) | ||
202 | { | ||
203 | Console.WriteLine(); | ||
204 | this._fieldList[count].Print(); | ||
205 | } | ||
180 | 206 | ||
181 | for (int count = 0; count < _methodCount; count++) | 207 | for (int count = 0; count < _methodCount; count++) |
182 | { | 208 | { |
@@ -184,7 +210,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
184 | this._methodsList[count].Print(); | 210 | this._methodsList[count].Print(); |
185 | } | 211 | } |
186 | 212 | ||
187 | Console.WriteLine("class name is " + this.mClass.Name.Value); | 213 | Console.WriteLine("class name is " + this.mClass.Name.Value); |
188 | } | 214 | } |
189 | 215 | ||
190 | public static byte[] ReadFully(Stream stream) | 216 | public static byte[] ReadFully(Stream stream) |
@@ -215,32 +241,32 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
215 | { | 241 | { |
216 | public string Value = ""; | 242 | public string Value = ""; |
217 | 243 | ||
218 | public void readValue(byte[] data,ref int pointer , int length) | 244 | public void readValue(byte[] data, ref int pointer, int length) |
219 | { | 245 | { |
220 | for (int i = 0; i < length; i++) | 246 | for (int i = 0; i < length; i++) |
221 | { | 247 | { |
222 | int a =(int) data[pointer++]; | 248 | int a = (int)data[pointer++]; |
223 | if ((a & 0x80) == 0) | 249 | if ((a & 0x80) == 0) |
224 | { | 250 | { |
225 | Value = Value + (char)a; | 251 | Value = Value + (char)a; |
226 | } | 252 | } |
227 | else if ((a & 0x20) == 0) | 253 | else if ((a & 0x20) == 0) |
228 | { | 254 | { |
229 | int b = (int) data[pointer++]; | 255 | int b = (int)data[pointer++]; |
230 | Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); | 256 | Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); |
231 | } | 257 | } |
232 | else | 258 | else |
233 | { | 259 | { |
234 | int b = (int)data[pointer++]; | 260 | int b = (int)data[pointer++]; |
235 | int c = (int)data[pointer++]; | 261 | int c = (int)data[pointer++]; |
236 | Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); | 262 | Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); |
237 | } | 263 | } |
238 | } | 264 | } |
239 | } | 265 | } |
240 | 266 | ||
241 | public override void Print() | 267 | public override void Print() |
242 | { | 268 | { |
243 | Console.WriteLine("Utf8 type: " + Value); | 269 | Console.WriteLine("Utf8 type: " + Value); |
244 | } | 270 | } |
245 | } | 271 | } |
246 | 272 | ||
@@ -263,7 +289,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
263 | 289 | ||
264 | public void readValue(byte[] data, ref int pointer) | 290 | public void readValue(byte[] data, ref int pointer) |
265 | { | 291 | { |
266 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 292 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); |
267 | } | 293 | } |
268 | 294 | ||
269 | public override void Print() | 295 | public override void Print() |
@@ -271,7 +297,34 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
271 | this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); | 297 | this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); |
272 | Console.Write("Class type: " + namePointer); | 298 | Console.Write("Class type: " + namePointer); |
273 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); | 299 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); |
274 | 300 | ||
301 | } | ||
302 | } | ||
303 | |||
304 | public class PoolFieldRef : PoolItem | ||
305 | { | ||
306 | public ushort classPointer = 0; | ||
307 | public ushort nameTypePointer = 0; | ||
308 | public PoolNamedType mNameType; | ||
309 | public PoolClass mClass; | ||
310 | private ClassRecord parent; | ||
311 | |||
312 | public PoolFieldRef(ClassRecord paren) | ||
313 | { | ||
314 | parent = paren; | ||
315 | } | ||
316 | |||
317 | public void readValue(byte[] data, ref int pointer) | ||
318 | { | ||
319 | classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
320 | nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
321 | } | ||
322 | |||
323 | public override void Print() | ||
324 | { | ||
325 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); | ||
326 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); | ||
327 | Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); | ||
275 | } | 328 | } |
276 | } | 329 | } |
277 | 330 | ||
@@ -298,7 +351,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
298 | { | 351 | { |
299 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); | 352 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); |
300 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); | 353 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); |
301 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); | 354 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); |
302 | } | 355 | } |
303 | } | 356 | } |
304 | 357 | ||
@@ -317,16 +370,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
317 | 370 | ||
318 | public void readValue(byte[] data, ref int pointer) | 371 | public void readValue(byte[] data, ref int pointer) |
319 | { | 372 | { |
320 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 373 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); |
321 | typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 374 | typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); |
322 | } | 375 | } |
323 | 376 | ||
324 | public override void Print() | 377 | public override void Print() |
325 | { | 378 | { |
326 | Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); | 379 | Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); |
327 | Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); | 380 | Type = ((PoolUtf8)this.parent._constantsPool[typePointer - 1]); |
328 | Console.Write("Named type: " + namePointer + " , " + typePointer ); | 381 | Console.Write("Named type: " + namePointer + " , " + typePointer); |
329 | Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); | 382 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); |
330 | } | 383 | } |
331 | } | 384 | } |
332 | 385 | ||
@@ -341,7 +394,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
341 | public List<MethodAttribute> Attributes = new List<MethodAttribute>(); | 394 | public List<MethodAttribute> Attributes = new List<MethodAttribute>(); |
342 | private ClassRecord parent; | 395 | private ClassRecord parent; |
343 | public int CodePointer = 0; | 396 | public int CodePointer = 0; |
344 | 397 | ||
345 | public MethodInfo(ClassRecord paren) | 398 | public MethodInfo(ClassRecord paren) |
346 | { | 399 | { |
347 | parent = paren; | 400 | parent = paren; |
@@ -361,7 +414,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
361 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 414 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
362 | DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 415 | DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
363 | AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); | 416 | AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); |
364 | for(int i =0; i< AttributeCount; i++) | 417 | for (int i = 0; i < AttributeCount; i++) |
365 | { | 418 | { |
366 | MethodAttribute attri = new MethodAttribute(this.parent); | 419 | MethodAttribute attri = new MethodAttribute(this.parent); |
367 | attri.ReadData(data, ref pointer); | 420 | attri.ReadData(data, ref pointer); |
@@ -371,11 +424,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
371 | 424 | ||
372 | public void Print() | 425 | public void Print() |
373 | { | 426 | { |
374 | Console.WriteLine("Method Info Struct: "); | 427 | Console.WriteLine("Method Info Struct: "); |
375 | Console.WriteLine("AccessFlags: " + AccessFlags); | 428 | Console.WriteLine("AccessFlags: " + AccessFlags); |
376 | Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); | 429 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); |
377 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); | 430 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value); |
378 | Console.WriteLine("Attribute Count:" + AttributeCount); | 431 | Console.WriteLine("Attribute Count:" + AttributeCount); |
379 | for (int i = 0; i < AttributeCount; i++) | 432 | for (int i = 0; i < AttributeCount; i++) |
380 | { | 433 | { |
381 | this.Attributes[i].Print(); | 434 | this.Attributes[i].Print(); |
@@ -426,12 +479,12 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
426 | 479 | ||
427 | public void Print() | 480 | public void Print() |
428 | { | 481 | { |
429 | Console.WriteLine("Method Attribute: "); | 482 | Console.WriteLine("Method Attribute: "); |
430 | Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); | 483 | Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); |
431 | Console.WriteLine("Length: " + Length); | 484 | Console.WriteLine("Length: " + Length); |
432 | Console.WriteLine("MaxStack: " + MaxStack); | 485 | Console.WriteLine("MaxStack: " + MaxStack); |
433 | Console.WriteLine("MaxLocals: " + MaxLocals); | 486 | Console.WriteLine("MaxLocals: " + MaxLocals); |
434 | Console.WriteLine("CodeLength: " + CodeLength); | 487 | Console.WriteLine("CodeLength: " + CodeLength); |
435 | for (int i = 0; i < Code.Length; i++) | 488 | for (int i = 0; i < Code.Length; i++) |
436 | { | 489 | { |
437 | Console.WriteLine("OpCode #" + i + " is: " + Code[i]); | 490 | Console.WriteLine("OpCode #" + i + " is: " + Code[i]); |
@@ -483,13 +536,97 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
483 | 536 | ||
484 | } | 537 | } |
485 | } | 538 | } |
486 | private class FieldInfo | 539 | |
540 | public class FieldInfo | ||
487 | { | 541 | { |
488 | public void ReadData(byte[] data, ref int i) | 542 | public ushort AccessFlags = 0; |
543 | public ushort NameIndex = 0; | ||
544 | public string Name = ""; | ||
545 | public ushort DescriptorIndex = 0; | ||
546 | public ushort AttributeCount = 0; | ||
547 | public List<FieldAttribute> Attributes = new List<FieldAttribute>(); | ||
548 | private ClassRecord parent; | ||
549 | |||
550 | public FieldInfo(ClassRecord paren) | ||
489 | { | 551 | { |
552 | parent = paren; | ||
553 | } | ||
490 | 554 | ||
555 | public void ReadData(byte[] data, ref int pointer) | ||
556 | { | ||
557 | AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
558 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
559 | DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
560 | AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
561 | for (int i = 0; i < AttributeCount; i++) | ||
562 | { | ||
563 | FieldAttribute attri = new FieldAttribute(this.parent); | ||
564 | attri.ReadData(data, ref pointer); | ||
565 | this.Attributes.Add(attri); | ||
566 | } | ||
567 | } | ||
568 | |||
569 | public void Print() | ||
570 | { | ||
571 | Console.WriteLine("Field Info Struct: "); | ||
572 | Console.WriteLine("AccessFlags: " + AccessFlags); | ||
573 | Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | ||
574 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value); | ||
575 | Console.WriteLine("Attribute Count:" + AttributeCount); | ||
576 | //if static, add to static field list | ||
577 | // if (this.AccessFlags == 9) //public and static | ||
578 | if ((this.AccessFlags & 0x08) != 0) | ||
579 | { | ||
580 | switch (((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value) | ||
581 | { | ||
582 | case "I": | ||
583 | Int newin = new Int(); | ||
584 | this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newin); | ||
585 | break; | ||
586 | case "F": | ||
587 | Float newfl = new Float(); | ||
588 | this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newfl); | ||
589 | break; | ||
590 | } | ||
591 | |||
592 | } | ||
593 | for (int i = 0; i < AttributeCount; i++) | ||
594 | { | ||
595 | this.Attributes[i].Print(); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | public class FieldAttribute | ||
600 | { | ||
601 | public ushort NameIndex = 0; | ||
602 | public string Name = ""; | ||
603 | public Int32 Length = 0; | ||
604 | public byte[] Data; | ||
605 | private ClassRecord parent; | ||
606 | |||
607 | public FieldAttribute(ClassRecord paren) | ||
608 | { | ||
609 | parent = paren; | ||
610 | } | ||
611 | |||
612 | public void ReadData(byte[] data, ref int pointer) | ||
613 | { | ||
614 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | ||
615 | Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); | ||
616 | Data = new byte[Length]; | ||
617 | for (int i = 0; i < Length; i++) | ||
618 | { | ||
619 | Data[i] = data[pointer++]; | ||
620 | } | ||
621 | } | ||
622 | |||
623 | public void Print() | ||
624 | { | ||
625 | Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | ||
626 | } | ||
491 | } | 627 | } |
492 | } | 628 | } |
629 | |||
493 | private class AttributeInfo | 630 | private class AttributeInfo |
494 | { | 631 | { |
495 | public void ReadData(byte[] data, ref int i) | 632 | public void ReadData(byte[] data, ref int i) |
@@ -500,4 +637,4 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM | |||
500 | #endregion | 637 | #endregion |
501 | 638 | ||
502 | } | 639 | } |
503 | } | 640 | } \ No newline at end of file |