Skip to content

Commit 647355b

Browse files
committed
let SymbolTable.export() optionally export non-global symbols too
This is then the same behaviour as before the .global directive was supported. It might be useful for debugging purposes or potentially some backward compatibility issues (e.g. scripts that depend on the symbol printout after assembling)
1 parent 0b46979 commit 647355b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

esp32_ulp/assemble.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def dump(self):
5353
for symbol, entry in self._symbols.items():
5454
print(symbol, entry)
5555

56-
def export(self):
56+
def export(self, incl_non_globals=False):
5757
addrs_syms = [(self.resolve_absolute(entry), symbol)
5858
for symbol, entry in self._symbols.items()
59-
if symbol in self._globals]
59+
if incl_non_globals or symbol in self._globals]
6060
return sorted(addrs_syms)
6161

6262
def to_abs_addr(self, section, offset):

tests/assemble.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ def test_assemble_global():
117117
exported_symbols = a.symbols.export()
118118
assert exported_symbols == [(0, 'counter'), (2, 'entry')] # internal not exported
119119

120+
exported_symbols = a.symbols.export(True) # include non-global symbols
121+
assert exported_symbols == [(0, 'counter'), (1, 'internal'), (2, 'entry')]
122+
120123

121124
def test_symbols():
122125
st = SymbolTable({}, {}, {})

0 commit comments

Comments
 (0)