blob: b94248c6e3498ee3fde3ae548017788063823e33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Scripting.EmbeddedJVM.Types;
using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
namespace OpenSim.Scripting.EmbeddedJVM
{
partial class Thread
{
private partial class Interpreter
{
private Thread _mThread;
public Interpreter(Thread parentThread)
{
_mThread = parentThread;
}
public bool Excute()
{
bool run = true;
byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
// Console.WriteLine("opCode is: " + currentOpCode);
bool handled = false;
handled = this.IsLogicOpCode(currentOpCode);
if (!handled)
{
handled = this.IsMethodOpCode(currentOpCode);
}
if (!handled)
{
if (currentOpCode == 172)
{
if (this._mThread.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;
if (bas1 is Int)
{
this._mThread.currentFrame.OpStack.Push((Int)bas1);
}
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
run = false;
}
handled = true;
}
if (currentOpCode == 174)
{
if (this._mThread.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;
if (bas1 is Float)
{
this._mThread.currentFrame.OpStack.Push((Float)bas1);
}
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
run = false;
}
handled = true;
}
if (currentOpCode == 177)
{
if (this._mThread.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;
}
else
{
// Console.WriteLine("No parent function so ending program");
this._mThread.stack.StackFrames.Pop();
run = false;
}
handled = true;
}
}
if (!handled)
{
Console.WriteLine("opcode " + currentOpCode + " not been handled ");
}
return run;
}
}
}
}
|