Skip to content

Commit bfa0ca9

Browse files
committed
refact: type array instrs
Also rename __array to _array.
1 parent 9600f5b commit bfa0ca9

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/arch/z80/backend/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@
112112
from src.arch.z80.backend.common import INITS, START_LABEL, QUADS, runtime_call, tmp_label, Quad, ICInfo
113113

114114
# Array store and load instructions
115-
from .__array import _aload8, _aload16, _aload32, _aloadf, _aloadstr
116-
from .__array import _astore8, _astore16, _astore32, _astoref16, _astoref, _astorestr
117-
from .__array import _aaddr
115+
from ._array import _aload8, _aload16, _aload32, _aloadf, _aloadstr
116+
from ._array import _astore8, _astore16, _astore32, _astoref16, _astoref, _astorestr
117+
from ._array import _aaddr
118118

119119
# Array store and load instructions
120120
from .__parray import _paload8, _paload16, _paload32, _paloadf, _paloadstr
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
# intermediate-code translations
1111
# --------------------------------------------------------------
1212

13+
from typing import List
1314

14-
from .common import REQUIRES, is_int
15-
from .common import runtime_call
15+
from src.arch.z80.backend.common import REQUIRES, is_int, runtime_call, Quad
1616
from src.arch.z80.backend.runtime import Labels as RuntimeLabel
17-
from ._f16 import _f16_oper
18-
from ._float import _fpush, _float_oper
19-
from .errors import InvalidICError
17+
from src.arch.z80.backend.errors import InvalidICError
2018

19+
from src.arch.z80.backend._f16 import _f16_oper
20+
from src.arch.z80.backend._float import _fpush, _float_oper
2121

22-
def _addr(value):
22+
23+
def _addr(value) -> List[str]:
2324
"""Common subroutine for emitting array address"""
2425
output = []
26+
indirect = False
2527

2628
try:
27-
indirect = False
2829
if value[0] == "*":
2930
indirect = True
3031
value = value[1:]
@@ -56,7 +57,7 @@ def _addr(value):
5657
return output
5758

5859

59-
def _aaddr(ins):
60+
def _aaddr(ins: Quad) -> List[str]:
6061
"""Loads the address of an array element
6162
into the stack.
6263
"""
@@ -66,7 +67,7 @@ def _aaddr(ins):
6667
return output
6768

6869

69-
def _aload8(ins):
70+
def _aload8(ins: Quad) -> List[str]:
7071
"""Loads an 8 bit value from a memory address
7172
If 2nd arg. start with '*', it is always treated as
7273
an indirect value.
@@ -78,7 +79,7 @@ def _aload8(ins):
7879
return output
7980

8081

81-
def _aload16(ins):
82+
def _aload16(ins: Quad) -> List[str]:
8283
"""Loads a 16 bit value from a memory address
8384
If 2nd arg. start with '*', it is always treated as
8485
an indirect value.
@@ -94,7 +95,7 @@ def _aload16(ins):
9495
return output
9596

9697

97-
def _aload32(ins):
98+
def _aload32(ins: Quad) -> List[str]:
9899
"""Load a 32 bit value from a memory address
99100
If 2nd arg. start with '*', it is always treated as
100101
an indirect value.
@@ -108,7 +109,7 @@ def _aload32(ins):
108109
return output
109110

110111

111-
def _aloadf(ins):
112+
def _aloadf(ins: Quad) -> List[str]:
112113
"""Loads a floating point value from a memory address.
113114
If 2nd arg. start with '*', it is always treated as
114115
an indirect value.
@@ -120,7 +121,7 @@ def _aloadf(ins):
120121
return output
121122

122123

123-
def _aloadstr(ins):
124+
def _aloadstr(ins: Quad) -> List[str]:
124125
"""Loads a string value from a memory address."""
125126
output = _addr(ins.quad[2])
126127

@@ -130,7 +131,7 @@ def _aloadstr(ins):
130131
return output
131132

132133

133-
def _astore8(ins):
134+
def _astore8(ins: Quad) -> List[str]:
134135
"""Stores 2º operand content into address of 1st operand.
135136
1st operand is an array element. Dimensions are pushed into the
136137
stack.
@@ -180,7 +181,7 @@ def _astore8(ins):
180181
return output
181182

182183

183-
def _astore16(ins):
184+
def _astore16(ins: Quad) -> List[str]:
184185
"""Stores 2º operand content into address of 1st operand.
185186
store16 a, x => *(&a) = x
186187
Use '*' for indirect store on 1st operand.
@@ -235,7 +236,7 @@ def _astore16(ins):
235236
return output
236237

237238

238-
def _astore32(ins):
239+
def _astore32(ins: Quad) -> List[str]:
239240
"""Stores 2º operand content into address of 1st operand.
240241
store16 a, x => *(&a) = x
241242
"""
@@ -269,7 +270,7 @@ def _astore32(ins):
269270
return output
270271

271272

272-
def _astoref16(ins):
273+
def _astoref16(ins: Quad) -> List[str]:
273274
"""Stores 2º operand content into address of 1st operand.
274275
storef16 a, x => *(&a) = x
275276
"""
@@ -295,7 +296,7 @@ def _astoref16(ins):
295296
return output
296297

297298

298-
def _astoref(ins):
299+
def _astoref(ins: Quad) -> List[str]:
299300
"""Stores a floating point value into a memory address."""
300301
output = _addr(ins.quad[1])
301302

@@ -317,7 +318,7 @@ def _astoref(ins):
317318
return output
318319

319320

320-
def _astorestr(ins):
321+
def _astorestr(ins: Quad) -> List[str]:
321322
"""Stores a string value into a memory address.
322323
It copies content of 2nd operand (string), into 1st, reallocating
323324
dynamic memory for the 1st str. These instruction DOES ALLOW

0 commit comments

Comments
 (0)