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
@@ -19,29 +19,60 @@ class DefUsePass(SymTabPass):
19
19
  def after_pass(self) -> None:
20
20
  """After pass."""
21
21
 
22
+ def inherit_baseclasses_sym(self, node: ast.Architype | ast.Enum) -> None:
23
+ """Inherit base classes symbol tables."""
24
+ if node.base_classes:
25
+ for cls in node.base_classes.items:
26
+ if (
27
+ isinstance(cls, ast.AstSymbolNode)
28
+ and (found := self.use_lookup(cls))
29
+ and found
30
+ and found.decl.sym_tab
31
+ and node.sym_tab
32
+ ):
33
+ node.sym_tab.inherit.append(found.decl.sym_tab)
34
+
22
35
  def enter_architype(self, node: ast.Architype) -> None:
23
36
  """Sub objects.
24
37
 
25
38
  name: Name,
26
- doc: Optional[Token],
27
- body: Optional[SubNodeList[ArchStmt]],
28
- sym_tab: Optional[SymbolTable],
39
+ arch_type: Token,
40
+ access: Optional[SubTag[Token]],
41
+ base_classes: Optional[SubNodeList[Expr]],
42
+ body: Optional[SubNodeList[ArchBlockStmt] | ArchDef],
43
+ doc: Optional[String] = None,
44
+ semstr: Optional[String] = None,
45
+ decorators: Optional[SubNodeList[Expr]] = None,
29
46
  """
47
+ self.inherit_baseclasses_sym(node)
48
+
49
+ def inform_from_walker(node: ast.AstNode) -> None:
50
+ for i in (
51
+ node.get_all_sub_nodes(ast.VisitStmt)
52
+ + node.get_all_sub_nodes(ast.IgnoreStmt)
53
+ + node.get_all_sub_nodes(ast.DisengageStmt)
54
+ + node.get_all_sub_nodes(ast.EdgeOpRef)
55
+ ):
56
+ i.from_walker = True
57
+
30
58
  if node.arch_type.name == Tok.KW_WALKER:
31
- self.inform_from_walker(node)
59
+ inform_from_walker(node)
32
60
  for i in self.get_all_sub_nodes(node, ast.Ability):
33
61
  if isinstance(i.body, ast.AbilityDef):
34
- self.inform_from_walker(i.body)
35
-
36
- def inform_from_walker(self, node: ast.AstNode) -> None:
37
- """Inform all sub nodes that they are from a walker."""
38
- for i in (
39
- self.get_all_sub_nodes(node, ast.VisitStmt)
40
- + self.get_all_sub_nodes(node, ast.IgnoreStmt)
41
- + self.get_all_sub_nodes(node, ast.DisengageStmt)
42
- + self.get_all_sub_nodes(node, ast.EdgeOpRef)
43
- ):
44
- i.from_walker = True
62
+ inform_from_walker(i.body)
63
+
64
+ def enter_enum(self, node: ast.Enum) -> None:
65
+ """Sub objects.
66
+
67
+ name: Name,
68
+ access: Optional[SubTag[Token]],
69
+ base_classes: Optional[SubNodeList[Expr]],
70
+ body: Optional[SubNodeList[EnumBlockStmt] | EnumDef],
71
+ doc: Optional[String] = None,
72
+ semstr: Optional[String] = None,
73
+ decorators: Optional[SubNodeList[Expr]] = None,
74
+ """
75
+ self.inherit_baseclasses_sym(node)
45
76
 
46
77
  def enter_arch_ref(self, node: ast.ArchRef) -> None:
