jaclang 0.3.1__py3-none-any.whl → 0.3.3__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaclang
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Home-page: https://github.com/Jaseci-Labs/jaclang
5
5
  Author: Jason Mars
6
6
  Author-email: jason@jaseci.org
@@ -1,5 +1,5 @@
1
1
  jaclang/__init__.py,sha256=-UY4_LToVeKlZbWglzUFIIey4wNNj3pXDF32y3Xhw3U,529
2
- jaclang/cli/__init__.py,sha256=EL5HqW1FDN0J40WJWORq2pe2G6C8w-_yLIHPa2UFxsw,168
2
+ jaclang/cli/__init__.py,sha256=UX9FHx5nqh1ewd1vD5C_EpYh-MWjp_CFddoXOhEKP48,155
3
3
  jaclang/cli/cli.jac,sha256=QwXwwGxHpjKVXdK6Vpkz_pBoGfICg7V_8eoOKrqQmAY,1040
4
4
  jaclang/cli/cli_impl.jac,sha256=4wGTdNXTMsZbmnJ9czSHrnzb24onyQqlNm1M6M6-10g,2945
5
5
  jaclang/cli/cmds.jac,sha256=uWCwl_P_j72cDZhtz4LdpGmrOJ75F01HGMYq8nWdTK8,539
@@ -9,12 +9,10 @@ jaclang/cli/__jac_gen__/cli.py,sha256=da_duZminm1ZSOanEwpkV_Nu2diDR7EED0p0GJlnVl
9
9
  jaclang/cli/__jac_gen__/cli_impl.py,sha256=PNSTjoeH1mMSwSKWBEVj7jXYOfSIW44VpLc1cU4XSTs,2661
10
10
  jaclang/cli/__jac_gen__/cmds.py,sha256=gx4G9iNSNnc66n7hv7T3QQuR9-hjGnzSv1nEact5els,2656
11
11
  jaclang/cli/__jac_gen__/cmds_impl.py,sha256=8MdR65i7-Ktts52vWLE5OmfNGiKSnquqmoIEHKa3AoY,2338
12
- jaclang/core/__init__.py,sha256=Eo02aQftQjsrx4i8iV0plFguMkytr7_A52bezFRl36Q,213
13
- jaclang/core/corelib.jac,sha256=8o-AC1IPIYL5_RsU-tzWSCgLoRMgbLMi5GfHt4XNXyI,3150
14
- jaclang/core/corelib_impl.jac,sha256=KPvlJkh0sEbHbMSVqzUDYFMO9YGAo77WaJVjrZm9Hnk,8194
12
+ jaclang/core/__init__.py,sha256=CdCREarVVgs-flWMzJLNpFhpibVYgI0MnVCP1QVlX_0,221
13
+ jaclang/core/corelib.jac,sha256=sGGj655swQzGq918hsnT7jdJEFrxDiSRxH_aEddA0ns,11211
15
14
  jaclang/core/__jac_gen__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- jaclang/core/__jac_gen__/corelib.py,sha256=eJgJKTqSBOthU-VCPdwYcZL9lcXF4OsDzJOzRTwb75A,9832
17
- jaclang/core/__jac_gen__/corelib_impl.py,sha256=3n6z0d0cAr8ys8bPmW8vssr-Ng8gLgTS83Vtl6VqtAM,7659
15
+ jaclang/core/__jac_gen__/corelib.py,sha256=UslvgBRL2yfD_2FKi8ZVW_zj0xkZL7gx3DYvZXAxfso,17129
18
16
  jaclang/jac/__init__.py,sha256=B07SnAx4emUUZoosOsqNwt9JnHnpEvOtjh5z6jz4hII,845
19
17
  jaclang/jac/absyntree.py,sha256=RBLAflfbOUq0vFTM83rzlM2_Lfv34xSS1zPI2d7SkUA,59874
20
18
  jaclang/jac/codeloc.py,sha256=jkUtR9xtB4eCCroclhAWagUaWEZrJdlzSzA1pOH3imw,2477
