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.

Files changed (51) hide show
  1. jaclang/__init__.py +2 -6
  2. jaclang/cli/cli.py +4 -2
  3. jaclang/compiler/__init__.py +12 -5
  4. jaclang/compiler/absyntree.py +23 -23
  5. jaclang/compiler/generated/jac_parser.py +2 -2
  6. jaclang/compiler/jac.lark +9 -9
  7. jaclang/compiler/parser.py +76 -21
  8. jaclang/compiler/passes/ir_pass.py +10 -8
  9. jaclang/compiler/passes/main/__init__.py +3 -2
  10. jaclang/compiler/passes/main/access_modifier_pass.py +173 -0
  11. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +3 -2
  12. jaclang/compiler/passes/main/import_pass.py +33 -21
  13. jaclang/compiler/passes/main/pyast_gen_pass.py +99 -44
  14. jaclang/compiler/passes/main/pyast_load_pass.py +141 -77
  15. jaclang/compiler/passes/main/pyout_pass.py +14 -13
  16. jaclang/compiler/passes/main/registry_pass.py +8 -3
  17. jaclang/compiler/passes/main/schedules.py +5 -3
  18. jaclang/compiler/passes/main/sym_tab_build_pass.py +47 -37
  19. jaclang/compiler/passes/main/tests/test_import_pass.py +2 -2
  20. jaclang/compiler/passes/tool/jac_formatter_pass.py +85 -23
  21. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -4
  22. jaclang/compiler/passes/transform.py +2 -0
  23. jaclang/compiler/symtable.py +10 -3
  24. jaclang/compiler/tests/test_importer.py +9 -0
  25. jaclang/compiler/workspace.py +19 -11
  26. jaclang/core/aott.py +34 -63
  27. jaclang/core/importer.py +73 -65
  28. jaclang/core/llms/__init__.py +20 -0
  29. jaclang/core/llms/anthropic.py +61 -0
  30. jaclang/core/llms/base.py +206 -0
  31. jaclang/core/llms/groq.py +67 -0
  32. jaclang/core/llms/huggingface.py +73 -0
  33. jaclang/core/llms/ollama.py +78 -0
  34. jaclang/core/llms/openai.py +61 -0
  35. jaclang/core/llms/togetherai.py +60 -0
  36. jaclang/core/llms/utils.py +9 -0
  37. jaclang/core/utils.py +16 -1
  38. jaclang/plugin/default.py +47 -16
  39. jaclang/plugin/feature.py +9 -6
  40. jaclang/plugin/spec.py +8 -1
  41. jaclang/settings.py +95 -0
  42. jaclang/utils/helpers.py +6 -2
  43. jaclang/utils/treeprinter.py +9 -6
  44. jaclang/vendor/mypy/checker.py +2 -3
  45. jaclang-0.6.0.dist-info/METADATA +17 -0
  46. {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/RECORD +49 -39
  47. jaclang/core/llms.py +0 -29
  48. jaclang-0.5.17.dist-info/METADATA +0 -7
  49. {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/WHEEL +0 -0
  50. {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/entry_points.txt +0 -0
  51. {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
- py_compat_path_str = []
496
- path_alias = {}
497
- for path in node.paths:
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
- imp_from[item.name.sym_name] = (
504
- item.alias.sym_name if item.alias else False
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=py_compat_path_str[0] if py_compat_path_str[0] else None,
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
- self.warning(
609
- "Includes import * in target module into current namespace."
610
- )
611
- if not node.items:
612
- py_nodes.append(
613
- self.sync(ast3.Import(names=[i.gen.py_ast[0] for i in node.paths]))
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=py_compat_path_str[0] if py_compat_path_str[0] else None,
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
- decorators.append(
719
- self.sync(
720
- ast3.Call(
721
- func=self.sync(ast3.Name(id="__jac_dataclass__", ctx=ast3.Load())),
722
- args=[],
723
- keywords=[
724
- self.sync(
725
- ast3.keyword(
726
- arg="eq",
727
- value=self.sync(
728
- ast3.Constant(value=False),
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 = node.semstr.gen.py_ast[0] if node.semstr else None
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.Attribute(
1381
- value=self.sync(
1382
- ast3.Name(id=Con.JAC_FEATURE.value, ctx=ast3.Load())
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
- attr="RootType",
1385
- ctx=ast3.Load(),
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 None,
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=node.signature.gen.py_ast[0],
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=ast3.Load(),
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
- node.gen.py_ast = [self.sync(ast3.Constant(value=int(node.value)))]
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.