mass rename: ACC_FOO
authoradam <adam@megacz.com>
Mon, 27 Jun 2005 08:17:49 +0000 (08:17 +0000)
committeradam <adam@megacz.com>
Mon, 27 Jun 2005 08:17:49 +0000 (08:17 +0000)
darcs-hash:20050627081749-5007d-0809071d4e8aef3f76eb7ff5fa7c52b39fcca3ad.gz

Makefile
src/org/ibex/classgen/CGConst.java
src/org/ibex/classgen/ClassFile.java
src/org/ibex/classgen/FieldGen.java
src/org/ibex/classgen/MethodGen.java

index 4a9bb40..9a965e3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ $(classes): $(sources)
        $(JAVAC) -d build $(sources)
 
 test: $(classes)
        $(JAVAC) -d build $(sources)
 
 test: $(classes)
-       java -cp build org.ibex.classgen.ClassFile
+       java -cp build org.ibex.classgen.ClassFile org.ibex.classgen.ClassFile
 
 clean: 
        rm -rf build/*
 
 clean: 
        rm -rf build/*
index 6649e8b..d789292 100644 (file)
@@ -3,27 +3,27 @@ package org.ibex.classgen;
 public interface CGConst {
 
     // Class only
 public interface CGConst {
 
     // Class only
-    public static final int ACC_INTERFACE = 0x0200;
-    public static final int ACC_SUPER     = 0x0020;
+    public static final int INTERFACE = 0x0200;
+    public static final int SUPER     = 0x0020;
 
     // Field/Method only
 
     // Field/Method only
-    public static final int ACC_PUBLIC    = 0x0001;
-    public static final int ACC_PRIVATE   = 0x0002;
-    public static final int ACC_PROTECTED = 0x0004;
-    public static final int ACC_STATIC    = 0x0008;
-    public static final int ACC_FINAL     = 0x0010;
+    public static final int PUBLIC    = 0x0001;
+    public static final int PRIVATE   = 0x0002;
+    public static final int PROTECTED = 0x0004;
+    public static final int STATIC    = 0x0008;
+    public static final int FINAL     = 0x0010;
 
     // Class/Method only
 
     // Class/Method only
-    public static final int ACC_ABSTRACT  = 0x0400;
+    public static final int ABSTRACT  = 0x0400;
     
     // Method Only
     
     // Method Only
-    public static final int ACC_SYNCHRONIZED = 0x0020;
-    public static final int ACC_NATIVE       = 0x0100;
-    public static final int ACC_STRICT       = 0x0800;
+    public static final int SYNCHRONIZED = 0x0020;
+    public static final int NATIVE       = 0x0100;
+    public static final int STRICT       = 0x0800;
 
     // Field only
 
     // Field only
-    public static final int ACC_VOLATILE  = 0x0040;
-    public static final int ACC_TRANSIENT = 0x0080;
+    public static final int VOLATILE  = 0x0040;
+    public static final int TRANSIENT = 0x0080;
     
     
     // Constant Pool Stuff
     
     
     // Constant Pool Stuff
index dd2247c..8cb2853 100644 (file)
@@ -19,17 +19,17 @@ public class ClassFile implements CGConst {
 
     static String flagsToString(int flags, boolean isClass) {
         StringBuffer sb = new StringBuffer(32);
 
     static String flagsToString(int flags, boolean isClass) {
         StringBuffer sb = new StringBuffer(32);
-        if ((flags & ACC_PUBLIC) != 0)       sb.append("public ");
-        if ((flags & ACC_PRIVATE) != 0)      sb.append("private ");
-        if ((flags & ACC_PROTECTED) != 0)    sb.append("protected ");
-        if ((flags & ACC_STATIC) != 0)       sb.append("static ");
-        if ((flags & ACC_FINAL) != 0)        sb.append("final ");
-        if ((flags & ACC_ABSTRACT) != 0)     sb.append("abstract ");
-        if (!isClass && (flags & ACC_SYNCHRONIZED) != 0) sb.append("synchronized ");
-        if (!isClass && (flags & ACC_NATIVE) != 0)       sb.append("native ");
-        if (!isClass && (flags & ACC_STRICT) != 0)       sb.append("strictfp ");
-        if (!isClass && (flags & ACC_VOLATILE) != 0)     sb.append("volatile ");
-        if (!isClass && (flags & ACC_TRANSIENT) != 0)    sb.append("transient ");
+        if ((flags & PUBLIC) != 0)       sb.append("public ");
+        if ((flags & PRIVATE) != 0)      sb.append("private ");
+        if ((flags & PROTECTED) != 0)    sb.append("protected ");
+        if ((flags & STATIC) != 0)       sb.append("static ");
+        if ((flags & FINAL) != 0)        sb.append("final ");
+        if ((flags & ABSTRACT) != 0)     sb.append("abstract ");
+        if (!isClass && (flags & SYNCHRONIZED) != 0) sb.append("synchronized ");
+        if (!isClass && (flags & NATIVE) != 0)       sb.append("native ");
+        if (!isClass && (flags & STRICT) != 0)       sb.append("strictfp ");
+        if (!isClass && (flags & VOLATILE) != 0)     sb.append("volatile ");
+        if (!isClass && (flags & TRANSIENT) != 0)    sb.append("transient ");
         return sb.toString();
     }
 
         return sb.toString();
     }
 
@@ -38,7 +38,7 @@ public class ClassFile implements CGConst {
     String debugToString() { return debugToString(new StringBuffer(4096)).toString(); }
     StringBuffer debugToString(StringBuffer sb) {
         sb.append(flagsToString(flags,true));
     String debugToString() { return debugToString(new StringBuffer(4096)).toString(); }
     StringBuffer debugToString(StringBuffer sb) {
         sb.append(flagsToString(flags,true));
-        sb.append((flags & ACC_INTERFACE) != 0 ? "interface " : "class ");
+        sb.append((flags & INTERFACE) != 0 ? "interface " : "class ");
         sb.append(thisType.debugToString());
         if (superType != null) sb.append(" extends " + superType.debugToString());
         if (interfaces != null && interfaces.length > 0) sb.append(" implements");
         sb.append(thisType.debugToString());
         if (superType != null) sb.append(" extends " + superType.debugToString());
         if (interfaces != null && interfaces.length > 0) sb.append(" implements");
@@ -63,7 +63,7 @@ public class ClassFile implements CGConst {
 
     public ClassFile(Type.Class thisType, Type.Class superType, int flags) { this(thisType, superType, flags, null); }
     public ClassFile(Type.Class thisType, Type.Class superType, int flags, Type.Class[] interfaces) {
 
     public ClassFile(Type.Class thisType, Type.Class superType, int flags) { this(thisType, superType, flags, null); }
     public ClassFile(Type.Class thisType, Type.Class superType, int flags, Type.Class[] interfaces) {
-        if((flags & ~(ACC_PUBLIC|ACC_FINAL|ACC_SUPER|ACC_INTERFACE|ACC_ABSTRACT)) != 0)
+        if((flags & ~(PUBLIC|FINAL|SUPER|INTERFACE|ABSTRACT)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.thisType = thisType;
         this.superType = superType;
             throw new IllegalArgumentException("invalid flags");
         this.thisType = thisType;
         this.superType = superType;
@@ -79,14 +79,14 @@ public class ClassFile implements CGConst {
         @param ret The return type of the method
         @param args The arguments to the method
         @param flags The flags for the method
         @param ret The return type of the method
         @param args The arguments to the method
         @param flags The flags for the method
-                     (ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT)
+                     (PUBLIC, PRIVATE, PROTECTED, STATIC, SYNCHRONIZED, NATIVE, ABSTRACT, STRICT)
         @return A new MethodGen object for the method
         @exception IllegalArgumentException if illegal flags are specified
         @see MethodGen
         @see CGConst
     */
     public final MethodGen addMethod(String name, Type ret, Type[] args, int flags) {
         @return A new MethodGen object for the method
         @exception IllegalArgumentException if illegal flags are specified
         @see MethodGen
         @see CGConst
     */
     public final MethodGen addMethod(String name, Type ret, Type[] args, int flags) {
-        MethodGen mg = new MethodGen(this, name, ret, args, flags, (this.flags & ACC_INTERFACE) != 0);
+        MethodGen mg = new MethodGen(this, name, ret, args, flags, (this.flags & INTERFACE) != 0);
         methods.addElement(mg);
         return mg;
     }
         methods.addElement(mg);
         return mg;
     }
