jaclang 0.7.2__py3-none-any.whl → 0.7.5__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 (62) hide show
  1. jaclang/cli/cli.py +2 -2
  2. jaclang/compiler/absyntree.py +337 -273
  3. jaclang/compiler/codeloc.py +2 -2
  4. jaclang/compiler/constant.py +2 -0
  5. jaclang/compiler/jac.lark +25 -19
  6. jaclang/compiler/parser.py +115 -92
  7. jaclang/compiler/passes/main/access_modifier_pass.py +15 -9
  8. jaclang/compiler/passes/main/def_impl_match_pass.py +25 -13
  9. jaclang/compiler/passes/main/def_use_pass.py +48 -17
  10. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +34 -34
  11. jaclang/compiler/passes/main/import_pass.py +8 -6
  12. jaclang/compiler/passes/main/pyast_gen_pass.py +97 -42
  13. jaclang/compiler/passes/main/pyast_load_pass.py +47 -12
  14. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +19 -10
  15. jaclang/compiler/passes/main/registry_pass.py +6 -6
  16. jaclang/compiler/passes/main/sym_tab_build_pass.py +30 -72
  17. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +21 -4
  18. jaclang/compiler/passes/main/tests/test_def_use_pass.py +5 -10
  19. jaclang/compiler/passes/main/type_check_pass.py +2 -1
  20. jaclang/compiler/passes/tool/jac_formatter_pass.py +30 -9
  21. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +16 -0
  22. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +16 -0
  23. jaclang/compiler/passes/transform.py +2 -4
  24. jaclang/{core/registry.py → compiler/semtable.py} +1 -3
  25. jaclang/compiler/symtable.py +25 -37
  26. jaclang/compiler/tests/test_parser.py +2 -2
  27. jaclang/core/aott.py +8 -8
  28. jaclang/core/{construct.py → architype.py} +25 -240
  29. jaclang/core/constructs.py +44 -0
  30. jaclang/core/context.py +157 -0
  31. jaclang/core/importer.py +18 -9
  32. jaclang/core/memory.py +99 -0
  33. jaclang/core/test.py +90 -0
  34. jaclang/core/utils.py +2 -2
  35. jaclang/langserve/engine.py +32 -19
  36. jaclang/langserve/tests/fixtures/circle.jac +16 -12
  37. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  38. jaclang/langserve/tests/test_server.py +3 -12
  39. jaclang/langserve/utils.py +10 -6
  40. jaclang/plugin/builtin.py +1 -1
  41. jaclang/plugin/default.py +21 -7
  42. jaclang/plugin/feature.py +24 -6
  43. jaclang/plugin/spec.py +17 -19
  44. jaclang/settings.py +3 -0
  45. jaclang/tests/fixtures/abc.jac +16 -12
  46. jaclang/tests/fixtures/byllmissue.jac +9 -0
  47. jaclang/tests/fixtures/edgetypetest.jac +16 -0
  48. jaclang/tests/fixtures/impl_match_confused.impl.jac +1 -0
  49. jaclang/tests/fixtures/impl_match_confused.jac +5 -0
  50. jaclang/tests/fixtures/maxfail_run_test.jac +17 -5
  51. jaclang/tests/fixtures/run_test.jac +17 -5
  52. jaclang/tests/test_bugs.py +19 -0
  53. jaclang/tests/test_cli.py +1 -1
  54. jaclang/tests/test_language.py +56 -1
  55. jaclang/tests/test_reference.py +1 -1
  56. jaclang/utils/lang_tools.py +5 -4
  57. jaclang/utils/test.py +2 -1
  58. jaclang/utils/treeprinter.py +22 -8
  59. {jaclang-0.7.2.dist-info → jaclang-0.7.5.dist-info}/METADATA +1 -1
  60. {jaclang-0.7.2.dist-info → jaclang-0.7.5.dist-info}/RECORD +62 -54
  61. {jaclang-0.7.2.dist-info → jaclang-0.7.5.dist-info}/WHEEL +0 -0
  62. {jaclang-0.7.2.dist-info → jaclang-0.7.5.dist-info}/entry_points.txt +0 -0
@@ -150,6 +150,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
150
150
  node.name if node.name != "root" else "root_"
151
151
  ), # root is a reserved keyword
152
152
  line=node.lineno,
153
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
153
154
  col_start=node.col_offset,
