Little bit more work on AllNewSceneObjectPart2

afrisby
MW 2007-08-01 20:11:42 +00:00
parent 2333de33f1
commit 1d5544a23a
9 changed files with 1119 additions and 1082 deletions

View File

@ -32,10 +32,10 @@ namespace OpenSim.Region.Environment.Scenes
public uint BaseMask = FULL_MASK_PERMISSIONS;
protected PrimitiveBaseShape m_Shape;
protected byte[] m_particleSystem = new byte[0];
protected AllNewSceneObjectGroup2 m_parentGroup;
#region Properties
protected LLUUID m_uuid;
@ -271,6 +271,35 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
#region Inventory
public void GetInventory(IClientAPI client, uint localID)
{
if (localID == this.m_localID)
{
client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
}
}
#endregion
public void UpdateExtraParam(ushort type, bool inUse, byte[] data)
{
this.m_Shape.ExtraParams = new byte[data.Length + 7];
int i = 0;
uint length = (uint)data.Length;
this.m_Shape.ExtraParams[i++] = 1;
this.m_Shape.ExtraParams[i++] = (byte)(type % 256);
this.m_Shape.ExtraParams[i++] = (byte)((type >> 8) % 256);
this.m_Shape.ExtraParams[i++] = (byte)(length % 256);
this.m_Shape.ExtraParams[i++] = (byte)((length >> 8) % 256);
this.m_Shape.ExtraParams[i++] = (byte)((length >> 16) % 256);
this.m_Shape.ExtraParams[i++] = (byte)((length >> 24) % 256);
Array.Copy(data, 0, this.m_Shape.ExtraParams, i, data.Length);
//this.ScheduleFullUpdate();
}
#region Texture
/// <summary>
///
@ -282,6 +311,12 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem)
{
this.m_particleSystem = pSystem.GetBytes();
}
#region Position
/// <summary>
///

View File

