X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Flaunch%2FMachineStackFrame.java;h=2744a3c333f0fbb9fdd4099f70b29eb53e488d21;hb=648fc6e69e09fe4467cb6bac47934be1a7dcf0d6;hp=14f64206b5c3277deea1b274b3d62c29311069dc;hpb=2d1f3e4780616f3b638133a243fcdb7a6738baf9;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineStackFrame.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineStackFrame.java index 14f64206..2744a3c3 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineStackFrame.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineStackFrame.java @@ -1,5 +1,9 @@ package net.mograsim.plugin.launch; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.eclipse.core.runtime.PlatformObject; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; @@ -10,17 +14,34 @@ import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IVariable; import net.mograsim.machine.Machine; +import net.mograsim.machine.MachineDefinition; +import net.mograsim.machine.registers.RegisterGroup; import net.mograsim.plugin.MograsimActivator; public class MachineStackFrame extends PlatformObject implements IStackFrame { private final MachineThread thread; - private final MachineRegisterGroup registerGroup; + private final List registerGroups; public MachineStackFrame(MachineThread thread) { this.thread = thread; - this.registerGroup = new MachineRegisterGroup(this); + List registerGroupsModifiable = new ArrayList<>(); + MachineDefinition machDef = getMachine().getDefinition(); + if (!machDef.getUnsortedRegisters().isEmpty()) + registerGroupsModifiable.add(new MachineRegisterGroup(this, "", machDef.getUnsortedRegisters())); + addRegisterGroups(null, registerGroupsModifiable, machDef.getRegisterGroups()); + this.registerGroups = Collections.unmodifiableList(registerGroupsModifiable); + } + + private void addRegisterGroups(String base, List target, List registerGroups) + { + for (RegisterGroup rg : registerGroups) + { + String name = (base == null ? "" : base + '.') + rg.id(); + target.add(new MachineRegisterGroup(this, name, rg.getRegisters())); + addRegisterGroups(name, target, rg.getSubGroups()); + } } @Override @@ -182,7 +203,7 @@ public class MachineStackFrame extends PlatformObject implements IStackFrame @Override public IRegisterGroup[] getRegisterGroups() throws DebugException { - return new IRegisterGroup[] { registerGroup }; + return registerGroups.toArray(IRegisterGroup[]::new); } @Override