Exemplo n.º 1
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);
     }
   }
 }
Exemplo n.º 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];
   }
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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];
 }