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/magic-interpreter.py | 335 +++++++++++++++++++++---------------------- 1 file changed, 163 insertions(+), 172 deletions(-) (limited to 'src/map/magic-interpreter.py') diff --git a/src/map/magic-interpreter.py b/src/map/magic-interpreter.py index f6fa4c9..cf17b1c 100644 --- a/src/map/magic-interpreter.py +++ b/src/map/magic-interpreter.py @@ -1,224 +1,215 @@ -class area_t(object): - ''' print an area_t - ''' +class AreaUnion(object): __slots__ = ('_value') - name = 'tmwa::area_t' + name = 'tmwa::magic::AreaUnion' enabled = True def __init__(self, value): self._value = value + def display_hint(self): + return 'array' + def to_string(self): return None def children(self): v = self._value - yield 'size', v['size'] - ty = v['ty'] - yield 'ty', ty - a = v['a'] - if ty == 0: - yield 'a.a_loc', a['a_loc'] - elif ty == 1: - yield 'a.a_union', a['a_union'] - elif ty == 2: - yield 'a.a_rect', a['a_rect'] - elif ty == 3: - yield 'a.a_bar', a['a_bar'] + for i in [0, 1]: + yield '[%d]', v['a_union'][i]['impl'].dereference() + tests = [] -class val_t(object): - ''' print a val_t - ''' - __slots__ = ('_value') - name = 'tmwa::val_t' +class area_t(object): enabled = True - def __init__(self, value): - self._value = value + test_extra = ''' + #include "../strings/fwd.hpp" + using tmwa::operator "" _s; + + inline + tmwa::map_local *fake_map_local_x_dup_for_area_t(tmwa::ZString name) + { + auto *p = new tmwa::map_local{}; + p->name_ = tmwa::stringish(name); + return p; + } + ''' - def to_string(self): - return None + tests = [ + ('tmwa::magic::area_t(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456})', + '{> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}'), + ('tmwa::magic::area_t(tmwa::magic::AreaUnion{{tmwa::dumb_ptr::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}), tmwa::dumb_ptr::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 321, 654})}})', + '{> = {(tmwa::magic::AreaUnion) = {{> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}, {> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 321, y = 654}}, size = 1}}}, size = 2}'), + ('tmwa::magic::area_t(tmwa::magic::AreaRect{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}, 789, 102})', + '{> = {(tmwa::magic::AreaRect) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}, width = 789, height = 102}}, size = 80478}'), + ('tmwa::magic::area_t(tmwa::magic::AreaBar{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 42, 43}, 123, 456, tmwa::DIR::NW})', + '{> = {(tmwa::magic::AreaBar) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 43}, width = 123, depth = 456, dir = tmwa::DIR::NW}}, size = 112632}'), + ] - def children(self): - v = self._value - ty = v['ty'] - yield 'ty', ty - u = v['v'] - if ty == 1: - yield 'v.v_int', u['v_int'] - elif ty == 2: - yield 'v.v_dir', u['v_dir'] - elif ty == 3: - yield 'v.v_string', u['v_string'] - elif ty == 4: - yield 'v.v_int', u['v_int'] - yield 'v.v_entity', u['v_entity'] - elif ty == 5: - yield 'v.v_location', u['v_location'] - elif ty == 6: - yield 'v.v_area', u['v_area'] - elif ty == 7: - yield 'v.v_spell', u['v_spell'] - elif ty == 8: - yield 'v.v_int', u['v_int'] - yield 'v.v_invocation', u['v_invocation'] +class val_t(object): + enabled = True -class e_area_t(object): - ''' print an e_area_t + test_extra = ''' + #include "../strings/fwd.hpp" + using tmwa::operator "" _s; + + inline + tmwa::map_local *fake_map_local_x_dup_for_val_t(tmwa::ZString name) + { + auto *p = new tmwa::map_local{}; + p->name_ = tmwa::stringish(name); + return p; + } ''' + + tests = [ + ('tmwa::magic::val_t(tmwa::magic::ValUndef{})', + '{> = {(tmwa::magic::ValUndef) = {}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValInt{42})', + '{> = {(tmwa::magic::ValInt) = {v_int = 42}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValDir{tmwa::DIR::NW})', + '{> = {(tmwa::magic::ValDir) = {v_dir = tmwa::DIR::NW}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValString{"Hello"_s})', + '{> = {(tmwa::magic::ValString) = {v_string = "Hello"}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValEntityInt{tmwa::wrap(123)})', + '{> = {(tmwa::magic::ValEntityInt) = {v_eid = 123}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValEntityPtr{tmwa::dumb_ptr()})', + '{> = {(tmwa::magic::ValEntityPtr) = {v_entity = 0x0}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValLocation{tmwa::magic::location_t{fake_map_local_x_dup_for_val_t("map"_s), 42, 123}})', + '{> = {(tmwa::magic::ValLocation) = {v_location = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 123}}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValArea{tmwa::dumb_ptr()})', + '{> = {(tmwa::magic::ValArea) = {v_area = 0x0}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValSpell{tmwa::dumb_ptr()})', + '{> = {(tmwa::magic::ValSpell) = {v_spell = 0x0}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValInvocationInt{tmwa::wrap(123)})', + '{> = {(tmwa::magic::ValInvocationInt) = {v_iid = 123}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValInvocationPtr{})', + '{> = {(tmwa::magic::ValInvocationPtr) = {v_invocation = 0x0}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValFail{})', + '{> = {(tmwa::magic::ValFail) = {}}, }'), + ('tmwa::magic::val_t(tmwa::magic::ValNegative1{})', + '{> = {(tmwa::magic::ValNegative1) = {}}, }'), + ] + + +class ExprAreaUnion(object): __slots__ = ('_value') - name = 'tmwa::e_area_t' + name = 'tmwa::magic::ExprAreaUnion' enabled = True def __init__(self, value): self._value = value + def display_hint(self): + return 'array' + def to_string(self): return None def children(self): v = self._value - ty = v['ty'] - yield 'ty', ty - a = v['a'] - if ty == 0: - yield 'a.a_loc', a['a_loc'] - elif ty == 1: - yield 'a.a_union', a['a_union'] - elif ty == 2: - yield 'a.a_rect', a['a_rect'] - elif ty == 3: - yield 'a.a_bar', a['a_bar'] + for i in [0, 1]: + yield '[%d]', v['a_union'][i]['impl'].dereference() + tests = [] -class expr_t(object): - ''' print an expr_t - ''' - __slots__ = ('_value') - name = 'tmwa::expr_t' - enabled = True - def __init__(self, value): - self._value = value +class e_area_t(object): + enabled = True - def to_string(self): - return None + tests = [ + ('tmwa::magic::e_area_t(tmwa::magic::e_location_t())', + '{> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, }'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaUnion{{tmwa::dumb_ptr::make(tmwa::magic::e_location_t()), tmwa::dumb_ptr::make(tmwa::magic::e_location_t())}})', + '{> = {(tmwa::magic::ExprAreaUnion) = {{> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, }, {> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, }}}, }'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaRect{tmwa::magic::e_location_t(), tmwa::dumb_ptr(), tmwa::dumb_ptr()})', + '{> = {(tmwa::magic::ExprAreaRect) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, height = 0x0}}, }'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaBar{tmwa::magic::e_location_t(), tmwa::dumb_ptr(), tmwa::dumb_ptr(), tmwa::dumb_ptr()})', + '{> = {(tmwa::magic::ExprAreaBar) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, depth = 0x0, dir = 0x0}}, }'), + ] - def children(self): - v = self._value - ty = v['ty'] - yield 'ty', ty - u = v['e'] - if ty == 0: - yield 'e.e_val', u['e_val'] - elif ty == 1: - yield 'e.e_location', u['e_location'] - elif ty == 2: - yield 'e.e_area', u['e_area'] - elif ty == 3: - yield 'e.e_funapp', u['e_funapp'] - elif ty == 4: - yield 'e.e_id', u['e_id'] - elif ty == 5: - yield 'e.e_field', u['e_field'] -class effect_t(object): - ''' print an effect_t - ''' - __slots__ = ('_value') - name = 'tmwa::effect_t' +class expr_t(object): enabled = True - def __init__(self, value): - self._value = value + tests = [ + ('tmwa::magic::expr_t(tmwa::magic::val_t(tmwa::magic::ValUndef()))', + '{> = {(tmwa::magic::val_t) = {> = {(tmwa::magic::ValUndef) = {}}, }}, }'), + ('tmwa::magic::expr_t(tmwa::magic::e_location_t())', + '{> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, }'), + ('tmwa::magic::expr_t(tmwa::magic::e_area_t(tmwa::magic::e_location_t()))', + '{> = {(tmwa::magic::e_area_t) = {> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, }}, }'), + ('tmwa::magic::expr_t(tmwa::magic::ExprFunApp())', + '{> = {(tmwa::magic::ExprFunApp) = {funp = (fun_t *) nullptr, line_nr = 0, column = 0, args_nr = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, }'), + ('tmwa::magic::expr_t(tmwa::magic::ExprId{123})', + '{> = {(tmwa::magic::ExprId) = {e_id = 123}}, }'), + ('tmwa::magic::expr_t(tmwa::magic::ExprField{tmwa::dumb_ptr(), 42})', + '{> = {(tmwa::magic::ExprField) = {expr = 0x0, id = 42}}, }'), + ] - def to_string(self): - return None - def children(self): - v = self._value - yield 'next', v['next'] - ty = v['ty'] - yield 'ty', ty - u = v['e'] - if ty == 2: - yield 'e.e_assign', u['e_assign'] - elif ty == 3: - yield 'e.e_foreach', u['e_foreach'] - elif ty == 4: - yield 'e.e_for', u['e_for'] - elif ty == 5: - yield 'e.e_if', u['e_if'] - elif ty == 6: - yield 'e.e_sleep', u['e_sleep'] - elif ty == 7: - yield 'e.e_script', u['e_script'] - elif ty == 9: - yield 'e.e_op', u['e_op'] - elif ty == 11: - yield 'e.e_call', u['e_call'] +class effect_t(object): + enabled = True + + tests = [ + ('tmwa::magic::effect_t(tmwa::magic::EffectSkip{}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectSkip) = {}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectAbort{}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectAbort) = {}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectAssign{42, tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectAssign) = {id = 42, expr = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectForEach{123, tmwa::dumb_ptr(), tmwa::dumb_ptr(), tmwa::magic::FOREACH_FILTER::PC}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectForEach) = {id = 123, area = 0x0, body = 0x0, filter = tmwa::magic::FOREACH_FILTER::PC}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectFor{42, tmwa::dumb_ptr(), tmwa::dumb_ptr(), tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectFor) = {id = 42, start = 0x0, stop = 0x0, body = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectIf{tmwa::dumb_ptr(), tmwa::dumb_ptr(), tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectIf) = {cond = 0x0, true_branch = 0x0, false_branch = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectSleep{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectSleep) = {e_sleep = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectScript{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectScript) = {e_script = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectBreak{}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectBreak) = {}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectOp(), tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectOp) = {opp = (op_t *) nullptr, args_nr = 0, line_nr = 0, column = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectEnd{}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectEnd) = {}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectCall{nullptr, tmwa::dumb_ptr>>(), tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::EffectCall) = {formalv = 0x0, actualvp = 0x0, body = 0x0}}, next = 0x0}'), + ] class spellguard_t(object): - ''' print a spellguard_t - ''' - __slots__ = ('_value') - name = 'tmwa::spellguard_t' enabled = True - def __init__(self, value): - self._value = value - - def to_string(self): - return None - - def children(self): - v = self._value - yield 'next', v['next'] - ty = v['ty'] - yield 'ty', ty - u = v['s'] - if ty == 0: - yield 's.s_condition', u['s_condition'] - elif ty == 1: - yield 's.s_components', u['s_components'] - elif ty == 2: - yield 's.s_catalysts', u['s_catalysts'] - elif ty == 3: - yield 's.s_alt', u['s_alt'] - elif ty == 4: - yield 's.s_mana', u['s_mana'] - elif ty == 5: - yield 's.s_casttime', u['s_casttime'] - elif ty == 6: - yield 's.s_effect', u['s_effect'] + tests = [ + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCondition{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardCondition) = {s_condition = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardMana{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardMana) = {s_mana = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCastTime{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardCastTime) = {s_casttime = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardComponents{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardComponents) = {s_components = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCatalysts{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardCatalysts) = {s_catalysts = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardChoice{tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::GuardChoice) = {s_alt = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::effect_set_t{tmwa::dumb_ptr(), tmwa::dumb_ptr(), tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::effect_set_t) = {effect = 0x0, at_trigger = 0x0, at_end = 0x0}}, next = 0x0}'), + ] class cont_activation_record_t(object): - ''' print a cont_activation_record_t - ''' - __slots__ = ('_value') - name = 'tmwa::cont_activation_record_t' enabled = True - def __init__(self, value): - self._value = value - - def to_string(self): - return None - - def children(self): - v = self._value - yield 'return_location', v['return_location'] - ty = v['ty'] - yield 'ty', ty - u = v['c'] - if ty == 0: - yield 'c.c_foreach', u['c_foreach'] - elif ty == 1: - yield 'c.c_for', u['c_for'] - elif ty == 2: - yield 'c.c_proc', u['c_proc'] + tests = [ + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarForEach{42, true, tmwa::dumb_ptr(), tmwa::dumb_ptr>(), 123}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::CarForEach) = {id = 42, ty_is_spell_not_entity = true, body = 0x0, entities_vp = 0x0, index = 123}}, return_location = 0x0}'), + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarFor{42, tmwa::dumb_ptr(), 123, 456}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::CarFor) = {id = 42, body = 0x0, current = 123, stop = 456}}, return_location = 0x0}'), + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarProc{123, nullptr, tmwa::dumb_ptr()}, tmwa::dumb_ptr())', + '{> = {(tmwa::magic::CarProc) = {args_nr = 123, formalap = 0x0, old_actualpa = 0x0 = {sz = 0}}}, return_location = 0x0}'), + ] -- cgit v1.2.3-60-g2f50