1
0

Porting to Python 3

This commit is contained in:
Jon Michael Aanes 2024-07-10 01:03:12 +02:00
parent 6131315d22
commit e0f8c0c2a1
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
5 changed files with 15 additions and 25 deletions

View File

@ -1,5 +1,4 @@
import re
import subprocess
NORMAL_COLOR = '\033[0m'

View File

@ -1,8 +1,8 @@
import re
import Junk
from opcodes import OPCODES
from . import Junk
from .opcodes import OPCODES
REGISTERS=["%rax", "%rbx", "%rcx", "%rdx", "%rsp", "%rbp", "%rsi", "%rdi",
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"]

View File

@ -6,8 +6,8 @@ class JunkComparisonException (BaseException):
class Junk:
def __init__ (self, represents = None):
assert(represents == None or isinstance(represents, basestring))
def __init__ (self, represents: str = None):
assert represents is None or isinstance(represents, str)
self.repr = represents
def __str__ (self):

View File

@ -1,4 +1,4 @@
"""
# Infernal Interpreter & Devious Stack Painter #################################
A very simple interpreter and stack tracer for the AMD x86-64 ABI written in
@ -22,4 +22,4 @@ License is `beerware`:
this notice you can do whatever you want with this stuff. If we
meet some day, and you think this stuff is worth it, you can buy
me a beer in return.
"""

View File

@ -1,27 +1,18 @@
#!/usr/bin/python2
ARG_DESC = '''
A silly x86-64 emulator and stack visualizer.
'''
LICENSE = '''
This program is BEER-WARE.
<jonjmaa@gmail.com> wrote this program. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in
return.
'''
import sys
import re
import argparse
from Emulator import Emulator, CodeParseException, REGISTERS
from TikzPainter import TikzPainter
from AsciiPainter import AsciiPainter
import Junk
from .Emulator import Emulator, REGISTERS
from .TikzPainter import TikzPainter
from .AsciiPainter import AsciiPainter
from . import Junk
ARG_DESC = '''
A silly x86-64 emulator and stack visualizer.
'''
PAINTER_ID_TO_CLASS = {
'ascii': AsciiPainter,
@ -29,7 +20,7 @@ PAINTER_ID_TO_CLASS = {
}
def parse_args ():
parser = argparse.ArgumentParser(description = ARG_DESC, epilog = LICENSE)
parser = argparse.ArgumentParser(description = ARG_DESC)
parser.add_argument('-i', '--input-file', default='-', help = 'File to use as input', dest = 'input-file')
parser.add_argument('-o', '--output-file', default='-', help = 'File to use as output', dest = 'output-file')
parser.add_argument('-p', '--painter', default='ascii', help = 'Drawer to use', dest = 'painter-name', choices=PAINTER_ID_TO_CLASS.keys())