@ -34,7 +34,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
public class ClassInstance : Object
{
public int size;
public int Size;
public ClassRecord ClassRec;
public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();

View File

@ -36,23 +36,23 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
public class ClassRecord
{
private ushort _majorVersion;
private ushort _minorVersion;
private ushort _constantPoolCount;
private ushort _accessFlags;
private ushort _thisClass;
private ushort _supperClass;
private ushort _interfaceCount;
private ushort _fieldCount;
private ushort _methodCount;
private ushort m_majorVersion;
private ushort m_minorVersion;
private ushort m_constantPoolCount;
private ushort m_accessFlags;
private ushort m_thisClass;
private ushort m_supperClass;
private ushort m_interfaceCount;
private ushort m_fieldCount;
private ushort m_methodCount;
//private ushort _attributeCount;
//private string _name;
public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>();
public PoolClass mClass;
public PoolClass MClass;
public List<PoolItem> _constantsPool = new List<PoolItem>();
private List<MethodInfo> _methodsList = new List<MethodInfo>();
private List<FieldInfo> _fieldList = new List<FieldInfo>();
public List<PoolItem> m_constantsPool = new List<PoolItem>();
private List<MethodInfo> m_methodsList = new List<MethodInfo>();
private List<FieldInfo> m_fieldList = new List<FieldInfo>();
public ClassRecord()
{
@ -80,11 +80,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
int i = 0;
i += 4;
_minorVersion = (ushort)((data[i++] << 8) + data[i++]);
_majorVersion = (ushort)((data[i++] << 8) + data[i++]);
_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]);
Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
for (int count = 0; count < (_constantPoolCount - 1); count++)
m_minorVersion = (ushort)((data[i++] << 8) + data[i++]);
m_majorVersion = (ushort)((data[i++] << 8) + data[i++]);
m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]);
Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool");
for (int count = 0; count < (m_constantPoolCount - 1); count++)
{
//read in the constant pool
byte pooltype = data[i++];
@ -98,7 +98,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
// Console.WriteLine("new utf8 type, length is " + uLength);
PoolUtf8 utf8 = new PoolUtf8();
utf8.readValue(data, ref i, uLength);
this._constantsPool.Add(utf8);
this.m_constantsPool.Add(utf8);
break;
case 3: //Int
break;
@ -107,74 +107,74 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
case 7: //Class
PoolClass pClass = new PoolClass(this);
pClass.readValue(data, ref i);
this._constantsPool.Add(pClass);
this.m_constantsPool.Add(pClass);
break;
case 9: //FieldRef
PoolFieldRef pField = new PoolFieldRef(this);
pField.readValue(data, ref i);
this._constantsPool.Add(pField);
this.m_constantsPool.Add(pField);
break;
case 10: //Method
PoolMethodRef pMeth = new PoolMethodRef(this);
pMeth.readValue(data, ref i);
this._constantsPool.Add(pMeth);
this.m_constantsPool.Add(pMeth);
break;
case 12: //NamedType
PoolNamedType pNamed = new PoolNamedType(this);
pNamed.readValue(data, ref i);
this._constantsPool.Add(pNamed);
this.m_constantsPool.Add(pNamed);
break;
}
}
_accessFlags = (ushort)((data[i++] << 8) + data[i++]);
_thisClass = (ushort)((data[i++] << 8) + data[i++]);
_supperClass = (ushort)((data[i++] << 8) + data[i++]);
m_accessFlags = (ushort)((data[i++] << 8) + data[i++]);
m_thisClass = (ushort)((data[i++] << 8) + data[i++]);
m_supperClass = (ushort)((data[i++] << 8) + data[i++]);
if (this._constantsPool[this._thisClass - 1] is PoolClass)
if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass)
{
this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]);
this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]);
}
_interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each interface
_fieldCount = (ushort)((data[i++] << 8) + data[i++]);
m_fieldCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each field
for (int count = 0; count < _fieldCount; count++)
for (int count = 0; count < m_fieldCount; count++)
{
FieldInfo fieldInf = new FieldInfo(this);
fieldInf.ReadData(data, ref i);
this._fieldList.Add(fieldInf);
this.m_fieldList.Add(fieldInf);
}
_methodCount = (ushort)((data[i++] << 8) + data[i++]);
for (int count = 0; count < _methodCount; count++)
m_methodCount = (ushort)((data[i++] << 8) + data[i++]);
for (int count = 0; count < m_methodCount; count++)
{
MethodInfo methInf = new MethodInfo(this);
methInf.ReadData(data, ref i);
this._methodsList.Add(methInf);
this.m_methodsList.Add(methInf);
}
}
public void AddMethodsToMemory(MethodMemory memory)
{
for (int count = 0; count < _methodCount; count++)
for (int count = 0; count < m_methodCount; count++)
{
this._methodsList[count].AddMethodCode(memory);
this.m_methodsList[count].AddMethodCode(memory);
}
}
public bool StartMethod(Thread thread, string methodName)
{
for (int count = 0; count < _methodCount; count++)
for (int count = 0; count < m_methodCount; count++)
{
if (this._constantsPool[this._methodsList[count].NameIndex - 1] is PoolUtf8)
if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8)
{
if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value == methodName)
if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName)
{
//Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
thread.SetPC(this._methodsList[count].CodePointer);
thread.SetPC(this.m_methodsList[count].CodePointer);
return true;
}
}
@ -185,32 +185,32 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void PrintToConsole()
{
Console.WriteLine("Class File:");
Console.WriteLine("Major version: " + _majorVersion);
Console.WriteLine("Minor version: " + _minorVersion);
Console.WriteLine("Pool size: " + _constantPoolCount);
Console.WriteLine("Major version: " + m_majorVersion);
Console.WriteLine("Minor version: " + m_minorVersion);
Console.WriteLine("Pool size: " + m_constantPoolCount);
for (int i = 0; i < _constantsPool.Count; i++)
for (int i = 0; i < m_constantsPool.Count; i++)
{
this._constantsPool[i].Print();
this.m_constantsPool[i].Print();
}
Console.WriteLine("Access flags: " + _accessFlags);
Console.WriteLine("This class: " + _thisClass);
Console.WriteLine("Super class: " + _supperClass);
Console.WriteLine("Access flags: " + m_accessFlags);
Console.WriteLine("This class: " + m_thisClass);
Console.WriteLine("Super class: " + m_supperClass);
for (int count = 0; count < _fieldCount; count++)
for (int count = 0; count < m_fieldCount; count++)
{
Console.WriteLine();
this._fieldList[count].Print();
this.m_fieldList[count].Print();
}
for (int count = 0; count < _methodCount; count++)
for (int count = 0; count < m_methodCount; count++)
{
Console.WriteLine();
this._methodsList[count].Print();
this.m_methodsList[count].Print();
}
Console.WriteLine("class name is " + this.mClass.Name.Value);
Console.WriteLine("class name is " + this.MClass.Name.Value);
}
public static byte[] ReadFully(Stream stream)
@ -294,9 +294,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public override void Print()
{
this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]);
Console.Write("Class type: " + namePointer);
Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value);
}
}
@ -322,8 +322,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public override void Print()
{
this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]);
Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer);
}
}
@ -349,8 +349,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public override void Print()
{
this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]);
Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
}
}
@ -376,10 +376,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public override void Print()
{
Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
Type = ((PoolUtf8)this.parent._constantsPool[typePointer - 1]);
Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]);
Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]);
Console.Write("Named type: " + namePointer + " , " + typePointer);
Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value);
}
}
@ -426,8 +426,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
Console.WriteLine("Method Info Struct: ");
Console.WriteLine("AccessFlags: " + AccessFlags);
Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("Attribute Count:" + AttributeCount);
for (int i = 0; i < AttributeCount; i++)
{
@ -480,7 +480,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print()
{
Console.WriteLine("Method Attribute: ");
Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value);
Console.WriteLine("Length: " + Length);
Console.WriteLine("MaxStack: " + MaxStack);
Console.WriteLine("MaxLocals: " + MaxLocals);
@ -522,7 +522,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print()
{
Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value);
}
}
@ -570,22 +570,22 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
Console.WriteLine("Field Info Struct: ");
Console.WriteLine("AccessFlags: " + AccessFlags);
Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("Attribute Count:" + AttributeCount);
//if static, add to static field list
// if (this.AccessFlags == 9) //public and static
if ((this.AccessFlags & 0x08) != 0)
{
switch (((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value)
switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value)
{
case "I":
Int newin = new Int();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newin);
this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin);
break;
case "F":
Float newfl = new Float();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newfl);
this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl);
break;
}
@ -622,7 +622,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print()
{
Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value);
}
}
}

View File

