diff options
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'OpenSim-Source/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs')
-rw-r--r-- | OpenSim-Source/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/OpenSim-Source/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs b/OpenSim-Source/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs deleted file mode 100644 index c66c148..0000000 --- a/OpenSim-Source/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Scripting.EmbeddedJVM.Types; | ||
5 | using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | ||
6 | using OpenSim.Framework.Interfaces; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Framework.Types; | ||
9 | |||
10 | namespace OpenSim.Scripting.EmbeddedJVM | ||
11 | { | ||
12 | partial class Thread | ||
13 | { | ||
14 | private partial class Interpreter | ||
15 | { | ||
16 | private bool IsMethodOpCode(byte opcode) | ||
17 | { | ||
18 | bool result = false; | ||
19 | switch (opcode) | ||
20 | { | ||
21 | case 184: | ||
22 | short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); | ||
23 | //Console.WriteLine("call to method : "+refIndex); | ||
24 | if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) | ||
25 | { | ||
26 | // Console.WriteLine("which is " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value + "." + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value); | ||
27 | // Console.WriteLine("of type " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value); | ||
28 | string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; | ||
29 | string typeparam = ""; | ||
30 | string typereturn = ""; | ||
31 | int firstbrak = 0; | ||
32 | int secondbrak = 0; | ||
33 | firstbrak = typ.LastIndexOf('('); | ||
34 | secondbrak = typ.LastIndexOf(')'); | ||
35 | typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); | ||
36 | typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); | ||
37 | //Console.WriteLine("split is " + typeparam + " which is length " + typeparam.Length + " , " + typereturn); | ||
38 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) | ||
39 | { | ||
40 | //calling a method in this class | ||
41 | if (typeparam.Length == 0) | ||
42 | { | ||
43 | this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); | ||
44 | } | ||
45 | else | ||
46 | { | ||
47 | this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); | ||
48 | } | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | //calling a method of a different class | ||
53 | |||
54 | //for now we will have a built in OpenSimAPI class, but this should be a java class that then calls native methods | ||
55 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") | ||
56 | { | ||
57 | switch (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value) | ||
58 | { | ||
59 | case "GetEntityID": | ||
60 | Int entityID = new Int(); | ||
61 | entityID.mValue =(int) this._mThread.EntityId; | ||
62 | this._mThread.currentFrame.OpStack.Push(entityID); | ||
63 | this._mThread.PC += 2; | ||
64 | break; | ||
65 | case "GetRandomAvatarID": | ||
66 | entityID = new Int(); | ||
67 | entityID.mValue = (int)Thread.OpenSimScriptAPI.GetRandomAvatarID(); | ||
68 | this._mThread.currentFrame.OpStack.Push(entityID); | ||
69 | this._mThread.PC += 2; | ||
70 | break; | ||
71 | case "GetEntityPositionX": | ||
72 | BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); | ||
73 | if (bs1 is Int) | ||
74 | { | ||
75 | //Console.WriteLine("get entity pos for " + ((Int)bs1).mValue); | ||
76 | //should get the position of the entity from the IScriptAPI | ||
77 | OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); | ||
78 | Float pos = new Float(); | ||
79 | pos.mValue = vec3.X; | ||
80 | // Console.WriteLine("returned x value " + vec3.X.ToString()); | ||
81 | this._mThread.currentFrame.OpStack.Push(pos); | ||
82 | } | ||
83 | this._mThread.PC += 2; | ||
84 | break; | ||
85 | case "GetEntityPositionY": | ||
86 | bs1 = this._mThread.currentFrame.OpStack.Pop(); | ||
87 | if (bs1 is Int) | ||
88 | { | ||
89 | //should get the position of the entity from the IScriptAPI | ||
90 | OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); | ||
91 | Float pos = new Float(); | ||
92 | pos.mValue = vec3.Y; | ||
93 | this._mThread.currentFrame.OpStack.Push(pos); | ||
94 | } | ||
95 | this._mThread.PC += 2; | ||
96 | break; | ||
97 | case "GetEntityPositionZ": | ||
98 | bs1 = this._mThread.currentFrame.OpStack.Pop(); | ||
99 | if (bs1 is Int) | ||
100 | { | ||
101 | //should get the position of the entity from the IScriptAPI | ||
102 | OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); | ||
103 | Float pos = new Float(); | ||
104 | pos.mValue = vec3.Z; | ||
105 | this._mThread.currentFrame.OpStack.Push(pos); | ||
106 | } | ||
107 | this._mThread.PC += 2; | ||
108 | break; | ||
109 | case "SetEntityPosition": | ||
110 | //pop the three float values and the entity id | ||
111 | BaseType ft3 = this._mThread.currentFrame.OpStack.Pop(); | ||
112 | BaseType ft2 = this._mThread.currentFrame.OpStack.Pop(); | ||
113 | BaseType ft1 = this._mThread.currentFrame.OpStack.Pop(); | ||
114 | BaseType in1 = this._mThread.currentFrame.OpStack.Pop(); | ||
115 | if (ft1 is Float && ft2 is Float && ft3 is Float) | ||
116 | { | ||
117 | if(in1 is Int) | ||
118 | { | ||
119 | //Console.WriteLine("set: " + ((Int)in1).mValue + " , " + ((Float)ft1).mValue + " , " + ((Float)ft2).mValue + " , " + ((Float)ft3).mValue); | ||
120 | Thread.OpenSimScriptAPI.SetEntityPosition((uint)((Int) in1).mValue, ((Float)ft1).mValue, ((Float)ft2).mValue, ((Float)ft3).mValue); | ||
121 | } | ||
122 | } | ||
123 | this._mThread.PC += 2; | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | this._mThread.PC += 2; | ||
132 | } | ||
133 | result = true; | ||
134 | break; | ||
135 | } | ||
136 | |||
137 | return result; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | } | ||