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.

PerFromSuper.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.patterns;
  13. import java.io.DataInputStream;
  14. import java.io.DataOutputStream;
  15. import java.io.IOException;
  16. import java.util.Set;
  17. import org.aspectj.bridge.MessageUtil;
  18. import org.aspectj.util.FuzzyBoolean;
  19. import org.aspectj.weaver.ISourceContext;
  20. import org.aspectj.weaver.ResolvedTypeX;
  21. import org.aspectj.weaver.Shadow;
  22. import org.aspectj.weaver.WeaverMessages;
  23. import org.aspectj.weaver.ast.Test;
  24. public class PerFromSuper extends PerClause {
  25. private PerClause.Kind kind;
  26. public PerFromSuper(PerClause.Kind kind) {
  27. this.kind = kind;
  28. }
  29. public Set couldMatchKinds() {
  30. return Shadow.ALL_SHADOW_KINDS;
  31. }
  32. public FuzzyBoolean fastMatch(FastMatchInfo type) {
  33. throw new RuntimeException("unimplemented");
  34. }
  35. protected FuzzyBoolean matchInternal(Shadow shadow) {
  36. throw new RuntimeException("unimplemented");
  37. }
  38. public void resolveBindings(IScope scope, Bindings bindings) {
  39. // this method intentionally left blank
  40. }
  41. protected Test findResidueInternal(Shadow shadow, ExposedState state) {
  42. throw new RuntimeException("unimplemented");
  43. }
  44. public PerClause concretize(ResolvedTypeX inAspect) {
  45. PerClause p = lookupConcretePerClause(inAspect.getSuperclass());
  46. if (p == null) {
  47. inAspect.getWorld().getMessageHandler().handleMessage(
  48. MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE,inAspect.getSuperclass()), getSourceLocation())
  49. );
  50. }
  51. if (p.getKind() != kind) {
  52. inAspect.getWorld().getMessageHandler().handleMessage(
  53. MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()),
  54. getSourceLocation())
  55. );
  56. }
  57. return p.concretize(inAspect);
  58. }
  59. private PerClause lookupConcretePerClause(ResolvedTypeX lookupType) {
  60. PerClause ret = lookupType.getPerClause();
  61. if (ret == null) return null;
  62. if (ret instanceof PerFromSuper) {
  63. return lookupConcretePerClause(lookupType.getSuperclass());
  64. }
  65. return ret;
  66. }
  67. public void write(DataOutputStream s) throws IOException {
  68. FROMSUPER.write(s);
  69. kind.write(s);
  70. writeLocation(s);
  71. }
  72. public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException {
  73. PerFromSuper ret = new PerFromSuper(Kind.read(s));
  74. ret.readLocation(context, s);
  75. return ret;
  76. }
  77. public String toString() {
  78. return "perFromSuper(" + kind + ", " + inAspect + ")";
  79. }
  80. public PerClause.Kind getKind() {
  81. return kind;
  82. }
  83. }