@ -45,293 +45,293 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
case (byte)(byte)OpCode.iconst_m1:
Int m_int = new Int();
m_int.mValue = -1;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)(byte)OpCode.iconst_0:
m_int = new Int();
m_int.mValue = 0;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)(byte)OpCode.iconst_1:
m_int = new Int();
m_int.mValue = 1;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)(byte)OpCode.iconst_2:
m_int = new Int();
m_int.mValue = 2;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)(byte)OpCode.iconst_3:
m_int = new Int();
m_int.mValue = 3;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
break;
case (byte)(byte)OpCode.iconst_4:
m_int = new Int();
m_int.mValue = 4;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)OpCode.iconst_5:
m_int = new Int();
m_int.mValue = 5;
this._mThread.currentFrame.OpStack.Push(m_int);
this.m_thread.m_currentFrame.OpStack.Push(m_int);
result = true;
break;
case (byte)OpCode.fconst_0:
Float m_float = new Float();
m_float.mValue = 0.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
this.m_thread.m_currentFrame.OpStack.Push(m_float);
result = true;
break;
case (byte)OpCode.fconst_1:
m_float = new Float();
m_float.mValue = 1.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
this.m_thread.m_currentFrame.OpStack.Push(m_float);
result = true;
break;
case (byte)OpCode.fconst_2:
m_float = new Float();
m_float.mValue = 2.0f;
this._mThread.currentFrame.OpStack.Push(m_float);
this.m_thread.m_currentFrame.OpStack.Push(m_float);
result = true;
break;
case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int?
int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC];
Int pushInt = new Int();
pushInt.mValue = pushvalue;
this._mThread.currentFrame.OpStack.Push(pushInt);
this._mThread.PC++;
this.m_thread.m_currentFrame.OpStack.Push(pushInt);
this.m_thread.PC++;
result = true;
break;
case (byte)OpCode.sipush:
short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
Int pushInt2 = new Int();
pushInt2.mValue = pushvalue2;
this._mThread.currentFrame.OpStack.Push(pushInt2);
this._mThread.PC += 2;
this.m_thread.m_currentFrame.OpStack.Push(pushInt2);
this.m_thread.PC += 2;
result = true;
break;
case (byte)OpCode.fload:
short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]));
Float fload = new Float();
if (this._mThread.currentFrame.LocalVariables[findex1] != null)
if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null)
{
if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float)
{
fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
this._mThread.currentFrame.OpStack.Push(fload);
fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(fload);
}
}
this._mThread.PC++;
this.m_thread.PC++;
result = true;
break;
case (byte)OpCode.iload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null)
if (this.m_thread.m_currentFrame.LocalVariables[0] != null)
{
if (this._mThread.currentFrame.LocalVariables[0] is Int)
if (this.m_thread.m_currentFrame.LocalVariables[0] is Int)
{
Int newInt = new Int();
newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
this._mThread.currentFrame.OpStack.Push(newInt);
newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newInt);
}
}
result = true;
break;
case (byte)OpCode.iload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null)
if (this.m_thread.m_currentFrame.LocalVariables[1] != null)
{
if (this._mThread.currentFrame.LocalVariables[1] is Int)
if (this.m_thread.m_currentFrame.LocalVariables[1] is Int)
{
Int newInt = new Int();
newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
this._mThread.currentFrame.OpStack.Push(newInt);
newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newInt);
}
}
result = true;
break;
case (byte)OpCode.fload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null)
if (this.m_thread.m_currentFrame.LocalVariables[0] != null)
{
if (this._mThread.currentFrame.LocalVariables[0] is Float)
if (this.m_thread.m_currentFrame.LocalVariables[0] is Float)
{
Float newfloat = new Float();
newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
this._mThread.currentFrame.OpStack.Push(newfloat);
newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newfloat);
}
}
result = true;
break;
case (byte)OpCode.fload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null)
if (this.m_thread.m_currentFrame.LocalVariables[1] != null)
{
if (this._mThread.currentFrame.LocalVariables[1] is Float)
if (this.m_thread.m_currentFrame.LocalVariables[1] is Float)
{
Float newfloat = new Float();
newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
this._mThread.currentFrame.OpStack.Push(newfloat);
newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newfloat);
}
}
result = true;
break;
case (byte)OpCode.fload_2:
if (this._mThread.currentFrame.LocalVariables[2] != null)
if (this.m_thread.m_currentFrame.LocalVariables[2] != null)
{
if (this._mThread.currentFrame.LocalVariables[2] is Float)
if (this.m_thread.m_currentFrame.LocalVariables[2] is Float)
{
Float newfloat = new Float();
newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
this._mThread.currentFrame.OpStack.Push(newfloat);
newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newfloat);
}
}
result = true;
break;
case (byte)OpCode.fload_3:
if (this._mThread.currentFrame.LocalVariables[3] != null)
if (this.m_thread.m_currentFrame.LocalVariables[3] != null)
{
if (this._mThread.currentFrame.LocalVariables[3] is Float)
if (this.m_thread.m_currentFrame.LocalVariables[3] is Float)
{
Float newfloat = new Float();
newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
this._mThread.currentFrame.OpStack.Push(newfloat);
newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(newfloat);
}
}
result = true;
break;
case (byte)OpCode.istore:
short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType istor = this._mThread.currentFrame.OpStack.Pop();
short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]));
BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop();
if (istor is Int)
{
this._mThread.currentFrame.LocalVariables[findex3] = (Int)istor;
this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor;
}
this._mThread.PC++;
this.m_thread.PC++;
result = true;
break;
case (byte)OpCode.fstore:
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]));
BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop();
if (fstor is Float)
{
this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor;
}
this._mThread.PC++;
this.m_thread.PC++;
result = true;
break;
case (byte)OpCode.istore_0:
BaseType baset = this._mThread.currentFrame.OpStack.Pop();
BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Int)
{
this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset;
}
result = true;
break;
case (byte)OpCode.istore_1:
baset = this._mThread.currentFrame.OpStack.Pop();
baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Int)
{
this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset;
}
result = true;
break;
case (byte)OpCode.fstore_0:
baset = this._mThread.currentFrame.OpStack.Pop();
baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Float)
{
this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset;
}
result = true;
break;
case (byte)OpCode.fstore_1:
baset = this._mThread.currentFrame.OpStack.Pop();
baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Float)
{
this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset;
}
result = true;
break;
case (byte)OpCode.fstore_2:
baset = this._mThread.currentFrame.OpStack.Pop();
baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Float)
{
this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset;
}
result = true;
break;
case (byte)OpCode.fstore_3:
baset = this._mThread.currentFrame.OpStack.Pop();
baset = this.m_thread.m_currentFrame.OpStack.Pop();
if (baset is Float)
{
this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset;
}
result = true;
break;
case (byte)OpCode.pop:
this._mThread.currentFrame.OpStack.Pop();
this.m_thread.m_currentFrame.OpStack.Pop();
result = true;
break;
case (byte)OpCode.fadd:
BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (bf1 is Float && bf2 is Float)
{
Float nflt = new Float();
nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
this._mThread.currentFrame.OpStack.Push(nflt);
this.m_thread.m_currentFrame.OpStack.Push(nflt);
}
result = true;
break;
case (byte)OpCode.fsub:
BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (bsf1 is Float && bsf2 is Float)
{
Float resf = new Float();
resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
this._mThread.currentFrame.OpStack.Push(resf);
this.m_thread.m_currentFrame.OpStack.Push(resf);
}
result = true;
break;
case (byte)OpCode.imul: //check the order of the two values off the stack is correct
BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (bs1 is Int && bs2 is Int)
{
Int nInt = new Int();
nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
this._mThread.currentFrame.OpStack.Push(nInt);
this.m_thread.m_currentFrame.OpStack.Push(nInt);
}
result = true;
break;
case (byte)OpCode.iinc:
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null)
{
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int)
{
((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1];
}
}
this._mThread.PC += 2;
this.m_thread.PC += 2;
result = true;
break;
case (byte)OpCode.f2i:
BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (conv1 is Float)
{
Int newconv = new Int();
newconv.mValue = (int)((Float)conv1).mValue;
this._mThread.currentFrame.OpStack.Push(newconv);
this.m_thread.m_currentFrame.OpStack.Push(newconv);
}
result = true;
break;
case (byte)OpCode.fcmpl:
BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType flcom1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (flcom1 is Float && flcom2 is Float)
{
Int compres = new Int();
@ -347,13 +347,13 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
compres.mValue = 0;
}
this._mThread.currentFrame.OpStack.Push(compres);
this.m_thread.m_currentFrame.OpStack.Push(compres);
}
result = true;
break;
case (byte)OpCode.fcmpg:
flcom2 = this._mThread.currentFrame.OpStack.Pop();
flcom1 = this._mThread.currentFrame.OpStack.Pop();
flcom2 = this.m_thread.m_currentFrame.OpStack.Pop();
flcom1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (flcom1 is Float && flcom2 is Float)
{
Int compres = new Int();
@ -369,54 +369,54 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
compres.mValue = 0;
}
this._mThread.currentFrame.OpStack.Push(compres);
this.m_thread.m_currentFrame.OpStack.Push(compres);
}
result = true;
break;
case (byte)OpCode.ifge:
short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType compe1 = this._mThread.currentFrame.OpStack.Pop();
short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (compe1 is Int)
{
if (((Int)compe1).mValue >= 0)
{
this._mThread.PC += -1 + compareoffset2;
this.m_thread.PC += -1 + compareoffset2;
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
result = true;
break;
case (byte)OpCode.ifle:
short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (comp1 is Int)
{
if (((Int)comp1).mValue <= 0)
{
this._mThread.PC += -1 + compareoffset1;
this.m_thread.PC += -1 + compareoffset1;
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
result = true;
break;
case (byte)OpCode.if_icmpge:
short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType bc1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (bc1 is Int && bc2 is Int)
{
//Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
@ -424,25 +424,25 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
// Console.WriteLine("branch compare true , offset is " +compareoffset);
// Console.WriteLine("current PC is " + this._mThread.PC);
this._mThread.PC += -1 + compareoffset;
this.m_thread.PC += -1 + compareoffset;
//Console.WriteLine("new PC is " + this._mThread.PC);
}
else
{
//Console.WriteLine("branch compare false");
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
result = true;
break;
case (byte)OpCode.if_icmple:
short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop();
BaseType bcl1 = this.m_thread.m_currentFrame.OpStack.Pop();
if (bcl1 is Int && bcl2 is Int)
{
//Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
@ -450,47 +450,47 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
// Console.WriteLine("branch compare true , offset is " + compareloffset);
// Console.WriteLine("current PC is " + this._mThread.PC);
this._mThread.PC += -1 + compareloffset;
this.m_thread.PC += -1 + compareloffset;
// Console.WriteLine("new PC is " + this._mThread.PC);
}
else
{
//Console.WriteLine("branch compare false");
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
result = true;
break;
case (byte)OpCode._goto:
short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
this._mThread.PC += -1 + offset;
short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
this.m_thread.PC += -1 + offset;
result = true;
break;
case (byte)OpCode.getstatic:
short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value)
{
//from this class
if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
{
Float retFloat = new Float();
retFloat.mValue = ((Float)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
this._mThread.currentFrame.OpStack.Push(retFloat);
retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
this.m_thread.m_currentFrame.OpStack.Push(retFloat);
}
else if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int)
else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int)
{
Int retInt = new Int();
retInt.mValue = ((Int)this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue;
// Console.WriteLine("getting static field, " + retInt.mValue);
this._mThread.currentFrame.OpStack.Push(retInt);
this.m_thread.m_currentFrame.OpStack.Push(retInt);
}
}
}
@ -499,36 +499,36 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
//get from a different class
}
}
this._mThread.PC += 2;
this.m_thread.PC += 2;
result = true;
break;
case (byte)OpCode.putstatic:
fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType addstatic = this._mThread.currentFrame.OpStack.Pop();
if (this._mThread.currentClass._constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]);
BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop();
if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value)
{
// this class
if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value))
{
if (addstatic is Float)
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float)
{
Float newf = new Float();
newf.mValue = ((Float)addstatic).mValue;
this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf;
this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf;
}
}
else if (addstatic is Int)
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int)
if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int)
{
//Console.WriteLine("setting static field to " + ((Int)addstatic).mValue);
Int newi = new Int();
newi.mValue = ((Int)addstatic).mValue;
this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi;
this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi;
}
}
}
@ -538,7 +538,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
// a different class
}
}
this._mThread.PC += 2;
this.m_thread.PC += 2;
result = true;
break;

