public MicroInstructionParameter getParameter(int index);
- public void setParameter(int index, MicroInstructionParameter param);
+ public MicroInstructionParameter[] getParameters();
/**
* @return The amount of {@link Mnemonic}s, the instruction is composed of
*/
public int getSize();
- public static MicroInstruction create(Runnable updateCallback, MicroInstructionParameter... parameters)
+ public static MicroInstruction create(MicroInstructionParameter... parameters)
{
- return new StandardMicroInstruction(updateCallback, parameters);
+ return new StandardMicroInstruction(parameters);
}
default BitVector toBitVector()
return Arrays.stream(getParameterClassifications()).mapToInt(e -> e.getExpectedBits()).reduce(0, (a, b) -> a + b);
}
- public default MicroInstruction createDefaultInstruction(Runnable updateCallback)
+ public default MicroInstruction createDefaultInstruction()
{
int size = size();
MicroInstructionParameter[] params = new MicroInstructionParameter[size];
ParameterClassification classification = classes[i];
params[i] = classification.getDefault();
}
- return new StandardMicroInstruction(updateCallback, params);
+ return new StandardMicroInstruction(params);
}
public Optional<String> getParameterDescription(int index);
public interface MicroInstructionMemory extends Memory<MicroInstruction>
{
+ @Override
public MicroInstructionMemoryDefinition getDefinition();
}
{
for (; i <= maxAddr && input.ready() && !"".equals((line = input.readLine())); i++)
{
- long iFinal = i;
- memory.setCell(i, parse(() -> memory.notifyObservers(iFinal), miDef, line));
+ memory.setCell(i, parse(miDef, line));
}
}
catch (IOException e)
for (; i <= maxAddr; i++)
{
- long iFinal = i;
- memory.setCell(i, miDef.createDefaultInstruction(() -> memory.notifyObservers(iFinal)));
+ memory.setCell(i, miDef.createDefaultInstruction());
}
}
- public static MicroInstruction parse(Runnable updateCallback, MicroInstructionDefinition definition, String toParse)
+ public static MicroInstruction parse(MicroInstructionDefinition definition, String toParse)
{
int size = definition.size();
String[] strings = toParse.split(",");
{
params[i] = classes[i].parse(strings[i]);
}
- return new StandardMicroInstruction(updateCallback, params);
+ return new StandardMicroInstruction(params);
}
catch (Exception e)
{
class StandardMicroInstruction implements MicroInstruction
{
- private final Runnable updateCallback;
private MicroInstructionParameter[] parameters;
- StandardMicroInstruction(Runnable updateCallback, MicroInstructionParameter... parameters)
+ StandardMicroInstruction(MicroInstructionParameter... parameters)
{
- this.updateCallback = updateCallback;
- this.parameters = parameters;
+ this.parameters = parameters.clone();
}
/**
return parameters.length;
}
- /**
- * @throws IndexOutOfBoundsException
- */
@Override
- public void setParameter(int index, MicroInstructionParameter param)
+ public MicroInstructionParameter[] getParameters()
{
- parameters[index] = param;
- updateCallback.run();
+ return parameters.clone();
}
}
int translatedAddress = translate(address);
MicroInstruction actual = data[translatedAddress];
if (actual == null)
- actual = data[translatedAddress] = definition.getMicroInstructionDefinition()
- .createDefaultInstruction(() -> notifyObservers(address));
+ actual = data[translatedAddress] = definition.getMicroInstructionDefinition().createDefaultInstruction();
return actual;
}
import org.eclipse.jface.viewers.TableViewer;
import net.mograsim.logic.core.types.Bit;
+import net.mograsim.machine.mi.MicroInstruction;
import net.mograsim.machine.mi.MicroInstructionDefinition;
import net.mograsim.machine.mi.parameters.BooleanClassification;
+import net.mograsim.machine.mi.parameters.MicroInstructionParameter;
public class BooleanEditingSupport extends EditingSupport
{
@Override
protected Object getValue(Object element)
{
- return ((InstructionTableRow) element).data.getParameter(index).getValue().getMSBit(0).equals(Bit.ONE);
+ InstructionTableRow row = (InstructionTableRow) element;
+ return row.data.getCell(row.address).getParameter(index).getValue().getMSBit(0).equals(Bit.ONE);
}
@Override
protected void setValue(Object element, Object value)
{
- ((InstructionTableRow) element).data.setParameter(index, boolClass.get((Boolean) value));
+ InstructionTableRow row = (InstructionTableRow) element;
+ MicroInstructionParameter[] params = row.data.getCell(row.address).getParameters();
+ params[index] = boolClass.get((Boolean) value);
+ row.data.setCell(row.address, MicroInstruction.create(params));
viewer.update(element, null);
}
public void updateElement(int index)
{
long address = memory.getDefinition().getMinimalAddress() + index;
- viewer.replace(new InstructionTableRow(address, memory.getCell(address)), index);
+ viewer.replace(new InstructionTableRow(address, memory), index);
}
@Override
package net.mograsim.plugin.tables.mi;
-import net.mograsim.machine.mi.MicroInstruction;
+import net.mograsim.machine.mi.MicroInstructionMemory;
import net.mograsim.plugin.tables.TableRow;
-public class InstructionTableRow extends TableRow<MicroInstruction>
+public class InstructionTableRow extends TableRow<MicroInstructionMemory>
{
- public InstructionTableRow(long address, MicroInstruction data)
+ public InstructionTableRow(long address, MicroInstructionMemory data)
{
super(address, data);
}
@Override
public BigInteger getAsBigInteger(Object element)
{
- return ((IntegerImmediate) ((InstructionTableRow) element).data.getParameter(index)).getValueAsBigInteger();
+ InstructionTableRow row = (InstructionTableRow) element;
+ return ((IntegerImmediate) row.data.getCell(row.address).getParameter(index)).getValueAsBigInteger();
}
}
import org.eclipse.jface.viewers.TableViewer;
+import net.mograsim.machine.mi.MicroInstruction;
import net.mograsim.machine.mi.MicroInstructionDefinition;
import net.mograsim.machine.mi.parameters.IntegerClassification;
import net.mograsim.machine.mi.parameters.IntegerImmediate;
+import net.mograsim.machine.mi.parameters.MicroInstructionParameter;
import net.mograsim.plugin.tables.DisplaySettings;
import net.mograsim.plugin.tables.NumberCellEditingSupport;
protected void setAsBigInteger(Object element, BigInteger value)
{
InstructionTableRow row = ((InstructionTableRow) element);
- row.data.setParameter(index, new IntegerImmediate(value, classification.getExpectedBits()));
+ MicroInstructionParameter[] params = row.data.getCell(row.address).getParameters();
+ params[index] = new IntegerImmediate(value, classification.getExpectedBits());
+ row.data.setCell(row.address, MicroInstruction.create(params));
provider.update(row.address);
// viewer.update(element, null); Does not do anything for some reason
}
@Override
protected BigInteger getAsBigInteger(Object element)
{
- return ((IntegerImmediate) ((InstructionTableRow) element).data.getParameter(index)).getValueAsBigInteger();
+ InstructionTableRow row = ((InstructionTableRow) element);
+ return ((IntegerImmediate) row.data.getCell(row.address).getParameter(index)).getValueAsBigInteger();
}
}
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
+import net.mograsim.machine.mi.MicroInstruction;
import net.mograsim.machine.mi.MicroInstructionDefinition;
+import net.mograsim.machine.mi.parameters.MicroInstructionParameter;
import net.mograsim.machine.mi.parameters.Mnemonic;
import net.mograsim.machine.mi.parameters.MnemonicFamily;
@Override
protected Object getValue(Object element)
{
- return ((Mnemonic) ((InstructionTableRow) element).data.getParameter(index)).ordinal();
+ InstructionTableRow row = ((InstructionTableRow) element);
+ return ((Mnemonic) row.data.getCell(row.address).getParameter(index)).ordinal();
}
@Override
protected void setValue(Object element, Object value)
{
InstructionTableRow row = ((InstructionTableRow) element);
- row.data.setParameter(index, family.get((Integer) value));
+ MicroInstructionParameter[] params = row.data.getCell(row.address).getParameters();
+ params[index] = family.get((Integer) value);
+ row.data.setCell(row.address, MicroInstruction.create(params));
provider.update(row.address);
}
@Override
public String getText(Object element)
{
- return ((InstructionTableRow) element).data.getParameter(index).toString();
+ InstructionTableRow row = (InstructionTableRow) element;
+ return row.data.getCell(row.address).getParameter(index).toString();
}
}