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.

PerClause.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.IOException;
  14. import org.aspectj.util.TypeSafeEnum;
  15. import org.aspectj.weaver.*;
  16. public abstract class PerClause extends Pointcut {
  17. protected ResolvedTypeX inAspect;
  18. public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException {
  19. Kind kind = Kind.read(s);
  20. if (kind == SINGLETON) return PerSingleton.readPerClause(s, context);
  21. else if (kind == PERCFLOW) return PerCflow.readPerClause(s, context);
  22. else if (kind == PEROBJECT) return PerObject.readPerClause(s, context);
  23. else if (kind == FROMSUPER) return PerFromSuper.readPerClause(s, context);
  24. throw new BCException("unknown kind: " + kind);
  25. }
  26. public final Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
  27. throw new RuntimeException("unimplemented: wrong concretize");
  28. }
  29. public abstract PerClause concretize(ResolvedTypeX inAspect);
  30. public abstract PerClause.Kind getKind();
  31. public static class Kind extends TypeSafeEnum {
  32. public Kind(String name, int key) { super(name, key); }
  33. public static Kind read(VersionedDataInputStream s) throws IOException {
  34. int key = s.readByte();
  35. switch(key) {
  36. case 1: return SINGLETON;
  37. case 2: return PERCFLOW;
  38. case 3: return PEROBJECT;
  39. case 4: return FROMSUPER;
  40. }
  41. throw new BCException("weird kind " + key);
  42. }
  43. }
  44. public void resolveBindingsFromRTTI() {
  45. throw new UnsupportedOperationException("Can't resolve per-clauses at runtime");
  46. }
  47. public static final Kind SINGLETON = new Kind("issingleton", 1);
  48. public static final Kind PERCFLOW = new Kind("percflow", 2);
  49. public static final Kind PEROBJECT = new Kind("perobject", 3);
  50. public static final Kind FROMSUPER = new Kind("fromsuper", 4);
  51. }