154
155
  col_end=node.col_offset + len(node.name),
155
156
  pos_start=0,
@@ -262,6 +263,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
262
263
  name=Tok.NAME,
263
264
  value=node.name,
264
265
  line=node.lineno,
266
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
265
267
  col_start=node.col_offset,
266
268
  col_end=node.col_offset + len(node.name),
267
269
  pos_start=0,
@@ -272,6 +274,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
272
274
  name=Tok.KW_CLASS,
273
275
  value="class",
274
276
  line=node.lineno,
277
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
275
278
  col_start=0,
276
279
  col_end=0,
277
280
  pos_start=0,
@@ -284,17 +287,18 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
284
287
  and isinstance(body_stmt.name_ref, ast.Name)
285
288
  and body_stmt.name_ref.value == "__init__"
286
289
  ):
287
- tok = ast.Token(
290
+ tok = ast.Name(
288
291
  file_path=self.mod_path,
289
292
  name=Tok.KW_INIT,
290
293
  value="init",
291
294
  line=node.lineno,
295
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
292
296
  col_start=node.col_offset,
293
297
  col_end=node.col_offset + len("init"),
294
298
  pos_start=0,
295
299
  pos_end=0,
296
300
  )
297
- body_stmt.name_ref = ast.SpecialVarRef(var=tok, kid=[tok])
301
+ body_stmt.name_ref = ast.SpecialVarRef(var=tok)
298
302
  if (
299
303
  isinstance(body_stmt, ast.Ability)
300
304
  and body_stmt.signature
@@ -373,17 +377,18 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
373
377
  converted_stmt.expr, ast.String
374
378
  ):
375
379
  continue
376
- tok = ast.Token(
380
+ pintok = ast.Token(
377
381
  file_path=self.mod_path,
378
382
  name=Tok.PYNLINE,
379
383
  value=py_ast.unparse(class_body_stmt),
380
384
  line=node.lineno,
385
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
381
386
  col_start=node.col_offset,
382
387
  col_end=node.col_offset + len(py_ast.unparse(class_body_stmt)),
383
388
  pos_start=0,
384
389
  pos_end=0,
385
390
  )
386
- valid_enum_body.append(ast.PyInlineCode(code=tok, kid=[tok]))
391
+ valid_enum_body.append(ast.PyInlineCode(code=pintok, kid=[pintok]))
387
392
 
388
393
  valid_enum_body2: list[ast.EnumBlockStmt] = [
389
394
  i for i in valid_enum_body if isinstance(i, ast.EnumBlockStmt)
@@ -903,17 +908,18 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
903
908
  and isinstance(value.target, ast.Name)
904
909
  and value.target.value == "super"
905
910
  ):
906
- tok = ast.Token(
911
+ tok = ast.Name(
907
912
  file_path=self.mod_path,
908
913
  name=Tok.KW_SUPER,
909
914
  value="super",
910
915
  line=node.lineno,
916
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
911
917
  col_start=node.col_offset,
912
918
  col_end=node.col_offset + len("super"),
913
919
  pos_start=0,
914
920
  pos_end=0,
915
921
  )
916
- value = ast.SpecialVarRef(var=tok, kid=[tok])
922
+ value = ast.SpecialVarRef(var=tok)
917
923
  # exit()
918
924
  attribute = ast.Name(
919
925
  file_path=self.mod_path,
@@ -924,6 +930,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
924
930
  else "init" if node.attr == "__init__" else node.attr
925
931
  ),
926
932
  line=node.lineno,
933
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
927
934
  col_start=node.col_offset,
928
935
  col_end=node.col_offset + len(node.attr),
929
936
  pos_start=0,
@@ -1030,6 +1037,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1030
1037
  name=Tok.KW_BREAK,
1031
1038
  value="break",
1032
1039
  line=0,
1040
+ end_line=0,
1033
1041
  col_start=0,
1034
1042
  col_end=0,
1035
1043
  pos_start=0,
@@ -1144,6 +1152,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1144
1152
  else str(node.value)
1145
1153
  ),
1146
1154
  line=node.lineno,
1155
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1147
1156
  col_start=node.col_offset,
1148
1157
  col_end=node.col_offset + len(str(node.value)),
1149
1158
  pos_start=0,
@@ -1155,6 +1164,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1155
1164
  name=Tok.ELLIPSIS,
1156
1165
  value="...",
1157
1166
  line=node.lineno,
1167
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1158
1168
  col_start=node.col_offset,
1159
1169
  col_end=node.col_offset + 3,
1160
1170
  pos_start=0,
@@ -1170,6 +1180,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1170
1180
  name=Tok.KW_CONTINUE,
1171
1181
  value="continue",
1172
1182
  line=0,
1183
+ end_line=0,
1173
1184
  col_start=0,
1174
1185
  col_end=0,
1175
1186
  pos_start=0,
@@ -1246,6 +1257,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1246
1257
  name=Tok.NAME,
1247
1258
  value="Exception",
1248
1259
  line=node.lineno,
1260
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1249
1261
  col_start=node.col_offset,
1250
1262
  col_end=node.col_offset + 9,
1251
1263
  pos_start=0,
@@ -1256,6 +1268,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1256
1268
  name=Tok.NAME,
1257
1269
  value="e",
1258
1270
  line=node.lineno,
1271
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1259
1272
  col_start=node.col_offset,
1260
1273
  col_end=node.col_offset + 1,
1261
1274
  pos_start=0,
@@ -1267,6 +1280,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1267
1280
  # name=Tok.NAME,
1268
1281
  # value=no,
1269
1282
  # line=node.lineno,
1283
+ # end_line = (node.end_lineno if node.end_lineno else node.lineno,)
1270
1284
  # col_start=node.col_offset,
1271
1285
  # col_end=node.col_offset + 9,
1272
1286
  # pos_start=0,
@@ -1278,6 +1292,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1278
1292
  name=Tok.NAME,
1279
1293
  value=node.name,
1280
1294
  line=node.lineno,
1295
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1281
1296
  col_start=node.col_offset,
1282
1297
  col_end=node.col_offset + len(node.name),
1283
1298
  pos_start=0,
@@ -1369,7 +1384,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1369
1384
  class Global(stmt):
1370
1385
  names: list[_Identifier]
1371
1386
  """
1372
- names: list[ast.NameSpec] = []
1387
+ names: list[ast.NameAtom] = []
1373
1388
  for id in node.names:
1374
1389
  names.append(
1375
1390
  ast.Name(
@@ -1377,13 +1392,14 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1377
1392
  name=Tok.NAME,
1378
1393
  value=id,
1379
1394
  line=node.lineno,
1395
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1380
1396
  col_start=node.col_offset,
1381
1397
  col_end=node.col_offset + len(id),
1382
1398
  pos_start=0,
1383
1399
  pos_end=0,
1384
1400
  )
1385
1401
  )
1386
- target = ast.SubNodeList[ast.NameSpec](items=names, delim=Tok.COMMA, kid=names)
1402
+ target = ast.SubNodeList[ast.NameAtom](items=names, delim=Tok.COMMA, kid=names)
1387
1403
  return ast.GlobalStmt(target=target, kid=[target])
1388
1404
 
1389
1405
  def proc_if_exp(self, node: py_ast.IfExp) -> ast.IfElseExpr:
@@ -1439,6 +1455,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1439
1455
  name=Tok.NAME,
1440
1456
  value="py",
1441
1457
  line=node.lineno,
1458
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1442
1459
  col_start=node.col_offset,
1443
1460
  col_end=0,
1444
1461
  pos_start=0,
@@ -1468,6 +1485,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1468
1485
  name=Tok.NAME,
1469
1486
  value="py",
1470
1487
  line=node.lineno,
1488
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1471
1489
  col_start=node.col_offset,
1472
1490
  col_end=0,
1473
1491
  pos_start=0,
@@ -1482,6 +1500,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1482
1500
  name=Tok.NAME,
1483
1501
  value=i,
1484
1502
  line=node.lineno,
1503
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1485
1504
  col_start=0,
1486
1505
  col_end=0,
1487
1506
  pos_start=0,
@@ -1643,6 +1662,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1643
1662
  name=Tok.NAME,
1644
1663
  value=node.name if node.name else "_",
1645
1664
  line=node.lineno,
1665
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1646
1666
  col_start=node.col_offset,
1647
1667
  col_end=(
1648
1668
  (node.col_offset + len(node.name))
@@ -1696,6 +1716,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1696
1716
  name=Tok.NAME,
1697
1717
  value=kwd_attrs,
1698
1718
  line=node.lineno,
1719
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1699
1720
  col_start=node.col_offset,
1700
1721
  col_end=node.col_offset + len(kwd_attrs),
1701
1722
  pos_start=0,
@@ -1720,7 +1741,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1720
1741
  kid.append(kw_patterns)
1721
1742
  else:
1722
1743
  kw_patterns = None
1723
- if isinstance(cls, (ast.NameSpec, ast.AtomTrailer)):
1744
+ if isinstance(cls, (ast.NameAtom, ast.AtomTrailer)):
1724
1745
  return ast.MatchArch(
1725
1746
  name=cls, arg_patterns=patterns_sub, kw_patterns=kw_patterns, kid=kid
1726
1747
  )
@@ -1738,7 +1759,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1738
1759
  values: list[ast.MatchKVPair | ast.MatchStar] = []
1739
1760
  keys = [self.convert(i) for i in node.keys]
1740
1761
  valid_keys = [
1741
- i for i in keys if isinstance(i, (ast.MatchPattern, ast.NameSpec))
1762
+ i for i in keys if isinstance(i, (ast.MatchPattern, ast.NameAtom))
1742
1763
  ]
1743
1764
  patterns = [self.convert(i) for i in node.patterns]
1744
1765
  valid_patterns = [i for i in patterns if isinstance(i, ast.MatchPattern)]
@@ -1755,6 +1776,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1755
1776
  name=Tok.NAME,
1756
1777
  value=node.rest,
1757
1778
  line=node.lineno,
1779
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1758
1780
  col_start=node.col_offset,
1759
1781
  col_end=node.col_offset + len(node.rest),
1760
1782
  pos_start=0,
@@ -1799,6 +1821,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1799
1821
  name=type,
1800
1822
  value=str(node.value),
1801
1823
  line=node.lineno,
1824
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1802
1825
  col_start=node.col_offset,
1803
1826
  col_end=node.col_offset + len(str(node.value)),
1804
1827
  pos_start=0,
@@ -1820,6 +1843,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1820
1843
  name=Tok.NAME,
1821
1844
  value=node.name if node.name else "_",
1822
1845
  line=node.lineno,
1846
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1823
1847
  col_start=node.col_offset,
1824
1848
  col_end=node.col_offset + len(node.name if node.name else "_"),
1825
1849
  pos_start=0,
@@ -1853,6 +1877,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1853
1877
  name=Tok.NAME,
1854
1878
  value=node.id if node.id != "root" else "root_", # reserved word
1855
1879
  line=node.lineno,
1880
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1856
1881
  col_start=node.col_offset,
1857
1882
  col_end=node.col_offset + len(node.id),
1858
1883
  pos_start=0,
@@ -1885,7 +1910,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1885
1910
  class Nonlocal(stmt):
1886
1911
  names: list[_Identifier]
1887
1912
  """
1888
- names: list[ast.NameSpec] = []
1913
+ names: list[ast.NameAtom] = []
1889
1914
  for name in node.names:
1890
1915
  names.append(
1891
1916
  ast.Name(
@@ -1893,13 +1918,14 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1893
1918
  name=Tok.NAME,
1894
1919
  value=name if name != "root" else "root_",
1895
1920
  line=node.lineno,
1921
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
1896
1922
  col_start=node.col_offset,
1897
1923
  col_end=node.col_offset + len(name),
1898
1924
  pos_start=0,
1899
1925
  pos_end=0,
1900
1926
  )
1901
1927
  )
1902
- target = ast.SubNodeList[ast.NameSpec](items=names, delim=Tok.COMMA, kid=names)
1928
+ target = ast.SubNodeList[ast.NameAtom](items=names, delim=Tok.COMMA, kid=names)
1903
1929
  return ast.NonLocalStmt(target=target, kid=names)
1904
1930
 
1905
1931
  def proc_pass(self, node: py_ast.Pass) -> ast.Semi:
@@ -1909,6 +1935,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1909
1935
  name=Tok.SEMI,
1910
1936
  value=";",
1911
1937
  line=0,
1938
+ end_line=0,
1912
1939
  col_start=0,
1913
1940
  col_end=0,
1914
1941
  pos_start=0,
@@ -2176,6 +2203,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2176
2203
  name=Tok.NAME,
2177
2204
  value=node.name,
2178
2205
  line=node.lineno,
2206
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
2179
2207
  col_start=node.col_offset,
2180
2208
  col_end=node.col_offset + len(node.name),
2181
2209
  pos_start=0,
@@ -2187,6 +2215,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2187
2215
  name=Tok.NAME,
2188
2216
  value=node.asname,
2189
2217
  line=node.lineno,
2218
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
2190
2219
  col_start=node.col_offset,
2191
2220
  col_end=node.col_offset + len(node.asname),
2192
2221
  pos_start=0,
@@ -2211,6 +2240,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2211
2240
  name=Tok.NAME,
2212
2241
  value=node.arg if node.arg != "root" else "root_", # reserved word
2213
2242
  line=node.lineno,
2243
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
2214
2244
  col_start=node.col_offset,
2215
2245
  col_end=node.col_offset + len(node.arg),
2216
2246
  pos_start=0,
@@ -2224,6 +2254,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2224
2254
  name=Tok.NAME,
2225
2255
  value="Any",
2226
2256
  line=node.lineno,
2257
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
2227
2258
  col_start=node.col_offset,
2228
2259
  col_end=node.col_offset + 3,
2229
2260
  pos_start=0,
@@ -2257,6 +2288,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2257
2288
  name=Tok.STAR_MUL,
2258
2289
  value="*",
2259
2290
  line=vararg.loc.first_line,
2291
+ end_line=vararg.loc.last_line,
2260
2292
  col_start=vararg.loc.col_start,
2261
2293
  col_end=vararg.loc.col_end,
2262
2294
  pos_start=0,
@@ -2282,6 +2314,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2282
2314
  name=Tok.STAR_POW,
2283
2315
  value="**",
2284
2316
  line=kwarg.loc.first_line,
2317
+ end_line=kwarg.loc.last_line,
2285
2318
  col_start=kwarg.loc.col_start,
2286
2319
  col_end=kwarg.loc.col_end,
2287
2320
  pos_start=0,
@@ -2327,6 +2360,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2327
2360
  name=tok,
2328
2361
  value=value,
2329
2362
  line=0,
2363
+ end_line=0,
2330
2364
  col_start=0,
2331
2365
  col_end=0,
2332
2366
  pos_start=0,
@@ -2491,6 +2525,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2491
2525
  name=Tok.NAME,
2492
2526
  value=node.arg if node.arg else "_",
2493
2527
  line=node.lineno,
2528
+ end_line=node.end_lineno if node.end_lineno else node.lineno,
2494
2529
  col_start=node.col_offset,
2495
2530
  col_end=node.col_offset + len(node.arg if node.arg else "_"),
2496
2531
  pos_start=0,
@@ -57,10 +57,13 @@ class PyJacAstLinkPass(Pass):
57
57
  decorators: Optional[SubNodeList[ExprType]],
58
58
  """
59
59
  for i in node.target.archs:
60
- if i.sym_link:
61
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
60
+ if i.name_spec.name_of.sym:
62
61
  self.link_jac_py_nodes(
63
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
62
+ jac_node=i, py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast
63
+ )
64
+ self.link_jac_py_nodes(
65
+ jac_node=i.name_spec,
66
+ py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast,
64
67
  )
65
68
 
66
69
  def exit_enum(self, node: ast.Enum) -> None:
@@ -85,10 +88,13 @@ class PyJacAstLinkPass(Pass):
85
88
  decorators: Optional[SubNodeList[ExprType]],
86
89
  """
87
90
  for i in node.target.archs:
88
- if i.sym_link:
89
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
91
+ if i.name_spec.name_of.sym:
92
+ self.link_jac_py_nodes(
93
+ jac_node=i, py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast
94
+ )
90
95
  self.link_jac_py_nodes(
91
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
96
+ jac_node=i.name_spec,
97
+ py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast,
92
98
  )
93
99
 
94
100
  def exit_ability(self, node: ast.Ability) -> None:
@@ -119,10 +125,13 @@ class PyJacAstLinkPass(Pass):
119
125
  decorators: Optional[SubNodeList[ExprType]],
120
126
  """
121
127
  for i in node.target.archs:
122
- if i.sym_link:
123
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
128
+ if i.name_spec.name_of.sym:
129
+ self.link_jac_py_nodes(
130
+ jac_node=i, py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast
131
+ )
124
132
  self.link_jac_py_nodes(
125
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
133
+ jac_node=i.name_spec,
134
+ py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast,
126
135
  )
127
136
 
128
137
  if isinstance(node.parent, ast.Ability) and node.parent.signature:
@@ -219,5 +228,5 @@ class PyJacAstLinkPass(Pass):
219
228
  """
220
229
  if node.is_attr and isinstance(node.right, ast.AstSymbolNode):
221
230
  self.link_jac_py_nodes(
222
- jac_node=node.right.sym_name_node, py_nodes=node.gen.py_ast
231
+ jac_node=node.right.name_spec, py_nodes=node.gen.py_ast
223
232
  )
@@ -12,7 +12,7 @@ import pickle
12
12
  import jaclang.compiler.absyntree as ast
13
13
  from jaclang.compiler.constant import Constants as Con
14
14
  from jaclang.compiler.passes import Pass
15
- from jaclang.core.registry import SemInfo, SemRegistry
15
+ from jaclang.compiler.semtable import SemInfo, SemRegistry
16
16
  from jaclang.core.utils import get_sem_scope
17
17
 
18
18
 
@@ -48,7 +48,7 @@ class RegistryPass(Pass):
48
48
  seminfo = SemInfo(
49
49
  node.name.value,
50
50
  node.arch_type.value,
51
- node.semstr.lit_value if node.semstr else None,
51
+ node.semstr.lit_value if node.semstr else "",
52
52
  )
53
53
  if (
54
54
  len(self.modules_visited)
@@ -61,7 +61,7 @@ class RegistryPass(Pass):
61
61
  """Save enum information."""
62
62
  scope = get_sem_scope(node)
63
63
  seminfo = SemInfo(
64
- node.name.value, "Enum", node.semstr.lit_value if node.semstr else None
64
+ node.name.value, "Enum", node.semstr.lit_value if node.semstr else ""
65
65
  )
66
66
  if (
67
67
  len(self.modules_visited)
@@ -79,7 +79,7 @@ class RegistryPass(Pass):
79
79
  seminfo = SemInfo(
80
80
  node.name.value,
81
81
  extracted_type,
82
- node.semstr.lit_value if node.semstr else None,
82
+ node.semstr.lit_value if node.semstr else "",
83
83
  )
84
84
  if len(self.modules_visited) and self.modules_visited[-1].registry:
85
85
  self.modules_visited[-1].registry.add(scope, seminfo)
@@ -100,7 +100,7 @@ class RegistryPass(Pass):
100
100
  else ""
101
101
  ),
102
102
  extracted_type,
103
- node.semstr.lit_value if node.semstr else None,
103
+ node.semstr.lit_value if node.semstr else "",
104
104
  )
105
105
  if len(self.modules_visited) and self.modules_visited[-1].registry:
106
106
  self.modules_visited[-1].registry.add(scope, seminfo)
@@ -113,7 +113,7 @@ class RegistryPass(Pass):
113
113
  and node.parent.parent.__class__.__name__ == "Enum"
114
114
  ):
115
115
  scope = get_sem_scope(node)
116
- seminfo = SemInfo(node.value, None, None)
116
+ seminfo = SemInfo(node.value, None, "")
117
117
  if len(self.modules_visited) and self.modules_visited[-1].registry:
118
118
  self.modules_visited[-1].registry.add(scope, seminfo)
119
119
 
@@ -17,19 +17,6 @@ from jaclang.compiler.symtable import Symbol, SymbolAccess, SymbolTable
17
17
  class SymTabPass(Pass):
18
18
  """Jac Ast build pass."""
19
19
 
20
- def before_pass(self) -> None:
21
- """Before pass."""
22
- self.unlinked: set[ast.AstSymbolNode] = set() # Failed use lookups
23
- self.linked: set[ast.AstSymbolNode] = set() # Successful use lookups
24
-
25
- def seen(self, node: ast.AstSymbolNode) -> bool:
26
- """Check if seen."""
27
- result = node in self.linked or node in self.unlinked
28
- if node.sym_link and not result:
29
- self.linked.add(node)
30
- return True
31
- return result
32
-
33
20
  def inherit_sym_tab(self, scope: SymbolTable, sym_tab: SymbolTable) -> None:
34
21
  """Inherit symbol table."""
35
22
  for i in sym_tab.tab.values():
@@ -44,21 +31,20 @@ class SymTabPass(Pass):
44
31
  ) -> Optional[Symbol]:
