jaclang 0.7.14__py3-none-any.whl → 0.7.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jaclang might be problematic. Click here for more details.
- jaclang/cli/cli.py +15 -10
- jaclang/cli/cmdreg.py +9 -12
- jaclang/compiler/__init__.py +19 -53
- jaclang/compiler/absyntree.py +86 -13
- jaclang/compiler/jac.lark +4 -3
- jaclang/compiler/parser.py +31 -23
- jaclang/compiler/passes/ir_pass.py +4 -13
- jaclang/compiler/passes/main/access_modifier_pass.py +1 -1
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +4 -5
- jaclang/compiler/passes/main/import_pass.py +18 -23
- jaclang/compiler/passes/main/pyast_gen_pass.py +307 -559
- jaclang/compiler/passes/main/pyast_load_pass.py +32 -6
- jaclang/compiler/passes/main/registry_pass.py +37 -3
- jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
- jaclang/compiler/passes/main/tests/__init__.py +1 -1
- jaclang/compiler/passes/main/type_check_pass.py +7 -0
- jaclang/compiler/passes/tool/jac_formatter_pass.py +124 -86
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +0 -1
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/architype_test.jac +13 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comment_alignment.jac +11 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comments.jac +13 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/decorator_stack.jac +37 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/esc_keywords.jac +5 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/long_names.jac +19 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +6 -0
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -0
- jaclang/compiler/passes/tool/tests/test_unparse_validate.py +33 -39
- jaclang/compiler/passes/transform.py +4 -0
- jaclang/compiler/semtable.py +31 -7
- jaclang/compiler/tests/test_importer.py +12 -5
- jaclang/langserve/engine.py +65 -118
- jaclang/langserve/sem_manager.py +379 -0
- jaclang/langserve/server.py +8 -10
- jaclang/langserve/tests/fixtures/base_module_structure.jac +27 -6
- jaclang/langserve/tests/fixtures/circle.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
- jaclang/langserve/tests/fixtures/import_include_statements.jac +1 -1
- jaclang/langserve/tests/test_sem_tokens.py +277 -0
- jaclang/langserve/tests/test_server.py +72 -16
- jaclang/langserve/utils.py +163 -96
- jaclang/plugin/builtin.py +1 -1
- jaclang/plugin/default.py +212 -24
- jaclang/plugin/feature.py +59 -11
- jaclang/plugin/spec.py +58 -6
- jaclang/{core → runtimelib}/architype.py +1 -1
- jaclang/{core → runtimelib}/context.py +8 -1
- jaclang/runtimelib/importer.py +361 -0
- jaclang/runtimelib/machine.py +94 -0
- jaclang/{core → runtimelib}/utils.py +13 -5
- jaclang/settings.py +4 -1
- jaclang/tests/fixtures/abc.jac +3 -3
- jaclang/tests/fixtures/byllmissue.jac +1 -5
- jaclang/tests/fixtures/chandra_bugs2.jac +11 -10
- jaclang/tests/fixtures/cls_method.jac +41 -0
- jaclang/tests/fixtures/dblhello.jac +6 -0
- jaclang/tests/fixtures/deep/one_lev.jac +3 -3
- jaclang/tests/fixtures/deep/one_lev_dup.jac +2 -3
- jaclang/tests/fixtures/deep_import_mods.jac +13 -0
- jaclang/tests/fixtures/err.impl.jac +3 -0
- jaclang/tests/fixtures/err.jac +4 -2
- jaclang/tests/fixtures/err.test.jac +3 -0
- jaclang/tests/fixtures/err_runtime.jac +15 -0
- jaclang/tests/fixtures/game1.jac +1 -1
- jaclang/tests/fixtures/hello.jac +4 -0
- jaclang/tests/fixtures/impl_grab.impl.jac +2 -1
- jaclang/tests/fixtures/impl_grab.jac +4 -1
- jaclang/tests/fixtures/jp_importer_auto.jac +14 -0
- jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
- jaclang/tests/fixtures/needs_import.jac +2 -2
- jaclang/tests/fixtures/pyfunc_2.py +3 -0
- jaclang/tests/fixtures/registry.jac +9 -0
- jaclang/tests/fixtures/run_test.jac +4 -4
- jaclang/tests/fixtures/semstr.jac +1 -4
- jaclang/tests/fixtures/simple_archs.jac +1 -1
- jaclang/tests/test_cli.py +65 -2
- jaclang/tests/test_language.py +74 -7
- jaclang/tests/test_reference.py +6 -0
- jaclang/utils/helpers.py +45 -21
- jaclang/utils/test.py +9 -0
- jaclang/utils/treeprinter.py +0 -4
- {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/METADATA +3 -2
- {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/RECORD +89 -74
- jaclang/core/importer.py +0 -344
- jaclang/tests/fixtures/aott_raise.jac +0 -25
- jaclang/tests/fixtures/package_import.jac +0 -6
- /jaclang/{core → runtimelib}/__init__.py +0 -0
- /jaclang/{core → runtimelib}/constructs.py +0 -0
- /jaclang/{core → runtimelib}/memory.py +0 -0
- /jaclang/{core → runtimelib}/test.py +0 -0
- {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/WHEEL +0 -0
- {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/entry_points.txt +0 -0
|
@@ -16,7 +16,10 @@ import jaclang.compiler.absyntree as ast
|
|
|
16
16
|
from jaclang.compiler.passes import Pass
|
|
17
17
|
from jaclang.compiler.passes.main import SubNodeTabPass
|
|
18
18
|
from jaclang.settings import settings
|
|
19
|
-
from jaclang.utils.helpers import
|
|
19
|
+
from jaclang.utils.helpers import is_standard_lib_module
|
|
20
|
+
from jaclang.utils.log import logging
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
class JacImportPass(Pass):
|
|
@@ -51,13 +54,10 @@ class JacImportPass(Pass):
|
|
|
51
54
|
|
|
52
55
|
def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
|
|
53
56
|
"""Process an import."""
|
|
54
|
-
|
|
55
|
-
if
|
|
56
|
-
self.import_jac_module(
|
|
57
|
-
|
|
58
|
-
mod_path=node.loc.mod_path,
|
|
59
|
-
)
|
|
60
|
-
elif lang == "py":
|
|
57
|
+
imp_node = i.parent_of_type(ast.Import)
|
|
58
|
+
if imp_node.is_jac and not i.sub_module:
|
|
59
|
+
self.import_jac_module(node=i)
|
|
60
|
+
elif imp_node.is_py:
|
|
61
61
|
self.__py_imports.add(i.path_str)
|
|
62
62
|
|
|
63
63
|
def attach_mod_to_node(
|
|
@@ -136,14 +136,10 @@ class JacImportPass(Pass):
|
|
|
136
136
|
if node.as_attr_list[0].sym_name in self.__py_imports:
|
|
137
137
|
self.py_resolve_list.add(".".join([i.sym_name for i in node.as_attr_list]))
|
|
138
138
|
|
|
139
|
-
def import_jac_module(self, node: ast.ModulePath
|
|
139
|
+
def import_jac_module(self, node: ast.ModulePath) -> None:
|
|
140
140
|
"""Import a module."""
|
|
141
141
|
self.cur_node = node # impacts error reporting
|
|
142
|
-
target =
|
|
143
|
-
level=node.level,
|
|
144
|
-
target=node.path_str,
|
|
145
|
-
base_path=os.path.dirname(node.loc.mod_path),
|
|
146
|
-
)
|
|
142
|
+
target = node.resolve_relative_path()
|
|
147
143
|
# If the module is a package (dir)
|
|
148
144
|
if os.path.isdir(target):
|
|
149
145
|
self.attach_mod_to_node(node, self.import_jac_mod_from_dir(target))
|
|
@@ -153,11 +149,7 @@ class JacImportPass(Pass):
|
|
|
153
149
|
# Import all from items as modules or packages
|
|
154
150
|
for i in import_node.items.items:
|
|
155
151
|
if isinstance(i, ast.ModuleItem):
|
|
156
|
-
from_mod_target =
|
|
157
|
-
level=node.level,
|
|
158
|
-
target=node.path_str + "." + i.name.value,
|
|
159
|
-
base_path=os.path.dirname(node.loc.mod_path),
|
|
160
|
-
)
|
|
152
|
+
from_mod_target = node.resolve_relative_path(i.name.value)
|
|
161
153
|
# If package
|
|
162
154
|
if os.path.isdir(from_mod_target):
|
|
163
155
|
self.attach_mod_to_node(
|
|
@@ -204,7 +196,7 @@ class JacImportPass(Pass):
|
|
|
204
196
|
self.warnings_had += mod_pass.warnings_had
|
|
205
197
|
mod = mod_pass.ir
|
|
206
198
|
except Exception as e:
|
|
207
|
-
|
|
199
|
+
logger.info(e)
|
|
208
200
|
mod = None
|
|
209
201
|
if isinstance(mod, ast.Module):
|
|
210
202
|
self.import_table[target] = mod
|
|
@@ -227,8 +219,12 @@ class PyImportPass(JacImportPass):
|
|
|
227
219
|
|
|
228
220
|
def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
|
|
229
221
|
"""Process an import."""
|
|
230
|
-
|
|
231
|
-
if
|
|
222
|
+
imp_node = i.parent_of_type(ast.Import)
|
|
223
|
+
if (
|
|
224
|
+
imp_node.is_py
|
|
225
|
+
and not i.sub_module
|
|
226
|
+
and not is_standard_lib_module(i.path_str)
|
|
227
|
+
):
|
|
232
228
|
mod = self.import_py_module(node=i, mod_path=node.loc.mod_path)
|
|
233
229
|
if mod:
|
|
234
230
|
i.sub_module = mod
|
|
@@ -252,7 +248,6 @@ class PyImportPass(JacImportPass):
|
|
|
252
248
|
if spec.origin in self.import_table:
|
|
253
249
|
return self.import_table[spec.origin]
|
|
254
250
|
with open(spec.origin, "r", encoding="utf-8") as f:
|
|
255
|
-
# print(f"\nImporting python module {node.path_str}")
|
|
256
251
|
mod = PyastBuildPass(
|
|
257
252
|
input_ir=ast.PythonModuleAst(
|
|
258
253
|
py_ast.parse(f.read()), mod_path=spec.origin
|