public BigInteger getCellAsBigInteger(long address);
public void setCellAsBigInteger(long address, BigInteger word);
+
+ @Override
+ public MainMemoryDefinition getDefinition();
}
\ No newline at end of file
* Formats a {@link BigInteger} in accordance with the pattern associated with the supplied {@link NumberType}
*/
public static String toString(BigInteger number, NumberType type)
+ {
+ return toString(number, type, 0);
+ }
+
+ /**
+ * Formats a {@link BigInteger} in accordance with the pattern associated with the supplied {@link NumberType}
+ */
+ public static String toString(BigInteger number, NumberType type, int minBits)
{
String pattern;
switch (type)
case HEXADECIMAL:
pattern = preferredHexPat;
}
+
+ int digits;
+
+ switch (type.radix)
+ {
+ case 2:
+ digits = minBits;
+ break;
+ case 8:
+ digits = minBits / 3;
+ break;
+ case 16:
+ digits = minBits / 4;
+ break;
+ default:
+ digits = 0;
+ }
+
+ String numberString, sign;
if (number.signum() < 0)
- return String.format(pattern, "-", number.abs().toString(type.radix));
- return String.format(pattern, "", number.toString(type.radix));
+ {
+ sign = "-";
+ numberString = number.abs().toString(type.radix);
+ } else
+ {
+ sign = "";
+ numberString = number.toString(type.radix);
+ }
+ numberString = "0".repeat(Integer.max(0, digits - numberString.length())) + numberString;
+ return String.format(pattern, sign, numberString);
}
public enum NumberType
@Override
final protected Object getValue(Object element)
{
- return AsmNumberUtil.toString(getAsBigInteger(element), displaySettings.getDataNumberType());
+ return AsmNumberUtil.toString(getAsBigInteger(element), displaySettings.getDataNumberType(), getBitLength(element));
}
@Override
protected abstract void setAsBigInteger(Object element, BigInteger value);
protected abstract BigInteger getAsBigInteger(Object element);
+
+ protected abstract int getBitLength(Object element);
}
public abstract class NumberColumnLabelProvider extends ColumnLabelProvider
{
- private DisplaySettings displaySettings;
+ private final DisplaySettings displaySettings;
public NumberColumnLabelProvider(DisplaySettings displaySettings)
{
@Override
public String getText(Object element)
{
- return AsmNumberUtil.toString(getAsBigInteger(element), displaySettings.getDataNumberType());
+ return AsmNumberUtil.toString(getAsBigInteger(element), displaySettings.getDataNumberType(), getBitLength(element));
}
public abstract BigInteger getAsBigInteger(Object element);
+
+ public abstract int getBitLength(Object element);
}
\ No newline at end of file
MemoryTableRow row = (MemoryTableRow) element;
return row.getMemory().getCellAsBigInteger(row.address);
}
+
+ @Override
+ public int getBitLength(Object element)
+ {
+ return ((MemoryTableRow) element).getMemory().getDefinition().getCellWidth();
+ }
}
\ No newline at end of file
return row.getMemory().getCellAsBigInteger(row.address);
}
+ @Override
+ public int getBitLength(Object element)
+ {
+ return ((MemoryTableRow) element).getMemory().getDefinition().getCellWidth();
+ }
+
});
col.setEditingSupport(new MemoryCellEditingSupport(viewer, displaySettings));
}
return ((IntegerImmediate) row.data.getCell(row.address).getParameter(index)).getValueAsBigInteger();
}
+ @Override
+ public int getBitLength(Object element)
+ {
+ return ((InstructionTableRow) element).getData().getDefinition().getMicroInstructionDefinition().getParameterClassification(index)
+ .getExpectedBits();
+ }
+
}
return ((IntegerImmediate) row.data.getCell(row.address).getParameter(index)).getValueAsBigInteger();
}
+ @Override
+ public int getBitLength(Object element)
+ {
+ return ((InstructionTableRow) element).getData().getDefinition().getMicroInstructionDefinition().getParameterClassification(index)
+ .getExpectedBits();
+ }
+
}