@@ -25,7 +23,7 @@ jaclang/jac/symtable.py,sha256=CXmHp2tBpWSL1rGKFUb7i0gpIPnLYvRQKlOjyTi08Wk,5027
25
23
  jaclang/jac/transpiler.py,sha256=3udqLrAFRSBs3iUvcVfIg3rISkE6rBn4DcsapS8CAEk,2697
26
24
  jaclang/jac/workspace.py,sha256=7o5gqUdOtT917NZdw1v4U1Q_iIt0eUergT-A3ZBSETI,6286
27
25
  jaclang/jac/__jac_gen__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- jaclang/jac/__jac_gen__/jac_parser.py,sha256=vq92cJri3ec6IFAGdAVgfC3zj2AvLSmTCkPl7KHmyQs,276197
26
+ jaclang/jac/__jac_gen__/jac_parser.py,sha256=84mNri1_i_TmjaMKBP1gib4GTc7jfwMzCy5IYA25szo,276097
29
27
  jaclang/jac/passes/__init__.py,sha256=0Tw0d130ZjzA05jVcny9cf5NfLjlaM70PKqFnY4zqn4,69
30
28
  jaclang/jac/passes/ir_pass.py,sha256=O4mh_kS4Qm3oooFpM-iR3RwdskrjzoSKq0crDSJiGYs,5000
31
29
  jaclang/jac/passes/transform.py,sha256=UBCyviweBWD4L5oPYmW3ApFR7sEj62hl-7F71hZj39k,2063
@@ -412,8 +410,8 @@ jaclang/vendor/pluggy/_manager.py,sha256=fcYU7VER0CplRym4jAJ7RCFYl6cfDSeVM589YHH
412
410
  jaclang/vendor/pluggy/_result.py,sha256=CMpNNTgyptUnoYigRZHuJs11gKt9OwTOteDYhY3wAFM,3238
413
411
  jaclang/vendor/pluggy/_tracing.py,sha256=ui2w1xQpsjn67ISaEmizvgojXXAUmRL2nwlV-VXmemc,2088
414
412
  jaclang/vendor/pluggy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
