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

Commit

Permalink
mod code doesnt need scope
Browse files Browse the repository at this point in the history
  • Loading branch information
marsninja committed Nov 20, 2023
1 parent e542f81 commit af64f73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
3 changes: 2 additions & 1 deletion jaclang/jac/passes/main/def_use_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def enter_atom_trailer(self, node: ast.AtomTrailer) -> None:
right: AtomType,
is_scope_contained: bool,
"""
self.chain_use_lookup(self.unwind_atom_trailer(node))
chain = self.unwind_atom_trailer(node)
self.chain_use_lookup(chain)

def unwind_atom_trailer(self, node: ast.AtomTrailer) -> list[ast.AstSymbolNode]:
"""Sub objects.
Expand Down
8 changes: 3 additions & 5 deletions jaclang/jac/passes/main/sym_tab_build_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ def use_lookup(
"""Link to symbol."""
if self.seen(node):
return node.sym_link
deep = False
if not sym_table:
sym_table = node.sym_tab
deep = True
if sym_table:
node.sym_link = (
sym_table.lookup(name=node.sym_name, deep=deep) if sym_table else None
sym_table.lookup(name=node.sym_name, deep=True) if sym_table else None
)
# If successful lookup mark linked, add to table uses, and link others
if node.sym_link:
Expand Down Expand Up @@ -300,7 +298,7 @@ def enter_module_code(self, node: ast.ModuleCode) -> None:
name: Optional[Name],
body: CodeBlock,
"""
self.push_scope("module_code", node)
# self.push_scope("module_code", node)
self.sync_node_to_scope(node)

def exit_module_code(self, node: ast.ModuleCode) -> None:
Expand All @@ -309,7 +307,7 @@ def exit_module_code(self, node: ast.ModuleCode) -> None:
doc: Optional[Token],
body: 'CodeBlock',
"""
self.pop_scope()
# self.pop_scope()

def enter_py_inline_code(self, node: ast.PyInlineCode) -> None:
"""Sub objects.
Expand Down
26 changes: 25 additions & 1 deletion jaclang/jac/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def test_get_uses_basic(self) -> None:
def test_man_code_dir(self) -> None:
"""Test of circle workspace."""
loc = os.path.join(os.path.dirname(__file__))
# print(loc)
ws = Workspace(path=loc + "/../../../examples/manual_code")
key = [i for i in ws.modules.keys() if "circle.jac" in i][0]
# print(ws.modules[key].ir.sym_tab.pp())
Expand All @@ -65,3 +64,28 @@ def test_man_code_dir(self) -> None:
"print",
]:
self.assertIn(i, out)

# def test_decl_impl(self) -> None:
# """Test of circle workspace."""
# loc = os.path.join(os.path.dirname(__file__))
# ws = Workspace(path=loc + "/../../../examples/manual_code")
# key = [i for i in ws.modules.keys() if "circle_clean.jac" in i][0]
# out = ""
# for i in ws.get_uses(key):
# out += i.pp(depth=2)
# for i in [
# "math",
# "calculate_area",
# "RAD",
# "expected_area",
# "Circle",
# "c",
# "ShapeType",
# "float",
# "radius",
# "CIRCLE",
# "Shape",
# "__init__",
# "print",
# ]:
# self.assertIn(i, out)

0 comments on commit af64f73

Please sign in to comment.