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.

Files changed (92) hide show
  1. jaclang/cli/cli.py +15 -10
  2. jaclang/cli/cmdreg.py +9 -12
  3. jaclang/compiler/__init__.py +19 -53
  4. jaclang/compiler/absyntree.py +86 -13
  5. jaclang/compiler/jac.lark +4 -3
  6. jaclang/compiler/parser.py +31 -23
  7. jaclang/compiler/passes/ir_pass.py +4 -13
  8. jaclang/compiler/passes/main/access_modifier_pass.py +1 -1
  9. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +4 -5
  10. jaclang/compiler/passes/main/import_pass.py +18 -23
  11. jaclang/compiler/passes/main/pyast_gen_pass.py +307 -559
  12. jaclang/compiler/passes/main/pyast_load_pass.py +32 -6
  13. jaclang/compiler/passes/main/registry_pass.py +37 -3
  14. jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
  15. jaclang/compiler/passes/main/tests/__init__.py +1 -1
  16. jaclang/compiler/passes/main/type_check_pass.py +7 -0
  17. jaclang/compiler/passes/tool/jac_formatter_pass.py +124 -86
  18. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +0 -1
  19. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/architype_test.jac +13 -0
  20. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comment_alignment.jac +11 -0
  21. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comments.jac +13 -0
  22. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/decorator_stack.jac +37 -0
  23. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/esc_keywords.jac +5 -0
  24. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/long_names.jac +19 -0
  25. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +6 -0
  26. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -0
  27. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +33 -39
  28. jaclang/compiler/passes/transform.py +4 -0
  29. jaclang/compiler/semtable.py +31 -7
  30. jaclang/compiler/tests/test_importer.py +12 -5
  31. jaclang/langserve/engine.py +65 -118
  32. jaclang/langserve/sem_manager.py +379 -0
  33. jaclang/langserve/server.py +8 -10
  34. jaclang/langserve/tests/fixtures/base_module_structure.jac +27 -6
  35. jaclang/langserve/tests/fixtures/circle.jac +3 -3
  36. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  37. jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
  38. jaclang/langserve/tests/fixtures/import_include_statements.jac +1 -1
  39. jaclang/langserve/tests/test_sem_tokens.py +277 -0
  40. jaclang/langserve/tests/test_server.py +72 -16
  41. jaclang/langserve/utils.py +163 -96
  42. jaclang/plugin/builtin.py +1 -1
  43. jaclang/plugin/default.py +212 -24
  44. jaclang/plugin/feature.py +59 -11
  45. jaclang/plugin/spec.py +58 -6
  46. jaclang/{core → runtimelib}/architype.py +1 -1
  47. jaclang/{core → runtimelib}/context.py +8 -1
  48. jaclang/runtimelib/importer.py +361 -0
  49. jaclang/runtimelib/machine.py +94 -0
  50. jaclang/{core → runtimelib}/utils.py +13 -5
  51. jaclang/settings.py +4 -1
  52. jaclang/tests/fixtures/abc.jac +3 -3
  53. jaclang/tests/fixtures/byllmissue.jac +1 -5
  54. jaclang/tests/fixtures/chandra_bugs2.jac +11 -10
  55. jaclang/tests/fixtures/cls_method.jac +41 -0
  56. jaclang/tests/fixtures/dblhello.jac +6 -0
  57. jaclang/tests/fixtures/deep/one_lev.jac +3 -3
  58. jaclang/tests/fixtures/deep/one_lev_dup.jac +2 -3
  59. jaclang/tests/fixtures/deep_import_mods.jac +13 -0
  60. jaclang/tests/fixtures/err.impl.jac +3 -0
  61. jaclang/tests/fixtures/err.jac +4 -2
  62. jaclang/tests/fixtures/err.test.jac +3 -0
  63. jaclang/tests/fixtures/err_runtime.jac +15 -0
  64. jaclang/tests/fixtures/game1.jac +1 -1
  65. jaclang/tests/fixtures/hello.jac +4 -0
  66. jaclang/tests/fixtures/impl_grab.impl.jac +2 -1
  67. jaclang/tests/fixtures/impl_grab.jac +4 -1
  68. jaclang/tests/fixtures/jp_importer_auto.jac +14 -0
  69. jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
  70. jaclang/tests/fixtures/needs_import.jac +2 -2
  71. jaclang/tests/fixtures/pyfunc_2.py +3 -0
  72. jaclang/tests/fixtures/registry.jac +9 -0
  73. jaclang/tests/fixtures/run_test.jac +4 -4
  74. jaclang/tests/fixtures/semstr.jac +1 -4
  75. jaclang/tests/fixtures/simple_archs.jac +1 -1
  76. jaclang/tests/test_cli.py +65 -2
  77. jaclang/tests/test_language.py +74 -7
  78. jaclang/tests/test_reference.py +6 -0
  79. jaclang/utils/helpers.py +45 -21
  80. jaclang/utils/test.py +9 -0
  81. jaclang/utils/treeprinter.py +0 -4
  82. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/METADATA +3 -2
  83. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/RECORD +89 -74
  84. jaclang/core/importer.py +0 -344
  85. jaclang/tests/fixtures/aott_raise.jac +0 -25
  86. jaclang/tests/fixtures/package_import.jac +0 -6
  87. /jaclang/{core → runtimelib}/__init__.py +0 -0
  88. /jaclang/{core → runtimelib}/constructs.py +0 -0
  89. /jaclang/{core → runtimelib}/memory.py +0 -0
  90. /jaclang/{core → runtimelib}/test.py +0 -0
  91. {jaclang-0.7.14.dist-info → jaclang-0.7.16.dist-info}/WHEEL +0 -0
  92. {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 import_target_to_relative_path, is_standard_lib_module
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
- lang = i.parent_of_type(ast.Import).hint.tag.value
55
- if lang == "jac" and not i.sub_module:
56
- self.import_jac_module(
57
- node=i,
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, mod_path: str) -> None:
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 = import_target_to_relative_path(
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 = import_target_to_relative_path(
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
- print(e)
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
- lang = i.parent_of_type(ast.Import).hint.tag.value
231
- if lang == "py" and not i.sub_module and not is_standard_lib_module(i.path_str):
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