Пример #1
0
 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];
 }
Пример #2
0
 /**
  * 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];
   }
 }
Пример #3
0
 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);
     }
   }
 }
Пример #4
0
 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];
 }
Пример #5
0
 MemberItem(Symbol member, boolean nonvirtual) {
   super(Code.typecode(member.erasure(types)));
   this.member = member;
   this.nonvirtual = nonvirtual;
 }
Пример #6
0
 StaticItem(Symbol member) {
   super(Code.typecode(member.erasure(types)));
   this.member = member;
 }
Пример #7
0
 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);
 }
Пример #8
0
 /**
  * Make an item representing a value on stack.
  *
  * @param type The value's type.
  */
 Item makeStackItem(Type type) {
   return stackItem[Code.typecode(type)];
 }
Пример #9
0
 int width() {
   return lhs.width() + Code.width(typecode);
 }
Пример #10
0
 void stash(int toscode) {
   code.emitop0(dup_x2 + 3 * (Code.width(toscode) - 1));
 }
Пример #11
0
 IndexedItem(Type type) {
   super(Code.typecode(type));
 }
Пример #12
0
 int width() {
   return Code.width(typecode);
 }
Пример #13
0
 void stash(int toscode) {
   code.emitop0((width() == 2 ? dup_x2 : dup_x1) + 3 * (Code.width(toscode) - 1));
 }
Пример #14
0
 /**
  * Generate code to coerce item to given type.
  *
  * @param targettype The type to coerce to.
  */
 Item coerce(Type targettype) {
   return coerce(Code.typecode(targettype));
 }
Пример #15
0
 ImmediateItem(Type type, Object value) {
   super(Code.typecode(type));
   this.value = value;
 }
Пример #16
0
 LocalItem(Type type, int reg) {
   super(Code.typecode(type));
   assert reg >= 0;
   this.type = type;
   this.reg = reg;
 }
Пример #17
0
 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];
 }
Пример #18
0
 public String toString() {
   return "cond(" + Code.mnem(opcode) + ")";
 }
Пример #19
0
 Item invoke() {
   MethodType mtype = (MethodType) member.erasure(types);
   int rescode = Code.typecode(mtype.restype);
   code.emitInvokestatic(pool.put(member), mtype);
   return stackItem[rescode];
 }