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.
afrisby
MW 2007-08-01 16:50:20 +00:00
parent 2e6505f38e
commit edc572dacf
19 changed files with 580 additions and 135 deletions

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.Capabilities
private string m_requestPath = "0000/"; private string m_requestPath = "0000/";
private string m_mapLayerPath = "0001/"; private string m_mapLayerPath = "0001/";
private string m_newInventory = "0002/"; private string m_newInventory = "0002/";
// private string m_requestTexture = "0003/"; //private string m_requestTexture = "0003/";
private string m_notecardUpdatePath = "0004/"; private string m_notecardUpdatePath = "0004/";
//private string eventQueue = "0100/"; //private string eventQueue = "0100/";
private BaseHttpServer httpListener; private BaseHttpServer httpListener;
@ -79,6 +79,7 @@ namespace OpenSim.Region.Capabilities
httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest));
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
//AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture);
AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory);
} }
@ -116,7 +117,6 @@ namespace OpenSim.Region.Capabilities
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
caps.MapLayer = capsBaseUrl + m_mapLayerPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath;
caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
//caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
return caps; return caps;
} }
@ -299,7 +299,7 @@ namespace OpenSim.Region.Capabilities
private LLUUID newAssetID; private LLUUID newAssetID;
private LLUUID inventoryItemID; private LLUUID inventoryItemID;
private BaseHttpServer httpListener; private BaseHttpServer httpListener;
private bool SaveImages = false; private bool SaveAssets = false;
private string m_assetName = ""; private string m_assetName = "";
/// <summary> /// <summary>
@ -338,8 +338,8 @@ namespace OpenSim.Region.Capabilities
httpListener.RemoveStreamHandler("POST", uploaderPath); httpListener.RemoveStreamHandler("POST", uploaderPath);
if(this.SaveImages) if(this.SaveAssets)
this.SaveImageToFile(m_assetName + ".jp2", data); this.SaveAssetToFile(m_assetName + ".jp2", data);
if (OnUpLoad != null) if (OnUpLoad != null)
{ {
@ -349,7 +349,7 @@ namespace OpenSim.Region.Capabilities
return res; return res;
} }
private void SaveImageToFile(string filename, byte[] data) private void SaveAssetToFile(string filename, byte[] data)
{ {
FileStream fs = File.Create(filename); FileStream fs = File.Create(filename);
BinaryWriter bw = new BinaryWriter(fs); BinaryWriter bw = new BinaryWriter(fs);
@ -360,3 +360,4 @@ namespace OpenSim.Region.Capabilities
} }
} }
} }

View File

@ -6,9 +6,10 @@ namespace OpenSim.Region.Capabilities
public string MapLayer = ""; public string MapLayer = "";
public string NewFileAgentInventory = ""; public string NewFileAgentInventory = "";
//public string EventQueueGet = ""; //public string EventQueueGet = "";
//public string RequestTextureDownload = ""; // public string RequestTextureDownload = "";
//public string ChatSessionRequest = ""; // public string ChatSessionRequest = "";
public string UpdateNotecardAgentInventory = ""; public string UpdateNotecardAgentInventory = "";
// public string ParcelVoiceInfoRequest = "";
public LLSDCapsDetails() public LLSDCapsDetails()
{ {
@ -16,3 +17,5 @@ namespace OpenSim.Region.Capabilities
} }
} }
} }

View File

@ -211,5 +211,6 @@ namespace OpenSim.Framework.Interfaces
void SendNameReply(LLUUID profileId, string firstname, string lastname); void SendNameReply(LLUUID profileId, string firstname, string lastname);
void SendAlertMessage(string message); void SendAlertMessage(string message);
void SendAgentAlertMessage(string message, bool modal); void SendAgentAlertMessage(string message, bool modal);
void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url);
} }
} }

View File

@ -142,5 +142,8 @@ namespace OpenSim.Framework
public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){} public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
public void SendAlertMessage(string message) { } public void SendAlertMessage(string message) { }
public void SendAgentAlertMessage(string message, bool modal) { } public void SendAgentAlertMessage(string message, bool modal) { }
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
} }
} }

View File

@ -133,4 +133,4 @@ namespace OpenSim.Framework.InventoryServiceBase
} }
} }
} }
} }

View File

@ -658,6 +658,19 @@ namespace OpenSim.Region.ClientStack
OutPacket(alertPack); OutPacket(alertPack);
} }
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url)
{
LoadURLPacket loadURL = new LoadURLPacket();
loadURL.Data.ObjectName = Helpers.StringToField(objectname);
loadURL.Data.ObjectID = objectID;
loadURL.Data.OwnerID = ownerID;
loadURL.Data.OwnerIsGroup = groupOwned;
loadURL.Data.Message = Helpers.StringToField(message);
loadURL.Data.URL = Helpers.StringToField(url);
OutPacket(loadURL);
}
#region Appearance/ Wearables Methods #region Appearance/ Wearables Methods
/// <summary> /// <summary>

