5 public class ClassDescriptor extends Descriptor {
6 private static int UIDCount=1; // start from 1 instead of 0 for multicore gc
7 private final int classid;
9 ClassDescriptor superdesc;
10 boolean hasFlags=false;
20 int numstaticblocks=0;
22 public ClassDescriptor(String classname) {
26 public ClassDescriptor(String packagename, String classname) {
29 flags=new SymbolTable();
30 fields=new SymbolTable();
31 fieldvec=new Vector();
32 methods=new SymbolTable();
34 this.packagename=packagename;
41 public Iterator getMethods() {
42 return methods.getDescriptorsIterator();
45 public Iterator getFields() {
46 return fields.getDescriptorsIterator();
49 public Iterator getFlags() {
50 return flags.getDescriptorsIterator();
53 public SymbolTable getFieldTable() {
57 public Vector getFieldVec() {
61 public SymbolTable getFlagTable() {
65 public SymbolTable getMethodTable() {
69 public String getSafeDescriptor() {
70 return "L"+safename.replace('.','/');
73 public String printTree(State state) {
75 String st=modifiers.toString()+"class "+getSymbol();
77 st+="extends "+superclass.toString();
79 indent=TreeNode.INDENT;
80 boolean printcr=false;
82 for(Iterator it=getFlags(); it.hasNext();) {
83 FlagDescriptor fd=(FlagDescriptor)it.next();
84 st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
92 for(Iterator it=getFields(); it.hasNext();) {
93 FieldDescriptor fd=(FieldDescriptor)it.next();
94 st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
100 for(Iterator it=getMethods(); it.hasNext();) {
101 MethodDescriptor md=(MethodDescriptor)it.next();
102 st+=TreeNode.printSpace(indent)+md.toString()+" ";
103 BlockNode bn=state.getMethodBody(md);
104 st+=bn.printNode(indent)+"\n\n";
110 public void addFlag(FlagDescriptor fd) {
111 if (flags.contains(fd.getSymbol()))
112 throw new Error(fd.getSymbol()+" already defined");
117 public boolean hasFlags() {
118 return hasFlags||getSuperDesc()!=null&&getSuperDesc().hasFlags();
121 public void addField(FieldDescriptor fd) {
122 if (fields.contains(fd.getSymbol()))
123 throw new Error(fd.getSymbol()+" already defined");
128 public void addMethod(MethodDescriptor md) {
132 public void setModifiers(Modifiers modifiers) {
133 this.modifiers=modifiers;
136 public void setSuper(String superclass) {
137 this.superclass=superclass;
140 public ClassDescriptor getSuperDesc() {
144 public void setSuper(ClassDescriptor scd) {
148 public String getSuper() {
152 public void incStaticBlocks() {
153 this.numstaticblocks++;
156 public int getNumStaticBlocks() {
157 return this.numstaticblocks;