You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LocalVariableTag.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * Andy Clement pushed down into bcel module
  12. * ******************************************************************/
  13. package org.aspectj.apache.bcel.generic;
  14. public final class LocalVariableTag extends Tag {
  15. private final String signature;
  16. private String name;
  17. private int slot;
  18. private final int startPosition;
  19. private boolean remapped = false;
  20. private int hashCode = 0;
  21. private Type type; // not always known, in which case signature has to be used
  22. // AMC - pr101047, two local vars with the same name can share the same slot, but must in that case
  23. // have different start positions.
  24. public LocalVariableTag(String signature, String name, int slot, int startPosition) {
  25. this.signature = signature;
  26. this.name = name;
  27. this.slot = slot;
  28. this.startPosition = startPosition;
  29. }
  30. public LocalVariableTag(Type type, String signature, String name, int slot, int startPosition) {
  31. this.type = type;
  32. this.signature = signature;
  33. this.name = name;
  34. this.slot = slot;
  35. this.startPosition = startPosition;
  36. }
  37. public String getName() {
  38. return name;
  39. }
  40. public int getSlot() {
  41. return slot;
  42. }
  43. public String getType() {
  44. return signature;
  45. }
  46. public Type getRealType() {
  47. return type;
  48. }
  49. public void updateSlot(int newSlot) {
  50. this.slot = newSlot;
  51. this.remapped = true;
  52. this.hashCode = 0;
  53. }
  54. public void setName(String name) {
  55. this.name = name;
  56. this.hashCode = 0;
  57. }
  58. public boolean isRemapped() {
  59. return this.remapped;
  60. }
  61. public String toString() {
  62. return "local " + slot + ": " + signature + " " + name;
  63. }
  64. public boolean equals(Object other) {
  65. if (!(other instanceof LocalVariableTag)) {
  66. return false;
  67. }
  68. LocalVariableTag o = (LocalVariableTag) other;
  69. return o.slot == slot && o.startPosition == startPosition && o.signature.equals(signature) && o.name.equals(name);
  70. }
  71. public int hashCode() {
  72. if (hashCode == 0) {
  73. int ret = signature.hashCode();
  74. ret = 37 * ret + name.hashCode();
  75. ret = 37 * ret + slot;
  76. ret = 37 * ret + startPosition;
  77. hashCode = ret;
  78. }
  79. return hashCode;
  80. }
  81. }