jaclang 0.8.0__py3-none-any.whl → 0.8.1__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 +11 -9
- jaclang/compiler/jac.lark +2 -12
- jaclang/compiler/larkparse/jac_parser.py +1 -1
- jaclang/compiler/parser.py +360 -521
- jaclang/compiler/passes/main/cfg_build_pass.py +2 -2
- jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
- jaclang/compiler/passes/main/def_use_pass.py +4 -7
- jaclang/compiler/passes/main/import_pass.py +3 -3
- jaclang/compiler/passes/main/inheritance_pass.py +2 -2
- jaclang/compiler/passes/main/pyast_gen_pass.py +196 -218
- jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
- jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
- jaclang/compiler/passes/main/sym_tab_link_pass.py +4 -4
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
- jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +4 -2
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +197 -120
- jaclang/compiler/program.py +2 -7
- jaclang/compiler/tests/fixtures/fam.jac +2 -2
- jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +11 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +7 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
- jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
- jaclang/compiler/tests/test_importer.py +20 -0
- jaclang/compiler/tests/test_parser.py +1 -0
- jaclang/compiler/unitree.py +456 -304
- jaclang/langserve/engine.jac +498 -0
- jaclang/langserve/sem_manager.jac +309 -0
- jaclang/langserve/server.jac +186 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +6 -7
- jaclang/langserve/tests/server_test/utils.py +4 -1
- jaclang/langserve/tests/session.jac +294 -0
- jaclang/langserve/tests/test_sem_tokens.py +2 -2
- jaclang/langserve/tests/test_server.py +12 -7
- jaclang/langserve/utils.jac +51 -30
- jaclang/runtimelib/archetype.py +1 -1
- jaclang/runtimelib/builtin.py +17 -14
- jaclang/runtimelib/importer.py +26 -8
- jaclang/runtimelib/machine.py +96 -55
- jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
- jaclang/runtimelib/utils.py +3 -3
- jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
- jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
- jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
- jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
- jaclang/tests/fixtures/concurrency.jac +1 -1
- jaclang/tests/fixtures/edge_ability.jac +49 -0
- jaclang/tests/fixtures/guess_game.jac +1 -1
- jaclang/tests/fixtures/here_usage_error.jac +21 -0
- jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
- jaclang/tests/fixtures/node_del.jac +30 -36
- jaclang/tests/fixtures/visit_traversal.jac +47 -0
- jaclang/tests/test_cli.py +12 -7
- jaclang/tests/test_language.py +91 -16
- jaclang/utils/helpers.py +14 -6
- jaclang/utils/lang_tools.py +2 -3
- jaclang/utils/tests/test_lang_tools.py +2 -1
- jaclang/utils/treeprinter.py +3 -4
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/METADATA +4 -3
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/RECORD +71 -55
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/WHEEL +1 -1
- jaclang/langserve/engine.py +0 -553
- jaclang/langserve/sem_manager.py +0 -383
- jaclang/langserve/server.py +0 -167
- jaclang/langserve/tests/session.py +0 -255
- jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
- jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
- /jaclang/langserve/{__init__.py → __init__.jac} +0 -0
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/entry_points.txt +0 -0
|
@@ -68,7 +68,7 @@ class CFGBuildPass(UniPass):
|
|
|
68
68
|
def enter_node(self, node: uni.UniNode) -> None:
|
|
69
69
|
"""Enter BasicBlockStmt nodes."""
|
|
70
70
|
if isinstance(node, uni.UniCFGNode) and not isinstance(node, uni.Semi):
|
|
71
|
-
if isinstance(node
|
|
71
|
+
if node.parent and isinstance(node, uni.CodeBlockStmt) and self.first_exit:
|
|
72
72
|
bb_stmts = [
|
|
73
73
|
bbs for bbs in node.parent.kid if isinstance(bbs, uni.UniCFGNode)
|
|
74
74
|
]
|
|
@@ -199,7 +199,7 @@ class CoalesceBBPass(UniPass):
|
|
|
199
199
|
}
|
|
200
200
|
self.bb_counter += 1
|
|
201
201
|
|
|
202
|
-
def
|
|
202
|
+
def printgraph_cfg(self) -> str:
|
|
203
203
|
"""Generate dot graph for CFG."""
|
|
204
204
|
cfg: dict = {}
|
|
205
205
|
dot = "digraph G {\n"
|
|
@@ -17,6 +17,8 @@ developers to define archetype and ability interfaces in one file while implemen
|
|
|
17
17
|
their behavior in separate files.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
+
from typing import Sequence
|
|
21
|
+
|
|
20
22
|
import jaclang.compiler.unitree as uni
|
|
21
23
|
from jaclang.compiler.constant import Tokens as Tok
|
|
22
24
|
from jaclang.compiler.passes.transform import Transform
|
|
@@ -124,7 +126,7 @@ class DeclImplMatchPass(Transform[uni.Module, uni.Module]):
|
|
|
124
126
|
|
|
125
127
|
valid_decl.body = sym.decl.name_of
|
|
126
128
|
sym.decl.name_of.decl_link = valid_decl
|
|
127
|
-
for idx, a in enumerate(sym.decl.name_of.target
|
|
129
|
+
for idx, a in enumerate(sym.decl.name_of.target):
|
|
128
130
|
if idx < len(name_of_links) and name_of_links[idx]:
|
|
129
131
|
a.name_spec.name_of = name_of_links[idx].name_of
|
|
130
132
|
a.name_spec.sym = name_of_links[idx].sym
|
|
@@ -159,7 +161,7 @@ class DeclImplMatchPass(Transform[uni.Module, uni.Module]):
|
|
|
159
161
|
|
|
160
162
|
if params_decl and params_defn:
|
|
161
163
|
# Check if the parameter count is matched.
|
|
162
|
-
if len(params_defn
|
|
164
|
+
if len(params_defn) != len(params_decl):
|
|
163
165
|
self.log_error(
|
|
164
166
|
f"Parameter count mismatch for ability {sym.sym_name}.",
|
|
165
167
|
sym.decl.name_of.name_spec,
|
|
@@ -170,10 +172,11 @@ class DeclImplMatchPass(Transform[uni.Module, uni.Module]):
|
|
|
170
172
|
)
|
|
171
173
|
else:
|
|
172
174
|
# Copy the parameter names from the declaration to the definition.
|
|
173
|
-
for idx in range(len(params_defn
|
|
174
|
-
params_decl
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
for idx in range(len(params_defn)):
|
|
176
|
+
if (par := params_decl[idx].parent) is not None:
|
|
177
|
+
loc_in_kid = par.kid.index(params_decl[idx])
|
|
178
|
+
par.kid[loc_in_kid] = params_defn[idx]
|
|
179
|
+
params_decl[idx] = params_defn[idx]
|
|
177
180
|
|
|
178
181
|
def check_archetypes(self, ir_in: uni.Module) -> None:
|
|
179
182
|
"""Check all archetypes for issues with attributes and methods."""
|
|
@@ -182,15 +185,13 @@ class DeclImplMatchPass(Transform[uni.Module, uni.Module]):
|
|
|
182
185
|
|
|
183
186
|
def check_archetype(self, node: uni.Archetype) -> None:
|
|
184
187
|
"""Check a single archetype for issues."""
|
|
185
|
-
if node.arch_type.name == Tok.KW_OBJECT and isinstance(
|
|
186
|
-
node.body, uni.SubNodeList
|
|
187
|
-
):
|
|
188
|
+
if node.arch_type.name == Tok.KW_OBJECT and isinstance(node.body, Sequence):
|
|
188
189
|
self.cur_node = node
|
|
189
190
|
found_default_init = False
|
|
190
|
-
for stmnt in node.body
|
|
191
|
+
for stmnt in node.body:
|
|
191
192
|
if not isinstance(stmnt, uni.ArchHas):
|
|
192
193
|
continue
|
|
193
|
-
for var in stmnt.vars
|
|
194
|
+
for var in stmnt.vars:
|
|
194
195
|
if (var.value is not None) or (var.defer):
|
|
195
196
|
found_default_init = True
|
|
196
197
|
else:
|
|
@@ -204,10 +205,10 @@ class DeclImplMatchPass(Transform[uni.Module, uni.Module]):
|
|
|
204
205
|
post_init_vars: list[uni.HasVar] = []
|
|
205
206
|
postinit_method: uni.Ability | None = None
|
|
206
207
|
|
|
207
|
-
for item in node.body
|
|
208
|
+
for item in node.body:
|
|
208
209
|
|
|
209
210
|
if isinstance(item, uni.ArchHas):
|
|
210
|
-
for var in item.vars
|
|
211
|
+
for var in item.vars:
|
|
211
212
|
if var.defer:
|
|
212
213
|
post_init_vars.append(var)
|
|
213
214
|
|
|
@@ -38,6 +38,7 @@ class DefUsePass(UniPass):
|
|
|
38
38
|
+ node.get_all_sub_nodes(uni.IgnoreStmt)
|
|
39
39
|
+ node.get_all_sub_nodes(uni.DisengageStmt)
|
|
40
40
|
+ node.get_all_sub_nodes(uni.EdgeOpRef)
|
|
41
|
+
+ node.get_all_sub_nodes(uni.EventSignature)
|
|
41
42
|
):
|
|
42
43
|
i.from_walker = True
|
|
43
44
|
|
|
@@ -57,19 +58,15 @@ class DefUsePass(UniPass):
|
|
|
57
58
|
node.sym_tab.def_insert(node)
|
|
58
59
|
|
|
59
60
|
def enter_has_var(self, node: uni.HasVar) -> None:
|
|
60
|
-
if isinstance(node.parent, uni.
|
|
61
|
-
node.parent.parent, uni.ArchHas
|
|
62
|
-
):
|
|
61
|
+
if isinstance(node.parent, uni.ArchHas):
|
|
63
62
|
node.sym_tab.def_insert(
|
|
64
|
-
node,
|
|
65
|
-
single_decl="has var",
|
|
66
|
-
access_spec=node.parent.parent,
|
|
63
|
+
node, single_decl="has var", access_spec=node.parent
|
|
67
64
|
)
|
|
68
65
|
else:
|
|
69
66
|
self.ice("Inconsistency in AST, has var should be under arch has")
|
|
70
67
|
|
|
71
68
|
def enter_assignment(self, node: uni.Assignment) -> None:
|
|
72
|
-
for i in node.target
|
|
69
|
+
for i in node.target:
|
|
73
70
|
if isinstance(i, uni.AtomTrailer):
|
|
74
71
|
i.sym_tab.chain_def_insert(i.as_attr_list)
|
|
75
72
|
elif isinstance(i, uni.AstSymbolNode):
|
|
@@ -73,7 +73,7 @@ class JacImportDepsPass(Transform[uni.Module, uni.Module]):
|
|
|
73
73
|
# And the import is a from import and I am the from module
|
|
74
74
|
if node == import_node.from_loc:
|
|
75
75
|
# Import all from items as modules or packages
|
|
76
|
-
for i in import_node.items
|
|
76
|
+
for i in import_node.items:
|
|
77
77
|
if isinstance(i, uni.ModuleItem):
|
|
78
78
|
from_mod_target = node.resolve_relative_path(i.name.value)
|
|
79
79
|
# If package
|
|
@@ -204,8 +204,8 @@ class PyImportDepsPass(JacImportDepsPass):
|
|
|
204
204
|
"""Process the imports in form of `import X`."""
|
|
205
205
|
# Expected that each ImportStatement will import one item
|
|
206
206
|
# In case of this assertion fired then we need to revisit this item
|
|
207
|
-
assert len(imp_node.items
|
|
208
|
-
imported_item = imp_node.items
|
|
207
|
+
assert len(imp_node.items) == 1
|
|
208
|
+
imported_item = imp_node.items[0]
|
|
209
209
|
assert isinstance(imported_item, uni.ModulePath)
|
|
210
210
|
|
|
211
211
|
imported_mod = self.__import_py_module(
|
|
@@ -36,11 +36,11 @@ class InheritancePass(Transform[uni.Module, uni.Module]):
|
|
|
36
36
|
|
|
37
37
|
def process_archetype_inheritance(self, node: uni.Archetype) -> None:
|
|
38
38
|
"""Fill archetype symbol tables with abilities from parent archetypes."""
|
|
39
|
-
if node.base_classes
|
|
39
|
+
if not node.base_classes:
|
|
40
40
|
return
|
|
41
41
|
|
|
42
42
|
self.cur_node = node
|
|
43
|
-
for item in node.base_classes
|
|
43
|
+
for item in node.base_classes:
|
|
44
44
|
# Handle different types of base class references
|
|
45
45
|
if isinstance(item, uni.Name):
|
|
46
46
|
self.inherit_from_name(node, item)
|