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.

PerSingleton.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.DataOutputStream;
  14. import java.io.IOException;
  15. import java.util.Set;
  16. import org.aspectj.util.FuzzyBoolean;
  17. import org.aspectj.weaver.AjcMemberMaker;
  18. import org.aspectj.weaver.ISourceContext;
  19. import org.aspectj.weaver.ResolvedTypeX;
  20. import org.aspectj.weaver.Shadow;
  21. import org.aspectj.weaver.VersionedDataInputStream;
  22. import org.aspectj.weaver.ast.Expr;
  23. import org.aspectj.weaver.ast.Literal;
  24. import org.aspectj.weaver.ast.Test;
  25. public class PerSingleton extends PerClause {
  26. public PerSingleton() {
  27. }
  28. public Set couldMatchKinds() {
  29. return Shadow.ALL_SHADOW_KINDS;
  30. }
  31. public FuzzyBoolean fastMatch(FastMatchInfo type) {
  32. return FuzzyBoolean.YES;
  33. }
  34. protected FuzzyBoolean matchInternal(Shadow shadow) {
  35. return FuzzyBoolean.YES;
  36. }
  37. public void resolveBindings(IScope scope, Bindings bindings) {
  38. // this method intentionally left blank
  39. }
  40. protected Test findResidueInternal(Shadow shadow, ExposedState state) {
  41. Expr myInstance =
  42. Expr.makeCallExpr(AjcMemberMaker.perSingletonAspectOfMethod(inAspect),
  43. Expr.NONE, inAspect);
  44. state.setAspectInstance(myInstance);
  45. // we have no test
  46. // a NoAspectBoundException will be thrown if we need an instance of this
  47. // aspect before we are bound
  48. return Literal.TRUE;
  49. }
  50. public PerClause concretize(ResolvedTypeX inAspect) {
  51. PerSingleton ret = new PerSingleton();
  52. ret.inAspect = inAspect;
  53. return ret;
  54. }
  55. public void write(DataOutputStream s) throws IOException {
  56. SINGLETON.write(s);
  57. writeLocation(s);
  58. }
  59. public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException {
  60. PerSingleton ret = new PerSingleton();
  61. ret.readLocation(context, s);
  62. return ret;
  63. }
  64. public PerClause.Kind getKind() {
  65. return SINGLETON;
  66. }
  67. public String toString() {
  68. return "persingleton(" + inAspect + ")";
  69. }
  70. }