Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arch/z80/visitor/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def visit_LETARRAYSUBSTR(self, node):
self.runtime_call(RuntimeLabel.LETSUBSTR, 0)

def visit_ARRAYACCESS(self, node):
yield self.visit(node.arglist)
yield self.visit(node.args)

def visit_STRSLICE(self, node):
yield self.visit(node.string)
Expand Down
13 changes: 2 additions & 11 deletions src/symbols/arrayaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ def entry(self, value: SymbolID):
def type_(self):
return self.entry.type_

@property
def arglist(self) -> SymbolARGLIST:
return self.children[1]

@arglist.setter
def arglist(self, value: SymbolARGLIST):
assert isinstance(value, SymbolARGLIST)
self.children[1] = value

@property
def scope(self):
return self.entry.scope
Expand All @@ -80,7 +71,7 @@ def offset(self) -> int | None:
offset = 0
# Now we must typecast each argument to a u16 (POINTER) type
# i is the dimension ith index, b is the bound
for i, b in zip(self.arglist, self.entry.bounds):
for i, b in zip(self.args, self.entry.bounds):
tmp = i.children[0]
if check.is_number(tmp) or check.is_const(tmp):
offset = offset * b.count + (tmp.value - b.lower)
Expand Down Expand Up @@ -131,4 +122,4 @@ def make_node(cls, id_: str, arglist: SymbolARGLIST, lineno: int, filename: str)

@classmethod
def copy_from(cls, other: Self) -> Self | None:
return cls(entry=other.entry, arglist=other.arglist, lineno=other.lineno, filename=other.filename)
return cls(entry=other.entry, arglist=other.args, lineno=other.lineno, filename=other.filename)
11 changes: 6 additions & 5 deletions src/symbols/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SymbolCALL(Symbol):
def __init__(self, entry: SymbolID, arglist: Iterable[SymbolARGUMENT], lineno: int, filename: str):
assert isinstance(entry, SymbolID)
assert all(isinstance(x, SymbolARGUMENT) for x in arglist)
assert entry.class_ in (CLASS.array, CLASS.function, CLASS.sub, CLASS.unknown)
assert entry.class_ in {CLASS.array, CLASS.function, CLASS.sub, CLASS.unknown}

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

@property
def entry(self):
def entry(self) -> SymbolID:
return self.children[0]

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

@property
def args(self):
def args(self) -> SymbolARGLIST:
return self.children[1]

@args.setter
def args(self, value):
def args(self, value: SymbolARGLIST):
assert isinstance(value, SymbolARGLIST)
if self.children is None or not self.children:
if not self.children:
self.children = [None]

if len(self.children) < 2:
Expand Down Expand Up @@ -104,6 +104,7 @@ def make_node(cls, id_: str, params, lineno: int, filename: str) -> Self | None:
else: # All functions go to global scope by default
if entry.token != "FUNCTION":
entry = entry.to_function(lineno)

gl.SYMBOL_TABLE.move_to_global_scope(id_)
result = cls(entry, params, lineno, filename)
gl.FUNCTION_CALLS.append(result)
Expand Down