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

Commit

Permalink
tweak: small
Browse files Browse the repository at this point in the history
  • Loading branch information
marsninja committed Jul 13, 2024
1 parent 995763c commit 39d77e2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jaclang/compiler/absyntree.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def __init__(
self.test_mod: list[Module] = []
self.mod_deps: dict[str, Module] = {}
self.registry = registry
self.py_lib: bool = False
self.is_py_raised: bool = False
AstNode.__init__(self, kid=kid)
AstDocNode.__init__(self, doc=doc)

Expand Down
4 changes: 2 additions & 2 deletions jaclang/compiler/passes/main/import_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def import_jac_mod_from_file(self, target: str) -> ast.Module | None:
self.errors_had += mod_pass.errors_had
self.warnings_had += mod_pass.warnings_had
mod = mod_pass.ir
except Exception as e:
except Exception:
mod = None
if isinstance(mod, ast.Module):
self.import_table[target] = mod
Expand Down Expand Up @@ -312,7 +312,7 @@ def after_pass(self) -> None:
[i],
)
SubNodeTabPass(prior=self, input_ir=py_mod_map[expected_file][0])
py_mod_map[expected_file][0].py_lib = True
py_mod_map[expected_file][0].is_py_raised = True
else:
py_mod_map[expected_file][1].append(i)

Expand Down
2 changes: 1 addition & 1 deletion jaclang/compiler/passes/main/type_check_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def before_pass(self) -> None:

def enter_module(self, node: ast.Module) -> None:
"""Call mypy checks on module level only."""
if not node.py_lib:
if not node.is_py_raised:
self.__modules.append(node)

def after_pass(self) -> None:
Expand Down
6 changes: 5 additions & 1 deletion jaclang/compiler/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def find_scope(self, name: str) -> Optional[SymbolTable]:
def find_py_scope(self, name: str) -> Optional[SymbolTable]:
"""Find a scope that was originally a python module in the symbol table."""
for k in self.kid:
if isinstance(k.owner, ast.Module) and k.owner.py_lib and k.name == name:
if (
isinstance(k.owner, ast.Module)
and k.owner.is_py_raised
and k.name == name
):
return k
return None

Expand Down
2 changes: 1 addition & 1 deletion jaclang/utils/treeprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def mapper(draw: bool) -> str:
file_name = file_name.split(os.path.sep)[-1]
tree_str = f"{file_name} {root.loc}\t{markers}{__node_repr_in_tree(root)}\n"
for i, child in enumerate(root.kid):
if isinstance(child, ast.Module) and child.py_lib:
if isinstance(child, ast.Module) and child.is_py_raised:
continue
is_last = i == len(root.kid) - 1
tree_str += print_ast_tree(
Expand Down

0 comments on commit 39d77e2

Please sign in to comment.