summaryrefslogtreecommitdiff
path: root/preprocessor.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-08-28 16:48:29 -0500
committerBryan Bishop <kanzure@gmail.com>2013-08-28 16:48:29 -0500
commitb602cc9bd649e9b8283643acaf3946a186dfad69 (patch)
treebacd22c62e7ca773f2df289be7378783da3ab55e /preprocessor.py
parentd46d1901c2214505ceab544c8f62555b3608deed (diff)
don't directly reference two macro classes
Ideally the macro classes will be removed from the preprocessor core soon, there's no reason they should be infecting these functions.
Diffstat (limited to 'preprocessor.py')
-rw-r--r--preprocessor.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/preprocessor.py b/preprocessor.py
index c4b843e1b..7a9ee756e 100644
--- a/preprocessor.py
+++ b/preprocessor.py
@@ -425,6 +425,18 @@ def macro_test(asm):
else:
return (None, None)
+def is_based_on(something, base):
+ """
+ Checks whether or not 'something' is a class that is a subclass of a class
+ by name. This is a terrible hack but it removes a direct dependency on
+ existing macros.
+
+ Used by macro_translator.
+ """
+ options = [str(klass.__name__) for klass in something.__bases__]
+ options += [something.__name__]
+ return (base in options)
+
def macro_translator(macro, token, line):
"""
Converts a line with a macro into a rgbasm-compatible line.
@@ -540,14 +552,14 @@ def macro_translator(macro, token, line):
output += ("; " + description + "\n")
- if size == 3 and issubclass(param_klass, PointerLabelBeforeBank):
+ if size == 3 and is_based_on(param_klass, "PointerLabelBeforeBank"):
# write the bank first
output += ("db " + param + "\n")
# write the pointer second
output += ("dw " + params[index+1].strip() + "\n")
index += 2
correction += 1
- elif size == 3 and issubclass(param_klass, PointerLabelAfterBank):
+ elif size == 3 and is_based_on(param_klass, "PointerLabelAfterBank"):
# write the pointer first
output += ("dw " + param + "\n")
# write the bank second