- private BitVector parseValue(String expression)
- {
- BitVector bitvector = null;
- if (expression.matches("0x[0-9a-fA-F]+"))
- // TODO should we check for overflows?
- bitvector = BitVector.from(new BigInteger(expression.substring(2), 16), machineRegister.getWidth());
- else if (expression.length() == machineRegister.getWidth())
- // TODO do this without exceptions
- try
- {
- bitvector = BitVector.parse(expression);
- }
- catch (@SuppressWarnings("unused") NullPointerException x)
- {
- // ignore
- }
- if (bitvector == null)
- try
- {
- // TODO should we check for overflows?
- bitvector = BitVector.from(new BigInteger(expression), machineRegister.getWidth());
- }
- catch (@SuppressWarnings("unused") NumberFormatException x)
- {
- // ignore
- }
- return bitvector;
- }
-