diff --git a/infernal_interpreter/AsciiPainter.py b/infernal_interpreter/AsciiPainter.py index 9992009..e0ce6cd 100644 --- a/infernal_interpreter/AsciiPainter.py +++ b/infernal_interpreter/AsciiPainter.py @@ -70,13 +70,17 @@ class AsciiPainter: state.append({'state': 'none', 'val': ''}) def getWidthOfColumns( - self, number_states: int, number_states_per_block: int, number_state_vars: int, + self, + number_states: int, + number_states_per_block: int, + number_state_vars: int, ) -> list[int]: widths = [0 for i in range(0, number_states_per_block)] for base_state in range(0, number_states, number_states_per_block): for var_i in range(0, number_state_vars): for state_i in range( - 0, min(number_states_per_block, number_states - base_state), + 0, + min(number_states_per_block, number_states - base_state), ): width = len(str(self.states[base_state + state_i][var_i]['val'])) widths[state_i] = max(widths[state_i], width) @@ -101,7 +105,9 @@ class AsciiPainter: column_fmt = [ '{}{:>' + str(width) + '} ' for width in self.getWidthOfColumns( - number_states, number_states_per_block, number_state_vars, + number_states, + number_states_per_block, + number_state_vars, ) ] @@ -110,12 +116,15 @@ class AsciiPainter: for var_i in range(0, number_state_vars): output.append(name_fmt.format(NORMAL_COLOR, self.nameOfVar(var_i - 4))) for state_i in range( - 0, min(number_states_per_block, number_states - base_state), + 0, + min(number_states_per_block, number_states - base_state), ): var = self.states[base_state + state_i][var_i] output.append( column_fmt[state_i].format( - REG_STATUS_TO_COLOR[var['state']], var['val'], NORMAL_COLOR, + REG_STATUS_TO_COLOR[var['state']], + var['val'], + NORMAL_COLOR, ), ) output.append('\n') diff --git a/infernal_interpreter/Emulator.py b/infernal_interpreter/Emulator.py index 0f79fa2..a0a5049 100644 --- a/infernal_interpreter/Emulator.py +++ b/infernal_interpreter/Emulator.py @@ -121,14 +121,16 @@ class Emulator: self.registers['%rsp'] -= 1 self.stack[self.registers['%rsp']] = new_element self.changedRegisters( - ('%rsp', 'change'), ('m' + str(self.registers['%rsp']), 'insert'), + ('%rsp', 'change'), + ('m' + str(self.registers['%rsp']), 'insert'), ) self.max_stack_size = max(self.registers['%rsp'], self.max_stack_size) def popFromStack(self): temp = self.stack[self.registers['%rsp']] self.changedRegisters( - ('%rsp', 'change'), ('m' + str(self.registers['%rsp']), 'remove'), + ('%rsp', 'change'), + ('m' + str(self.registers['%rsp']), 'remove'), ) self.registers['%rsp'] += 1 return temp diff --git a/infernal_interpreter/TikzPainter.py b/infernal_interpreter/TikzPainter.py index 2b2e71c..3d2f2ef 100644 --- a/infernal_interpreter/TikzPainter.py +++ b/infernal_interpreter/TikzPainter.py @@ -15,7 +15,11 @@ DEFAULT_OPTIONS = """register_node/.style={rectangle, draw=black!30, class TikzPainter: def __init__( - self, registers=None, max_stack_size=8, stack_draw_mode='up', options=None, + self, + registers=None, + max_stack_size=8, + stack_draw_mode='up', + options=None, ): self.registers = registers if registers else REGISTERS self.text = [] @@ -53,7 +57,10 @@ class TikzPainter: ) if base_pointer == index: self.addText( - '\t\\draw ({0},{2}) -- ({1},{2});\n', x - 1.1, x + 1.1, pos - 0.25, + '\t\\draw ({0},{2}) -- ({1},{2});\n', + x - 1.1, + x + 1.1, + pos - 0.25, ) base_pointer = emu.stack[base_pointer] pos -= 0.5 @@ -62,7 +69,8 @@ class TikzPainter: def drawStackDownward(self, pos, emu, x): pos -= 1 for index in range( - emu.getVal('%rsp') - 8, max(emu.last_sp, emu.getVal('%rsp')), + emu.getVal('%rsp') - 8, + max(emu.last_sp, emu.getVal('%rsp')), ): reg_state = emu.regState('m' + str(index)) reg_dect = 'register_node, fill=' + self.getRegColor(reg_state) + '!10' @@ -109,7 +117,10 @@ class TikzPainter: signature = emu.getLineSignature(line_nr) for token in signature: self.addText( - '\t\\node[text_node]() at ({}, {}){{{}}};\n', x - 1.25, pos, token, + '\t\\node[text_node]() at ({}, {}){{{}}};\n', + x - 1.25, + pos, + token, ) pos -= 0.5 @@ -118,7 +129,10 @@ class TikzPainter: pos = 0 for reg_name in self.registers: self.addText( - '\t\\node[text_node]() at ({}, {}){{{}}};\n', x, pos, reg_name[1:], + '\t\\node[text_node]() at ({}, {}){{{}}};\n', + x, + pos, + reg_name[1:], ) pos -= 0.5 @@ -135,7 +149,10 @@ class TikzPainter: for index in range(1, self.max_stack_size): pos -= 0.5 self.addText( - '\t\\node[text_node]() at ({}, {}){{TOS-{}}};\n', x, pos, index, + '\t\\node[text_node]() at ({}, {}){{TOS-{}}};\n', + x, + pos, + index, ) def to_string(self, emu): diff --git a/infernal_interpreter/__init__.py b/infernal_interpreter/__init__.py index c10d174..410550a 100644 --- a/infernal_interpreter/__init__.py +++ b/infernal_interpreter/__init__.py @@ -15,3 +15,7 @@ Compiling the LaTeX requires both a LaTeX compiler, and packages Please ignore the `/tests` folder. It is very old, and unsupported, but kept for archival purposes. """ + +__all__ = ['__version__'] + +from ._version import __version__ diff --git a/infernal_interpreter/_version.py b/infernal_interpreter/_version.py new file mode 100644 index 0000000..0404d81 --- /dev/null +++ b/infernal_interpreter/_version.py @@ -0,0 +1 @@ +__version__ = '0.3.0' diff --git a/setup.py b/setup.py index 6f1c842..04a9f56 100644 --- a/setup.py +++ b/setup.py @@ -41,10 +41,7 @@ this stuff is worth it, you can buy me a beer in return. Jon Michael Aanes ```""" -PACKAGE_DESCRIPTION_SHORT = ( - 'Simple interpreter and stack tracer for the AMD x86-64 ABI.' -) - +PACKAGE_DESCRIPTION_SHORT='Simple interpreter and stack tracer for the AMD x86-64 ABI.' def parse_version_file(text: str) -> str: match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)