45
32
  """Insert into symbol table."""
46
33
  table = table_override if table_override else node.sym_tab
47
- if self.seen(node) and node.sym_link and table == node.sym_link.parent_tab:
48
- return node.sym_link
34
+ if node.sym and table == node.sym.parent_tab:
35
+ return node.sym
49
36
  if table:
50
37
  table.insert(
51
38
  node=node, single=single_decl is not None, access_spec=access_spec
52
39
  )
53
40
  self.update_py_ctx_for_def(node)
54
- self.handle_hit_outcome(node)
55
- return node.sym_link
41
+ return node.sym
56
42
 
57
43
  def update_py_ctx_for_def(self, node: ast.AstSymbolNode) -> None:
58
44
  """Update python context for definition."""
59
- node.py_ctx_func = ast3.Store
60
- if isinstance(node.sym_name_node, ast.AstSymbolNode):
61
- node.sym_name_node.py_ctx_func = ast3.Store
45
+ node.name_spec.py_ctx_func = ast3.Store
46
+ if isinstance(node.name_spec, ast.AstSymbolNode):
47
+ node.name_spec.py_ctx_func = ast3.Store
62
48
  if isinstance(node, (ast.TupleVal, ast.ListVal)) and node.values:
63
49
  # Handling of UnaryExpr case for item is only necessary for
