Skip to content

Commit 253172b

Browse files
authored
Merge pull request #1053 from boriel-basic/refact/typing
refact: consolidate redundant properties
2 parents 379040b + 5c09e9c commit 253172b

3 files changed

Lines changed: 9 additions & 17 deletions

File tree

src/arch/z80/visitor/translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def visit_LETARRAYSUBSTR(self, node):
443443
self.runtime_call(RuntimeLabel.LETSUBSTR, 0)
444444

445445
def visit_ARRAYACCESS(self, node):
446-
yield self.visit(node.arglist)
446+
yield self.visit(node.args)
447447

448448
def visit_STRSLICE(self, node):
449449
yield self.visit(node.string)

src/symbols/arrayaccess.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ def entry(self, value: SymbolID):
5252
def type_(self):
5353
return self.entry.type_
5454

55-
@property
56-
def arglist(self) -> SymbolARGLIST:
57-
return self.children[1]
58-
59-
@arglist.setter
60-
def arglist(self, value: SymbolARGLIST):
61-
assert isinstance(value, SymbolARGLIST)
62-
self.children[1] = value
63-
6455
@property
6556
def scope(self):
6657
return self.entry.scope
@@ -80,7 +71,7 @@ def offset(self) -> int | None:
8071
offset = 0
8172
# Now we must typecast each argument to a u16 (POINTER) type
8273
# i is the dimension ith index, b is the bound
83-
for i, b in zip(self.arglist, self.entry.bounds):
74+
for i, b in zip(self.args, self.entry.bounds):
8475
tmp = i.children[0]
8576
if check.is_number(tmp) or check.is_const(tmp):
8677
offset = offset * b.count + (tmp.value - b.lower)
@@ -131,4 +122,4 @@ def make_node(cls, id_: str, arglist: SymbolARGLIST, lineno: int, filename: str)
131122

132123
@classmethod
133124
def copy_from(cls, other: Self) -> Self | None:
134-
return cls(entry=other.entry, arglist=other.arglist, lineno=other.lineno, filename=other.filename)
125+
return cls(entry=other.entry, arglist=other.args, lineno=other.lineno, filename=other.filename)

src/symbols/call.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SymbolCALL(Symbol):
3333
def __init__(self, entry: SymbolID, arglist: Iterable[SymbolARGUMENT], lineno: int, filename: str):
3434
assert isinstance(entry, SymbolID)
3535
assert all(isinstance(x, SymbolARGUMENT) for x in arglist)
36-
assert entry.class_ in (CLASS.array, CLASS.function, CLASS.sub, CLASS.unknown)
36+
assert entry.class_ in {CLASS.array, CLASS.function, CLASS.sub, CLASS.unknown}
3737

3838
super().__init__()
3939
self.entry = entry
@@ -55,7 +55,7 @@ def __init__(self, entry: SymbolID, arglist: Iterable[SymbolARGUMENT], lineno: i
5555
arg.value.ref.is_dynamically_accessed = True
5656

5757
@property
58-
def entry(self):
58+
def entry(self) -> SymbolID:
5959
return self.children[0]
6060

6161
@entry.setter
@@ -67,13 +67,13 @@ def entry(self, value: SymbolID):
6767
self.children[0] = value
6868

6969
@property
70-
def args(self):
70+
def args(self) -> SymbolARGLIST:
7171
return self.children[1]
7272

7373
@args.setter
74-
def args(self, value):
74+
def args(self, value: SymbolARGLIST):
7575
assert isinstance(value, SymbolARGLIST)
76-
if self.children is None or not self.children:
76+
if not self.children:
7777
self.children = [None]
7878

7979
if len(self.children) < 2:
@@ -104,6 +104,7 @@ def make_node(cls, id_: str, params, lineno: int, filename: str) -> Self | None:
104104
else: # All functions go to global scope by default
105105
if entry.token != "FUNCTION":
106106
entry = entry.to_function(lineno)
107+
107108
gl.SYMBOL_TABLE.move_to_global_scope(id_)
108109
result = cls(entry, params, lineno, filename)
109110
gl.FUNCTION_CALLS.append(result)

0 commit comments

Comments
 (0)