47
78
  """Sub objects.
@@ -296,9 +327,9 @@ class DefUsePass(SymTabPass):
296
327
  )
297
328
  for i in items:
298
329
  if isinstance(i, ast.AtomTrailer):
299
- self.unwind_atom_trailer(i)[-1].py_ctx_func = ast3.Del
330
+ self.unwind_atom_trailer(i)[-1].name_spec.py_ctx_func = ast3.Del
300
331
  elif isinstance(i, ast.AstSymbolNode):
301
- i.py_ctx_func = ast3.Del
332
+ i.name_spec.py_ctx_func = ast3.Del
302
333
  else:
303
334
  self.error("Delete target not valid")
304
335
 
@@ -46,7 +46,7 @@ class FuseTypeInfoPass(Pass):
46
46
  )
47
47
 
48
48
  def __set_sym_table_link(self, node: ast.AstSymbolNode) -> None:
49
- typ = node.sym_info.typ.split(".")
49
+ typ = node.sym_type.split(".")
50
50
  typ_sym_table = self.ir.sym_tab
51
51
 
52
52
  if typ[0] == "builtins":
@@ -63,7 +63,7 @@ class FuseTypeInfoPass(Pass):
63
63
  typ_sym_table = f
64
64
 
65
65
  if typ_sym_table != self.ir.sym_tab:
66
- node.sym_info.typ_sym_table = typ_sym_table
66
+ node.name_spec.type_sym_tab = typ_sym_table
67
67
 
68
68
  @staticmethod
69
69
  def __handle_node(
@@ -133,7 +133,7 @@ class FuseTypeInfoPass(Pass):
133
133
  t = t.split("->")[1].strip()
134
134
  elif "def" in t:
135
135
  t = "None"
136
- node.sym_info.typ = t
136
+ node.name_spec.sym_type = t
137
137
  else:
138
138
  self.__debug_print(f"{node.loc} MemberExpr type is not found")
139
139
 
@@ -145,16 +145,16 @@ class FuseTypeInfoPass(Pass):
145
145
  self.__call_type_handler(node, mypy_node.type)
146
146
 
147
147
  elif isinstance(mypy_node, MypyNodes.MypyFile):
148
- node.sym_info = ast.SymbolInfo("types.ModuleType")
148
+ node.name_spec.sym_type = "types.ModuleType"
149
149
 
150
150
  elif isinstance(mypy_node, MypyNodes.TypeInfo):
151
- node.sym_info = ast.SymbolInfo(mypy_node.fullname)
151
+ node.name_spec.sym_type = mypy_node.fullname
152
152
 
153
153
  elif isinstance(mypy_node, MypyNodes.OverloadedFuncDef):
154
154
  self.__call_type_handler(node, mypy_node.items[0].func.type)
155
155
 
156
156
  elif mypy_node is None:
157
- node.sym_info = ast.SymbolInfo("None")
157
+ node.name_spec.sym_type = "None"
158
158
 
159
159
  else:
160
160
  self.__debug_print(
@@ -164,7 +164,7 @@ class FuseTypeInfoPass(Pass):
164
164
 
165
165
  else:
166
166
  if isinstance(mypy_node, MypyNodes.ClassDef):
167
- node.sym_info.typ = mypy_node.fullname
167
+ node.name_spec.sym_type = mypy_node.fullname
168
168
  self.__set_sym_table_link(node)
169
169
  elif isinstance(mypy_node, MypyNodes.FuncDef):
170
170
  self.__call_type_handler(node, mypy_node.type)
@@ -179,7 +179,7 @@ class FuseTypeInfoPass(Pass):
179
179
  )
180
180
 
181
181
  @__handle_node
182
- def enter_name(self, node: ast.NameSpec) -> None:
182
+ def enter_name(self, node: ast.NameAtom) -> None:
183
183
  """Pass handler for name nodes."""
184
184
  self.__collect_type_from_symbol(node)
185
185
 
@@ -188,12 +188,12 @@ class FuseTypeInfoPass(Pass):
188
188
  if isinstance(node.parent, ast.AtomTrailer):
189
189
  target_node = node.parent.target
190
190
  if isinstance(target_node, ast.AstSymbolNode):
191
- parent_symbol_table = target_node.sym_info.typ_sym_table
191
+ parent_symbol_table = target_node.type_sym_tab
192
192
  if isinstance(parent_symbol_table, ast.SymbolTable):
193
193
  owner = parent_symbol_table.owner
194
194
  if isinstance(owner, ast.AstSymbolNode):
195
- target_node.sym_link = owner.sym_link
196
- node.sym_link = parent_symbol_table.lookup(node.sym_name)
195
+ target_node.name_spec.sym = owner.sym
196
+ node.sym = parent_symbol_table.lookup(node.sym_name)
197
197
 
198
198
  @__handle_node
199
199
  def enter_module_path(self, node: ast.ModulePath) -> None:
@@ -279,13 +279,13 @@ class FuseTypeInfoPass(Pass):
279
279
 
280
280
  def exit_has_var(self, node: ast.HasVar) -> None:
281
281
  """Pass handler for HasVar nodes."""
282
- node.sym_info.typ = node.name.sym_info.typ
283
- node.sym_info.typ_sym_table = node.name.sym_info.typ_sym_table
282
+ node.name_spec.sym_type = node.name.sym_type
283
+ node.name_spec.type_sym_tab = node.name.type_sym_tab
284
284
 
285
285
  @__handle_node
286
286
  def enter_multi_string(self, node: ast.MultiString) -> None:
287
287
  """Pass handler for MultiString nodes."""
288
- node.sym_info = ast.SymbolInfo("builtins.str")
288
+ node.name_spec.sym_type = "builtins.str"
289
289
 
290
290
  @__handle_node
291
291
  def enter_f_string(self, node: ast.FString) -> None:
@@ -297,48 +297,48 @@ class FuseTypeInfoPass(Pass):
297
297
  """Pass handler for ListVal nodes."""
298
298
  mypy_node = node.gen.mypy_ast[0]
299
299
  if mypy_node in self.node_type_hash:
300
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
300
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
301
301
  else:
302
- node.sym_info.typ = "builtins.list"
302
+ node.name_spec.sym_type = "builtins.list"
303
303
 
304
304
  @__handle_node
305
305
  def enter_set_val(self, node: ast.SetVal) -> None:
306
306
  """Pass handler for SetVal nodes."""
307
307
  mypy_node = node.gen.mypy_ast[0]
308
308
  if mypy_node in self.node_type_hash:
309
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
309
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
310
310
  else:
311
- node.sym_info.typ = "builtins.set"
311
+ node.name_spec.sym_type = "builtins.set"
312
312
 
313
313
  @__handle_node
314
314
  def enter_tuple_val(self, node: ast.TupleVal) -> None:
315
315
  """Pass handler for TupleVal nodes."""
316
316
  mypy_node = node.gen.mypy_ast[0]
317
317
  if mypy_node in self.node_type_hash:
318
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
318
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
319
319
  else:
320
- node.sym_info.typ = "builtins.tuple"
320
+ node.name_spec.sym_type = "builtins.tuple"
321
321
 
322
322
  @__handle_node
323
323
  def enter_dict_val(self, node: ast.DictVal) -> None:
324
324
  """Pass handler for DictVal nodes."""
325
325
  mypy_node = node.gen.mypy_ast[0]
326
326
  if mypy_node in self.node_type_hash:
327
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
327
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
328
328
  else:
329
- node.sym_info.typ = "builtins.dict"
329
+ node.name_spec.sym_type = "builtins.dict"
330
330
 
331
331
  @__handle_node
332
332
  def enter_list_compr(self, node: ast.ListCompr) -> None:
333
333
  """Pass handler for ListCompr nodes."""
334
334
  mypy_node = node.gen.mypy_ast[0]
335
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
335
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
336
336
 
337
337
  @__handle_node
338
338
  def enter_dict_compr(self, node: ast.DictCompr) -> None:
339
339
  """Pass handler for DictCompr nodes."""
340
340
  mypy_node = node.gen.mypy_ast[0]
341
- node.sym_info.typ = str(self.node_type_hash[mypy_node])
341
+ node.name_spec.sym_type = str(self.node_type_hash[mypy_node])
342
342
 
343
343
  @__handle_node
344
344
  def enter_index_slice(self, node: ast.IndexSlice) -> None:
@@ -350,7 +350,7 @@ class FuseTypeInfoPass(Pass):
350
350
  """Pass handler for ArchRef nodes."""
351
351
  if isinstance(node.gen.mypy_ast[0], MypyNodes.ClassDef):
352
352
  mypy_node: MypyNodes.ClassDef = node.gen.mypy_ast[0]
353
- node.sym_info.typ = mypy_node.fullname
353
+ node.name_spec.sym_type = mypy_node.fullname
354
354
  self.__set_sym_table_link(node)
355
355
  elif isinstance(node.gen.mypy_ast[0], MypyNodes.FuncDef):
356
356
  mypy_node2: MypyNodes.FuncDef = node.gen.mypy_ast[0]
@@ -384,22 +384,22 @@ class FuseTypeInfoPass(Pass):
384
384
  @__handle_node
385
385
  def enter_int(self, node: ast.Int) -> None:
386
386
  """Pass handler for Int nodes."""
387
- node.sym_info.typ = "builtins.int"
387
+ node.name_spec.sym_type = "builtins.int"
388
388
 
389
389
  @__handle_node
390
390
  def enter_float(self, node: ast.Float) -> None:
391
391
  """Pass handler for Float nodes."""
392
- node.sym_info.typ = "builtins.float"
392
+ node.name_spec.sym_type = "builtins.float"
393
393
 
394
394
  @__handle_node
395
395
  def enter_string(self, node: ast.String) -> None:
396
396
  """Pass handler for String nodes."""
397
- node.sym_info.typ = "builtins.str"
397
+ node.name_spec.sym_type = "builtins.str"
398
398
 
399
399
  @__handle_node
400
400
  def enter_bool(self, node: ast.Bool) -> None:
401
401
  """Pass handler for Bool nodes."""
402
- node.sym_info.typ = "builtins.bool"
402
+ node.name_spec.sym_type = "builtins.bool"
403
403
 
404
404
  @__handle_node
405
405
  def enter_builtin_type(self, node: ast.BuiltinType) -> None:
@@ -410,13 +410,13 @@ class FuseTypeInfoPass(Pass):
410
410
  self, node: ast.AstSymbolNode, mypy_type: MypyTypes.Instance
411
411
  ) -> None:
412
412
  """Get type info from mypy type Instance."""
413
- node.sym_info = ast.SymbolInfo(str(mypy_type))
413
+ node.name_spec.sym_type = str(mypy_type)
414
414
 
415
415
  def get_type_from_callable_type(
416
416
  self, node: ast.AstSymbolNode, mypy_type: MypyTypes.CallableType
417
417
  ) -> None:
418
418
  """Get type info from mypy type CallableType."""
419
- node.sym_info = ast.SymbolInfo(str(mypy_type.ret_type))
419
+ node.name_spec.sym_type = str(mypy_type.ret_type)
420
420
 
421
421
  # TODO: Which overloaded function to get the return value from?
422
422
  def get_type_from_overloaded(
@@ -429,16 +429,16 @@ class FuseTypeInfoPass(Pass):
429
429
  self, node: ast.AstSymbolNode, mypy_type: MypyTypes.NoneType
430
430
  ) -> None:
431
431
  """Get type info from mypy type NoneType."""
432
- node.sym_info = ast.SymbolInfo("None")
432
+ node.name_spec.sym_type = "None"
433
433
 
434
434
  def get_type_from_any_type(
435
435
  self, node: ast.AstSymbolNode, mypy_type: MypyTypes.AnyType
436
436
  ) -> None:
437
437
  """Get type info from mypy type NoneType."""
438
- node.sym_info = ast.SymbolInfo("Any")
438
+ node.name_spec.sym_type = "Any"
439
439
 
440
440
  def get_type_from_tuple_type(
441
441
  self, node: ast.AstSymbolNode, mypy_type: MypyTypes.TupleType
442
442
  ) -> None:
443
443
  """Get type info from mypy type TupleType."""
444
- node.sym_info = ast.SymbolInfo("builtins.tuple")
444
+ node.name_spec.sym_type = "builtins.tuple"
@@ -204,15 +204,17 @@ class JacImportPass(Pass):
204
204
  class PyImportPass(JacImportPass):
205
205
  """Jac statically imports Python modules."""
206
206
 
207
+ def before_pass(self) -> None:
208
+ """Only run pass if settings are set to raise python."""
209
+ if not settings.py_raise:
210
+ self.terminate()
211
+ else:
212
+ return super().before_pass()
213
+
207
214
  def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
208
215
  """Process an import."""
209
216
  lang = i.parent_of_type(ast.Import).hint.tag.value
210
- if (
211
- lang == "py"
212
- and not i.sub_module
213
- and settings.py_raise
214
- and not is_standard_lib_module(i.path_str)
215
- ):
217
+ if lang == "py" and not i.sub_module and not is_standard_lib_module(i.path_str):
216
218
  mod = self.import_py_module(node=i, mod_path=node.loc.mod_path)
217
219
  if mod:
218
220
  i.sub_module = mod
@@ -42,7 +42,6 @@ class PyastGenPass(Pass):
42
42
  """Initialize pass."""
43
43
  self.debuginfo: dict[str, list[str]] = {"jac_mods": []}
44
44
  self.already_added: list[str] = []
45
- self.method_sigs: list[ast.FuncSignature | ast.EventSignature] = []
46
45
  self.preamble: list[ast3.AST] = [
47
46
  self.sync(
48
47
  ast3.ImportFrom(
@@ -393,7 +392,7 @@ class PyastGenPass(Pass):
393
392
  args=self.sync(
394
393
  ast3.arguments(
395
394
  posonlyargs=[],
396
- args=[self.sync(ast3.arg(arg="check", annotation=None))],
395
+ args=[self.sync(ast3.arg(arg="_jac_check", annotation=None))],
397
396
  kwonlyargs=[],
398
397
  vararg=None,
399
398
  kwargs=None,
@@ -552,7 +551,7 @@ class PyastGenPass(Pass):
552
551
  arg="mod_bundle",
553
552
  value=self.sync(
554
553
  ast3.Name(
555
- id="__jac_mod_bundle__",
554
+ id="__name__",
556
555
  ctx=ast3.Load(),
557
556
  )
558
557
  ),
@@ -678,14 +677,6 @@ class PyastGenPass(Pass):
678
677
  doc: Optional[String],
679
678
  decorators: Optional[SubNodeList[ExprType]],
680
679
  """
