projects
/
org.ibex.classgen.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
made all CPGen.FooEnt classes non-static, since they needed a reference to their...
[org.ibex.classgen.git]
/
src
/
org
/
ibex
/
classgen
/
CPGen.java
diff --git
a/src/org/ibex/classgen/CPGen.java
b/src/org/ibex/classgen/CPGen.java
index
3682fe9
..
08bb904
100644
(file)
--- a/
src/org/ibex/classgen/CPGen.java
+++ b/
src/org/ibex/classgen/CPGen.java
@@
-20,12
+20,11
@@
class CPGen {
/*
* Entries
*/
/*
* Entries
*/
- public abstract static class Ent {
- CPGen owner; // don't need this yet, but we will to implement ref() and unref()
+ public abstract class Ent {
int n; // this is the refcount if state == OPEN, index if >= STABLE
int tag;
int n; // this is the refcount if state == OPEN, index if >= STABLE
int tag;
- Ent(CPGen owner, int tag) { this.owner = owner; this.tag = tag; }
+ Ent(int tag) { this.tag = tag; }
void dump(DataOutput o) throws IOException { o.writeByte(tag); }
String debugToString() { return toString(); } // so we can remove this method when not debugging
void dump(DataOutput o) throws IOException { o.writeByte(tag); }
String debugToString() { return toString(); } // so we can remove this method when not debugging
@@
-33,9
+32,9
@@
class CPGen {
}
// INVARIANTS: tag == 3 || tag == 4
}
// INVARIANTS: tag == 3 || tag == 4
- static class IntEnt extends Ent {
+ class IntEnt extends Ent {
int i;
int i;
- IntEnt(CPGen owner, int tag) { super(owner, tag); }
+ IntEnt(int tag) { super(tag); }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeInt(i); }
Object key() {
switch(tag) {
void dump(DataOutput o) throws IOException { super.dump(o); o.writeInt(i); }
Object key() {
switch(tag) {
@@
-47,9
+46,9
@@
class CPGen {
}
// INVARIANTS: tag == 5 || tag == 6
}
// INVARIANTS: tag == 5 || tag == 6
- static class LongEnt extends Ent {
+ class LongEnt extends Ent {
long l;
long l;
- LongEnt(CPGen owner, int tag) { super(owner, tag); }
+ LongEnt(int tag) { super(tag); }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeLong(l); }
Object key() {
switch(tag) {
void dump(DataOutput o) throws IOException { super.dump(o); o.writeLong(l); }
Object key() {
switch(tag) {
@@
-71,10
+70,10
@@
class CPGen {
e0 instanceof Utf8Ent
}
*/
e0 instanceof Utf8Ent
}
*/
- static class CPRefEnt extends Ent {
+ class CPRefEnt extends Ent {
Ent e1;
Ent e2;
Ent e1;
Ent e2;
- CPRefEnt(CPGen owner, int tag) { super(owner, tag); }
+ CPRefEnt(int tag) { super(tag); }
String debugToString() { return "[" + e1.n + ":" + e1.debugToString() + (e2 == null ? "" : " + " + e2.n + ":" + e2.debugToString()) + "]"; }
String debugToString() { return "[" + e1.n + ":" + e1.debugToString() + (e2 == null ? "" : " + " + e2.n + ":" + e2.debugToString()) + "]"; }
@@
-87,18
+86,18
@@
class CPGen {
private String fixme() { throw new Error("fixme"); }
Object key() throws ClassGen.ClassReadExn {
switch(tag) {
private String fixme() { throw new Error("fixme"); }
Object key() throws ClassGen.ClassReadExn {
switch(tag) {
- case 7: return Type.fromDescriptor(((Utf8Ent)e1).s);
+ case 7: return Type.instance(((Utf8Ent)e1).s);
case 8: return (((Utf8Ent)e1).s);
case 9: {
NameAndTypeKey nt = (NameAndTypeKey) e2.key();
case 8: return (((Utf8Ent)e1).s);
case 9: {
NameAndTypeKey nt = (NameAndTypeKey) e2.key();
- Type t = Type.fromDescriptor(nt.type);
+ Type t = Type.instance(nt.type);
if(t == null) throw new ClassGen.ClassReadExn("invalid type descriptor");
if(t == null) throw new ClassGen.ClassReadExn("invalid type descriptor");
- return new FieldRef((Type.Object)e1.key(), nt.name, t);
+ return new FieldRef((Type.Class)e1.key(), nt.name, t);
}
case 10: case 11: {
NameAndTypeKey nt = (NameAndTypeKey) e2.key();
if (e1.key() == null) throw new Error(e1.tag + " => " + e1.key());
}
case 10: case 11: {
NameAndTypeKey nt = (NameAndTypeKey) e2.key();
if (e1.key() == null) throw new Error(e1.tag + " => " + e1.key());
- return new MethodRef((Type.Object)e1.key(), "methodname", Type.VOID, new Type[0]); // FIXME FIXME
+ return new MethodRef((Type.Class)e1.key(), "methodname", Type.VOID, new Type[0]); // FIXME FIXME
}
case 12: {
return new NameAndTypeKey(((Utf8Ent)e1).s, ((Utf8Ent)e2).s);
}
case 12: {
return new NameAndTypeKey(((Utf8Ent)e1).s, ((Utf8Ent)e2).s);
@@
-108,9
+107,9
@@
class CPGen {
}
}
}
}
- static class Utf8Ent extends Ent {
+ class Utf8Ent extends Ent {
String s;
String s;
- Utf8Ent(CPGen owner) { super(owner, 1); }
+ Utf8Ent() { super(1); }
String debugToString() { return s; }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); }
Object key() {
String debugToString() { return s; }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); }
Object key() {
@@
-166,7
+165,7
@@
class CPGen {
public final Type getType(int index) throws ClassGen.ClassReadExn {
Ent e = getByIndex(index);
public final Type getType(int index) throws ClassGen.ClassReadExn {
Ent e = getByIndex(index);
- if (e instanceof Utf8Ent) return Type.fromDescriptor(((Utf8Ent)e).s);
+ if (e instanceof Utf8Ent) return Type.instance(((Utf8Ent)e).s);
else return (Type)e.key();
}
else return (Type)e.key();
}
@@
-190,36
+189,36
@@
class CPGen {
return ent;
}
return ent;
}
- if(o instanceof Type.Object) {
- CPRefEnt ce = new CPRefEnt(this, 7);
- ce.e1 = addUtf8(((Type.Object)o).internalForm());
+ if(o instanceof Type.Class) {
+ CPRefEnt ce = new CPRefEnt(7);
+ ce.e1 = addUtf8(((Type.Class)o).internalForm());
ent = ce;
} else if(o instanceof String) {
ent = ce;
} else if(o instanceof String) {
- CPRefEnt ce = new CPRefEnt(this, 8);
+ CPRefEnt ce = new CPRefEnt(8);
ce.e1 = addUtf8((String)o);
ent = ce;
} else if(o instanceof Integer) {
ce.e1 = addUtf8((String)o);
ent = ce;
} else if(o instanceof Integer) {
- IntEnt ue = new IntEnt(this, 3);
+ IntEnt ue = new IntEnt(3);
ue.i = ((Integer)o).intValue();
ent = ue;
} else if(o instanceof Float) {
ue.i = ((Integer)o).intValue();
ent = ue;
} else if(o instanceof Float) {
- IntEnt ue = new IntEnt(this, 4);
+ IntEnt ue = new IntEnt(4);
ue.i = Float.floatToIntBits(((Float)o).floatValue());
ent = ue;
} else if(o instanceof Long) {
ue.i = Float.floatToIntBits(((Float)o).floatValue());
ent = ue;
} else if(o instanceof Long) {
- LongEnt le = new LongEnt(this, 5);
+ LongEnt le = new LongEnt(5);
le.l = ((Long)o).longValue();
ent = le;
} else if(o instanceof Double) {
le.l = ((Long)o).longValue();
ent = le;
} else if(o instanceof Double) {
- LongEnt le = new LongEnt(this, 6);
+ LongEnt le = new LongEnt(6);
le.l = Double.doubleToLongBits(((Double)o).doubleValue());
ent = le;
} else if(o instanceof Utf8Key) {
le.l = Double.doubleToLongBits(((Double)o).doubleValue());
ent = le;
} else if(o instanceof Utf8Key) {
- Utf8Ent ue = new Utf8Ent(this);
+ Utf8Ent ue = new Utf8Ent();
ue.s = ((Utf8Key)o).s;
ent = ue;
} else if(o instanceof NameAndTypeKey) {
ue.s = ((Utf8Key)o).s;
ent = ue;
} else if(o instanceof NameAndTypeKey) {
- CPRefEnt ce = new CPRefEnt(this, 12);
+ CPRefEnt ce = new CPRefEnt(12);
NameAndTypeKey key = (NameAndTypeKey) o;
ce.e1 = addUtf8(key.name);
ce.e2 = addUtf8(key.type);
NameAndTypeKey key = (NameAndTypeKey) o;
ce.e1 = addUtf8(key.name);
ce.e2 = addUtf8(key.type);
@@
-228,7
+227,7
@@
class CPGen {
ClassGen.FieldOrMethodRef key = (ClassGen.FieldOrMethodRef) o;
int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
if(tag == 0) throw new Error("should never happen");
ClassGen.FieldOrMethodRef key = (ClassGen.FieldOrMethodRef) o;
int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
if(tag == 0) throw new Error("should never happen");
- CPRefEnt ce = new CPRefEnt(this, tag);
+ CPRefEnt ce = new CPRefEnt(tag);
ce.e1 = add(key.klass);
ce.e2 = addNameAndType(key.name, key.descriptor);
ent = ce;
ce.e1 = add(key.klass);
ce.e2 = addNameAndType(key.name, key.descriptor);
ent = ce;
@@
-340,7
+339,7
@@
class CPGen {
case 11: // Instance Method Ref
case 12: // NameAndType
{
case 11: // Instance Method Ref
case 12: // NameAndType
{
- e = new CPRefEnt(this, tag);
+ e = new CPRefEnt(tag);
e1s[index] = in.readUnsignedShort();
if(tag != 7 && tag != 8) e2s[index] = in.readUnsignedShort();
break;
e1s[index] = in.readUnsignedShort();
if(tag != 7 && tag != 8) e2s[index] = in.readUnsignedShort();
break;
@@
-349,7
+348,7
@@
class CPGen {
case 4: // Float
{
IntEnt ie;
case 4: // Float
{
IntEnt ie;
- e = ie = new IntEnt(this, tag);
+ e = ie = new IntEnt(tag);
ie.i = in.readInt();
break;
}
ie.i = in.readInt();
break;
}
@@
-357,14
+356,14
@@
class CPGen {
case 6: // Double
{
LongEnt le;
case 6: // Double
{
LongEnt le;
- e = le = new LongEnt(this, tag);
+ e = le = new LongEnt(tag);
le.l = in.readLong();
break;
}
case 1: // Utf8
{
Utf8Ent ue;
le.l = in.readLong();
break;
}
case 1: // Utf8
{
Utf8Ent ue;
- e = ue = new Utf8Ent(this);
+ e = ue = new Utf8Ent();
ue.s = in.readUTF();
break;
}
ue.s = in.readUTF();
break;
}