From 9951ad78c80e144c166a7d476cad7ffdf84332a9 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 13 Aug 2014 14:55:49 -0700 Subject: Debug debugging --- src/map/script.py | 74 ++++++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 56 deletions(-) (limited to 'src/map/script.py') diff --git a/src/map/script.py b/src/map/script.py index dcde08d..e3029d5 100644 --- a/src/map/script.py +++ b/src/map/script.py @@ -1,59 +1,21 @@ -class ByteCode: - ''' print a ByteCode - (workaround for gcc bug 58150) - ''' - __slots__ = ('_value') - name = 'tmwa::ByteCode' - enabled = True - - def __init__(self, value): - self._value = value - - def to_string(self): - val = int(self._value) - try: - return 'ByteCode::' + self.types[val] - except IndexError: - return 'ByteCode(%x)' % val - - types = [ - 'NOP', 'POS', 'INT', 'PARAM', 'FUNC', 'STR', 'CONSTSTR', 'ARG', - 'VARIABLE', 'EOL', 'RETINFO', - - 'LOR', 'LAND', 'LE', 'LT', 'GE', 'GT', 'EQ', 'NE', - 'XOR', 'OR', 'AND', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD', - 'NEG', 'LNOT', 'NOT', 'R_SHIFT', 'L_SHIFT', - - 'FUNC_REF', - ] -for i, n in enumerate(ByteCode.types): - setattr(ByteCode, n, i) -del i, n - class script_data(object): - ''' print a script_data - ''' - __slots__ = ('_value') - name = 'tmwa::script_data' enabled = True - def __init__(self, value): - self._value = value - - def children(self): - v = self._value - t = v['type'] - yield 'type', ByteCode(t).to_string() # why does this not work? - v = v['u'] - t = int(t) - if t == ByteCode.PARAM: - yield 'reg', v['reg'] - elif t == ByteCode.RETINFO: - yield 'script', v['script'] - elif t in (ByteCode.STR, ByteCode.CONSTSTR): - yield 'str', v['str'] - else: - yield 'numi', v['numi'] - - def to_string(self): - return None + tests = [ + ('tmwa::script_data(tmwa::ScriptDataPos{42})', + '{> = {(tmwa::ScriptDataPos) = {numi = 42}}, }'), + ('tmwa::script_data(tmwa::ScriptDataInt{123})', + '{> = {(tmwa::ScriptDataInt) = {numi = 123}}, }'), + ('tmwa::script_data(tmwa::ScriptDataParam{tmwa::SIR()})', + '{> = {(tmwa::ScriptDataParam) = {reg = {impl = 0}}}, }'), + ('tmwa::script_data(tmwa::ScriptDataStr{"Hello"_s})', + '{> = {(tmwa::ScriptDataStr) = {str = "Hello"}}, }'), + ('tmwa::script_data(tmwa::ScriptDataArg{0})', + '{> = {(tmwa::ScriptDataArg) = {numi = 0}}, }'), + ('tmwa::script_data(tmwa::ScriptDataVariable{tmwa::SIR()})', + '{> = {(tmwa::ScriptDataVariable) = {reg = {impl = 0}}}, }'), + ('tmwa::script_data(tmwa::ScriptDataRetInfo{static_cast(nullptr)})', + '{> = {(tmwa::ScriptDataRetInfo) = {script = 0x0}}, }'), + ('tmwa::script_data(tmwa::ScriptDataFuncRef{404})', + '{> = {(tmwa::ScriptDataFuncRef) = {numi = 404}}, }'), + ] -- cgit v1.2.3-60-g2f50