- this.memory = memory;
- this.miDef = memory.getDefinition().getMicroInstructionDefinition();
- this.memory.registerObserver(this);
- setViewerInput(memory);
- }
-
- private void setViewerInput(MicroInstructionMemory memory)
- {
- if (viewer != null)
- {
- deleteColumns();
- viewer.setInput(memory);
- createColumns();
- }
- }
-
- private void deleteColumns()
- {
- for (TableViewerColumn col : columns)
- col.getColumn().dispose();
- }
-
- private void createColumns()
- {
- int size = miDef.size();
- columns = new TableViewerColumn[size + 1];
-
- TableViewerColumn col = createTableViewerColumn("Address", generateLongestHexStrings(12));
- columns[0] = col;
- col.setLabelProvider(new AddressLabelProvider());
-
- int bit = miDef.sizeInBits();
- ParameterClassification[] classes = miDef.getParameterClassifications();
-
- for (int i = 0; i < size; i++)
- {
- int startBit = bit - 1;
- int endBit = bit = bit - classes[i].getExpectedBits();
- String name = startBit == endBit ? Integer.toString(startBit) : startBit + "..." + endBit;
-
- String[] longestPossibleContents;
- switch (classes[i].getExpectedType())
- {
- case INTEGER_IMMEDIATE:
- longestPossibleContents = generateLongestHexStrings(classes[i].getExpectedBits());
- break;
- case BOOLEAN_IMMEDIATE:
- case MNEMONIC:
- longestPossibleContents = ((MnemonicFamily) classes[i]).getStringValues();
- break;
- default:
- longestPossibleContents = new String[0];
- break;
- }
-
- col = createTableViewerColumn(name, longestPossibleContents);
- columns[i + 1] = col;
- createEditingAndLabel(col, miDef, i);
- }
- }
-
- private static final String[] HEX_DIGITS = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" };
-
- private static String[] generateLongestHexStrings(int bitWidth)
- {
- return Arrays.stream(HEX_DIGITS).map(s -> "0x" + s.repeat((bitWidth + 3) / 4)).toArray(String[]::new);
- }
-
- private void createEditingAndLabel(TableViewerColumn col, MicroInstructionDefinition miDef, int index)
- {
- ParameterClassification parameterClassification = miDef.getParameterClassifications()[index];
- EditingSupport support;
- ColumnLabelProvider provider;
- switch (parameterClassification.getExpectedType())