Thread.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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;
  7. using OpenSim.Framework.Interfaces;
  8. namespace OpenSim.Scripting.EmbeddedJVM
  9. {
  10. public partial class Thread
  11. {
  12. public static MainMemory GlobalMemory;
  13. public static IScriptAPI OpenSimScriptAPI;
  14. private int PC = 0;
  15. private Stack stack;
  16. private Interpreter mInterpreter;
  17. public ClassRecord currentClass;
  18. public ClassInstance currentInstance;
  19. private StackFrame currentFrame;
  20. public int excutionCounter = 0;
  21. public bool running = false;
  22. public uint EntityId = 0;
  23. public Thread()
  24. {
  25. this.mInterpreter = new Interpreter(this);
  26. this.stack = new Stack();
  27. }
  28. public void SetPC(int methodpointer)
  29. {
  30. //Console.WriteLine("Thread PC has been set to " + methodpointer);
  31. PC = methodpointer;
  32. }
  33. public void StartMethod(ClassRecord rec, string methName)
  34. {
  35. currentFrame = new StackFrame();
  36. this.stack.StackFrames.Push(currentFrame);
  37. this.currentClass = rec;
  38. currentClass.StartMethod(this, methName);
  39. }
  40. public void StartMethod( string methName)
  41. {
  42. currentFrame = new StackFrame();
  43. this.stack.StackFrames.Push(currentFrame);
  44. currentClass.StartMethod(this, methName);
  45. }
  46. public void JumpToStaticVoidMethod(string methName, int returnPC)
  47. {
  48. currentFrame = new StackFrame();
  49. currentFrame.ReturnPC = returnPC;
  50. this.stack.StackFrames.Push(currentFrame);
  51. currentClass.StartMethod(this, methName);
  52. }
  53. public void JumpToStaticParamMethod(string methName, string param, int returnPC)
  54. {
  55. if (param == "I")
  56. {
  57. BaseType bs1 = currentFrame.OpStack.Pop();
  58. currentFrame = new StackFrame();
  59. currentFrame.ReturnPC = returnPC;
  60. this.stack.StackFrames.Push(currentFrame);
  61. currentFrame.LocalVariables[0] = ((Int)bs1);
  62. currentClass.StartMethod(this, methName);
  63. }
  64. if (param == "F")
  65. {
  66. }
  67. }
  68. public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
  69. {
  70. }
  71. public bool Excute()
  72. {
  73. excutionCounter++;
  74. return this.mInterpreter.Excute();
  75. }
  76. }
  77. }