Interpreter.Methods.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
  28. {
  29. partial class Thread
  30. {
  31. private partial class Interpreter
  32. {
  33. private bool IsMethodOpCode(byte opcode)
  34. {
  35. bool result = false;
  36. switch (opcode)
  37. {
  38. case 184:
  39. short refIndex =
  40. (short)
  41. ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) +
  42. GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]);
  43. if (m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
  44. {
  45. string typ =
  46. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]).
  47. mNameType.Type.Value;
  48. string typeparam = System.String.Empty;
  49. string typereturn = System.String.Empty;
  50. int firstbrak = 0;
  51. int secondbrak = 0;
  52. firstbrak = typ.LastIndexOf('(');
  53. secondbrak = typ.LastIndexOf(')');
  54. typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
  55. typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
  56. if (
  57. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass
  58. .Name.Value == m_thread.currentClass.MClass.Name.Value)
  59. {
  60. //calling a method in this class
  61. if (typeparam.Length == 0)
  62. {
  63. m_thread.JumpToStaticVoidMethod(
  64. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1])
  65. .mNameType.Name.Value, (m_thread.PC + 2));
  66. }
  67. else
  68. {
  69. m_thread.JumpToStaticParamMethod(
  70. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1])
  71. .mNameType.Name.Value, typeparam, (m_thread.PC + 2));
  72. }
  73. }
  74. else
  75. {
  76. //calling a method of a different class
  77. // OpenSimAPI Class
  78. if (
  79. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]).
  80. mClass.Name.Value == "OpenSimAPI")
  81. {
  82. m_thread.scriptInfo.api.CallMethod(
  83. ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1])
  84. .mNameType.Name.Value, null);
  85. }
  86. }
  87. }
  88. else
  89. {
  90. m_thread.PC += 2;
  91. }
  92. result = true;
  93. break;
  94. }
  95. return result;
  96. }
  97. }
  98. }
  99. }