@@ -95,7 +95,7 @@ public class ClassFile implements CGConst {
         @param name The name of the filed (not the signature, just the name)
         @param type The type of the field
         @param flags The flags for the field
         @param name The name of the filed (not the signature, just the name)
         @param type The type of the field
         @param flags The flags for the field
-        (ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT)
+        (PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL, VOLATILE, TRANSIENT)
         @return A new FieldGen object for the method
         @exception IllegalArgumentException if illegal flags are specified
         @see FieldGen
         @return A new FieldGen object for the method
         @exception IllegalArgumentException if illegal flags are specified
         @see FieldGen
@@ -206,7 +206,7 @@ public class ClassFile implements CGConst {
         major = i.readShort();
         ConstantPool cp = new ConstantPool(i);
         flags = i.readShort();
         major = i.readShort();
         ConstantPool cp = new ConstantPool(i);
         flags = i.readShort();
-        if((flags & ~(ACC_PUBLIC|ACC_FINAL|ACC_SUPER|ACC_INTERFACE|ACC_ABSTRACT)) != 0)
+        if((flags & ~(PUBLIC|FINAL|SUPER|INTERFACE|ABSTRACT)) != 0)
             throw new ClassReadExn("invalid flags: " + Integer.toString(flags,16));
         thisType = (Type.Class) cp.getKeyByIndex(i.readShort());
         superType = (Type.Class) cp.getKeyByIndex(i.readShort());
             throw new ClassReadExn("invalid flags: " + Integer.toString(flags,16));
         thisType = (Type.Class) cp.getKeyByIndex(i.readShort());
         superType = (Type.Class) cp.getKeyByIndex(i.readShort());
@@ -215,7 +215,7 @@ public class ClassFile implements CGConst {
         int numFields = i.readShort();
         for(int j=0; j<numFields; j++) fields.addElement(new FieldGen(i, cp));
         int numMethods = i.readShort();
         int numFields = i.readShort();
         for(int j=0; j<numFields; j++) fields.addElement(new FieldGen(i, cp));
         int numMethods = i.readShort();
-        for(int j=0; j<numMethods; j++) methods.addElement(new MethodGen(this, i, cp, (this.flags & ACC_INTERFACE) != 0));
+        for(int j=0; j<numMethods; j++) methods.addElement(new MethodGen(this, i, cp, (this.flags & INTERFACE) != 0));
         attributes = new AttrGen(i, cp);
         
         // FEATURE: Support these
         attributes = new AttrGen(i, cp);
         
         // FEATURE: Support these
@@ -306,10 +306,10 @@ public class ClassFile implements CGConst {
         } else {
             /*
             Type.Class me = new Type.Class("Test");
         } else {
             /*
             Type.Class me = new Type.Class("Test");
-            ClassFile cg = new ClassFile("Test", "java.lang.Object", ACC_PUBLIC|ACC_SUPER|ACC_FINAL);
-            FieldGen fg = cg.addField("foo", Type.INT, ACC_PUBLIC|ACC_STATIC);
+            ClassFile cg = new ClassFile("Test", "java.lang.Object", PUBLIC|SUPER|FINAL);
+            FieldGen fg = cg.addField("foo", Type.INT, PUBLIC|STATIC);
         
         
-            MethodGen mg = cg.addMethod("main", Type.VOID, new Type[]{Type.arrayType(Type.STRING)}, ACC_STATIC|ACC_PUBLIC);
+            MethodGen mg = cg.addMethod("main", Type.VOID, new Type[]{Type.arrayType(Type.STRING)}, STATIC|PUBLIC);
             mg.setMaxLocals(1);
             mg.addPushConst(0);
             //mg.add(ISTORE_0);
             mg.setMaxLocals(1);
             mg.addPushConst(0);
             //mg.add(ISTORE_0);
index b65cb09..b657342 100644 (file)
@@ -23,7 +23,7 @@ public class FieldGen implements CGConst {
     
     FieldGen(DataInput in, ConstantPool cp) throws IOException {
         flags = in.readShort();
     
     FieldGen(DataInput in, ConstantPool cp) throws IOException {
         flags = in.readShort();
-        if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_VOLATILE|ACC_TRANSIENT|ACC_STATIC|ACC_FINAL)) != 0)
+        if((flags & ~(PUBLIC|PRIVATE|PROTECTED|VOLATILE|TRANSIENT|STATIC|FINAL)) != 0)
             throw new ClassFile.ClassReadExn("invalid flags");        
         name = cp.getUtf8KeyByIndex(in.readShort());
         type = Type.instance(cp.getUtf8KeyByIndex(in.readShort()));
             throw new ClassFile.ClassReadExn("invalid flags");        
         name = cp.getUtf8KeyByIndex(in.readShort());
         type = Type.instance(cp.getUtf8KeyByIndex(in.readShort()));
@@ -31,7 +31,7 @@ public class FieldGen implements CGConst {
     }
 
     FieldGen(ClassFile owner, String name, Type type, int flags) {
     }
 
     FieldGen(ClassFile owner, String name, Type type, int flags) {
-        if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_VOLATILE|ACC_TRANSIENT|ACC_STATIC|ACC_FINAL)) != 0)
+        if((flags & ~(PUBLIC|PRIVATE|PROTECTED|VOLATILE|TRANSIENT|STATIC|FINAL)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.name = name;
         this.type = type;
             throw new IllegalArgumentException("invalid flags");
         this.name = name;
         this.type = type;
@@ -42,7 +42,7 @@ public class FieldGen implements CGConst {
     /** Sets the ContantValue attribute for this field. 
         @param val The value to set this field to. Must be an Integer, Long, Float, Double, or String */
     public void setConstantValue(Object val) {
     /** Sets the ContantValue attribute for this field. 
         @param val The value to set this field to. Must be an Integer, Long, Float, Double, or String */
     public void setConstantValue(Object val) {
-        if((flags & ACC_STATIC) == 0) throw new IllegalStateException("field does not have the ACC_STATIC bit set");
+        if((flags & STATIC) == 0) throw new IllegalStateException("field does not have the STATIC bit set");
         attrs.put("ConstantValue",val);
     }
     
         attrs.put("ConstantValue",val);
     }
     
index e773359..e534c65 100644 (file)
@@ -97,7 +97,7 @@ public class MethodGen implements CGConst {
                 sb.append(" ");
             }
         }
                 sb.append(" ");
             }
         }
-        if((flags & (ACC_NATIVE|ACC_ABSTRACT))==0) {
+        if((flags & (NATIVE|ABSTRACT))==0) {
             sb.append("{\n");
             for(int i=0;i<size();i++) {
                 sb.append("    ");
             sb.append("{\n");
             for(int i=0;i<size();i++) {
                 sb.append("    ");
@@ -121,7 +121,7 @@ public class MethodGen implements CGConst {
     MethodGen(ClassFile cf, DataInput in, ConstantPool cp, boolean ownerInterface) throws IOException {
         this.cf = cf;
         flags = in.readShort();
     MethodGen(ClassFile cf, DataInput in, ConstantPool cp, boolean ownerInterface) throws IOException {
         this.cf = cf;
         flags = in.readShort();
-        if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) != 0)
+        if((flags & ~(PUBLIC|PRIVATE|PROTECTED|STATIC|FINAL|SYNCHRONIZED|NATIVE|ABSTRACT|STRICT)) != 0)
             throw new ClassFile.ClassReadExn("invalid flags");
         this.name = cp.getUtf8KeyByIndex(in.readShort());
         //System.err.println("Processing " + name + "...");
             throw new ClassFile.ClassReadExn("invalid flags");
         this.name = cp.getUtf8KeyByIndex(in.readShort());
         //System.err.println("Processing " + name + "...");
@@ -131,7 +131,7 @@ public class MethodGen implements CGConst {
         for(int i=0; i<args.length; i++) args[i] = m.getArgType(i);
         this.attrs = new ClassFile.AttrGen(in,cp);
         
         for(int i=0; i<args.length; i++) args[i] = m.getArgType(i);
         this.attrs = new ClassFile.AttrGen(in,cp);
         
-        if((flags & (ACC_NATIVE|ACC_ABSTRACT))==0)  {
+        if((flags & (NATIVE|ABSTRACT))==0)  {
             byte[] codeAttr = (byte[]) attrs.get("Code");
             if(codeAttr == null) throw new ClassFile.ClassReadExn("code attr expected");
             DataInputStream ci = new DataInputStream(new ByteArrayInputStream(codeAttr));
             byte[] codeAttr = (byte[]) attrs.get("Code");
             if(codeAttr == null) throw new ClassFile.ClassReadExn("code attr expected");
             DataInputStream ci = new DataInputStream(new ByteArrayInputStream(codeAttr));
@@ -314,7 +314,7 @@ public class MethodGen implements CGConst {
     }
 
     MethodGen(ClassFile cf, String name, Type ret, Type[] args, int flags, boolean ownerInterface) {
     }
 
     MethodGen(ClassFile cf, String name, Type ret, Type[] args, int flags, boolean ownerInterface) {
-        if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) != 0)
+        if((flags & ~(PUBLIC|PRIVATE|PROTECTED|STATIC|FINAL|SYNCHRONIZED|NATIVE|ABSTRACT|STRICT)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.cf = cf;
         this.name = name;
             throw new IllegalArgumentException("invalid flags");
         this.cf = cf;
         this.name = name;
@@ -325,9 +325,9 @@ public class MethodGen implements CGConst {
         attrs = new ClassFile.AttrGen();
         codeAttrs = new ClassFile.AttrGen();
         
         attrs = new ClassFile.AttrGen();
         codeAttrs = new ClassFile.AttrGen();
         
-        if(ownerInterface || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1;
+        if(ownerInterface || (flags & (ABSTRACT|NATIVE)) != 0) size = capacity = -1;
         
         
-        maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0, 4);
+        maxLocals = Math.max(args.length + (flags&STATIC)==0 ? 1 : 0, 4);
     }
     
     class ExnTableEnt {
     }
     
     class ExnTableEnt {
@@ -634,7 +634,7 @@ public class MethodGen implements CGConst {
             ((ExnTableEnt)exnTable.elementAt(i)).finish(cp);
         
         // We'll set these correctly later
             ((ExnTableEnt)exnTable.elementAt(i)).finish(cp);
         
         // We'll set these correctly later
-        if((flags & (ACC_NATIVE|ACC_ABSTRACT))==0) attrs.put("Code","");
+        if((flags & (NATIVE|ABSTRACT))==0) attrs.put("Code","");
         if(thrownExceptions.size() > 0) attrs.put("Exceptions","");
         attrs.finish(cp);
         codeAttrs.finish(cp);
         if(thrownExceptions.size() > 0) attrs.put("Exceptions","");
         attrs.finish(cp);
         codeAttrs.finish(cp);
@@ -953,7 +953,7 @@ public class MethodGen implements CGConst {
     }
     
     void dump(DataOutput o, ConstantPool cp) throws IOException {
     }
     
     void dump(DataOutput o, ConstantPool cp) throws IOException {
-        if((flags & (ACC_NATIVE|ACC_ABSTRACT))==0) generateCode(cp);
+        if((flags & (NATIVE|ABSTRACT))==0) generateCode(cp);
         generateExceptions(cp);
         
         o.writeShort(flags);
         generateExceptions(cp);
         
         o.writeShort(flags);