Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kugesan1105 committed Sep 5, 2024
1 parent 13a4dda commit 9ad2d4f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion jaclang/compiler/passes/main/sym_tab_build_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,27 @@ def exit_import(self, node: ast.Import) -> None:
sub_module: Optional[Module],
"""
if not node.is_absorb:
# if node.from_loc:
# print('--',node.from_loc.sym_name )
for i in node.items.items:
i.sym_tab.def_insert(i, single_decl="import item")
# print('i.symname ----',i.sym_name)
if not isinstance(i, ast.ModuleItem):
# print('-mod path----',i.sym_name)
continue
if not i.from_mod_path.sub_module:
# print('-no sub mod----',i.sym_name)
continue
lookup = i.from_mod_path.sub_module.sym_tab.lookup(i.name.value)
if lookup:
lookup.add_use(i.name_spec)
node.sym_tab.insert(lookup.decl, lookup.access)
else:
i.sym_tab.def_insert(i, single_decl="import item")
# print(i.sym_name)

# if not node.is_absorb:
# for i in node.items.items:
# i.sym_tab.def_insert(i, single_decl="import item")
elif node.is_absorb and node.is_jac:
source = node.items.items[0]
if not isinstance(source, ast.ModulePath) or not source.sub_module:
Expand All @@ -206,6 +225,8 @@ def exit_import(self, node: ast.Import) -> None:
)
else:
node.sym_tab.inherit_sym_tab(source.sub_module.sym_tab)
else:
print("elseeeeeee")

def enter_module_path(self, node: ast.ModulePath) -> None:
"""Sub objects.
Expand Down
2 changes: 1 addition & 1 deletion jaclang/utils/treeprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _build_symbol_tree_common(

if sym.decl and sym.decl.loc.first_line > 0:
SymbolTree(
node_name=f"decl: line {sym.decl.loc.first_line}, col {sym.decl.loc.col_start}",
node_name=f"decl: line {sym.decl.loc.first_line}, col {sym.decl.loc.col_start} {sym.decl.loc.mod_path}",
parent=symbol_node,
)
defn = SymbolTree(node_name="defn", parent=symbol_node)
Expand Down

0 comments on commit 9ad2d4f

Please sign in to comment.