jaclang 0.5.17__py3-none-any.whl → 0.6.0__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/__init__.py +2 -6
- jaclang/cli/cli.py +4 -2
- jaclang/compiler/__init__.py +12 -5
- jaclang/compiler/absyntree.py +23 -23
- jaclang/compiler/generated/jac_parser.py +2 -2
- jaclang/compiler/jac.lark +9 -9
- jaclang/compiler/parser.py +76 -21
- jaclang/compiler/passes/ir_pass.py +10 -8
- jaclang/compiler/passes/main/__init__.py +3 -2
- jaclang/compiler/passes/main/access_modifier_pass.py +173 -0
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +3 -2
- jaclang/compiler/passes/main/import_pass.py +33 -21
- jaclang/compiler/passes/main/pyast_gen_pass.py +99 -44
- jaclang/compiler/passes/main/pyast_load_pass.py +141 -77
- jaclang/compiler/passes/main/pyout_pass.py +14 -13
- jaclang/compiler/passes/main/registry_pass.py +8 -3
- jaclang/compiler/passes/main/schedules.py +5 -3
- jaclang/compiler/passes/main/sym_tab_build_pass.py +47 -37
- jaclang/compiler/passes/main/tests/test_import_pass.py +2 -2
- jaclang/compiler/passes/tool/jac_formatter_pass.py +85 -23
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -4
- jaclang/compiler/passes/transform.py +2 -0
- jaclang/compiler/symtable.py +10 -3
- jaclang/compiler/tests/test_importer.py +9 -0
- jaclang/compiler/workspace.py +19 -11
- jaclang/core/aott.py +34 -63
- jaclang/core/importer.py +73 -65
- jaclang/core/llms/__init__.py +20 -0
- jaclang/core/llms/anthropic.py +61 -0
- jaclang/core/llms/base.py +206 -0
- jaclang/core/llms/groq.py +67 -0
- jaclang/core/llms/huggingface.py +73 -0
- jaclang/core/llms/ollama.py +78 -0
- jaclang/core/llms/openai.py +61 -0
- jaclang/core/llms/togetherai.py +60 -0
- jaclang/core/llms/utils.py +9 -0
- jaclang/core/utils.py +16 -1
- jaclang/plugin/default.py +47 -16
- jaclang/plugin/feature.py +9 -6
- jaclang/plugin/spec.py +8 -1
- jaclang/settings.py +95 -0
- jaclang/utils/helpers.py +6 -2
- jaclang/utils/treeprinter.py +9 -6
- jaclang/vendor/mypy/checker.py +2 -3
- jaclang-0.6.0.dist-info/METADATA +17 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/RECORD +49 -39
- jaclang/core/llms.py +0 -29
- jaclang-0.5.17.dist-info/METADATA +0 -7
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/WHEEL +0 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/entry_points.txt +0 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/top_level.txt +0 -0
|
@@ -492,17 +492,20 @@ class PyastGenPass(Pass):
|
|
|
492
492
|
py_nodes.append(
|
|
493
493
|
self.sync(ast3.Expr(value=node.doc.gen.py_ast[0]), jac_node=node.doc)
|
|
494
494
|
)
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
py_compat_path_str.append(path.path_str.lstrip("."))
|
|
499
|
-
path_alias[path.path_str] = path.alias.sym_name if path.alias else None
|
|
495
|
+
path_alias: dict[str, Optional[str]] = (
|
|
496
|
+
{node.from_loc.path_str: None} if node.from_loc else {}
|
|
497
|
+
)
|
|
500
498
|
imp_from = {}
|
|
501
499
|
if node.items:
|
|
502
500
|
for item in node.items.items:
|
|
503
|
-
|
|
504
|
-
item.
|
|
505
|
-
|
|
501
|
+
if isinstance(item, ast.ModuleItem):
|
|
502
|
+
imp_from[item.name.sym_name] = (
|
|
503
|
+
item.alias.sym_name if item.alias else False
|
|
504
|
+
)
|
|
505
|
+
elif isinstance(item, ast.ModulePath):
|
|
506
|
+
path_alias[item.path_str] = (
|
|
507
|
+
item.alias.sym_name if item.alias else None
|
|
508
|
+
)
|
|
506
509
|
|
|
507
510
|
keys = []
|
|
508
511
|
values = []
|
|
@@ -594,10 +597,13 @@ class PyastGenPass(Pass):
|
|
|
594
597
|
)
|
|
595
598
|
)
|
|
596
599
|
if node.is_absorb:
|
|
600
|
+
source = node.items.items[0]
|
|
601
|
+
if not isinstance(source, ast.ModulePath):
|
|
602
|
+
raise self.ice()
|
|
597
603
|
py_nodes.append(
|
|
598
604
|
self.sync(
|
|
599
605
|
py_node=ast3.ImportFrom(
|
|
600
|
-
module=
|
|
606
|
+
module=(source.path_str.lstrip(".") if source else None),
|
|
601
607
|
names=[self.sync(ast3.alias(name="*"), node)],
|
|
602
608
|
level=0,
|
|
603
609
|
),
|
|
@@ -605,18 +611,21 @@ class PyastGenPass(Pass):
|
|
|
605
611
|
)
|
|
606
612
|
)
|
|
607
613
|
if node.items:
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
)
|
|
614
|
+
pass
|
|
615
|
+
# self.warning(
|
|
616
|
+
# "Includes import * in target module into current namespace."
|
|
617
|
+
# )
|
|
618
|
+
if not node.from_loc:
|
|
619
|
+
py_nodes.append(self.sync(ast3.Import(names=node.items.gen.py_ast)))
|
|
615
620
|
else:
|
|
616
621
|
py_nodes.append(
|
|
617
622
|
self.sync(
|
|
618
623
|
ast3.ImportFrom(
|
|
619
|
-
module=
|
|
624
|
+
module=(
|
|
625
|
+
node.from_loc.path_str.lstrip(".")
|
|
626
|
+
if node.from_loc
|
|
627
|
+
else None
|
|
628
|
+
),
|
|
620
629
|
names=node.items.gen.py_ast,
|
|
621
630
|
level=0,
|
|
622
631
|
)
|
|
@@ -668,8 +677,6 @@ class PyastGenPass(Pass):
|
|
|
668
677
|
doc: Optional[String],
|
|
669
678
|
decorators: Optional[SubNodeList[ExprType]],
|
|
670
679
|
"""
|
|
671
|
-
self.needs_jac_feature()
|
|
672
|
-
self.needs_dataclass()
|
|
673
680
|
body = self.resolve_stmt_block(
|
|
674
681
|
node.body.body if isinstance(node.body, ast.ArchDef) else node.body,
|
|
675
682
|
doc=node.doc,
|
|
@@ -681,6 +688,8 @@ class PyastGenPass(Pass):
|
|
|
681
688
|
)
|
|
682
689
|
ds_on_entry, ds_on_exit = self.collect_events(node)
|
|
683
690
|
if node.arch_type.name != Tok.KW_CLASS:
|
|
691
|
+
self.needs_jac_feature()
|
|
692
|
+
self.needs_dataclass()
|
|
684
693
|
decorators.append(
|
|
685
694
|
self.sync(
|
|
686
695
|
ast3.Call(
|
|
@@ -715,24 +724,26 @@ class PyastGenPass(Pass):
|
|
|
715
724
|
)
|
|
716
725
|
)
|
|
717
726
|
)
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
727
|
+
decorators.append(
|
|
728
|
+
self.sync(
|
|
729
|
+
ast3.Call(
|
|
730
|
+
func=self.sync(
|
|
731
|
+
ast3.Name(id="__jac_dataclass__", ctx=ast3.Load())
|
|
732
|
+
),
|
|
733
|
+
args=[],
|
|
734
|
+
keywords=[
|
|
735
|
+
self.sync(
|
|
736
|
+
ast3.keyword(
|
|
737
|
+
arg="eq",
|
|
738
|
+
value=self.sync(
|
|
739
|
+
ast3.Constant(value=False),
|
|
740
|
+
),
|
|
741
|
+
)
|
|
730
742
|
)
|
|
731
|
-
|
|
732
|
-
|
|
743
|
+
],
|
|
744
|
+
)
|
|
733
745
|
)
|
|
734
746
|
)
|
|
735
|
-
)
|
|
736
747
|
base_classes = node.base_classes.gen.py_ast if node.base_classes else []
|
|
737
748
|
if node.is_abstract:
|
|
738
749
|
self.needs_jac_feature()
|
|
@@ -1057,7 +1068,11 @@ class PyastGenPass(Pass):
|
|
|
1057
1068
|
if isinstance(node.signature, ast.FuncSignature)
|
|
1058
1069
|
else []
|
|
1059
1070
|
)
|
|
1060
|
-
action =
|
|
1071
|
+
action = (
|
|
1072
|
+
node.semstr.gen.py_ast[0]
|
|
1073
|
+
if node.semstr
|
|
1074
|
+
else self.sync(ast3.Constant(value=None))
|
|
1075
|
+
)
|
|
1061
1076
|
return [
|
|
1062
1077
|
self.sync(
|
|
1063
1078
|
ast3.Assign(
|
|
@@ -1377,12 +1392,20 @@ class PyastGenPass(Pass):
|
|
|
1377
1392
|
):
|
|
1378
1393
|
node.gen.py_ast = [
|
|
1379
1394
|
self.sync(
|
|
1380
|
-
ast3.
|
|
1381
|
-
|
|
1382
|
-
ast3.
|
|
1395
|
+
ast3.Call(
|
|
1396
|
+
func=self.sync(
|
|
1397
|
+
ast3.Attribute(
|
|
1398
|
+
value=self.sync(
|
|
1399
|
+
ast3.Name(
|
|
1400
|
+
id=Con.JAC_FEATURE.value, ctx=ast3.Load()
|
|
1401
|
+
)
|
|
1402
|
+
),
|
|
1403
|
+
attr="get_root_type",
|
|
1404
|
+
ctx=ast3.Load(),
|
|
1405
|
+
)
|
|
1383
1406
|
),
|
|
1384
|
-
|
|
1385
|
-
|
|
1407
|
+
args=[],
|
|
1408
|
+
keywords=[],
|
|
1386
1409
|
)
|
|
1387
1410
|
)
|
|
1388
1411
|
]
|
|
@@ -1674,7 +1697,7 @@ class PyastGenPass(Pass):
|
|
|
1674
1697
|
self.sync(
|
|
1675
1698
|
ast3.Try(
|
|
1676
1699
|
body=self.resolve_stmt_block(node.body),
|
|
1677
|
-
handlers=node.excepts.gen.py_ast if node.excepts else
|
|
1700
|
+
handlers=node.excepts.gen.py_ast if node.excepts else [],
|
|
1678
1701
|
orelse=node.else_body.gen.py_ast if node.else_body else [],
|
|
1679
1702
|
finalbody=node.finally_body.gen.py_ast if node.finally_body else [],
|
|
1680
1703
|
)
|
|
@@ -2376,7 +2399,19 @@ class PyastGenPass(Pass):
|
|
|
2376
2399
|
node.gen.py_ast = [
|
|
2377
2400
|
self.sync(
|
|
2378
2401
|
ast3.Lambda(
|
|
2379
|
-
args=
|
|
2402
|
+
args=(
|
|
2403
|
+
node.signature.gen.py_ast[0]
|
|
2404
|
+
if node.signature
|
|
2405
|
+
else self.sync(
|
|
2406
|
+
ast3.arguments(
|
|
2407
|
+
posonlyargs=[],
|
|
2408
|
+
args=[],
|
|
2409
|
+
kwonlyargs=[],
|
|
2410
|
+
kw_defaults=[],
|
|
2411
|
+
defaults=[],
|
|
2412
|
+
)
|
|
2413
|
+
)
|
|
2414
|
+
),
|
|
2380
2415
|
body=node.body.gen.py_ast[0],
|
|
2381
2416
|
)
|
|
2382
2417
|
)
|
|
@@ -2435,11 +2470,16 @@ class PyastGenPass(Pass):
|
|
|
2435
2470
|
)
|
|
2436
2471
|
]
|
|
2437
2472
|
elif node.op.name in [Tok.STAR_MUL]:
|
|
2473
|
+
ctx_val = (
|
|
2474
|
+
node.operand.py_ctx_func()
|
|
2475
|
+
if isinstance(node.operand, ast.AstSymbolNode)
|
|
2476
|
+
else ast3.Load()
|
|
2477
|
+
)
|
|
2438
2478
|
node.gen.py_ast = [
|
|
2439
2479
|
self.sync(
|
|
2440
2480
|
ast3.Starred(
|
|
2441
2481
|
value=node.operand.gen.py_ast[0],
|
|
2442
|
-
ctx=
|
|
2482
|
+
ctx=ctx_val,
|
|
2443
2483
|
)
|
|
2444
2484
|
)
|
|
2445
2485
|
]
|
|
@@ -3648,7 +3688,22 @@ class PyastGenPass(Pass):
|
|
|
3648
3688
|
pos_start: int,
|
|
3649
3689
|
pos_end: int,
|
|
3650
3690
|
"""
|
|
3651
|
-
|
|
3691
|
+
|
|
3692
|
+
def handle_node_value(value: str) -> int:
|
|
3693
|
+
if value.startswith(("0x", "0X")):
|
|
3694
|
+
return int(value, 16)
|
|
3695
|
+
elif value.startswith(("0b", "0B")):
|
|
3696
|
+
return int(value, 2)
|
|
3697
|
+
elif value.startswith(("0o", "0O")):
|
|
3698
|
+
return int(value, 8)
|
|
3699
|
+
else:
|
|
3700
|
+
return int(value)
|
|
3701
|
+
|
|
3702
|
+
node.gen.py_ast = [
|
|
3703
|
+
self.sync(
|
|
3704
|
+
ast3.Constant(value=handle_node_value(str(node.value)), kind=None)
|
|
3705
|
+
)
|
|
3706
|
+
]
|
|
3652
3707
|
|
|
3653
3708
|
def exit_string(self, node: ast.String) -> None:
|
|
3654
3709
|
"""Sub objects.
|