64
50
  # the generation of Starred nodes in the AST for examples
@@ -66,11 +52,11 @@ class SymTabPass(Pass):
66
52
  def fix(item: ast.TupleVal | ast.ListVal | ast.UnaryExpr) -> None:
67
53
  if isinstance(item, ast.UnaryExpr):
68
54
  if isinstance(item.operand, ast.AstSymbolNode):
69
- item.operand.py_ctx_func = ast3.Store
55
+ item.operand.name_spec.py_ctx_func = ast3.Store
70
56
  elif isinstance(item, (ast.TupleVal, ast.ListVal)):
71
57
  for i in item.values.items if item.values else []:
72
58
  if isinstance(i, ast.AstSymbolNode):
73
- i.py_ctx_func = ast3.Store
59
+ i.name_spec.py_ctx_func = ast3.Store
74
60
  elif isinstance(i, ast.AtomTrailer):
75
61
  self.chain_def_insert(self.unwind_atom_trailer(i))
76
62
  if isinstance(i, (ast.TupleVal, ast.ListVal, ast.UnaryExpr)):
@@ -84,28 +70,23 @@ class SymTabPass(Pass):
84
70
  sym_table: Optional[SymbolTable] = None,
85
71
  ) -> Optional[Symbol]:
86
72
  """Link to symbol."""
