Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

AspectInstanceVar.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* *******************************************************************
  2. * Copyright (c) 2011 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. * Andy Clement - SpringSource/vmware
  11. * ******************************************************************/
  12. package org.aspectj.weaver.bcel;
  13. import org.aspectj.apache.bcel.Constants;
  14. import org.aspectj.apache.bcel.generic.Instruction;
  15. import org.aspectj.apache.bcel.generic.InstructionFactory;
  16. import org.aspectj.apache.bcel.generic.InstructionList;
  17. import org.aspectj.weaver.ResolvedType;
  18. /**
  19. * Used to represent a variable reference to an aspect instance. This is used to support the if pointcut usage of
  20. * 'thisAspectInstance'. This variable does not have a slot, instead on requesting a reference we call aspectOf() on the aspect in
  21. * question to retrieve it. For now it only works with singleton aspects.
  22. */
  23. public class AspectInstanceVar extends BcelVar {
  24. public AspectInstanceVar(ResolvedType type) {
  25. super(type, -1);
  26. }
  27. // fact is used in the subtypes
  28. public Instruction createLoad(InstructionFactory fact) {
  29. throw new IllegalStateException();
  30. // return InstructionFactory.createLoad(BcelWorld.makeBcelType(getType()), slot);
  31. }
  32. public Instruction createStore(InstructionFactory fact) {
  33. throw new IllegalStateException();
  34. // return InstructionFactory.createStore(BcelWorld.makeBcelType(getType()), slot);
  35. }
  36. public void appendStore(InstructionList il, InstructionFactory fact) {
  37. throw new IllegalStateException();
  38. // il.append(createStore(fact));
  39. }
  40. public void appendLoad(InstructionList il, InstructionFactory fact) {
  41. throw new IllegalStateException();
  42. // il.append(createLoad(fact));
  43. }
  44. public void appendLoadAndConvert(InstructionList il, InstructionFactory fact, ResolvedType toType) {
  45. throw new IllegalStateException();
  46. // il.append(createLoad(fact));
  47. // Utility.appendConversion(il, fact, getType(), toType);
  48. }
  49. public void insertLoad(InstructionList il, InstructionFactory fact) {
  50. InstructionList loadInstructions = new InstructionList();
  51. loadInstructions.append(fact.createInvoke(getType().getName(), "aspectOf", "()" + getType().getSignature(),
  52. Constants.INVOKESTATIC));
  53. il.insert(loadInstructions);
  54. // throw new IllegalStateException();
  55. // il.insert(createLoad(fact));
  56. }
  57. public InstructionList createCopyFrom(InstructionFactory fact, int oldSlot) {
  58. throw new IllegalStateException();
  59. // InstructionList il = new InstructionList();
  60. // il.append(InstructionFactory.createLoad(BcelWorld.makeBcelType(getType()), oldSlot));
  61. // il.append(createStore(fact));
  62. // return il;
  63. }
  64. // this is an array var
  65. void appendConvertableArrayLoad(InstructionList il, InstructionFactory fact, int index, ResolvedType convertTo) {
  66. throw new IllegalStateException();
  67. // ResolvedType convertFromType = getType().getResolvedComponentType();
  68. // appendLoad(il, fact);
  69. // il.append(Utility.createConstant(fact, index));
  70. // il.append(InstructionFactory.createArrayLoad(BcelWorld.makeBcelType(convertFromType)));
  71. // Utility.appendConversion(il, fact, convertFromType, convertTo);
  72. }
  73. void appendConvertableArrayStore(InstructionList il, InstructionFactory fact, int index, BcelVar storee) {
  74. throw new IllegalStateException();
  75. // ResolvedType convertToType = getType().getResolvedComponentType();
  76. // appendLoad(il, fact);
  77. // il.append(Utility.createConstant(fact, index));
  78. // storee.appendLoad(il, fact);
  79. // Utility.appendConversion(il, fact, storee.getType(), convertToType);
  80. // il.append(InstructionFactory.createArrayStore(BcelWorld.makeBcelType(convertToType)));
  81. }
  82. InstructionList createConvertableArrayStore(InstructionFactory fact, int index, BcelVar storee) {
  83. throw new IllegalStateException();
  84. // InstructionList il = new InstructionList();
  85. // appendConvertableArrayStore(il, fact, index, storee);
  86. // return il;
  87. }
  88. InstructionList createConvertableArrayLoad(InstructionFactory fact, int index, ResolvedType convertTo) {
  89. throw new IllegalStateException();
  90. // InstructionList il = new InstructionList();
  91. // appendConvertableArrayLoad(il, fact, index, convertTo);
  92. // return il;
  93. }
  94. public int getPositionInAroundState() {
  95. throw new IllegalStateException();
  96. // return positionInAroundState;
  97. }
  98. public void setPositionInAroundState(int positionInAroundState) {
  99. throw new IllegalStateException();
  100. // this.positionInAroundState = positionInAroundState;
  101. }
  102. }