View File

@ -46,10 +46,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
switch (opcode)
{
case 184:
short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]);
if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
{
string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value;
string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value;
string typeparam = "";
string typereturn = "";
int firstbrak = 0;
@ -58,16 +58,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
secondbrak = typ.LastIndexOf(')');
typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value)
{
//calling a method in this class
if (typeparam.Length == 0)
{
this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2));
this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2));
}
else
{
this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2));
this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2));
}
}
else
@ -75,15 +75,15 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
//calling a method of a different class
// OpenSimAPI Class
if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
{
this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null);
this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null);
}
}
}
else
{
this._mThread.PC += 2;
this.m_thread.PC += 2;
}
result = true;
break;

View File

@ -37,17 +37,17 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
private partial class Interpreter
{
private Thread _mThread;
private Thread m_thread;
public Interpreter(Thread parentThread)
{
_mThread = parentThread;
m_thread = parentThread;
}
public bool Excute()
{
bool run = true;
byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++];
// Console.WriteLine("opCode is: " + currentOpCode);
bool handled = false;
@ -60,64 +60,64 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
if (currentOpCode == 172)
{
if (this._mThread.stack.StackFrames.Count > 1)
if (this.m_thread.stack.StackFrames.Count > 1)
{
Console.WriteLine("returning int from function");
int retPC1 = this._mThread.currentFrame.ReturnPC;
BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
this._mThread.stack.StackFrames.Pop();
this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
this._mThread.PC = retPC1;
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
this.m_thread.stack.StackFrames.Pop();
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
this.m_thread.PC = retPC1;
if (bas1 is Int)
{
this._mThread.currentFrame.OpStack.Push((Int)bas1);
this.m_thread.m_currentFrame.OpStack.Push((Int)bas1);
}
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
this.m_thread.stack.StackFrames.Pop();
run = false;
}
handled = true;
}
if (currentOpCode == 174)
{
if (this._mThread.stack.StackFrames.Count > 1)
if (this.m_thread.stack.StackFrames.Count > 1)
{
Console.WriteLine("returning float from function");
int retPC1 = this._mThread.currentFrame.ReturnPC;
BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
this._mThread.stack.StackFrames.Pop();
this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
this._mThread.PC = retPC1;
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
this.m_thread.stack.StackFrames.Pop();
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
this.m_thread.PC = retPC1;
if (bas1 is Float)
{
this._mThread.currentFrame.OpStack.Push((Float)bas1);
this.m_thread.m_currentFrame.OpStack.Push((Float)bas1);
}
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
this.m_thread.stack.StackFrames.Pop();
run = false;
}
handled = true;
}
if (currentOpCode == 177)
{
if (this._mThread.stack.StackFrames.Count > 1)
if (this.m_thread.stack.StackFrames.Count > 1)
{
Console.WriteLine("returning from function");
int retPC = this._mThread.currentFrame.ReturnPC;
this._mThread.stack.StackFrames.Pop();
this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
this._mThread.PC = retPC;
int retPC = this.m_thread.m_currentFrame.ReturnPC;
this.m_thread.stack.StackFrames.Pop();
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
this.m_thread.PC = retPC;
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
this.m_thread.stack.StackFrames.Pop();
run = false;
}
handled = true;

View File

@ -44,10 +44,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public static Scene World;
private int PC = 0;
private Stack stack;
private Interpreter mInterpreter;
private Interpreter m_Interpreter;
public ClassRecord currentClass;
public ClassInstance currentInstance;
private StackFrame currentFrame;
private StackFrame m_currentFrame;
public int excutionCounter = 0;
public bool running = false;
@ -55,7 +55,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public Thread()
{
this.mInterpreter = new Interpreter(this);
this.m_Interpreter = new Interpreter(this);
this.stack = new Stack();
}
@ -67,24 +67,24 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void StartMethod(ClassRecord rec, string methName)
{
currentFrame = new StackFrame();
this.stack.StackFrames.Push(currentFrame);
m_currentFrame = new StackFrame();
this.stack.StackFrames.Push(m_currentFrame);
this.currentClass = rec;
currentClass.StartMethod(this, methName);
}
public void StartMethod( string methName)
{
currentFrame = new StackFrame();
this.stack.StackFrames.Push(currentFrame);
m_currentFrame = new StackFrame();
this.stack.StackFrames.Push(m_currentFrame);
currentClass.StartMethod(this, methName);
}
public void JumpToStaticVoidMethod(string methName, int returnPC)
{
currentFrame = new StackFrame();
currentFrame.ReturnPC = returnPC;
this.stack.StackFrames.Push(currentFrame);
m_currentFrame = new StackFrame();
m_currentFrame.ReturnPC = returnPC;
this.stack.StackFrames.Push(m_currentFrame);
currentClass.StartMethod(this, methName);
}
@ -92,11 +92,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{
if (param == "I")
{
BaseType bs1 = currentFrame.OpStack.Pop();
currentFrame = new StackFrame();
currentFrame.ReturnPC = returnPC;
this.stack.StackFrames.Push(currentFrame);
currentFrame.LocalVariables[0] = ((Int)bs1);
BaseType bs1 = m_currentFrame.OpStack.Pop();
m_currentFrame = new StackFrame();
m_currentFrame.ReturnPC = returnPC;
this.stack.StackFrames.Push(m_currentFrame);
m_currentFrame.LocalVariables[0] = ((Int)bs1);
currentClass.StartMethod(this, methName);
}
if (param == "F")
@ -113,7 +113,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public bool Excute()
{
excutionCounter++;
return this.mInterpreter.Excute();
return this.m_Interpreter.Excute();
}
}
}

View File

@ -27,325 +27,325 @@
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace OpenSim.Region.Scripting.LSL
namespace OpenSim.Region.Scripting.LSL
{
partial class LSO_Parser
{
//LSO_Enums MyLSO_Enums = new LSO_Enums();
internal bool LSL_PROCESS_OPCODE(ILGenerator il)
{
partial class LSO_Parser
byte bp1;
UInt32 u32p1;
UInt16 opcode = br_read(1)[0];
Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString());
string idesc = ((LSO_Enums.Operation_Table)opcode).ToString();
switch ((LSO_Enums.Operation_Table)opcode)
{
//LSO_Enums MyLSO_Enums = new LSO_Enums();
internal bool LSL_PROCESS_OPCODE(ILGenerator il)
{
byte bp1;
UInt32 u32p1;
UInt16 opcode = br_read(1)[0];
Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString());
string idesc = ((LSO_Enums.Operation_Table)opcode).ToString();
switch ((LSO_Enums.Operation_Table)opcode)
{
case LSO_Enums.Operation_Table.POP:
case LSO_Enums.Operation_Table.POPL:
case LSO_Enums.Operation_Table.POPV:
case LSO_Enums.Operation_Table.POPQ:
case LSO_Enums.Operation_Table.POPIP:
case LSO_Enums.Operation_Table.POPBP:
case LSO_Enums.Operation_Table.POPSP:
case LSO_Enums.Operation_Table.POPSLR:
// ignore -- builds callframe
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Pop);");
il.Emit(OpCodes.Pop);
break;
case LSO_Enums.Operation_Table.POPARG:
Common.SendToDebug("Instruction " + idesc + ": Ignored");
Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack ");
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
case LSO_Enums.Operation_Table.POP:
case LSO_Enums.Operation_Table.POPL:
case LSO_Enums.Operation_Table.POPV:
case LSO_Enums.Operation_Table.POPQ:
case LSO_Enums.Operation_Table.POPIP:
case LSO_Enums.Operation_Table.POPBP:
case LSO_Enums.Operation_Table.POPSP:
case LSO_Enums.Operation_Table.POPSLR:
// ignore -- builds callframe
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Pop);");
il.Emit(OpCodes.Pop);
break;
case LSO_Enums.Operation_Table.POPARG:
Common.SendToDebug("Instruction " + idesc + ": Ignored");
Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack ");
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.STORE:
case LSO_Enums.Operation_Table.STORES:
case LSO_Enums.Operation_Table.STOREL:
case LSO_Enums.Operation_Table.STOREV:
case LSO_Enums.Operation_Table.STOREQ:
case LSO_Enums.Operation_Table.STOREG:
case LSO_Enums.Operation_Table.STOREGS:
case LSO_Enums.Operation_Table.STOREGL:
case LSO_Enums.Operation_Table.STOREGV:
case LSO_Enums.Operation_Table.STOREGQ:
case LSO_Enums.Operation_Table.LOADP:
case LSO_Enums.Operation_Table.LOADSP:
case LSO_Enums.Operation_Table.LOADLP:
case LSO_Enums.Operation_Table.LOADVP:
case LSO_Enums.Operation_Table.LOADQP:
case LSO_Enums.Operation_Table.PUSH:
case LSO_Enums.Operation_Table.PUSHS:
case LSO_Enums.Operation_Table.PUSHL:
case LSO_Enums.Operation_Table.PUSHV:
case LSO_Enums.Operation_Table.PUSHQ:
case LSO_Enums.Operation_Table.PUSHG:
case LSO_Enums.Operation_Table.PUSHGS:
case LSO_Enums.Operation_Table.PUSHGL:
case LSO_Enums.Operation_Table.PUSHGV:
case LSO_Enums.Operation_Table.PUSHGQ:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// None
case LSO_Enums.Operation_Table.PUSHIP:
case LSO_Enums.Operation_Table.PUSHBP:
case LSO_Enums.Operation_Table.PUSHSP:
// Push Stack Top (Memory Address) to stack
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, " + myHeader.SP + ");");
Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack");
il.Emit(OpCodes.Ldc_I4, myHeader.SP);
break;
// BYTE
case LSO_Enums.Operation_Table.PUSHARGB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// INTEGER
case LSO_Enums.Operation_Table.PUSHARGI:
// TODO: What is size of integer?
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes.Ldc_I4, " + u32p1 + ");");
Common.SendToDebug("Param1: " + u32p1);
il.Emit(OpCodes.Ldc_I4, u32p1);
break;
// FLOAT
case LSO_Enums.Operation_Table.PUSHARGF:
// TODO: What is size of float?
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// STRING
case LSO_Enums.Operation_Table.PUSHARGS:
string s = Read_String();
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldstr, \"" + s + "\");");
Common.SendToDebug("Param1: " + s);
il.Emit(OpCodes.Ldstr, s);
break;
// VECTOR z,y,x
case LSO_Enums.Operation_Table.PUSHARGV:
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// ROTATION s,z,y,x
case LSO_Enums.Operation_Table.PUSHARGQ:
Common.SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.PUSHARGE:
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
//Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes., " + u32p1 + ");");
Common.SendToDebug("Instruction " + idesc + ": Ignoring (not in use according to doc)");
//Common.SendToDebug("Instruction " + idesc + ": Description: Pushes X bytes of $00 onto the stack (used to put space for local variable memory for a call)");
Common.SendToDebug("Param1: " + u32p1);
//il.Emit(OpCodes.ldc_i4, u32p1);
//if (u32p1 > 0) {
//for (int _ic=0; _ic < u32p1; _ic++)
//{
// Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldnull);");
// il.Emit(OpCodes.Ldnull);
//}
break;
// BYTE
case LSO_Enums.Operation_Table.ADD:
bp1 = br_read(1)[0];
Common.SendToDebug("Instruction " + idesc + ": Add type: " + ((LSO_Enums.OpCode_Add_TypeDefs)bp1).ToString());
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Add_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Add_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc
+ ": il.Emit(OpCodes.Call, typeof(System.String).GetMethod(\"Concat\", new Type[] { typeof(object), typeof(object) }));");
il.Emit(OpCodes.Call, typeof(System.String).GetMethod
("Concat", new Type[] { typeof(object), typeof(object) }));
break;
case LSO_Enums.OpCode_Add_TypeDefs.UInt32:
default:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Add);");
il.Emit(OpCodes.Add);
break;
}
//il.Emit(OpCodes.Add, p1);
break;
case LSO_Enums.Operation_Table.SUB:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Sub);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Sub);
//il.Emit(OpCodes.Sub, p1);
break;
case LSO_Enums.Operation_Table.MUL:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Mul);");
// LONG
case LSO_Enums.Operation_Table.STORE:
case LSO_Enums.Operation_Table.STORES:
case LSO_Enums.Operation_Table.STOREL:
case LSO_Enums.Operation_Table.STOREV:
case LSO_Enums.Operation_Table.STOREQ:
case LSO_Enums.Operation_Table.STOREG:
case LSO_Enums.Operation_Table.STOREGS:
case LSO_Enums.Operation_Table.STOREGL:
case LSO_Enums.Operation_Table.STOREGV:
case LSO_Enums.Operation_Table.STOREGQ:
case LSO_Enums.Operation_Table.LOADP:
case LSO_Enums.Operation_Table.LOADSP:
case LSO_Enums.Operation_Table.LOADLP:
case LSO_Enums.Operation_Table.LOADVP:
case LSO_Enums.Operation_Table.LOADQP:
case LSO_Enums.Operation_Table.PUSH:
case LSO_Enums.Operation_Table.PUSHS:
case LSO_Enums.Operation_Table.PUSHL:
case LSO_Enums.Operation_Table.PUSHV:
case LSO_Enums.Operation_Table.PUSHQ:
case LSO_Enums.Operation_Table.PUSHG:
case LSO_Enums.Operation_Table.PUSHGS:
case LSO_Enums.Operation_Table.PUSHGL:
case LSO_Enums.Operation_Table.PUSHGV:
case LSO_Enums.Operation_Table.PUSHGQ:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// None
case LSO_Enums.Operation_Table.PUSHIP:
case LSO_Enums.Operation_Table.PUSHBP:
case LSO_Enums.Operation_Table.PUSHSP:
// Push Stack Top (Memory Address) to stack
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, " + myHeader.SP + ");");
Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack");
il.Emit(OpCodes.Ldc_I4, myHeader.SP);
break;
// BYTE
case LSO_Enums.Operation_Table.PUSHARGB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// INTEGER
case LSO_Enums.Operation_Table.PUSHARGI:
// TODO: What is size of integer?
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes.Ldc_I4, " + u32p1 + ");");
Common.SendToDebug("Param1: " + u32p1);
il.Emit(OpCodes.Ldc_I4, u32p1);
break;
// FLOAT
case LSO_Enums.Operation_Table.PUSHARGF:
// TODO: What is size of float?
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// STRING
case LSO_Enums.Operation_Table.PUSHARGS:
string s = Read_String();
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldstr, \"" + s + "\");");
Common.SendToDebug("Param1: " + s);
il.Emit(OpCodes.Ldstr, s);
break;
// VECTOR z,y,x
case LSO_Enums.Operation_Table.PUSHARGV:
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// ROTATION s,z,y,x
case LSO_Enums.Operation_Table.PUSHARGQ:
Common.SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.PUSHARGE:
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
//Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes., " + u32p1 + ");");
Common.SendToDebug("Instruction " + idesc + ": Ignoring (not in use according to doc)");
//Common.SendToDebug("Instruction " + idesc + ": Description: Pushes X bytes of $00 onto the stack (used to put space for local variable memory for a call)");
Common.SendToDebug("Param1: " + u32p1);
//il.Emit(OpCodes.ldc_i4, u32p1);
//if (u32p1 > 0) {
//for (int _ic=0; _ic < u32p1; _ic++)
//{
// Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldnull);");
// il.Emit(OpCodes.Ldnull);
//}
break;
// BYTE
case LSO_Enums.Operation_Table.ADD:
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Mul);
//il.Emit(OpCodes.Mul, p1);
break;
case LSO_Enums.Operation_Table.DIV:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Div);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Div);
//il.Emit(OpCodes.Div, p1);
break;
case LSO_Enums.Operation_Table.EQ:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ceq);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Ceq);
//il.Emit(OpCodes.Ceq, p1);
break;
case LSO_Enums.Operation_Table.NEQ:
case LSO_Enums.Operation_Table.LEQ:
case LSO_Enums.Operation_Table.GEQ:
case LSO_Enums.Operation_Table.LESS:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Clt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Clt_Un);
//il.Emit(OpCodes.Clt, p1);
break;
case LSO_Enums.Operation_Table.GREATER:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Cgt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Cgt_Un);
//il.Emit(OpCodes.Cgt, p1);
break;
case LSO_Enums.Operation_Table.MOD:
case LSO_Enums.Operation_Table.BOOLOR:
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
break;
// LONG
case LSO_Enums.Operation_Table.JUMP:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE, LONG
case LSO_Enums.Operation_Table.JUMPIF:
case LSO_Enums.Operation_Table.JUMPNIF:
Common.SendToDebug("Param1: " + br_read(1)[0]);
Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.STATE:
bp1 = br_read(1)[0];
//il.Emit(OpCodes.Ld); // Load local variable 0 onto stack
//il.Emit(OpCodes.Ldc_I4, 0); // Push index position
//il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value
//il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value
break;
case LSO_Enums.Operation_Table.CALL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE
case LSO_Enums.Operation_Table.CAST:
bp1 = br_read(1)[0];
Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1));
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Cast_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Calli, typeof(System.Convert).GetMethod(\"ToString\", new Type[] { typeof(object) }));");
//il.Emit(OpCodes.Box, typeof (UInt32));
il.Emit(OpCodes.Calli, typeof(Common).GetMethod
("Cast_ToString", new Type[] { typeof(object) }));
//il.Emit(OpCodes.Box, typeof(System.UInt32) );
//il.Emit(OpCodes.Box, typeof(string));
Common.SendToDebug("Instruction " + idesc + ": Add type: " + ((LSO_Enums.OpCode_Add_TypeDefs)bp1).ToString());
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Add_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Add_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc
+ ": il.Emit(OpCodes.Call, typeof(System.String).GetMethod(\"Concat\", new Type[] { typeof(object), typeof(object) }));");
il.Emit(OpCodes.Call, typeof(System.String).GetMethod
("Concat", new Type[] { typeof(object), typeof(object) }));
//il.Emit(OpCodes.Conv_R8);
//il.Emit(OpCodes.Call, typeof(System.Convert).GetMethod
// ("ToString", new Type[] { typeof(float) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!");
break;
}
break;
// LONG
case LSO_Enums.Operation_Table.STACKTOS:
case LSO_Enums.Operation_Table.STACKTOL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
case LSO_Enums.OpCode_Add_TypeDefs.UInt32:
default:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Add);");
il.Emit(OpCodes.Add);
break;
// BYTE
case LSO_Enums.Operation_Table.PRINT:
case LSO_Enums.Operation_Table.CALLLIB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// SHORT
case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
// TODO: What is size of short?
UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0);
Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString());
Common.SendToDebug("Param1: " + U16p1);
switch ((LSO_Enums.BuiltIn_Functions)U16p1)
{
case LSO_Enums.BuiltIn_Functions.llSay:
Common.SendToDebug("Instruction " + idesc + " " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()
+ ": Mapped to internal function");
//il.Emit(OpCodes.Ldstr, "INTERNAL COMMAND: llSay({0}, \"{1}\"");
//il.Emit(OpCodes.Call, typeof(IL_Helper).GetMethod("ReverseFormatString",
// new Type[] { typeof(string), typeof(UInt32), typeof(string) }
//));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Call,
// typeof(Console).GetMethod("WriteLine",
// new Type[] { typeof(string) }
//));
il.Emit(OpCodes.Call,
typeof(Common).GetMethod("SendToLog",
new Type[] { typeof(string) }
));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Ldind_I2, 0);
//il.Emit(OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) }));
//il.EmitCalli(OpCodes.Calli,
//il.Emit(OpCodes.Call, typeof().GetMethod
// ("llSay", new Type[] { typeof(UInt32), typeof(string) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() + ": INTERNAL COMMAND NOT IMPLEMENTED");
break;
}
//Common.SendToDebug("Instruction " + idesc + ": DEBUG: Faking return code:");
//Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, 0);");
//il.Emit(OpCodes.Ldc_I4, 0);
break;
// RETURN
case LSO_Enums.Operation_Table.RETURN:
Common.SendToDebug("Last OPCODE was return command. Code chunk execution complete.");
return true;
}
return false;
}
//il.Emit(OpCodes.Add, p1);
break;
case LSO_Enums.Operation_Table.SUB:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Sub);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Sub);
//il.Emit(OpCodes.Sub, p1);
break;
case LSO_Enums.Operation_Table.MUL:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Mul);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Mul);
//il.Emit(OpCodes.Mul, p1);
break;
case LSO_Enums.Operation_Table.DIV:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Div);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Div);
//il.Emit(OpCodes.Div, p1);
break;
case LSO_Enums.Operation_Table.EQ:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ceq);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Ceq);
//il.Emit(OpCodes.Ceq, p1);
break;
case LSO_Enums.Operation_Table.NEQ:
case LSO_Enums.Operation_Table.LEQ:
case LSO_Enums.Operation_Table.GEQ:
case LSO_Enums.Operation_Table.LESS:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Clt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Clt_Un);
//il.Emit(OpCodes.Clt, p1);
break;
case LSO_Enums.Operation_Table.GREATER:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Cgt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Cgt_Un);
//il.Emit(OpCodes.Cgt, p1);
break;
case LSO_Enums.Operation_Table.MOD:
case LSO_Enums.Operation_Table.BOOLOR:
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
break;
// LONG
case LSO_Enums.Operation_Table.JUMP:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE, LONG
case LSO_Enums.Operation_Table.JUMPIF:
case LSO_Enums.Operation_Table.JUMPNIF:
Common.SendToDebug("Param1: " + br_read(1)[0]);
Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.STATE:
bp1 = br_read(1)[0];
//il.Emit(OpCodes.Ld); // Load local variable 0 onto stack
//il.Emit(OpCodes.Ldc_I4, 0); // Push index position
//il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value
//il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value
break;
case LSO_Enums.Operation_Table.CALL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE
case LSO_Enums.Operation_Table.CAST:
bp1 = br_read(1)[0];
Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1));
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Cast_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Calli, typeof(System.Convert).GetMethod(\"ToString\", new Type[] { typeof(object) }));");
//il.Emit(OpCodes.Box, typeof (UInt32));
il.Emit(OpCodes.Calli, typeof(Common).GetMethod
("Cast_ToString", new Type[] { typeof(object) }));
//il.Emit(OpCodes.Box, typeof(System.UInt32) );
//il.Emit(OpCodes.Box, typeof(string));
//il.Emit(OpCodes.Conv_R8);
//il.Emit(OpCodes.Call, typeof(System.Convert).GetMethod
// ("ToString", new Type[] { typeof(float) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!");
break;
}
break;
// LONG
case LSO_Enums.Operation_Table.STACKTOS:
case LSO_Enums.Operation_Table.STACKTOL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE
case LSO_Enums.Operation_Table.PRINT:
case LSO_Enums.Operation_Table.CALLLIB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// SHORT
case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
// TODO: What is size of short?
UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0);
Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString());
Common.SendToDebug("Param1: " + U16p1);
switch ((LSO_Enums.BuiltIn_Functions)U16p1)
{
case LSO_Enums.BuiltIn_Functions.llSay:
Common.SendToDebug("Instruction " + idesc + " " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()
+ ": Mapped to internal function");
//il.Emit(OpCodes.Ldstr, "INTERNAL COMMAND: llSay({0}, \"{1}\"");
//il.Emit(OpCodes.Call, typeof(IL_Helper).GetMethod("ReverseFormatString",
// new Type[] { typeof(string), typeof(UInt32), typeof(string) }
//));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Call,
// typeof(Console).GetMethod("WriteLine",
// new Type[] { typeof(string) }
//));
il.Emit(OpCodes.Call,
typeof(Common).GetMethod("SendToLog",
new Type[] { typeof(string) }
));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Ldind_I2, 0);
//il.Emit(OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) }));
//il.EmitCalli(OpCodes.Calli,
//il.Emit(OpCodes.Call, typeof().GetMethod
// ("llSay", new Type[] { typeof(UInt32), typeof(string) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() + ": INTERNAL COMMAND NOT IMPLEMENTED");
break;
}
//Common.SendToDebug("Instruction " + idesc + ": DEBUG: Faking return code:");
//Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, 0);");
//il.Emit(OpCodes.Ldc_I4, 0);
break;
// RETURN
case LSO_Enums.Operation_Table.RETURN:
Common.SendToDebug("Last OPCODE was return command. Code chunk execution complete.");
return true;
}
return false;
}
}
}