From fe3d4ce758822d65a0a5d617b7b77df2dbc972d8 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 16 Mar 2014 14:55:57 -0700 Subject: Implement new magic frontend using sexpr --- src/map/magic-interpreter.py | 224 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/map/magic-interpreter.py (limited to 'src/map/magic-interpreter.py') diff --git a/src/map/magic-interpreter.py b/src/map/magic-interpreter.py new file mode 100644 index 0000000..8170f27 --- /dev/null +++ b/src/map/magic-interpreter.py @@ -0,0 +1,224 @@ +class area_t(object): + ''' print an area_t + ''' + __slots__ = ('_value') + name = 'area_t' + enabled = True + + def __init__(self, value): + self._value = value + + 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'] + + +class val_t(object): + ''' print a val_t + ''' + __slots__ = ('_value') + name = 'val_t' + enabled = True + + def __init__(self, value): + self._value = value + + def to_string(self): + return None + + 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 e_area_t(object): + ''' print an e_area_t + ''' + __slots__ = ('_value') + name = 'e_area_t' + enabled = True + + def __init__(self, value): + self._value = value + + 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'] + + +class expr_t(object): + ''' print an expr_t + ''' + __slots__ = ('_value') + name = 'expr_t' + enabled = True + + def __init__(self, value): + self._value = value + + def to_string(self): + return None + + 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 = 'effect_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['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 spellguard_t(object): + ''' print a spellguard_t + ''' + __slots__ = ('_value') + name = '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'] + + +class cont_activation_record_t(object): + ''' print a cont_activation_record_t + ''' + __slots__ = ('_value') + name = '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'] -- cgit v1.2.3-60-g2f50