Skip to content

Commit 1da5516

Browse files
authored
Merge pull request #337 from boriel/bugfix/crash_local_array_of_strings
Bugfix/crash local array of strings
2 parents c0807a6 + feb7f4e commit 1da5516

17 files changed

+7415
-1
lines changed

arch/zx48k/translator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,14 @@ def visit_LETARRAY(self, node):
310310
if scope == SCOPE.global_:
311311
self.ic_store(arr.type_, '%s + %i' % (name, arr.offset), node.children[1].t)
312312
elif scope == SCOPE.local:
313-
self.ic_pstore(arr.type_, -(arr.entry.offset - arr.offset), node.children[1].t)
313+
t1 = optemps.new_t()
314+
t2 = optemps.new_t()
315+
self.ic_pload(gl.PTR_TYPE, t1, -(arr.entry.offset - self.TYPE(gl.PTR_TYPE).size))
316+
self.ic_add(gl.PTR_TYPE, t2, t1, arr.offset)
317+
if arr.type_ == Type.string:
318+
self.ic_store(arr.type_, '*{}'.format(t2), node.children[1].t)
319+
else:
320+
self.ic_store(arr.type_, t2, node.children[1].t)
314321
else:
315322
raise InternalError("Invalid scope {} for variable '{}'".format(scope, arr.entry.name))
316323

0 commit comments

Comments
 (0)