public static void fixType(Type from, Type to, CodeAttr code) {

		// boxing
		if (from instanceof PrimType && to instanceof ClassType) {
			PrimType from_prim = (PrimType) from;
			Method valueOf = from_prim.boxedType().getMethod("valueOf", new Type[] { from });
			code.emitInvoke(valueOf);
		}

		// unboxing
		else if (from instanceof ClassType && to instanceof PrimType) {

			Method val = null;
			switch (to.getSignature().charAt(0)) {
			case 'I':
				val = Type.intValue_method;
				break;
			case 'F':
				val = Type.floatValue_method;
				break;
			case 'S':
				val = ClassType.make("java.lang.Number").getMethod("shortValue", Type.typeArray0);
				break;
			default:
				break;
			}

			code.emitInvoke(val);
		}

		// converting
		else if (from instanceof PrimType && to instanceof PrimType) {
			code.emitConvert(from, to);
		}

	}