681
- # Record all signatures that are part of methods
682
- for i in (
683
- node.body.body.items
684
- if isinstance(node.body, ast.ArchDef)
685
- else node.body.items if node.body else []
686
- ):
687
- if isinstance(i, ast.Ability):
688
- self.method_sigs.append(i.signature)
689
680
  if isinstance(node.body, ast.AstImplOnlyNode):
690
681
  self.traverse(node.body)
691
682
 
@@ -768,6 +759,18 @@ class PyastGenPass(Pass):
768
759
  )
769
760
  )
770
761
  base_classes = node.base_classes.gen.py_ast if node.base_classes else []
762
+ if node.arch_type.name != Tok.KW_CLASS:
763
+ base_classes.append(
764
+ self.sync(
765
+ ast3.Attribute(
766
+ value=self.sync(
767
+ ast3.Name(id=Con.JAC_FEATURE.value, ctx=ast3.Load())
768
+ ),
769
+ attr=node.arch_type.value.capitalize(),
770
+ ctx=ast3.Load(),
771
+ )
772
+ )
773
+ )
771
774
  if node.is_abstract:
772
775
  self.needs_jac_feature()
773
776
  base_classes.append(
@@ -1091,7 +1094,7 @@ class PyastGenPass(Pass):
1091
1094
  value=(
1092
1095
  node.signature.semstr.lit_value
1093
1096
  if node.signature.semstr
1094
- else None
1097
+ else ""
1095
1098
  )
1096
1099
  )
