public TypeConversion getTypeConversion(Type from, Type to) { if (to.equals(from)) { return TypeConversion.NONE; } if (from.isPrimitive() && !to.isPrimitive()) { return new BoxingTypeConversion((PrimitiveType) from); } else if (!from.isPrimitive() && to.isPrimitive()) { return new UnboxingTypeConversion((PrimitiveType) to); } else if (!from.isPrimitive() && !to.isPrimitive()) { if (to.isAssignableFrom(from)) { return TypeConversion.NONE; } else { return new CastTypeConversion(to); } } else { // TODO: add cast in between primitives throw new UnsupportedOperationException("TODO: convert " + from + " to " + to); } }
private int getALoad(Type type) { if (type.isPrimitive()) { // TODO: other primitive types switch (type.getClassIdentifier().charAt(0)) { case 'I': // int case 'Z': // boolean return IALOAD; case 'J': // long return LALOAD; case 'F': // float return FALOAD; case 'D': // double return DALOAD; case 'C': // char case 'V': // void case 'B': // byte case 'S': // short default: throw new RuntimeException("Unsupported "+type); } } else { return AALOAD; } }
private void incLocalVarIndex(Type type) { if (!type.isPrimitive()) { ++ currentLocalVariableByteCodeIndex; } else { switch (type.getClassIdentifier().charAt(0)) { case 'I': // int case 'Z': // boolean case 'F': // float case 'C': // char case 'V': // void case 'B': // byte case 'S': // short ++ currentLocalVariableByteCodeIndex; break; case 'J': // long case 'D': // double currentLocalVariableByteCodeIndex += 2; break; default: throw new RuntimeException("Unsupported "+type); } } }
private int getLoad(Type type) { if (type.isPrimitive()) { // TODO: other primitive types switch (type.getClassIdentifier().charAt(0)) { case 'I': // int case 'Z': // boolean return ILOAD; case 'J': // long return LLOAD; case 'F': // float return FLOAD; case 'D': // double return DLOAD; case 'C': // char case 'V': // void case 'B': // byte case 'S': // short default: throw new RuntimeException("Unsupported "+type); } } else { return ALOAD; } }
private int getStore(Type type) { if (type.isPrimitive()) { // TODO: other primitive types switch (type.getClassIdentifier().charAt(0)) { case 'I': // int case 'Z': // boolean return ISTORE; case 'J': // long return LSTORE; case 'F': // float return FSTORE; case 'D': // double return DSTORE; case 'C': // char case 'V': // void case 'B': // byte case 'S': // short default: throw new RuntimeException("Unsupported "+type); } } else { return ASTORE; } }
private int getReturn(Type type) { if (type.isPrimitive()) { // TODO: other primitive types switch (type.getClassIdentifier().charAt(0)) { case 'I': // int case 'Z': // boolean return IRETURN; case 'J': // long return LRETURN; case 'F': // float return FRETURN; case 'D': // float return DRETURN; default: throw new RuntimeException("Unsupported " + type + " " + type.getClassIdentifier().charAt(0)); } } else { return ARETURN; } }
public void newArray(Type type, Object... comments) { if (type.isPrimitive()) {