5 public class ClassDescriptor extends Descriptor {
6 public ClassDescriptor(String classname) {
9 flags=new SymbolTable();
10 fields=new SymbolTable();
11 methods=new SymbolTable();
14 private static int UIDCount=0;
15 private final int classid;
17 ClassDescriptor superdesc;
18 boolean hasFlags=false;
30 public Iterator getMethods() {
31 return methods.getDescriptorsIterator();
34 public Iterator getFields() {
35 return fields.getDescriptorsIterator();
38 public Iterator getFlags() {
39 return flags.getDescriptorsIterator();
42 public SymbolTable getFieldTable() {
46 public SymbolTable getFlagTable() {
50 public SymbolTable getMethodTable() {
54 public String getSafeDescriptor() {
55 return "L"+safename.replace('.','/');
58 public String printTree(State state) {
60 String st=modifiers.toString()+"class "+getSymbol();
62 st+="extends "+superclass.toString();
64 indent=TreeNode.INDENT;
65 boolean printcr=false;
67 for(Iterator it=getFlags();it.hasNext();) {
68 FlagDescriptor fd=(FlagDescriptor)it.next();
69 st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
77 for(Iterator it=getFields();it.hasNext();) {
78 FieldDescriptor fd=(FieldDescriptor)it.next();
79 st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
85 for(Iterator it=getMethods();it.hasNext();) {
86 MethodDescriptor md=(MethodDescriptor)it.next();
87 st+=TreeNode.printSpace(indent)+md.toString()+" ";
88 BlockNode bn=state.getMethodBody(md);
89 st+=bn.printNode(indent)+"\n\n";
95 public void addFlag(FlagDescriptor fd) {
96 if (flags.contains(fd.getSymbol()))
97 throw new Error(fd.getSymbol()+" already defined");
102 public boolean hasFlags() {
106 public void addField(FieldDescriptor fd) {
107 if (fields.contains(fd.getSymbol()))
108 throw new Error(fd.getSymbol()+" already defined");
112 public void addMethod(MethodDescriptor md) {
116 public void setModifiers(Modifiers modifiers) {
117 this.modifiers=modifiers;
120 public void setSuper(String superclass) {
121 this.superclass=superclass;
124 public ClassDescriptor getSuperDesc() {
128 public void setSuper(ClassDescriptor scd) {
132 public String getSuper() {