Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

HelperInterfaceBinding.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 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. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.compiler.lookup;
  13. import java.util.ArrayList;
  14. import java.util.Iterator;
  15. import java.util.List;
  16. import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
  17. import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
  19. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
  20. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
  21. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
  22. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
  23. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
  24. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
  25. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
  26. import org.aspectj.weaver.ResolvedMember;
  27. import org.aspectj.weaver.UnresolvedType;
  28. public class HelperInterfaceBinding extends SourceTypeBinding {
  29. private UnresolvedType typeX;
  30. SourceTypeBinding enclosingType;
  31. List methods = new ArrayList();
  32. public HelperInterfaceBinding(SourceTypeBinding enclosingType, UnresolvedType typeX) {
  33. super();
  34. this.fPackage = enclosingType.fPackage;
  35. //this.fileName = scope.referenceCompilationUnit().getFileName();
  36. this.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccInterface | ClassFileConstants.AccAbstract;
  37. this.sourceName = enclosingType.scope.referenceContext.name;
  38. this.enclosingType = enclosingType;
  39. this.typeX = typeX;
  40. this.typeVariables = Binding.NO_TYPE_VARIABLES;
  41. this.scope =enclosingType.scope;
  42. this.superInterfaces = new ReferenceBinding[0];
  43. }
  44. public HelperInterfaceBinding(
  45. char[][] compoundName,
  46. PackageBinding fPackage,
  47. ClassScope scope) {
  48. super(compoundName, fPackage, scope);
  49. }
  50. public char[] getFileName() {
  51. return enclosingType.getFileName();
  52. }
  53. public UnresolvedType getTypeX() {
  54. return typeX;
  55. }
  56. public void addMethod(EclipseFactory world , ResolvedMember member) {
  57. MethodBinding binding = world.makeMethodBinding(member);
  58. this.methods.add(binding);
  59. }
  60. public FieldBinding[] fields() { return new FieldBinding[0]; }
  61. public MethodBinding[] methods() { return new MethodBinding[0]; }
  62. public char[] constantPoolName() {
  63. String sig = typeX.getSignature();
  64. return sig.substring(1, sig.length()-1).toCharArray();
  65. }
  66. public void generateClass(CompilationResult result, ClassFile enclosingClassFile) {
  67. ClassFile classFile = new ClassFile(this);
  68. classFile.initialize(this, enclosingClassFile, false);
  69. classFile.recordInnerClasses(this);
  70. //classFile.addFieldInfos();
  71. classFile.contents[classFile.contentsOffset++] = (byte) 0;
  72. classFile.contents[classFile.contentsOffset++] = (byte) 0;
  73. classFile.setForMethodInfos();
  74. for (Iterator i = methods.iterator(); i.hasNext(); ) {
  75. MethodBinding b = (MethodBinding)i.next();
  76. generateMethod(classFile, b);
  77. }
  78. classFile.addAttributes();
  79. result.record(this.constantPoolName(), classFile);
  80. }
  81. private void generateMethod(ClassFile classFile, MethodBinding binding) {
  82. classFile.generateMethodInfoHeader(binding);
  83. int methodAttributeOffset = classFile.contentsOffset;
  84. int attributeNumber = classFile.generateMethodInfoAttributes(binding);
  85. classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber);
  86. }
  87. public ReferenceBinding[] superInterfaces() {
  88. return new ReferenceBinding[0];
  89. }
  90. }