View File

@ -15,6 +15,7 @@ namespace OpenSim.Region.Communications.Local
private NetworkServersInfo serversInfo; private NetworkServersInfo serversInfo;
private uint defaultHomeX ; private uint defaultHomeX ;
private uint defaultHomeY; private uint defaultHomeY;
public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData) public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
{ {
m_Parent = parent; m_Parent = parent;

View File

@ -152,7 +152,6 @@ namespace OpenSim.Region.Communications.OGS1
{ {
return this.regions[regionHandle]; return this.regions[regionHandle];
} }
//TODO not a region in this instance so ask remote grid server
Hashtable requestData = new Hashtable(); Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString(); requestData["region_handle"] = regionHandle.ToString();

View File

@ -23,7 +23,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int primCount public int PrimCount
{ {
get get
{ {
@ -99,7 +99,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
{ {
if (part.m_localID == localID) if (part.LocalID == localID)
{ {
return part; return part;
} }
@ -185,7 +185,7 @@ namespace OpenSim.Region.Environment.Scenes
AllNewSceneObjectPart2 part = this.GetChildPrim(localID); AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
if (part != null) if (part != null)
{ {
if (part.uuid == this.m_rootPart.uuid) if (part.UUID == this.m_rootPart.UUID)
{ {
this.UpdateRootPosition(pos); this.UpdateRootPosition(pos);
} }
@ -210,7 +210,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values) foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values)
{ {
if (obPart.uuid != this.m_rootPart.uuid) if (obPart.UUID != this.m_rootPart.UUID)
{ {
obPart.OffsetPosition = obPart.OffsetPosition + diff; obPart.OffsetPosition = obPart.OffsetPosition + diff;
} }
@ -244,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes
AllNewSceneObjectPart2 part = this.GetChildPrim(localID); AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
if (part != null) if (part != null)
{ {
if (part.uuid == this.m_rootPart.uuid) if (part.UUID == this.m_rootPart.UUID)
{ {
this.UpdateRootRotation(rot); this.UpdateRootRotation(rot);
} }
@ -262,7 +262,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values) foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values)
{ {
if (prim.uuid != this.m_rootPart.uuid) if (prim.UUID != this.m_rootPart.UUID)
{ {
Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
axPos = oldParentRot * axPos; axPos = oldParentRot * axPos;
@ -283,8 +283,8 @@ namespace OpenSim.Region.Environment.Scenes
private void SetPartAsRoot(AllNewSceneObjectPart2 part) private void SetPartAsRoot(AllNewSceneObjectPart2 part)
{ {
this.m_rootPart = part; this.m_rootPart = part;
this.m_uuid = part.uuid; this.m_uuid = part.UUID;
this.m_localId = part.m_localID; this.m_localId = part.LocalID;
} }
/// <summary> /// <summary>

View File

@ -14,21 +14,15 @@ namespace OpenSim.Region.Environment.Scenes
{ {
private const uint FULL_MASK_PERMISSIONS = 2147483647; private const uint FULL_MASK_PERMISSIONS = 2147483647;
private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
private ulong m_regionHandle;
public string SitName = ""; public string SitName = "";
public string TouchName = ""; public string TouchName = "";
public string Text = ""; public string Text = "";
public LLUUID CreatorID; public LLUUID CreatorID;
public LLUUID OwnerID; public LLUUID OwnerID;
public LLUUID GroupID;
public LLUUID LastOwnerID; public LLUUID LastOwnerID;
public Int32 CreationDate; public Int32 CreationDate;
public LLUUID uuid;
public uint m_localID;
public uint ParentID = 0; public uint ParentID = 0;
public uint OwnerMask = FULL_MASK_PERMISSIONS; public uint OwnerMask = FULL_MASK_PERMISSIONS;
@ -43,6 +37,33 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties #region Properties
protected LLUUID m_uuid;
public LLUUID UUID
{
get
{
return m_uuid;
}
set
{
value = m_uuid;
}
}
protected uint m_localID;
public uint LocalID
{
get
{
return m_localID;
}
set
{
m_localID = value;
}
}
protected string m_name; protected string m_name;
/// <summary> /// <summary>
/// ///
@ -53,6 +74,32 @@ namespace OpenSim.Region.Environment.Scenes
set { m_name = value; } set { m_name = value; }
} }
protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags) 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
public uint ObjectFlags
{
get
{
return (uint)m_flags;
}
set
{
m_flags =(LLObject.ObjectFlags) value;
}
}
protected ulong m_regionHandle;
public ulong RegionHandle
{
get
{
return m_regionHandle;
}
set
{
m_regionHandle = value;
}
}
protected LLVector3 m_offset; protected LLVector3 m_offset;
public LLVector3 OffsetPosition public LLVector3 OffsetPosition
{ {
@ -79,6 +126,48 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
protected LLVector3 m_velocity;
/// <summary></summary>
public LLVector3 Velocity
{
get
{
return m_velocity;
}
set
{
m_velocity = value;
}
}
protected LLVector3 m_angularVelocity;
/// <summary></summary>
public LLVector3 AngularVelocity
{
get
{
return m_angularVelocity;
}
set
{
m_angularVelocity = value;
}
}
protected LLVector3 m_acceleration;
/// <summary></summary>
public LLVector3 Acceleration
{
get
{
return m_acceleration;
}
set
{
m_acceleration = value;
}
}
private string m_description = ""; private string m_description = "";
public string Description public string Description
{ {
@ -123,14 +212,14 @@ namespace OpenSim.Region.Environment.Scenes
this.OwnerID = ownerID; this.OwnerID = ownerID;
this.CreatorID = this.OwnerID; this.CreatorID = this.OwnerID;
this.LastOwnerID = LLUUID.Zero; this.LastOwnerID = LLUUID.Zero;
this.uuid = LLUUID.Random(); this.UUID = LLUUID.Random();
this.m_localID = (uint)(localID); this.LocalID = (uint)(localID);
this.m_Shape = shape; this.m_Shape = shape;
this.OffsetPosition = position; this.OffsetPosition = position;
//temporary code just so the m_flags field doesn't give a compiler warning //temporary code just so the m_flags field doesn't give a compiler warning
if (m_flags == 1) if (m_flags ==LLObject.ObjectFlags.AllowInventoryDrop)
{ {
} }

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using Axiom.Math; using Axiom.Math;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
@ -27,6 +29,7 @@ namespace OpenSim.Region.Environment.Scenes
public LLUUID CreatorID; public LLUUID CreatorID;
public LLUUID OwnerID; public LLUUID OwnerID;
public LLUUID LastOwnerID; public LLUUID LastOwnerID;
public Int32 CreationDate; public Int32 CreationDate;
public uint ParentID = 0; public uint ParentID = 0;

View File

@ -550,7 +550,7 @@ namespace OpenSim.Region.Environment.Scenes
m_estateManager.sendRegionHandshake(client); m_estateManager.sendRegionHandshake(client);
CreateAndAddScenePresence(client); CreateAndAddScenePresence(client);
m_LandManager.sendParcelOverlay(client); m_LandManager.sendParcelOverlay(client);
// commsManager.UserProfiles.AddNewUser(client.AgentId); //commsManager.UserProfiles.AddNewUser(client.AgentId);
} }
protected virtual void SubscribeToClientEvents(IClientAPI client) protected virtual void SubscribeToClientEvents(IClientAPI client)
@ -595,7 +595,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
// client.OnCreateNewInventoryItem += CreateNewInventoryItem; // client.OnCreateNewInventoryItem += CreateNewInventoryItem;
//client.OnCreateNewInventoryFolder += commsManager.UserProfiles.HandleCreateInventoryFolder; //client.OnCreateNewInventoryFolder += commsManager.UserProfiles.HandleCreateInventoryFolder;
client.OnFetchInventoryDescendents += commsManager.UserProfiles.HandleFecthInventoryDescendents; client.OnFetchInventoryDescendents += commsManager.UserProfiles.HandleFecthInventoryDescendents;
client.OnRequestTaskInventory += RequestTaskInventory; client.OnRequestTaskInventory += RequestTaskInventory;

View File

@ -27,6 +27,9 @@
*/ */
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
@ -93,7 +96,6 @@ namespace OpenSim.Region.Environment.Scenes
this.CreateRootFromShape(ownerID, localID, shape, pos); this.CreateRootFromShape(ownerID, localID, shape, pos);
registerEvents(); registerEvents();
} }
/// <summary> /// <summary>
@ -182,6 +184,14 @@ namespace OpenSim.Region.Environment.Scenes
return dupe; return dupe;
} }
/// <summary>
///
/// </summary>
public void Serialise()
{
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -443,8 +443,11 @@ namespace OpenSim.Region.Environment.Scenes
foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) foreach (ScenePresence avatar in this.m_scene.RequestAvatarList())
{ {
this.SendFullUpdateToOtherClient(avatar); this.SendFullUpdateToOtherClient(avatar);
avatar.SendFullUpdateToOtherClient(this); if (avatar.LocalId != this.LocalId)
avatar.SendAppearanceToOtherAgent(this); {
avatar.SendFullUpdateToOtherClient(this);
avatar.SendAppearanceToOtherAgent(this);
}
} }
} }

View File

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

View File

@ -30,6 +30,7 @@ using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenSim.Region.Scripting.EmbeddedJVM.Types; using OpenSim.Region.Scripting.EmbeddedJVM.Types;
using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
namespace OpenSim.Region.Scripting.EmbeddedJVM namespace OpenSim.Region.Scripting.EmbeddedJVM
{ {
@ -60,7 +61,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public ClassInstance CreateNewInstance() public ClassInstance CreateNewInstance()
{ {
return new ClassInstance(); ClassInstance classInst = new ClassInstance();
classInst.ClassRec = this;
//TODO: set fields
return classInst;
} }
public void LoadClassFromFile(string fileName) public void LoadClassFromFile(string fileName)
@ -75,33 +80,40 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{ {
int i = 0; int i = 0;
i += 4; i += 4;
_minorVersion = (ushort)((data[i++] << 8) + data[i++] ); _minorVersion = (ushort)((data[i++] << 8) + data[i++]);
_majorVersion = (ushort)((data[i++] << 8) + data[i++] ); _majorVersion = (ushort)((data[i++] << 8) + data[i++]);
_constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); _constantPoolCount = (ushort)((data[i++] << 8) + data[i++]);
// Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
for (int count = 0; count < _constantPoolCount -1 ; count++) for (int count = 0; count < (_constantPoolCount - 1); count++)
{ {
//read in the constant pool //read in the constant pool
byte pooltype = data[i++]; byte pooltype = data[i++];
//Console.WriteLine("#" +count +": new constant type = " +pooltype); Console.WriteLine("#" + count + ": new constant type = " + pooltype);
//Console.WriteLine("start position is: " + i); //Console.WriteLine("start position is: " + i);
switch (pooltype) switch (pooltype)
{ {
case 1: //Utf8 case 1: //Utf8
ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); ushort uLength = (ushort)((data[i++] << 8) + data[i++]);
// Console.WriteLine("new utf8 type, length is " + uLength); // Console.WriteLine("new utf8 type, length is " + uLength);
PoolUtf8 utf8 = new PoolUtf8(); PoolUtf8 utf8 = new PoolUtf8();
utf8.readValue(data, ref i, uLength); utf8.readValue(data, ref i, uLength);
this._constantsPool.Add(utf8); this._constantsPool.Add(utf8);
break; break;
case 3: //Int case 3: //Int
break; break;
case 4: //Float
break;
case 7: //Class case 7: //Class
PoolClass pClass = new PoolClass(this); PoolClass pClass = new PoolClass(this);
pClass.readValue(data, ref i); pClass.readValue(data, ref i);
this._constantsPool.Add(pClass); this._constantsPool.Add(pClass);
break; break;
case 9: //FieldRef
PoolFieldRef pField = new PoolFieldRef(this);
pField.readValue(data, ref i);
this._constantsPool.Add(pField);
break;
case 10: //Method case 10: //Method
PoolMethodRef pMeth = new PoolMethodRef(this); PoolMethodRef pMeth = new PoolMethodRef(this);
pMeth.readValue(data, ref i); pMeth.readValue(data, ref i);
@ -115,9 +127,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
} }
_accessFlags = (ushort)((data[i++] << 8) + data[i++] ); _accessFlags = (ushort)((data[i++] << 8) + data[i++]);
_thisClass = (ushort)((data[i++] << 8) + data[i++] ); _thisClass = (ushort)((data[i++] << 8) + data[i++]);
_supperClass = (ushort)((data[i++] << 8) + data[i++] ); _supperClass = (ushort)((data[i++] << 8) + data[i++]);
if (this._constantsPool[this._thisClass - 1] is PoolClass) if (this._constantsPool[this._thisClass - 1] is PoolClass)
{ {
@ -126,8 +138,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); _interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each interface //should now read in the info for each interface
_fieldCount = (ushort)((data[i++] << 8) + data[i++]); _fieldCount = (ushort)((data[i++] << 8) + data[i++]);
//should now read in the info for each field //should now read in the info for each field
for (int count = 0; count < _fieldCount; count++)
{
FieldInfo fieldInf = new FieldInfo(this);
fieldInf.ReadData(data, ref i);
this._fieldList.Add(fieldInf);
}
_methodCount = (ushort)((data[i++] << 8) + data[i++]); _methodCount = (ushort)((data[i++] << 8) + data[i++]);
for (int count = 0; count < _methodCount; count++) for (int count = 0; count < _methodCount; count++)
{ {
@ -149,9 +169,9 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{ {
for (int count = 0; count < _methodCount; count++) for (int count = 0; count < _methodCount; count++)
{ {
if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) if (this._constantsPool[this._methodsList[count].NameIndex - 1] is PoolUtf8)
{ {
if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value == methodName)
{ {
//Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
thread.SetPC(this._methodsList[count].CodePointer); thread.SetPC(this._methodsList[count].CodePointer);
@ -165,8 +185,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void PrintToConsole() public void PrintToConsole()
{ {
Console.WriteLine("Class File:"); Console.WriteLine("Class File:");
Console.WriteLine("Major version: " + _majorVersion); Console.WriteLine("Major version: " + _majorVersion);
Console.WriteLine("Minor version: " + _minorVersion); Console.WriteLine("Minor version: " + _minorVersion);
Console.WriteLine("Pool size: " + _constantPoolCount); Console.WriteLine("Pool size: " + _constantPoolCount);
for (int i = 0; i < _constantsPool.Count; i++) for (int i = 0; i < _constantsPool.Count; i++)
@ -174,9 +194,15 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._constantsPool[i].Print(); this._constantsPool[i].Print();
} }
Console.WriteLine("Access flags: " + _accessFlags); Console.WriteLine("Access flags: " + _accessFlags);
Console.WriteLine("This class: " + _thisClass ); Console.WriteLine("This class: " + _thisClass);
Console.WriteLine("Super class: " + _supperClass); Console.WriteLine("Super class: " + _supperClass);
for (int count = 0; count < _fieldCount; count++)
{
Console.WriteLine();
this._fieldList[count].Print();
}
for (int count = 0; count < _methodCount; count++) for (int count = 0; count < _methodCount; count++)
{ {
@ -184,7 +210,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._methodsList[count].Print(); this._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) public static byte[] ReadFully(Stream stream)
@ -215,32 +241,32 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{ {
public string Value = ""; public string Value = "";
public void readValue(byte[] data,ref int pointer , int length) public void readValue(byte[] data, ref int pointer, int length)
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
int a =(int) data[pointer++]; int a = (int)data[pointer++];
if ((a & 0x80) == 0) if ((a & 0x80) == 0)
{ {
Value = Value + (char)a; Value = Value + (char)a;
} }
else if ((a & 0x20) == 0) else if ((a & 0x20) == 0)
{ {
int b = (int) data[pointer++]; int b = (int)data[pointer++];
Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
} }
else else
{ {
int b = (int)data[pointer++]; int b = (int)data[pointer++];
int c = (int)data[pointer++]; int c = (int)data[pointer++];
Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
} }
} }
} }
public override void Print() public override void Print()
{ {
Console.WriteLine("Utf8 type: " + Value); Console.WriteLine("Utf8 type: " + Value);
} }
} }
@ -263,7 +289,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void readValue(byte[] data, ref int pointer) public void readValue(byte[] data, ref int pointer)
{ {
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
} }
public override void Print() public override void Print()
@ -271,7 +297,34 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
Console.Write("Class type: " + namePointer); Console.Write("Class type: " + namePointer);
Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
}
}
public class PoolFieldRef : PoolItem
{
public ushort classPointer = 0;
public ushort nameTypePointer = 0;
public PoolNamedType mNameType;
public PoolClass mClass;
private ClassRecord parent;
public PoolFieldRef(ClassRecord paren)
{
parent = paren;
}
public void readValue(byte[] data, ref int pointer)
{
classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
}
public override void Print()
{
this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer);
} }
} }
@ -298,7 +351,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
{ {
this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
} }
} }
@ -317,16 +370,16 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void readValue(byte[] data, ref int pointer) public void readValue(byte[] data, ref int pointer)
{ {
namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
} }
public override void Print() public override void Print()
{ {
Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); Type = ((PoolUtf8)this.parent._constantsPool[typePointer - 1]);
Console.Write("Named type: " + namePointer + " , " + typePointer ); Console.Write("Named type: " + namePointer + " , " + typePointer);
Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
} }
} }
@ -341,7 +394,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public List<MethodAttribute> Attributes = new List<MethodAttribute>(); public List<MethodAttribute> Attributes = new List<MethodAttribute>();
private ClassRecord parent; private ClassRecord parent;
public int CodePointer = 0; public int CodePointer = 0;
public MethodInfo(ClassRecord paren) public MethodInfo(ClassRecord paren)
{ {
parent = paren; parent = paren;
@ -361,7 +414,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
for(int i =0; i< AttributeCount; i++) for (int i = 0; i < AttributeCount; i++)
{ {
MethodAttribute attri = new MethodAttribute(this.parent); MethodAttribute attri = new MethodAttribute(this.parent);
attri.ReadData(data, ref pointer); attri.ReadData(data, ref pointer);
@ -371,11 +424,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print() public void Print()
{ {
Console.WriteLine("Method Info Struct: "); Console.WriteLine("Method Info Struct: ");
Console.WriteLine("AccessFlags: " + AccessFlags); Console.WriteLine("AccessFlags: " + AccessFlags);
Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent._constantsPool[DescriptorIndex - 1]).Value);
Console.WriteLine("Attribute Count:" + AttributeCount); Console.WriteLine("Attribute Count:" + AttributeCount);
for (int i = 0; i < AttributeCount; i++) for (int i = 0; i < AttributeCount; i++)
{ {
this.Attributes[i].Print(); this.Attributes[i].Print();
@ -426,12 +479,12 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
public void Print() public void Print()
{ {
Console.WriteLine("Method Attribute: "); Console.WriteLine("Method Attribute: ");
Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
Console.WriteLine("Length: " + Length); Console.WriteLine("Length: " + Length);
Console.WriteLine("MaxStack: " + MaxStack); Console.WriteLine("MaxStack: " + MaxStack);
Console.WriteLine("MaxLocals: " + MaxLocals); Console.WriteLine("MaxLocals: " + MaxLocals);
Console.WriteLine("CodeLength: " + CodeLength); Console.WriteLine("CodeLength: " + CodeLength);
for (int i = 0; i < Code.Length; i++) for (int i = 0; i < Code.Length; i++)
{ {
Console.WriteLine("OpCode #" + i + " is: " + Code[i]); Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
@ -483,13 +536,97 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
} }
private class FieldInfo
{
public void ReadData(byte[] data, ref int i)
{
public class FieldInfo
{
public ushort AccessFlags = 0;
public ushort NameIndex = 0;
public string Name = "";
public ushort DescriptorIndex = 0;
public ushort AttributeCount = 0;
public List<FieldAttribute> Attributes = new List<FieldAttribute>();
private ClassRecord parent;
public FieldInfo(ClassRecord paren)
{
parent = paren;
}
public void ReadData(byte[] data, ref int pointer)
{
AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]);
NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
for (int i = 0; i < AttributeCount; i++)
{
FieldAttribute attri = new FieldAttribute(this.parent);
attri.ReadData(data, ref pointer);
this.Attributes.Add(attri);
}
}
public void Print()
{
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("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)
{
case "I":
Int newin = new Int();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newin);
break;
case "F":
Float newfl = new Float();
this.parent.StaticFields.Add(((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value, newfl);
break;
}
}
for (int i = 0; i < AttributeCount; i++)
{
this.Attributes[i].Print();
}
}
public class FieldAttribute
{
public ushort NameIndex = 0;
public string Name = "";
public Int32 Length = 0;
public byte[] Data;
private ClassRecord parent;
public FieldAttribute(ClassRecord paren)
{
parent = paren;
}
public void ReadData(byte[] data, ref int pointer)
{
NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
Data = new byte[Length];
for (int i = 0; i < Length; i++)
{
Data[i] = data[pointer++];
}
}
public void Print()
{
Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
}
} }
} }
private class AttributeInfo private class AttributeInfo
{ {
public void ReadData(byte[] data, ref int i) public void ReadData(byte[] data, ref int i)
@ -500,4 +637,4 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
#endregion #endregion
} }
} }

View File

@ -42,66 +42,66 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
bool result = false; bool result = false;
switch (opcode) switch (opcode)
{ {
case 2: case (byte)(byte)OpCode.iconst_m1:
Int m_int= new Int(); Int m_int = new Int();
m_int.mValue = -1; m_int.mValue = -1;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 3: case (byte)(byte)OpCode.iconst_0:
m_int= new Int(); m_int = new Int();
m_int.mValue = 0; m_int.mValue = 0;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 4: case (byte)(byte)OpCode.iconst_1:
m_int = new Int(); m_int = new Int();
m_int.mValue = 1; m_int.mValue = 1;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 5: case (byte)(byte)OpCode.iconst_2:
m_int = new Int(); m_int = new Int();
m_int.mValue = 2; m_int.mValue = 2;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 6: case (byte)(byte)OpCode.iconst_3:
m_int = new Int(); m_int = new Int();
m_int.mValue = 3; m_int.mValue = 3;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
break; break;
case 7: case (byte)(byte)OpCode.iconst_4:
m_int = new Int(); m_int = new Int();
m_int.mValue = 4; m_int.mValue = 4;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 8: case (byte)OpCode.iconst_5:
m_int = new Int(); m_int = new Int();
m_int.mValue = 5; m_int.mValue = 5;
this._mThread.currentFrame.OpStack.Push(m_int); this._mThread.currentFrame.OpStack.Push(m_int);
result = true; result = true;
break; break;
case 11: case (byte)OpCode.fconst_0:
Float m_float = new Float(); Float m_float = new Float();
m_float.mValue = 0.0f; m_float.mValue = 0.0f;
this._mThread.currentFrame.OpStack.Push(m_float); this._mThread.currentFrame.OpStack.Push(m_float);
result = true; result = true;
break; break;
case 12: case (byte)OpCode.fconst_1:
m_float = new Float(); m_float = new Float();
m_float.mValue = 1.0f; m_float.mValue = 1.0f;
this._mThread.currentFrame.OpStack.Push(m_float); this._mThread.currentFrame.OpStack.Push(m_float);
result = true; result = true;
break; break;
case 13: case (byte)OpCode.fconst_2:
m_float = new Float(); m_float = new Float();
m_float.mValue = 2.0f; m_float.mValue = 2.0f;
this._mThread.currentFrame.OpStack.Push(m_float); this._mThread.currentFrame.OpStack.Push(m_float);
result = true; result = true;
break; break;
case 16: 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._mThread.PC];
Int pushInt = new Int(); Int pushInt = new Int();
pushInt.mValue = pushvalue; pushInt.mValue = pushvalue;
@ -109,7 +109,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++; this._mThread.PC++;
result = true; result = true;
break; break;
case 17: 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._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
Int pushInt2 = new Int(); Int pushInt2 = new Int();
pushInt2.mValue = pushvalue2; pushInt2.mValue = pushvalue2;
@ -117,7 +117,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC += 2; this._mThread.PC += 2;
result = true; result = true;
break; break;
case 23: case (byte)OpCode.fload:
short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
Float fload = new Float(); Float fload = new Float();
if (this._mThread.currentFrame.LocalVariables[findex1] != null) if (this._mThread.currentFrame.LocalVariables[findex1] != null)
@ -131,7 +131,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++; this._mThread.PC++;
result = true; result = true;
break; break;
case 26: case (byte)OpCode.iload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null) if (this._mThread.currentFrame.LocalVariables[0] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[0] is Int) if (this._mThread.currentFrame.LocalVariables[0] is Int)
@ -143,7 +143,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 27: case (byte)OpCode.iload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null) if (this._mThread.currentFrame.LocalVariables[1] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[1] is Int) if (this._mThread.currentFrame.LocalVariables[1] is Int)
@ -155,7 +155,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 34: case (byte)OpCode.fload_0:
if (this._mThread.currentFrame.LocalVariables[0] != null) if (this._mThread.currentFrame.LocalVariables[0] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[0] is Float) if (this._mThread.currentFrame.LocalVariables[0] is Float)
@ -167,7 +167,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 35: case (byte)OpCode.fload_1:
if (this._mThread.currentFrame.LocalVariables[1] != null) if (this._mThread.currentFrame.LocalVariables[1] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[1] is Float) if (this._mThread.currentFrame.LocalVariables[1] is Float)
@ -179,7 +179,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 36: case (byte)OpCode.fload_2:
if (this._mThread.currentFrame.LocalVariables[2] != null) if (this._mThread.currentFrame.LocalVariables[2] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[2] is Float) if (this._mThread.currentFrame.LocalVariables[2] is Float)
@ -191,7 +191,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 37: case (byte)OpCode.fload_3:
if (this._mThread.currentFrame.LocalVariables[3] != null) if (this._mThread.currentFrame.LocalVariables[3] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[3] is Float) if (this._mThread.currentFrame.LocalVariables[3] is Float)
@ -203,8 +203,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 56: case (byte)OpCode.istore:
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType istor = this._mThread.currentFrame.OpStack.Pop();
if (istor is Int)
{
this._mThread.currentFrame.LocalVariables[findex3] = (Int)istor;
}
this._mThread.PC++;
result = true;
break;
case (byte)OpCode.fstore:
short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
if (fstor is Float) if (fstor is Float)
{ {
@ -213,7 +223,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
this._mThread.PC++; this._mThread.PC++;
result = true; result = true;
break; break;
case 59: case (byte)OpCode.istore_0:
BaseType baset = this._mThread.currentFrame.OpStack.Pop(); BaseType baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Int) if (baset is Int)
{ {
@ -221,7 +231,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 60: case (byte)OpCode.istore_1:
baset = this._mThread.currentFrame.OpStack.Pop(); baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Int) if (baset is Int)
{ {
@ -229,7 +239,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 67: case (byte)OpCode.fstore_0:
baset = this._mThread.currentFrame.OpStack.Pop(); baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float) if (baset is Float)
{ {
@ -237,7 +247,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 68: case (byte)OpCode.fstore_1:
baset = this._mThread.currentFrame.OpStack.Pop(); baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float) if (baset is Float)
{ {
@ -245,7 +255,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 69: case (byte)OpCode.fstore_2:
baset = this._mThread.currentFrame.OpStack.Pop(); baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float) if (baset is Float)
{ {
@ -253,7 +263,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 70: case (byte)OpCode.fstore_3:
baset = this._mThread.currentFrame.OpStack.Pop(); baset = this._mThread.currentFrame.OpStack.Pop();
if (baset is Float) if (baset is Float)
{ {
@ -261,11 +271,11 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 87: case (byte)OpCode.pop:
this._mThread.currentFrame.OpStack.Pop(); this._mThread.currentFrame.OpStack.Pop();
result = true; result = true;
break; break;
case 98: case (byte)OpCode.fadd:
BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
if (bf1 is Float && bf2 is Float) if (bf1 is Float && bf2 is Float)
@ -276,7 +286,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 102: case (byte)OpCode.fsub:
BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
if (bsf1 is Float && bsf2 is Float) if (bsf1 is Float && bsf2 is Float)
@ -287,7 +297,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 104: //check the order of the two values off the stack is correct case (byte)OpCode.imul: //check the order of the two values off the stack is correct
BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
if (bs1 is Int && bs2 is Int) if (bs1 is Int && bs2 is Int)
@ -298,18 +308,18 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 132: case (byte)OpCode.iinc:
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
{ {
if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.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._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
} }
} }
this._mThread.PC += 2; this._mThread.PC += 2;
result = true; result = true;
break; break;
case 139: case (byte)OpCode.f2i:
BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
if (conv1 is Float) if (conv1 is Float)
{ {
@ -319,7 +329,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 149: case (byte)OpCode.fcmpl:
BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
if (flcom1 is Float && flcom2 is Float) if (flcom1 is Float && flcom2 is Float)
@ -341,7 +351,49 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 158: case (byte)OpCode.fcmpg:
flcom2 = this._mThread.currentFrame.OpStack.Pop();
flcom1 = this._mThread.currentFrame.OpStack.Pop();
if (flcom1 is Float && flcom2 is Float)
{
Int compres = new Int();
if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
{
compres.mValue = -1;
}
else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
{
compres.mValue = 1;
}
else
{
compres.mValue = 0;
}
this._mThread.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();
if (compe1 is Int)
{
if (((Int)compe1).mValue >= 0)
{
this._mThread.PC += -1 + compareoffset2;
}
else
{
this._mThread.PC += 2;
}
}
else
{
this._mThread.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]); short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
if (comp1 is Int) if (comp1 is Int)
@ -361,7 +413,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 162: case (byte)OpCode.if_icmpge:
short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 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 bc2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
@ -370,8 +422,8 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
//Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
if (((Int)bc1).mValue >= ((Int)bc2).mValue) if (((Int)bc1).mValue >= ((Int)bc2).mValue)
{ {
// Console.WriteLine("branch compare true , offset is " +compareoffset); // Console.WriteLine("branch compare true , offset is " +compareoffset);
// Console.WriteLine("current PC is " + this._mThread.PC); // Console.WriteLine("current PC is " + this._mThread.PC);
this._mThread.PC += -1 + compareoffset; this._mThread.PC += -1 + compareoffset;
//Console.WriteLine("new PC is " + this._mThread.PC); //Console.WriteLine("new PC is " + this._mThread.PC);
} }
@ -387,7 +439,7 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 164: case (byte)OpCode.if_icmple:
short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 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 bcl2 = this._mThread.currentFrame.OpStack.Pop();
BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
@ -396,10 +448,10 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
//Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
{ {
// Console.WriteLine("branch compare true , offset is " + compareloffset); // Console.WriteLine("branch compare true , offset is " + compareloffset);
// Console.WriteLine("current PC is " + this._mThread.PC); // Console.WriteLine("current PC is " + this._mThread.PC);
this._mThread.PC += -1 + compareloffset; this._mThread.PC += -1 + compareloffset;
// Console.WriteLine("new PC is " + this._mThread.PC); // Console.WriteLine("new PC is " + this._mThread.PC);
} }
else else
{ {
@ -413,15 +465,87 @@ namespace OpenSim.Region.Scripting.EmbeddedJVM
} }
result = true; result = true;
break; break;
case 167: case (byte)OpCode._goto:
short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
this._mThread.PC += -1 + offset; this._mThread.PC += -1 + offset;
result = true; result = true;
break; 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)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.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._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._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);
}
else if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._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;
// Console.WriteLine("getting static field, " + retInt.mValue);
this._mThread.currentFrame.OpStack.Push(retInt);
}
}
}
else
{
//get from a different class
}
}
this._mThread.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)
{
if (((ClassRecord.PoolFieldRef)this._mThread.currentClass._constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
{
// this class
if (this._mThread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this._mThread.currentClass._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)
{
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;
}
}
else if (addstatic is Int)
{
if (this._mThread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this._mThread.currentClass._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;
}
}
}
}
else
{
// a different class
}
}
this._mThread.PC += 2;
result = true;
break;
} }
return result; return result;
} }
} }
} }
} }

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Scripting.EmbeddedJVM
{
public enum OpCode : byte
{
iconst_m1 = 2,
iconst_0 = 3,
iconst_1 = 4,
iconst_2 = 5,
iconst_3 = 6,
iconst_4 = 7,
iconst_5 = 8,
fconst_0 = 11,
fconst_1 = 12,
fconst_2 = 13,
bipush = 16,
sipush = 17,
fload = 23,
iload_0 = 26,
iload_1 = 27,
fload_0 = 34,
fload_1 = 35,
fload_2 = 36,
fload_3 = 37,
istore = 54,
fstore = 56,
istore_0 = 59,
istore_1 = 60,
istore_2 = 61,
istore_3 = 62,
fstore_0 = 67,
fstore_1 = 68,
fstore_2 = 69,
fstore_3 = 70,
pop = 87,
fadd = 98,
fsub = 102,
imul = 104,
iinc = 132,
f2i = 139,
fcmpl = 149,
fcmpg = 150,
ifge = 156,
ifgt = 157,
ifle = 158,
if_icmpge = 162,
if_icmpgt = 163,
if_icmple = 164,
_goto = 167,
getstatic = 178,
putstatic = 179
}
}

View File

@ -157,6 +157,7 @@ namespace SimpleApp
public void SendAlertMessage(string message) { } public void SendAlertMessage(string message) { }
public void SendAgentAlertMessage(string message, bool modal) { } public void SendAgentAlertMessage(string message, bool modal) { }
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
public virtual void SendRegionHandshake(RegionInfo regionInfo) public virtual void SendRegionHandshake(RegionInfo regionInfo)
{ {