Skip to content

Commit 91c8cf7

Browse files
committed
Allow declaring array vars with address
Now it the array contains an address when declared, it will be anotated, and the variable will be made global (an array at a fixed position is just an static variable). Also cleanup dead code.
1 parent cb3f7c1 commit 91c8cf7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

api/symboltable.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ def declare_variable(self, id_, lineno, type_, default_value=None):
567567
"declared as '%s'" %
568568
(id_, entry.type_, type_))
569569
return None
570-
# type_ = entry.type_ # TODO: Unused??
571570

572571
entry.scope = SCOPE.global_ if self.current_scope == self.global_scope else SCOPE.local
573572
entry.callable = False
@@ -701,9 +700,11 @@ def declare_param(self, id_, lineno, type_=None):
701700
warning_implicit_type(lineno, id_, type_)
702701
return entry
703702

704-
def declare_array(self, id_, lineno, type_, bounds, default_value=None):
703+
def declare_array(self, id_, lineno, type_, bounds, default_value=None, addr=None):
705704
""" Declares an array in the symbol table (VARARRAY). Error if already
706705
exists.
706+
The optional parameter addr specifies if the array elements must be placed at an specific
707+
(constant) memory address.
707708
"""
708709
assert isinstance(type_, symbols.TYPEREF)
709710
assert isinstance(bounds, symbols.BOUNDLIST)
@@ -754,6 +755,7 @@ def declare_array(self, id_, lineno, type_, bounds, default_value=None):
754755
entry.callable = True
755756
entry.class_ = CLASS.array
756757
entry.lbound_used = entry.ubound_used = False # Flag to true when LBOUND/UBOUND used somewhere in the code
758+
entry.addr = addr
757759

758760
__DEBUG__('Entry %s declared with class %s at scope %i' % (id_, CLASS.to_string(entry.class_),
759761
self.current_scope))

0 commit comments

Comments
 (0)