1097
1100
  )
@@ -1333,7 +1336,7 @@ class PyastGenPass(Pass):
1333
1336
  """
1334
1337
  params = (
1335
1338
  [self.sync(ast3.arg(arg="self", annotation=None))]
1336
- if node in self.method_sigs and not node.is_static
1339
+ if node.is_method and not node.is_static
1337
1340
  else []
1338
1341
  )
1339
1342
  vararg = None
@@ -1391,7 +1394,7 @@ class PyastGenPass(Pass):
1391
1394
  posonlyargs=[],
1392
1395
  args=(
1393
1396
  [self.sync(ast3.arg(arg="self", annotation=None)), here]
1394
- if node in self.method_sigs
1397
+ if node.is_method
1395
1398
  else [here]
1396
1399
  ),
1397
1400
  kwonlyargs=[],
@@ -1409,27 +1412,19 @@ class PyastGenPass(Pass):
1409
1412
  name_ref: NameType,
1410
1413
  arch: Token,
1411
1414
  """
1412
- if node.arch.name == Tok.TYPE_OP:
1415
+ if node.arch_type.name == Tok.TYPE_OP:
1413
1416
  if (
1414
- isinstance(node.name_ref, ast.SpecialVarRef)
1415
- and node.name_ref.var.name == Tok.KW_ROOT
1417
+ isinstance(node.arch_name, ast.SpecialVarRef)
1418
+ and node.arch_name.orig.name == Tok.KW_ROOT
1416
1419
  ):
