Make it so mapping files are used and then reapplied.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / SoftInteger.java
blob0e4a25d2cb5510c5c916f907d36c07f5284c55a4
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.jvm;
12 import cc.squirreljme.runtime.cldc.annotation.Exported;
13 import cc.squirreljme.runtime.cldc.debug.Debugging;
15 /**
16 * Software integer operations.
18 * @since 2019/05/27
20 @Exported
21 @SuppressWarnings("MagicNumber")
22 public final class SoftInteger
24 /**
25 * Not used.
27 * @since 2019/05/27
29 private SoftInteger()
33 /**
34 * Converts to double.
36 * @param __a A.
37 * @return The result.
38 * @since 2019/05/24
40 @Exported
41 public static double toDouble(int __a)
43 Assembly.breakpoint();
44 throw Debugging.todo();
47 /**
48 * Converts to float.
50 * @param __a A.
51 * @return The result.
52 * @since 2019/05/24
54 @Exported
55 public static float toFloat(int __a)
57 boolean sign = (__a < 0);
59 // if ( ! (a & 0x7FFFFFFF) ) {
60 if ((__a & 0x7FFF_FFFF) == 0)
62 // uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
63 return Float.intBitsToFloat((sign ?
64 SoftFloat.__packToF32UI(true, 0x9E, 0) :
65 0));
68 int absA = sign ? -__a : __a;
70 // return softfloat_normRoundPackToF32( sign, 0x9C, absA );
71 return Float.intBitsToFloat(
72 SoftFloat.__normRoundPackToF32(sign, 0x9C, absA));
75 /**
76 * Converts to long.
78 * @param __a A.
79 * @return The result.
80 * @since 2019/05/24
82 @Exported
83 public static long toLong(int __a)
85 // If the integer has the sign bit, then it will be sign extended
86 // meaning all the upper bits get set
87 if ((__a & 0x80000000) != 0)
88 return Assembly.longPack(__a, 0xFFFFFFFF);
90 // Otherwise, the top is just zero
91 else
92 return Assembly.longPack(__a, 0);