87
- if self.seen(node):
88
- return node.sym_link
73
+ if node.sym:
74
+ return node.sym
89
75
  if not sym_table:
90
76
  sym_table = node.sym_tab
91
77
  if sym_table:
92
- node.sym_link = (
93
- sym_table.lookup(name=node.sym_name, deep=True) if sym_table else None
94
- )
95
- # If successful lookup mark linked, add to table uses, and link others
96
- if node.sym_link:
97
- sym_table.uses.append(node)
98
- self.handle_hit_outcome(node)
99
- return node.sym_link
78
+ lookup = sym_table.lookup(name=node.sym_name, deep=True)
79
+ lookup.add_use(node.name_spec) if lookup else None
80
+ return node.sym
100
81
 
101
82
  def chain_def_insert(self, node_list: Sequence[ast.AstSymbolNode]) -> None:
102
83
  """Link chain of containing names to symbol."""
103
84
  if not node_list:
104
85
  return
105
86
  cur_sym_tab = node_list[0].sym_tab
106
- node_list[-1].py_ctx_func = ast3.Store
107
- if isinstance(node_list[-1].sym_name_node, ast.AstSymbolNode):
108
- node_list[-1].sym_name_node.py_ctx_func = ast3.Store
87
+ node_list[-1].name_spec.py_ctx_func = ast3.Store
88
+ if isinstance(node_list[-1].name_spec, ast.AstSymbolNode):
89
+ node_list[-1].name_spec.py_ctx_func = ast3.Store
109
90
 
