Skip to content

Commit 8eeeea1

Browse files
committed
refactor: use sym.scope_name in IrWriter instead of sym.scope.name
Avoids unnecessary Scope object lookup for serialization.
1 parent 88b1b3f commit 8eeeea1

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

polyphony/compiler/ir/irwriter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ def _write_scope_head(self, scope: Scope):
102102
for name, sym in sorted(scope.symbols.items()):
103103
if not sym.is_imported():
104104
continue
105-
from_scope = sym.scope
106-
self.lines.append(f'from {from_scope.name} import {sym.name}')
105+
self.lines.append(f'from {sym.scope_name} import {sym.name}')
107106

108107
def _write_all_blocks(self, scope: Scope):
109108
for blk in scope.traverse_blocks():
@@ -282,7 +281,7 @@ def _format_type(self, typ: Type) -> str:
282281
elif typ.is_port():
283282
dtype_str = self._format_type(typ.dtype)
284283
root_sym = typ.root_symbol
285-
root_ref = f'{root_sym.scope.name}:{root_sym.name}'
284+
root_ref = f'{root_sym.scope_name}:{root_sym.name}'
286285
return f'port({typ.scope_name}, {dtype_str}, {typ.direction}, {typ.init}, {typ.assigned}, {root_ref})'
287286
elif typ.is_expr():
288287
exp_str = self._format_exp(typ.expr.exp)

0 commit comments

Comments
 (0)