1417
1420
  node.gen.py_ast = [
1418
1421
  self.sync(
1419
- ast3.Call(
1420
- func=self.sync(
1421
- ast3.Attribute(
1422
- value=self.sync(
1423
- ast3.Name(
1424
- id=Con.JAC_FEATURE.value, ctx=ast3.Load()
1425
- )
1426
- ),
1427
- attr="get_root_type",
1428
- ctx=ast3.Load(),
1429
- )
1422
+ ast3.Attribute(
1423
+ value=self.sync(
1424
+ ast3.Name(id=Con.JAC_FEATURE.value, ctx=ast3.Load())
1430
1425
  ),
1431
- args=[],
1432
- keywords=[],
1426
+ attr="RootType",
1427
+ ctx=ast3.Load(),
1433
1428
  )
1434
1429
  )
1435
1430
  ]
@@ -1439,13 +1434,13 @@ class PyastGenPass(Pass):
1439
1434
  self.sync(
1440
1435
  ast3.Attribute(
1441
1436
  value=self.sync(ast3.Name(id="_jac_typ", ctx=ast3.Load())),
1442
- attr=node.name_ref.sym_name,
1437
+ attr=node.arch_name.sym_name,
1443
1438
  ctx=ast3.Load(),
1444
1439
  )
1445
1440
  )
1446
1441
  ]
1447
1442
  else:
1448
- node.gen.py_ast = node.name_ref.gen.py_ast
1443
+ node.gen.py_ast = node.arch_name.gen.py_ast
1449
1444
 
1450
1445
  def exit_arch_ref_chain(self, node: ast.ArchRefChain) -> None:
1451
1446
  """Sub objects.
@@ -1463,7 +1458,7 @@ class PyastGenPass(Pass):
1463
1458
  attr = self.sync(
1464
1459
  ast3.Attribute(
1465
1460
  value=make_attr_chain(arch[:-1]),
1466
- attr=cur.name_ref.sym_name,
1461
+ attr=cur.arch_name.sym_name,
1467
1462
  ctx=ast3.Load(),
1468
1463
  ),
1469
1464
  jac_node=cur,
@@ -1881,6 +1876,38 @@ class PyastGenPass(Pass):
1881
1876
  )
1882
1877
  ]
1883
1878
 
1879
+ def exit_check_stmt(self, node: ast.CheckStmt) -> None:
1880
+ """Sub objects.
1881
+
1882
+ target: ExprType,
1883
+ """
1884
+ if isinstance(node.target, ast.FuncCall) and isinstance(
1885
+ node.target.gen.py_ast[0], ast3.Call
1886
+ ):
1887
+ func = node.target.target.gen.py_ast[0]
1888
+ if isinstance(func, ast3.Name):
1889
+ new_func: ast3.expr = self.sync(
1890
+ ast3.Attribute(
1891
+ value=self.sync(ast3.Name(id="_jac_check", ctx=ast3.Load())),
1892
+ attr=func.id,
1893
+ ctx=ast3.Load(),
1894
+ )
1895
+ )
1896
+ node.target.gen.py_ast[0].func = new_func
1897
+ node.gen.py_ast = [
1898
+ self.sync(
1899
+ ast3.Expr(
1900
+ value=node.target.gen.py_ast[0],
1901
+ )
1902
+ )
1903
+ ]
1904
+ return
1905
+ self.error(
1906
+ "For now, check statements must be function calls "
1907
+ "in the style of assertTrue(), assertEqual(), etc.",
1908
+ node,
1909
+ )
1910
+
1884
1911
  def exit_ctrl_stmt(self, node: ast.CtrlStmt) -> None:
1885
1912
  """Sub objects.
1886
1913
 
@@ -3090,14 +3117,42 @@ class PyastGenPass(Pass):
3090
3117
 
3091
3118
  var: Token,
3092
3119
  """
3093
- try:
3094
- var_ast_expr = ast3.parse(node.sym_name).body[0]
3095
- if not isinstance(var_ast_expr, ast3.Expr):
3096
- raise self.ice("Invalid special var ref for pyast generation")
3097
- var_ast = var_ast_expr.value
3098
- except Exception:
3099
- raise self.ice("Invalid special var ref for pyast generation")
3100
- node.gen.py_ast = [self.sync(var_ast, deep=True)]
3120
+ if node.name == Tok.KW_SUPER:
3121
+ node.gen.py_ast = [
3122
+ self.sync(
3123
+ ast3.Call(
3124
+ func=self.sync(ast3.Name(id="super", ctx=node.py_ctx_func())),
3125
+ args=[],
3126
+ keywords=[],
3127
+ )
3128
+ )
3129
+ ]
3130
+ elif node.name == Tok.KW_ROOT:
3131
+ node.gen.py_ast = [
3132
+ self.sync(
3133
+ ast3.Call(
3134
+ func=self.sync(
3135
+ ast3.Attribute(
3136
+ value=self.sync(
3137
+ ast3.Name(
3138
+ id=Con.JAC_FEATURE.value,
3139
+ ctx=ast3.Load(),
3140
+ )
3141
+ ),
3142
+ attr="get_root",
3143
+ ctx=ast3.Load(),
3144
+ )
3145
+ ),
3146
+ args=[],
3147
+ keywords=[],
3148
+ )
3149
+ )
3150
+ ]
3151
+
3152
+ else:
3153
+ node.gen.py_ast = [
3154
+ self.sync(ast3.Name(id=node.sym_name, ctx=node.py_ctx_func()))
3155
+ ]
3101
3156
 
3102
3157
  def exit_edge_ref_trailer(self, node: ast.EdgeRefTrailer) -> None:
3103
3158
  """Sub objects.
@@ -3577,7 +3632,7 @@ class PyastGenPass(Pass):
3577
3632
  [
3578
3633
  x.key.sym_name
3579
3634
  for x in node.kw_patterns.items
3580
- if isinstance(x.key, ast.NameSpec)
3635
+ if isinstance(x.key, ast.NameAtom)
3581
3636
  ]
3582
3637
  if node.kw_patterns
3583
3638
  else []