use of org.eclipse.ceylon.langtools.tools.javac.code.Types.UniqueType in project ceylon by eclipse.
the class Code method emitop2.
/**
* Emit an opcode with a two-byte operand field.
*/
public void emitop2(int op, int od) {
emitop(op);
if (!alive)
return;
emit2(od);
switch(op) {
case getstatic:
state.push(((Symbol) (pool.pool[od])).erasure(types));
break;
case putstatic:
state.pop(((Symbol) (pool.pool[od])).erasure(types));
break;
case new_:
Symbol sym;
if (pool.pool[od] instanceof UniqueType) {
// Required by change in Gen.makeRef to allow
// annotated types.
// TODO: is this needed anywhere else?
sym = ((UniqueType) (pool.pool[od])).type.tsym;
} else {
sym = (Symbol) (pool.pool[od]);
}
state.push(uninitializedObject(sym.erasure(types), cp - 3));
break;
case sipush:
state.push(syms.intType);
break;
case if_acmp_null:
case if_acmp_nonnull:
case ifeq:
case ifne:
case iflt:
case ifge:
case ifgt:
case ifle:
state.pop(1);
break;
case if_icmpeq:
case if_icmpne:
case if_icmplt:
case if_icmpge:
case if_icmpgt:
case if_icmple:
case if_acmpeq:
case if_acmpne:
state.pop(2);
break;
case goto_:
markDead();
break;
case putfield:
state.pop(((Symbol) (pool.pool[od])).erasure(types));
// object ref
state.pop(1);
break;
case getfield:
// object ref
state.pop(1);
state.push(((Symbol) (pool.pool[od])).erasure(types));
break;
case checkcast:
{
// object ref
state.pop(1);
Object o = pool.pool[od];
Type t = (o instanceof Symbol) ? ((Symbol) o).erasure(types) : types.erasure((((UniqueType) o).type));
state.push(t);
break;
}
case ldc2w:
state.push(typeForPool(pool.pool[od]));
break;
case instanceof_:
state.pop(1);
state.push(syms.intType);
break;
case ldc2:
state.push(typeForPool(pool.pool[od]));
break;
case jsr:
break;
default:
throw new AssertionError(mnem(op));
}
// postop();
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Types.UniqueType in project ceylon by eclipse.
the class ClassWriter method writePool.
/**
* Write constant pool to pool buffer.
* Note: during writing, constant pool
* might grow since some parts of constants still need to be entered.
*/
void writePool(Pool pool) throws PoolOverflow, StringOverflow {
int poolCountIdx = poolbuf.length;
poolbuf.appendChar(0);
int i = 1;
while (i < pool.pp) {
Object value = pool.pool[i];
Assert.checkNonNull(value);
if (value instanceof Method || value instanceof Variable)
value = ((DelegatedSymbol) value).getUnderlyingSymbol();
if (value instanceof MethodSymbol) {
MethodSymbol m = (MethodSymbol) value;
if (!m.isDynamic()) {
poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0 ? CONSTANT_InterfaceMethodref : CONSTANT_Methodref);
poolbuf.appendChar(pool.put(m.owner));
poolbuf.appendChar(pool.put(nameType(m)));
} else {
// invokedynamic
DynamicMethodSymbol dynSym = (DynamicMethodSymbol) m;
MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
DynamicMethod dynMeth = new DynamicMethod(dynSym, types);
bootstrapMethods.put(dynMeth, handle);
// init cp entries
pool.put(names.BootstrapMethods);
pool.put(handle);
for (Object staticArg : dynSym.staticArgs) {
pool.put(staticArg);
}
poolbuf.appendByte(CONSTANT_InvokeDynamic);
poolbuf.appendChar(bootstrapMethods.size() - 1);
poolbuf.appendChar(pool.put(nameType(dynSym)));
}
} else if (value instanceof VarSymbol) {
VarSymbol v = (VarSymbol) value;
poolbuf.appendByte(CONSTANT_Fieldref);
poolbuf.appendChar(pool.put(v.owner));
poolbuf.appendChar(pool.put(nameType(v)));
} else if (value instanceof Name) {
poolbuf.appendByte(CONSTANT_Utf8);
byte[] bs = ((Name) value).toUtf();
poolbuf.appendChar(bs.length);
poolbuf.appendBytes(bs, 0, bs.length);
if (bs.length > Pool.MAX_STRING_LENGTH)
throw new StringOverflow(value.toString());
} else if (value instanceof ClassSymbol) {
ClassSymbol c = (ClassSymbol) value;
if (c.owner.kind == TYP)
pool.put(c.owner);
poolbuf.appendByte(CONSTANT_Class);
if (c.type.hasTag(ARRAY)) {
poolbuf.appendChar(pool.put(typeSig(c.type)));
} else {
poolbuf.appendChar(pool.put(names.fromUtf(externalize(c.flatname))));
enterInner(c);
}
} else if (value instanceof NameAndType) {
NameAndType nt = (NameAndType) value;
poolbuf.appendByte(CONSTANT_NameandType);
poolbuf.appendChar(pool.put(nt.name));
poolbuf.appendChar(pool.put(typeSig(nt.uniqueType.type)));
} else if (value instanceof Integer) {
poolbuf.appendByte(CONSTANT_Integer);
poolbuf.appendInt(((Integer) value).intValue());
} else if (value instanceof Long) {
poolbuf.appendByte(CONSTANT_Long);
poolbuf.appendLong(((Long) value).longValue());
i++;
} else if (value instanceof Float) {
poolbuf.appendByte(CONSTANT_Float);
poolbuf.appendFloat(((Float) value).floatValue());
} else if (value instanceof Double) {
poolbuf.appendByte(CONSTANT_Double);
poolbuf.appendDouble(((Double) value).doubleValue());
i++;
} else if (value instanceof String) {
poolbuf.appendByte(CONSTANT_String);
poolbuf.appendChar(pool.put(names.fromString((String) value)));
} else if (value instanceof UniqueType) {
Type type = ((UniqueType) value).type;
if (type instanceof MethodType) {
poolbuf.appendByte(CONSTANT_MethodType);
poolbuf.appendChar(pool.put(typeSig((MethodType) type)));
} else {
if (type.hasTag(CLASS))
enterInner((ClassSymbol) type.tsym);
poolbuf.appendByte(CONSTANT_Class);
poolbuf.appendChar(pool.put(xClassName(type)));
}
} else if (value instanceof MethodHandle) {
MethodHandle ref = (MethodHandle) value;
poolbuf.appendByte(CONSTANT_MethodHandle);
poolbuf.appendByte(ref.refKind);
poolbuf.appendChar(pool.put(ref.refSym));
} else {
Assert.error("writePool " + value);
}
i++;
}
if (pool.pp > Pool.MAX_ENTRIES)
throw new PoolOverflow();
putChar(poolbuf, poolCountIdx, pool.pp);
}
Aggregations