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.

ResolvableTypeList.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* *******************************************************************
  2. * Copyright (c) 2009 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 initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. /**
  14. * Carries an array of unresolved types - will resolve them on demand. Can be used where currently the entire array gets resolved
  15. * and a ResolvedType array is passed on. Depending on the situation there may not be a need to resolve all the entries so this can
  16. * perform better. Note: the array elements are resolved in place, so the caller should not be surprised if elements and resolved
  17. * after the type list has been used.
  18. *
  19. * @author Andy Clement
  20. */
  21. public class ResolvableTypeList {
  22. public int length;
  23. private World world;
  24. private UnresolvedType[] types;
  25. public ResolvableTypeList(World world, UnresolvedType[] unresolvedTypes) {
  26. length = unresolvedTypes.length;
  27. types = unresolvedTypes;
  28. this.world = world;
  29. }
  30. public ResolvedType getResolved(int nameIndex) {
  31. UnresolvedType ut = types[nameIndex];
  32. if (!(ut instanceof ResolvedType)) {
  33. types[nameIndex] = world.resolve(ut);
  34. return (ResolvedType) types[nameIndex];
  35. } else {
  36. return (ResolvedType) ut;
  37. }
  38. }
  39. }