415
- jaclang-0.3.1.dist-info/METADATA,sha256=vp_0fLqe2X0voyaXJY6rZdLXHeQ_V4r0OMsM0wwB0pk,152
416
- jaclang-0.3.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
417
- jaclang-0.3.1.dist-info/entry_points.txt,sha256=KqztNA90AII0EUssRkjTELFitHgtG_dsOBEsnVu1Xsk,90
418
- jaclang-0.3.1.dist-info/top_level.txt,sha256=ZOAoLpE67ozkUJd-v3C59wBNXiteRD8IWPbsYB3M08g,8
419
- jaclang-0.3.1.dist-info/RECORD,,
413
+ jaclang-0.3.3.dist-info/METADATA,sha256=KdTz504VBV9JoPNjuzIQU4NDvMWGMNc9RFFfUf6Nv94,152
414
+ jaclang-0.3.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
415
+ jaclang-0.3.3.dist-info/entry_points.txt,sha256=KqztNA90AII0EUssRkjTELFitHgtG_dsOBEsnVu1Xsk,90
416
+ jaclang-0.3.3.dist-info/top_level.txt,sha256=ZOAoLpE67ozkUJd-v3C59wBNXiteRD8IWPbsYB3M08g,8
417
+ jaclang-0.3.3.dist-info/RECORD,,
@@ -1,220 +0,0 @@
1
- """Jac's Key Elemental Abstractions"""
2
- from __future__ import annotations
3
- from enum import Enum as __jac_Enum__, auto as __jac_auto__
4
- import sys
5
- from uuid import UUID, uuid4
6
- from jaclang.jac.constant import EdgeDir
7
- from jaclang.jac.plugin import hookimpl
8
-
9
- def o_Memory_c_get_obj(self, caller_id: UUID, item_id: UUID, override: bool=False) -> Element:
10
- ret = self.index.get(item_id)
11
- if override or ret.__is_readable(ret is not None and caller_id):
12
- return ret
13
-
14
- def o_Memory_c_has_obj(self, item_id: UUID) -> bool:
15
- return item_id in self.index
16
-
17
- def o_Memory_c_save_obj(self, caller_id: UUID, item: Element) -> None:
18
- if item.is_writable(caller_id):
19
- self.index[item.id] = item
20
- if item._persist:
21
- self.save_obj_list.add(item)
22
- self.mem[item.id] = item
23
- if item._persist:
24
- self.save_obj_list.add(item)
25
-
26
- def o_Memory_c_del_obj(self, caller_id: UUID, item: Element) -> None:
27
- if item.is_writable(caller_id):
28
- self.index.pop(item.id)
29
- if item._persist:
30
- self.save_obj_list.remove(item)
31
-
32
- def o_Memory_c_get_object_distribution(self) -> dict:
33
- dist = {}
34
- for i in self.index.keys():
35
- t = type(self.index[i])
36
- if t in dist:
37
- dist[t] += 1
38
- else:
39
- dist[t] = 1
40
- return dist
41
-
42
- def o_Memory_c_get_mem_size(self) -> float:
43
- return sys.getsizeof(self.index) / 1024.0
44
-
45
- def o_ExecutionContext_c_get_root(self) -> None:
46
- if type(self.master) == UUID:
47
- self.master = Master()
48
- return self.master.root_node
49
-
50
- def o_ExecutionContext_c_reset(self) -> None:
51
- self.__init__()
52
-
53
- class e_AccessMode(__jac_Enum__):
54
- READ_ONLY = __jac_auto__()
55
- READ_WRITE = __jac_auto__()
56
- PRIVATE = __jac_auto__()
57
-
58
- def o_ElementInterface_c_make_public_ro(self) -> None:
59
- self.__jinfo.access_mode = AccessMode.READ_ONLY
60
-
61
- def o_ElementInterface_c_make_public_rw(self) -> None:
62
- self.__jinfo.access_mode = AccessMode.READ_WRITE
63
-
64
- def o_ElementInterface_c_make_private(self) -> None:
65
- self.__jinfo.access_mode = AccessMode.PRIVATE
66
-
67
- def o_ElementInterface_c_is_public_ro(self) -> bool:
68
- return self.__jinfo.access_mode == AccessMode.READ_ONLY
69
-
70
- def o_ElementInterface_c_is_public_rw(self) -> bool:
71
- return self.__jinfo.access_mode == AccessMode.READ_WRITE
72
-
73
- def o_ElementInterface_c_is_private(self) -> bool:
74
- return self.__jinfo.access_mode == AccessMode.PRIVATE
75
-
76
- def o_ElementInterface_c_is_readable(self, caller_id: UUID) -> bool:
77
- return caller_id == self.owner_id or (self.is_public_read() or (caller_id in self.ro_access or caller_id in self.rw_access))
78
-
79
- def o_ElementInterface_c_is_writable(self, caller_id: UUID) -> bool:
80
- return caller_id == self.owner_id or (self.is_public_write() or caller_id in self.rw_access)
81
-
82
- def o_ElementInterface_c_give_access(self, caller_id: UUID, read_write: bool=False) -> None:
83
- if read_write:
84
- self.rw_access.add(caller_id)
85
- else:
86
- add.ro_access.self(caller_id)
87
-
88
- def o_ElementInterface_c_revoke_access(self, caller_id: UUID) -> None:
89
- self.ro_access.discard(caller_id)
90
- self.rw_access.discard(caller_id)
91
-
92
- def o_DataSpatialInterface_c_on_entry(cls: type, triggers: list) -> None:
93
-
94
- def decorator(func: callable) -> callable:
95
- cls.ds_entry_funcs.append({'types': triggers, 'func': func})
96
-
97
- def wrapper(*args: list, **kwargs: dict) -> callable:
98
- return func(*args, **kwargs)
99
- return wrapper
100
- return decorator
101
-
102
- def o_DataSpatialInterface_c_on_exit(cls: type, triggers: list) -> None:
103
-
104
- def decorator(func: callable) -> callable:
105
- cls.ds_exit_funcs.append({'types': triggers, 'func': func})
106
-
107
- def wrapper(*args: list, **kwargs: dict) -> callable:
108
- return func(*args, **kwargs)
109
- return wrapper
110
- return decorator
111
-
112
- def o_NodeInterface_c_connect_node(self, nd: Node, edg: Edge) -> Node:
113
- edg.attach(self.py_obj, nd)
114
- return self
115
-
116
- def o_NodeInterface_c_edges_to_nodes(self, dir: EdgeDir) -> list[Node]:
117
- ret_nodes = []
118
- if dir in [EdgeDir.OUT, EdgeDir.ANY]:
119
- for i in self.edges[EdgeDir.OUT]:
120
- ret_nodes.append(i.target)
121
- elif dir in [EdgeDir.IN, EdgeDir.ANY]:
122
- for i in self.edges[EdgeDir.IN]:
123
- ret_nodes.append(i.source)
124
- return ret_nodes
125
-
126
- def o_EdgeInterface_c_apply_dir(self, dir: EdgeDir) -> Edge:
127
- self.dir = dir
128
- return self
129
-
130
- def o_EdgeInterface_c_attach(self, src: Node, trg: Node) -> Edge:
131
- if self.dir == EdgeDir.IN:
132
- self.source = trg
133
- self.target = src
134
- src._jac_.edges[EdgeDir.IN].append(self)
135
- trg._jac_.edges[EdgeDir.OUT].append(self)
136
- else:
137
- self.source = src
138
- self.target = trg
139
- src._jac_.edges[EdgeDir.OUT].append(self)
140
- trg._jac_.edges[EdgeDir.IN].append(self)
141
- return self
142
-
143
- def o_WalkerInterface_c_visit_node(self, nds: list[Node] | (list[Edge] | (Node | Edge))) -> None:
144
- if isinstance(nds, list):
145
- for i in nds:
146
- if i not in self.ignores:
147
- self.next.append(i)
148
- elif nds not in self.ignores:
149
- self.next.append(nds)
150
- return len(nds) if isinstance(nds, list) else 1
151
-
152
- def o_WalkerInterface_c_ignore_node(self, nds: list[Node] | (list[Edge] | (Node | Edge))) -> None:
153
- if isinstance(nds, list):
154
- for i in nds:
155
- self.ignores.append(i)
156
- else:
157
- self.ignores.append(nds)
158
-
159
- def o_WalkerInterface_c_disengage_now(self) -> None:
160
- self.next = []
161
- self.disengaged = True
162
-
163
- def o_NodeInterface_c___call__(self, walk: Walker) -> None:
164
- if not isinstance(walk, Walker):
165
- raise TypeError('Argument must be a Walker instance')
166
- walk(self)
167
-
168
- def o_EdgeInterface_c___call__(self, walk: Walker) -> None:
169
- if not isinstance(walk, Walker):
170
- raise TypeError('Argument must be a Walker instance')
171
- walk(self._jac_.target)
172
-
173
- def o_WalkerInterface_c___call__(self, nd: Node) -> None:
174
- self._jac_.path = []
175
- self._jac_.next = [nd]
176
- walker_type = self.__class__.__name__
177
- while len(self._jac_.next):
178
- nd = self._jac_.next.pop(0)
179
- node_type = nd.__class__.__name__
180
- for i in nd._jac_ds_.ds_entry_funcs:
181
- if i['func'].__qualname__.split('.')[0] == node_type and type(self) in i['types']:
182
- i['func'](nd, self)
183
- if self._jac_.disengaged:
184
- return
185
- for i in self._jac_ds_.ds_entry_funcs:
186
- if i['func'].__qualname__.split('.')[0] == walker_type and (type(nd) in i['types'] or nd in i['types']):
187
- i['func'](self, nd)
188
- if self._jac_.disengaged:
189
- return
190
- for i in self._jac_ds_.ds_exit_funcs:
191
- if i['func'].__qualname__.split('.')[0] == walker_type and (type(nd) in i['types'] or nd in i['types']):
192
- i['func'](self, nd)
193
- if self._jac_.disengaged:
194
- return
195
- for i in nd._jac_ds_.ds_exit_funcs:
196
- if i['func'].__qualname__.split('.')[0] == node_type and type(self) in i['types']:
197
- i['func'](nd, self)
198
- if self._jac_.disengaged:
199
- return
200
- self._jac_.path.append(nd)
201
- self._jac_.ignores = []
202
-
203
- @hookimpl
204
- def o_JacPlugin_c_bind_architype(arch: AT, arch_type: str) -> bool:
205
- match arch_type:
206
- case 'obj':
207
- arch._jac_ = ObjectInterface()
208
- case 'node':
209
- arch._jac_ = NodeInterface()
210
- case 'edge':
211
- arch._jac_ = EdgeInterface()
212
- case 'walker':
213
- arch._jac_ = WalkerInterface()
214
- case _:
215
- raise TypeError('Invalid archetype type')
216
- return True
217
-
218
- @hookimpl
219
- def o_JacPlugin_c_get_root() -> None:
220
- return exec_ctx.get_root()
@@ -1,317 +0,0 @@
1
- """Jac's Key Elemental Abstractions"""
2
-
3
- import:py sys;
4
- import:py from uuid, UUID, uuid4;
5
- import:py from jaclang.jac.constant, EdgeDir;
6
- import:py from jaclang.jac.plugin, hookimpl;
7
-
8
- :obj:Memory:can:get_obj
9
- (caller_id: UUID, item_id: UUID, override: bool = False) -> Element {
10
- ret = item_id |> <self>.index.get;
11
- if override or (ret is not None and caller_id |> ret.__is_readable) {
12
- return ret;
13
- }
14
- }
15
-
16
- :obj:Memory:can:has_obj
17
- (item_id: UUID) -> bool {
18
- return item_id in <self>.index;
19
- }
20
-
21
- :obj:Memory:can:save_obj
22
- (caller_id: UUID, item: Element) {
23
- if caller_id |> item.is_writable {
24
- <self>.index[item.id] = item;
25
- if item._persist {
26
- item |> <self>.save_obj_list.add;
27
- }
28
- }
29
- <self>.mem[item.id] = item;
30
- if item._persist {
31
- item |> <self>.save_obj_list.add;
32
- }
33
- }
34
-
35
- :obj:Memory:can:del_obj
36
- (caller_id: UUID, item: Element) {
37
- if caller_id |> item.is_writable {
38
- <self>.index.pop(item.id);
39
- if item._persist {
40
- item |> <self>.save_obj_list.remove;
41
- }
42
- }
43
- }
44
-
45
- :obj:Memory:can:get_object_distribution -> dict {
46
- dist = {};
47
- for i in |> <self>.index.keys {
48
- t = <self>.index[i] |> type;
49
- if t in dist {
50
- dist[t] += 1;
51
- }
52
- else {
53
- dist[t] = 1;
54
- }
55
- }
56
- return dist;
57
- }
58
-
59
- :obj:Memory:can:get_mem_size -> float {
60
- return (<self>.index |> sys.getsizeof) / 1024.0;
61
- }
62
-
63
- :obj:ExecutionContext:c:get_root
64
- () {
65
- if <self>.master :> type == UUID {
66
- <self>.master = Master();
67
- }
68
- return <self>.master.root_node;
69
- }
70
-
71
- :obj:ExecutionContext:c:reset {
72
- <self>.<init>();
73
- }
74
-
75
- """Implementation for Jac's Element Abstractions"""
76
-
77
- :enum:AccessMode {
78
- READ_ONLY,
79
- READ_WRITE,
80
- PRIVATE
81
- }
82
-
83
- :obj:ElementInterface:can:make_public_ro {
84
- <self>.__jinfo.access_mode = AccessMode.READ_ONLY;
85
- }
86
-
87
- :obj:ElementInterface:can:make_public_rw {
88
- <self>.__jinfo.access_mode = AccessMode.READ_WRITE;
89
- }
90
-
91
- :obj:ElementInterface:can:make_private {
92
- <self>.__jinfo.access_mode = AccessMode.PRIVATE;
93
- }
94
-
95
- :obj:ElementInterface:can:is_public_ro -> bool {
96
- return <self>.__jinfo.access_mode == AccessMode.READ_ONLY;
97
- }
98
-
99
- :obj:ElementInterface:can:is_public_rw -> bool {
100
- return <self>.__jinfo.access_mode == AccessMode.READ_WRITE;
101
- }
102
-
103
- :obj:ElementInterface:can:is_private -> bool {
104
- return <self>.__jinfo.access_mode == AccessMode.PRIVATE;
105
- }
106
-
107
- :obj:ElementInterface:can:is_readable
108
- (caller_id: UUID) -> bool {
109
- return (
110
- caller_id == <self>.owner_id
111
- or |> <self>.is_public_read
112
- or caller_id in <self>.ro_access
113
- or caller_id in <self>.rw_access
114
- );
115
- }
116
-
117
- :obj:ElementInterface:can:is_writable
118
- (caller_id: UUID) -> bool {
119
- return (
120
- caller_id == <self>.owner_id
121
- or |> <self>.is_public_write
122
- or caller_id in <self>.rw_access
123
- );
124
- }
125
-
126
- :obj:ElementInterface:can:give_access
127
- (caller_id: UUID, read_write: bool = False) {
128
- if read_write {
129
- caller_id |> <self>.rw_access.add;
130
- }
131
- else {
132
- caller_id |> add .> ro_access .> <self>;
133
- }
134
- }
135
-
136
- :obj:ElementInterface:can:revoke_access
137
- (caller_id: UUID) {
138
- caller_id |> <self>.ro_access.discard;
139
- caller_id |> <self>.rw_access.discard;
140
- }
141
-
142
-
143
- :obj:DataSpatialInterface:can:on_entry
144
- (cls: type, triggers: list) {
145
- can decorator(func: callable) -> callable {
146
- cls.ds_entry_funcs.append({'types': triggers, 'func': func});
147
- can wrapper(*args: list, **kwargs: dict) -> callable {
148
- return func(*args, **kwargs);
149
- }
150
- return wrapper;
151
- }
152
- return decorator;
153
- }
154
-
155
- :obj:DataSpatialInterface:can:on_exit
156
- (cls: type, triggers: list) {
157
- can decorator(func: callable) -> callable {
158
- cls.ds_exit_funcs.append({'types': triggers, 'func': func});
159
- can wrapper(*args: list, **kwargs: dict) -> callable {
160
- return func(*args, **kwargs);
161
- }
162
- return wrapper;
163
- }
164
- return decorator;
165
- }
166
-
167
- :obj:NodeInterface:can:connect_node
168
- (nd: Node, edg: Edge) -> Node {
169
- (<self>.py_obj, nd) :> edg.attach;
170
- return <self>;
171
- }
172
-
173
- :obj:NodeInterface:can:edges_to_nodes
174
- (dir: EdgeDir) -> list[Node] {
175
- ret_nodes = [];
176
- if dir in [EdgeDir.OUT, EdgeDir.ANY] {
177
- for i in <self>.edges[EdgeDir.OUT] {
178
- ret_nodes.append(i.target);
179
- }
180
- } elif dir in [EdgeDir.IN, EdgeDir.ANY] {
181
- for i in <self>.edges[EdgeDir.IN] {
182
- ret_nodes.append(i.source);
183
- }
184
- }
185
- return ret_nodes;
186
- }
187
-
188
- :obj:EdgeInterface:can:apply_dir
189
- (dir: EdgeDir) -> Edge {
190
- <self>.dir = dir;
191
- return <self>;
192
- }
193
-
194
- :obj:EdgeInterface:can:attach
195
- (src: Node, trg: Node) -> Edge {
196
- if <self>.dir == EdgeDir.IN {
197
- <self>.source = trg;
198
- <self>.target = src;
199
- <self> :> src._jac_.edges[EdgeDir.IN].append;
200
- <self> :> trg._jac_.edges[EdgeDir.OUT].append;
201
- } else {
202
- <self>.source = src;
203
- <self>.target = trg;
204
- <self> :> src._jac_.edges[EdgeDir.OUT].append;
205
- <self> :> trg._jac_.edges[EdgeDir.IN].append;
206
- }
207
-
208
- return <self>;
209
- }
210
-
211
- :obj:WalkerInterface:can:visit_node
212
- (nds: list[Node]|list[Edge]|Node|Edge) {
213
- if isinstance(nds, list) {
214
- for i in nds {
215
- if(i not in <self>.ignores) { i :> <self>.next.append; }
216
- }
217
- } elif nds not in <self>.ignores { nds :> <self>.next.append; }
218
- return len(nds) if isinstance(nds, list) else 1;
219
- }
220
-
221
- :obj:WalkerInterface:can:ignore_node
222
- (nds: list[Node]|list[Edge]|Node|Edge) {
223
- if isinstance(nds, list) {
224
- for i in nds {
225
- i :> <self>.ignores.append;
226
- }
227
- } else { nds :> <self>.ignores.append; }
228
- }
229
-
230
- :obj:WalkerInterface:can:disengage_now {
231
- <self>.next = [];
232
- <self>.disengaged = True;
233
- }
234
-
235
-
236
- :obj:NodeInterface:can:__call__
237
- (walk: Walker) {
238
- if not (walk, Walker) :> isinstance {
239
- raise ("Argument must be a Walker instance") :> TypeError;
240
- }
241
- <self> :> walk;
242
- }
243
-
244
-
245
- :obj:EdgeInterface:can:__call__
246
- (walk: Walker) {
247
- if not (walk, Walker) :> isinstance {
248
- raise ("Argument must be a Walker instance") :> TypeError;
249
- }
250
- <self>._jac_.target :> walk;
251
- }
252
-
253
- :obj:WalkerInterface:can:__call__
254
- (nd: Node) {
255
- <self>._jac_.path = [];
256
- <self>._jac_.next = [nd];
257
- walker_type = <self>.__class__.__name__;
258
- while <self>._jac_.next :> len {
259
- nd = 0 :> <self>._jac_.next.pop;
260
- node_type = nd.__class__.__name__;
261
-
262
- for i in nd._jac_ds_.ds_entry_funcs {
263
- if i['func'].__qualname__.split(".")[0] == node_type and
264
- <self>:>type in i['types'] {
265
- (nd, <self>) :> i['func'];
266
- }
267
- if <self>._jac_.disengaged {return;}
268
- }
269
- for i in <self>._jac_ds_.ds_entry_funcs {
270
- if i['func'].__qualname__.split(".")[0] == walker_type and
271
- (nd:>type in i['types'] or nd in i['types']) { # if nd==root direct chec
272
- (<self>, nd) :> i['func'];
273
- }
274
- if <self>._jac_.disengaged {return;}
275
- }
276
- for i in <self>._jac_ds_.ds_exit_funcs {
277
- if i['func'].__qualname__.split(".")[0] == walker_type and
278
- (nd:>type in i['types'] or nd in i['types']) {
279
- (<self>, nd) :> i['func'];
280
- }
281
- if <self>._jac_.disengaged {return;}
282
- }
283
- for i in nd._jac_ds_.ds_exit_funcs {
284
- if i['func'].__qualname__.split(".")[0] == node_type and
285
- <self>:>type in i['types'] {
286
- (nd, <self>) :> i['func'];
287
- }
288
- if <self>._jac_.disengaged {return;}
289
- }
290
- nd :> <self>._jac_.path.append;
291
- }
292
- <self>._jac_.ignores=[];
293
- }
294
-
295
- @hookimpl
296
- :obj:JacPlugin:can:bind_architype
297
- (arch: AT, arch_type: str) -> bool {
298
- match arch_type {
299
- case 'obj':
300
- arch._jac_ = ObjectInterface();
301
- case 'node':
302
- arch._jac_ = NodeInterface();
303
- case 'edge':
304
- arch._jac_ = EdgeInterface();
305
- case 'walker':
306
- arch._jac_ = WalkerInterface();
307
- case _:
308
- raise ("Invalid archetype type") :> TypeError;
309
- }
310
- return True;
311
- }
312
-
313
- @hookimpl
314
- :obj:JacPlugin:can:get_root
315
- () -> None {
316
- return exec_ctx.get_root();
317
- }