Skip to content
Snippets Groups Projects

FIxed recursion error when clicking "display memory content"

Merged Martin Högstedt requested to merge 70-mia-micro-memory-maximum-recursion-depth into main
Files
6
 
import sys
 
import traceback
from enum import Enum
from enum import Enum
from qtpy.QtWidgets import QButtonGroup, QHBoxLayout, QHeaderView, QRadioButton
from qtpy.QtWidgets import QButtonGroup, QHBoxLayout, QHeaderView, QRadioButton
@@ -40,7 +42,10 @@ class IntegerMemoryWindow(MemoryWindow):
@@ -40,7 +42,10 @@ class IntegerMemoryWindow(MemoryWindow):
An integer specifying the number of bits of each address.
An integer specifying the number of bits of each address.
"""
"""
def __init__(self, memory_module: Memory, bit_length: int):
def __init__(
 
self,
 
memory_module: Memory,
 
):
# Do not let parent create edit/view buttons
# Do not let parent create edit/view buttons
super().__init__(memory_module, False)
super().__init__(memory_module, False)
@@ -49,11 +54,11 @@ class IntegerMemoryWindow(MemoryWindow):
@@ -49,11 +54,11 @@ class IntegerMemoryWindow(MemoryWindow):
self.layout.removeWidget(self._memory_table)
self.layout.removeWidget(self._memory_table)
# Add our own
# Add our own
self._memory_table = IntegerMemoryTable(memory_module, bit_length)
self._memory_table = IntegerMemoryTable(memory_module)
self.layout.addWidget(self._memory_table)
self.layout.addWidget(self._memory_table)
# Create base buttons, they are exclusive by default
# Create base buttons, they are exclusive by default
# so need a seperate QButtonGroup since these four
# so need a separate QButtonGroup since these four
# have nothing to do with the edit/view buttons
# have nothing to do with the edit/view buttons
self.dec_signed_button = QRadioButton("Decimal Signed")
self.dec_signed_button = QRadioButton("Decimal Signed")
self.dec_unsigned_button = QRadioButton("Decimal Unsigned")
self.dec_unsigned_button = QRadioButton("Decimal Unsigned")
@@ -136,9 +141,9 @@ class IntegerMemoryTable(MemoryTable):
@@ -136,9 +141,9 @@ class IntegerMemoryTable(MemoryTable):
"""
"""
def __init__(self, memory_module: Memory, bit_length: int, column_size=-1):
def __init__(self, memory_module: Memory, column_size=-1):
self._base = Base.DECIMAL_UNSIGNED
self._base = Base.DECIMAL_UNSIGNED
self._bit_length = bit_length
self._bit_length = memory_module.get_parameter()["bit_length"]
super().__init__(memory_module, column_size)
super().__init__(memory_module, column_size)
self.update()
self.update()
@@ -248,6 +253,6 @@ class IntegerMemoryTable(MemoryTable):
@@ -248,6 +253,6 @@ class IntegerMemoryTable(MemoryTable):
# -7 + 16 % 16 = 9 = 1001 = -7
# -7 + 16 % 16 = 9 = 1001 = -7
value = (value + max_value) % max_value
value = (value + max_value) % max_value
index = row * 4 + col
index = row * self._column_size + col
state['memory'][index] = value
state['memory'][index] = value
self._memory.set_state(state)
self._memory.set_state(state)
Loading