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
12 changes: 5 additions & 7 deletions src/arch/z80/visitor/function_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ def visit_FUNCTION(self, node):
lbound_label = local_var.mangled + ".__LBOUND__"
ubound_label = local_var.mangled + ".__UBOUND__"
lbound_needed = not local_var.is_zero_based and (
local_var.is_dynamically_accessed or local_var.lbound_used
local_var.is_dynamically_accessed or local_var.lbound_used or OPTIONS.array_check
)
ubound_needed = local_var.ubound_used or OPTIONS.array_check
bound_ptrs = [lbound_label if lbound_needed else "0", ubound_label if ubound_needed else "0"]

bound_ptrs = [lbound_label if lbound_needed else "0", "0"]
if local_var.ubound_used:
bound_ptrs[1] = ubound_label

if bound_ptrs != ["0", "0"]:
if lbound_needed or ubound_needed:
OPTIONS["__DEFINES"].value["__ZXB_USE_LOCAL_ARRAY_WITH_BOUNDS__"] = ""

if lbound_needed:
l = ["%04X" % bound.lower for bound in local_var.bounds]
bound_tables.append(LabelledData(lbound_label, l))

if local_var.ubound_used:
if ubound_needed:
l = ["%04X" % bound.upper for bound in local_var.bounds]
bound_tables.append(LabelledData(ubound_label, l))

Expand Down
9 changes: 7 additions & 2 deletions src/arch/z80/visitor/translator_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ def runtime_call(self, label: str, num: int):
if label in LABEL_REQUIRED_MODULES:
backend.REQUIRES.add(LABEL_REQUIRED_MODULES[label])

# This function must be called before emit_strings
def emit_data_blocks(self):
"""Emits the DATA instruction blocks used by READ.
This function must be called before emit_strings() because it will emit access to string variables,
marking them as required.
"""
if not gl.DATA_IS_USED or not gl.DATAS:
return # nothing to do

Expand Down Expand Up @@ -254,10 +257,12 @@ def traverse_const(node):
raise InvalidCONSTexpr(node)

@staticmethod
def check_attr(node, n):
def check_attr(node: Symbol, n: int) -> Symbol | None:
"""Check if ATTR has to be normalized
after this instruction has been translated
to intermediate code.
"""
if len(node.children) > n:
return node.children[n]

return None
Loading
Loading