110
91
  node_list = node_list[:-1] # Just performs lookup mappings of pre assign chain
111
92
  for i in node_list:
@@ -165,25 +146,6 @@ class SymTabPass(Pass):
165
146
  trag_list.insert(0, left)
166
147
  return trag_list
167
148
 
168
- def handle_hit_outcome(
169
- self,
170
- node: ast.AstSymbolNode,
171
- ) -> None:
172
- """Handle outcome of lookup or insert."""
173
- # If successful lookup mark linked, add to table uses, and link others
174
- if node.sym_link:
175
- self.linked.add(node)
176
- if isinstance(node.sym_name_node, ast.AstSymbolNode):
177
- node.sym_name_node.sym_link = node.sym_link
178
- if not node.sym_link:
179
- # Mark nodes that were not successfully linked
180
- self.unlinked.add(node)
181
- if (
182
- isinstance(node.sym_name_node, ast.AstSymbolNode)
183
- and not node.sym_name_node.sym_link
184
- ):
185
- self.unlinked.add(node.sym_name_node)
186
-
187
149
  def already_declared_err(
188
150
  self,
189
151
  name: str,
@@ -238,7 +200,7 @@ class SymTabBuildPass(SymTabPass):
238
200
  mod_path: str,
239
201
  is_imported: bool,
240
202
  """
241
- self.push_scope(node.name, node, fresh=True)
203
+ self.push_scope(node.name, node, fresh=(node == self.ir))
242
204
  self.sync_node_to_scope(node)
243
205
  for obj in dir(builtins):
244
206
  builtin = ast.Name(
@@ -246,6 +208,7 @@ class SymTabBuildPass(SymTabPass):
246
208
  name=Tok.NAME,
247
209
  value=str(obj),
248
210
  line=0,
211
+ end_line=0,
249
212
  col_start=0,
250
213
  col_end=0,
251
214
  pos_start=0,
@@ -253,6 +216,7 @@ class SymTabBuildPass(SymTabPass):
253
216
  )
254
217
  self.sync_node_to_scope(builtin)
255
218
  self.def_insert(builtin)
219
+ # self.def_insert(ast.Name.gen_stub_from_node(node.name, "root"))
256
220
 
257
221
  def exit_module(self, node: ast.Module) -> None:
258
222
  """Sub objects.
@@ -263,23 +227,7 @@ class SymTabBuildPass(SymTabPass):
263
227
  mod_path: str,
264
228
  is_imported: bool,
265
229
  """
266
- s = self.pop_scope()
267
- # If not the main module add all the other modules symbol table
268
- # as a child to the current symbol table
269
- if node != self.ir:
270
- self.cur_scope().kid.append(s)
271
- s.parent = self.cur_scope()
272
-
273
- if (
274
- isinstance(node.parent, ast.Module)
275
- and node
276
- in [
277
- node.parent.impl_mod,
278
- node.parent.test_mod,
279
- ]
280
- and node.sym_tab
281
- ):
282
- self.inherit_sym_tab(scope=self.cur_scope(), sym_tab=node.sym_tab)
230
+ self.pop_scope()
283
231
 
284
232
  def enter_global_vars(self, node: ast.GlobalVars) -> None:
285
233
  """Sub objects.
@@ -510,6 +458,9 @@ class SymTabBuildPass(SymTabPass):
510
458
  self.def_insert(node, access_spec=node, single_decl="ability")
511
459
  self.push_scope(node.sym_name, node)
512
460
  self.sync_node_to_scope(node)
461
+ if node.is_method:
462
+ self.def_insert(ast.Name.gen_stub_from_node(node, "self"))
463
+ self.def_insert(ast.Name.gen_stub_from_node(node, "super"))
513
464
 
514
465
  def exit_ability(self, node: ast.Ability) -> None:
515
466
  """Sub objects.
@@ -896,6 +847,13 @@ class SymTabBuildPass(SymTabPass):
896
847
  """
897
848
  self.sync_node_to_scope(node)
898
849
 
850
+ def enter_check_stmt(self, node: ast.CheckStmt) -> None:
851
+ """Sub objects.
852
+
853
+ target: Expr,
854
+ """
855
+ self.sync_node_to_scope(node)
856
+
899
857
  def enter_ctrl_stmt(self, node: ast.CtrlStmt) -> None:
900
858
  """Sub objects.
901
859