@@ -8,7 +8,7 @@ class PrgmCompiler(object):
8
8
program files
9
9
"""
10
10
11
- def compile (raw_text ):
11
+ def compile (self , raw_text = None ):
12
12
"""
13
13
Compiles to 8Xp format. This logic works, but the TIFile class is
14
14
incomplete so the file may not work properly on the TI calculator.
@@ -18,6 +18,14 @@ def compile(raw_text):
18
18
Returns:
19
19
TIFile
20
20
"""
21
+ # To be compatible with Python 2.7 without changing
22
+ # the public class API, we do some gross magic. This
23
+ # has a side effect that we can use this method either
24
+ # as a static method or not.
25
+ # FIXME
26
+ if not isinstance (self , PrgmCompiler ):
27
+ raw_text = self
28
+
21
29
tifile = TIPrgmFile ()
22
30
tifile .prgmdata = []
23
31
tokens = get_inverse_tokens ()
@@ -45,7 +53,7 @@ def compile(raw_text):
45
53
return tifile
46
54
47
55
48
- def decompile (tifile ):
56
+ def decompile (self , tifile = None ):
49
57
"""
50
58
Decompiles to plaintext.
51
59
@@ -54,6 +62,15 @@ def decompile(tifile):
54
62
Returns:
55
63
Array[string]
56
64
"""
65
+
66
+ # To be compatible with Python 2.7 without changing
67
+ # the public class API, we do some gross magic. This
68
+ # has a side effect that we can use this method either
69
+ # as a static method or not.
70
+ # FIXME
71
+ if not isinstance (self , PrgmCompiler ):
72
+ tifile = self
73
+
57
74
prgm_data = tifile .prgmdata
58
75
plaintext = []
59
76
tokens = get_tokens ()
0 commit comments