aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs
diff options
context:
space:
mode:
authorMW2007-08-28 18:30:28 +0000
committerMW2007-08-28 18:30:28 +0000
commitc16aafee09bfcce12c3d667cd6ec382e29695490 (patch)
treec36c20a4c0efa3fbe5351b79d278d57a66e363ff /OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs
parentstartup event on script added to object, not all inside object. (diff)
downloadopensim-SC_OLD-c16aafee09bfcce12c3d667cd6ec382e29695490.zip
opensim-SC_OLD-c16aafee09bfcce12c3d667cd6ec382e29695490.tar.gz
opensim-SC_OLD-c16aafee09bfcce12c3d667cd6ec382e29695490.tar.bz2
opensim-SC_OLD-c16aafee09bfcce12c3d667cd6ec382e29695490.tar.xz
Taken the old scripting engine out of Region.Environment and moved it into a separate module: OpenSim.Region.ExtensionsScriptModule (named as such because the purpose of it is to script server extensions, rather than "user scripting" like Tedd's engine.)
Diffstat (limited to 'OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs')
-rw-r--r--OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs135
1 files changed, 135 insertions, 0 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs
new file mode 100644
index 0000000..efc8ac3
--- /dev/null
+++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs
@@ -0,0 +1,135 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
32using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
33
34namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
35{
36 partial class Thread
37 {
38 private partial class Interpreter
39 {
40 private Thread m_thread;
41
42 public Interpreter(Thread parentThread)
43 {
44 m_thread = parentThread;
45 }
46
47 public bool Excute()
48 {
49 bool run = true;
50 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++];
51 // Console.WriteLine("opCode is: " + currentOpCode);
52 bool handled = false;
53
54 handled = this.IsLogicOpCode(currentOpCode);
55 if (!handled)
56 {
57 handled = this.IsMethodOpCode(currentOpCode);
58 }
59 if (!handled)
60 {
61 if (currentOpCode == 172)
62 {
63 if (this.m_thread.stack.StackFrames.Count > 1)
64 {
65 Console.WriteLine("returning int from function");
66 int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
67 BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
68 this.m_thread.stack.StackFrames.Pop();
69 this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
70 this.m_thread.PC = retPC1;
71 if (bas1 is Int)
72 {
73 this.m_thread.m_currentFrame.OpStack.Push((Int)bas1);
74 }
75 }
76 else
77 {
78 // Console.WriteLine("No parent function so ending program");
79 this.m_thread.stack.StackFrames.Pop();
80 run = false;
81 }
82 handled = true;
83 }
84 if (currentOpCode == 174)
85 {
86 if (this.m_thread.stack.StackFrames.Count > 1)
87 {
88 Console.WriteLine("returning float from function");
89 int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
90 BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
91 this.m_thread.stack.StackFrames.Pop();
92 this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
93 this.m_thread.PC = retPC1;
94 if (bas1 is Float)
95 {
96 this.m_thread.m_currentFrame.OpStack.Push((Float)bas1);
97 }
98 }
99 else
100 {
101 // Console.WriteLine("No parent function so ending program");
102 this.m_thread.stack.StackFrames.Pop();
103 run = false;
104 }
105 handled = true;
106 }
107 if (currentOpCode == 177)
108 {
109 if (this.m_thread.stack.StackFrames.Count > 1)
110 {
111 Console.WriteLine("returning from function");
112 int retPC = this.m_thread.m_currentFrame.ReturnPC;
113 this.m_thread.stack.StackFrames.Pop();
114 this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
115 this.m_thread.PC = retPC;
116 }
117 else
118 {
119 // Console.WriteLine("No parent function so ending program");
120 this.m_thread.stack.StackFrames.Pop();
121 run = false;
122 }
123 handled = true;
124 }
125 }
126 if (!handled)
127 {
128 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
129 }
130 return run;
131
132 }
133 }
134 }
135}