Thread.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.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. using OpenSim.Region.Environment.Scenes;
  28. using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
  29. using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
  30. namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
  31. {
  32. public partial class Thread
  33. {
  34. // Is this smart?
  35. public static MainMemory GlobalMemory;
  36. public static Scene World;
  37. private int PC = 0;
  38. private Stack stack;
  39. private Interpreter m_Interpreter;
  40. public ClassRecord currentClass;
  41. public ClassInstance currentInstance;
  42. private StackFrame m_currentFrame;
  43. public int excutionCounter = 0;
  44. public bool running = false;
  45. public ScriptInfo scriptInfo;
  46. public Thread()
  47. {
  48. m_Interpreter = new Interpreter(this);
  49. stack = new Stack();
  50. }
  51. public void SetPC(int methodpointer)
  52. {
  53. //Console.WriteLine("Thread PC has been set to " + methodpointer);
  54. PC = methodpointer;
  55. }
  56. public void StartMethod(ClassRecord rec, string methName)
  57. {
  58. m_currentFrame = new StackFrame();
  59. stack.StackFrames.Push(m_currentFrame);
  60. currentClass = rec;
  61. currentClass.StartMethod(this, methName);
  62. }
  63. public void StartMethod(string methName)
  64. {
  65. m_currentFrame = new StackFrame();
  66. stack.StackFrames.Push(m_currentFrame);
  67. currentClass.StartMethod(this, methName);
  68. }
  69. public void JumpToStaticVoidMethod(string methName, int returnPC)
  70. {
  71. m_currentFrame = new StackFrame();
  72. m_currentFrame.ReturnPC = returnPC;
  73. stack.StackFrames.Push(m_currentFrame);
  74. currentClass.StartMethod(this, methName);
  75. }
  76. public void JumpToStaticParamMethod(string methName, string param, int returnPC)
  77. {
  78. if (param == "I")
  79. {
  80. BaseType bs1 = m_currentFrame.OpStack.Pop();
  81. m_currentFrame = new StackFrame();
  82. m_currentFrame.ReturnPC = returnPC;
  83. stack.StackFrames.Push(m_currentFrame);
  84. m_currentFrame.LocalVariables[0] = ((Int) bs1);
  85. currentClass.StartMethod(this, methName);
  86. }
  87. if (param == "F")
  88. {
  89. }
  90. }
  91. public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
  92. {
  93. }
  94. public bool Excute()
  95. {
  96. excutionCounter++;
  97. return m_Interpreter.Excute();
  98. }
  99. }
  100. }