Item invoke() { MethodType mtype = (MethodType) member.erasure(types); int argsize = Code.width(mtype.argtypes); int rescode = Code.typecode(mtype.restype); int sdiff = Code.width(rescode) - argsize; code.emitInvokestatic(pool.put(member), mtype); return stackItem[rescode]; }
/** * Generate code to coerce item to given type code. * * @param targetcode The type code to coerce to. */ Item coerce(int targetcode) { if (typecode == targetcode) return this; else { load(); int typecode1 = Code.truncate(typecode); int targetcode1 = Code.truncate(targetcode); if (typecode1 != targetcode1) { int offset = targetcode1 > typecode1 ? targetcode1 - 1 : targetcode1; code.emitop0(i2l + typecode1 * 3 + offset); } if (targetcode != targetcode1) { code.emitop0(int2byte + targetcode - BYTEcode); } return stackItem[targetcode]; } }
Item coerce(int targetcode) { if (typecode == targetcode) { return this; } else { switch (targetcode) { case INTcode: if (Code.truncate(typecode) == INTcode) return this; else return new ImmediateItem(syms.intType, ((Number) value).intValue()); case LONGcode: return new ImmediateItem(syms.longType, ((Number) value).longValue()); case FLOATcode: return new ImmediateItem(syms.floatType, ((Number) value).floatValue()); case DOUBLEcode: return new ImmediateItem(syms.doubleType, ((Number) value).doubleValue()); case BYTEcode: return new ImmediateItem(syms.byteType, (int) (byte) ((Number) value).intValue()); case CHARcode: return new ImmediateItem(syms.charType, (int) (char) ((Number) value).intValue()); case SHORTcode: return new ImmediateItem(syms.shortType, (int) (short) ((Number) value).intValue()); default: return super.coerce(targetcode); } } }
Item invoke() { MethodType mtype = (MethodType) member.externalType(types); int rescode = Code.typecode(mtype.restype); if ((member.owner.flags() & Flags.INTERFACE) != 0) { code.emitInvokeinterface(pool.put(member), mtype); } else if (nonvirtual) { code.emitInvokespecial(pool.put(member), mtype); } else { code.emitInvokevirtual(pool.put(member), mtype); } return stackItem[rescode]; }
MemberItem(Symbol member, boolean nonvirtual) { super(Code.typecode(member.erasure(types))); this.member = member; this.nonvirtual = nonvirtual; }
StaticItem(Symbol member) { super(Code.typecode(member.erasure(types))); this.member = member; }
void store() { if (reg <= 3) code.emitop0(istore_0 + Code.truncate(typecode) * 4 + reg); else code.emitop1w(istore + Code.truncate(typecode), reg); code.setDefined(reg); }
/** * Make an item representing a value on stack. * * @param type The value's type. */ Item makeStackItem(Type type) { return stackItem[Code.typecode(type)]; }
int width() { return lhs.width() + Code.width(typecode); }
void stash(int toscode) { code.emitop0(dup_x2 + 3 * (Code.width(toscode) - 1)); }
IndexedItem(Type type) { super(Code.typecode(type)); }
int width() { return Code.width(typecode); }
void stash(int toscode) { code.emitop0((width() == 2 ? dup_x2 : dup_x1) + 3 * (Code.width(toscode) - 1)); }
/** * Generate code to coerce item to given type. * * @param targettype The type to coerce to. */ Item coerce(Type targettype) { return coerce(Code.typecode(targettype)); }
ImmediateItem(Type type, Object value) { super(Code.typecode(type)); this.value = value; }
LocalItem(Type type, int reg) { super(Code.typecode(type)); assert reg >= 0; this.type = type; this.reg = reg; }
Item load() { if (reg <= 3) code.emitop0(iload_0 + Code.truncate(typecode) * 4 + reg); else code.emitop1w(iload + Code.truncate(typecode), reg); return stackItem[typecode]; }
public String toString() { return "cond(" + Code.mnem(opcode) + ")"; }
Item invoke() { MethodType mtype = (MethodType) member.erasure(types); int rescode = Code.typecode(mtype.restype); code.emitInvokestatic(pool.put(member), mtype); return stackItem[rescode]; }