1 | from asdl import pybase
|
2 | from mycpp import mops
|
3 | from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
|
4 |
|
5 | if TYPE_CHECKING:
|
6 | from _devbuild.gen.syntax_asdl import loc_t, Token, expr_t, command_t, DoubleQuoted, re_t, proc_sig_t, LiteralBlock, Func, NameType, EggexFlag
|
7 | from _devbuild.gen.runtime_asdl import Cell
|
8 |
|
9 |
|
10 | from asdl import runtime # For runtime.NO_SPID
|
11 | from asdl.runtime import NewRecord, NewLeaf, TraversalState
|
12 | from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
|
13 |
|
14 | class y_lvalue_e(object):
|
15 | Local = 66
|
16 | Container = 2
|
17 |
|
18 | _y_lvalue_str = {
|
19 | 2: 'Container',
|
20 | 66: 'Local',
|
21 | }
|
22 |
|
23 | def y_lvalue_str(tag, dot=True):
|
24 | # type: (int, bool) -> str
|
25 | v = _y_lvalue_str[tag]
|
26 | if dot:
|
27 | return "y_lvalue.%s" % v
|
28 | else:
|
29 | return v
|
30 |
|
31 | class y_lvalue_t(pybase.CompoundObj):
|
32 | def tag(self):
|
33 | # type: () -> int
|
34 | return self._type_tag
|
35 | pass
|
36 |
|
37 | class y_lvalue(object):
|
38 | class Container(y_lvalue_t):
|
39 | _type_tag = 2
|
40 | __slots__ = ('obj', 'index')
|
41 |
|
42 | def __init__(self, obj, index):
|
43 | # type: (value_t, value_t) -> None
|
44 | self.obj = obj
|
45 | self.index = index
|
46 |
|
47 | @staticmethod
|
48 | def CreateNull(alloc_lists=False):
|
49 | # type: () -> y_lvalue.Container
|
50 | return y_lvalue.Container(cast(value_t, None), cast(value_t, None))
|
51 |
|
52 | def PrettyTree(self, trav=None):
|
53 | # type: (Optional[TraversalState]) -> hnode_t
|
54 | trav = trav or TraversalState()
|
55 | heap_id = id(self)
|
56 | if heap_id in trav.seen:
|
57 | return hnode.AlreadySeen(heap_id)
|
58 | trav.seen[heap_id] = True
|
59 | out_node = NewRecord('y_lvalue.Container')
|
60 | L = out_node.fields
|
61 |
|
62 | assert self.obj is not None
|
63 | x0 = self.obj.PrettyTree(trav=trav)
|
64 | L.append(Field('obj', x0))
|
65 |
|
66 | assert self.index is not None
|
67 | x1 = self.index.PrettyTree(trav=trav)
|
68 | L.append(Field('index', x1))
|
69 |
|
70 | return out_node
|
71 |
|
72 | def _AbbreviatedTree(self, trav=None):
|
73 | # type: (Optional[TraversalState]) -> hnode_t
|
74 | trav = trav or TraversalState()
|
75 | heap_id = id(self)
|
76 | if heap_id in trav.seen:
|
77 | return hnode.AlreadySeen(heap_id)
|
78 | trav.seen[heap_id] = True
|
79 | out_node = NewRecord('y_lvalue.Container')
|
80 | L = out_node.fields
|
81 | assert self.obj is not None
|
82 | x0 = self.obj.AbbreviatedTree(trav=trav)
|
83 | L.append(Field('obj', x0))
|
84 |
|
85 | assert self.index is not None
|
86 | x1 = self.index.AbbreviatedTree(trav=trav)
|
87 | L.append(Field('index', x1))
|
88 |
|
89 | return out_node
|
90 |
|
91 | def AbbreviatedTree(self, trav=None):
|
92 | # type: (Optional[TraversalState]) -> hnode_t
|
93 | return self._AbbreviatedTree(trav=trav)
|
94 |
|
95 | pass
|
96 |
|
97 | class sh_lvalue_e(object):
|
98 | Var = 66
|
99 | Indexed = 2
|
100 | Keyed = 3
|
101 |
|
102 | _sh_lvalue_str = {
|
103 | 2: 'Indexed',
|
104 | 3: 'Keyed',
|
105 | 66: 'Var',
|
106 | }
|
107 |
|
108 | def sh_lvalue_str(tag, dot=True):
|
109 | # type: (int, bool) -> str
|
110 | v = _sh_lvalue_str[tag]
|
111 | if dot:
|
112 | return "sh_lvalue.%s" % v
|
113 | else:
|
114 | return v
|
115 |
|
116 | class sh_lvalue_t(pybase.CompoundObj):
|
117 | def tag(self):
|
118 | # type: () -> int
|
119 | return self._type_tag
|
120 | pass
|
121 |
|
122 | class sh_lvalue(object):
|
123 | class Indexed(sh_lvalue_t):
|
124 | _type_tag = 2
|
125 | __slots__ = ('name', 'index', 'blame_loc')
|
126 |
|
127 | def __init__(self, name, index, blame_loc):
|
128 | # type: (str, int, loc_t) -> None
|
129 | self.name = name
|
130 | self.index = index
|
131 | self.blame_loc = blame_loc
|
132 |
|
133 | @staticmethod
|
134 | def CreateNull(alloc_lists=False):
|
135 | # type: () -> sh_lvalue.Indexed
|
136 | return sh_lvalue.Indexed('', -1, cast(loc_t, None))
|
137 |
|
138 | def PrettyTree(self, trav=None):
|
139 | # type: (Optional[TraversalState]) -> hnode_t
|
140 | trav = trav or TraversalState()
|
141 | heap_id = id(self)
|
142 | if heap_id in trav.seen:
|
143 | return hnode.AlreadySeen(heap_id)
|
144 | trav.seen[heap_id] = True
|
145 | out_node = NewRecord('sh_lvalue.Indexed')
|
146 | L = out_node.fields
|
147 |
|
148 | x0 = NewLeaf(self.name, color_e.StringConst)
|
149 | L.append(Field('name', x0))
|
150 |
|
151 | x1 = hnode.Leaf(str(self.index), color_e.OtherConst)
|
152 | L.append(Field('index', x1))
|
153 |
|
154 | assert self.blame_loc is not None
|
155 | x2 = self.blame_loc.PrettyTree(trav=trav)
|
156 | L.append(Field('blame_loc', x2))
|
157 |
|
158 | return out_node
|
159 |
|
160 | def _AbbreviatedTree(self, trav=None):
|
161 | # type: (Optional[TraversalState]) -> hnode_t
|
162 | trav = trav or TraversalState()
|
163 | heap_id = id(self)
|
164 | if heap_id in trav.seen:
|
165 | return hnode.AlreadySeen(heap_id)
|
166 | trav.seen[heap_id] = True
|
167 | out_node = NewRecord('sh_lvalue.Indexed')
|
168 | L = out_node.fields
|
169 | x0 = NewLeaf(self.name, color_e.StringConst)
|
170 | L.append(Field('name', x0))
|
171 |
|
172 | x1 = hnode.Leaf(str(self.index), color_e.OtherConst)
|
173 | L.append(Field('index', x1))
|
174 |
|
175 | assert self.blame_loc is not None
|
176 | x2 = self.blame_loc.AbbreviatedTree(trav=trav)
|
177 | L.append(Field('blame_loc', x2))
|
178 |
|
179 | return out_node
|
180 |
|
181 | def AbbreviatedTree(self, trav=None):
|
182 | # type: (Optional[TraversalState]) -> hnode_t
|
183 | return self._AbbreviatedTree(trav=trav)
|
184 |
|
185 | class Keyed(sh_lvalue_t):
|
186 | _type_tag = 3
|
187 | __slots__ = ('name', 'key', 'blame_loc')
|
188 |
|
189 | def __init__(self, name, key, blame_loc):
|
190 | # type: (str, str, loc_t) -> None
|
191 | self.name = name
|
192 | self.key = key
|
193 | self.blame_loc = blame_loc
|
194 |
|
195 | @staticmethod
|
196 | def CreateNull(alloc_lists=False):
|
197 | # type: () -> sh_lvalue.Keyed
|
198 | return sh_lvalue.Keyed('', '', cast(loc_t, None))
|
199 |
|
200 | def PrettyTree(self, trav=None):
|
201 | # type: (Optional[TraversalState]) -> hnode_t
|
202 | trav = trav or TraversalState()
|
203 | heap_id = id(self)
|
204 | if heap_id in trav.seen:
|
205 | return hnode.AlreadySeen(heap_id)
|
206 | trav.seen[heap_id] = True
|
207 | out_node = NewRecord('sh_lvalue.Keyed')
|
208 | L = out_node.fields
|
209 |
|
210 | x0 = NewLeaf(self.name, color_e.StringConst)
|
211 | L.append(Field('name', x0))
|
212 |
|
213 | x1 = NewLeaf(self.key, color_e.StringConst)
|
214 | L.append(Field('key', x1))
|
215 |
|
216 | assert self.blame_loc is not None
|
217 | x2 = self.blame_loc.PrettyTree(trav=trav)
|
218 | L.append(Field('blame_loc', x2))
|
219 |
|
220 | return out_node
|
221 |
|
222 | def _AbbreviatedTree(self, trav=None):
|
223 | # type: (Optional[TraversalState]) -> hnode_t
|
224 | trav = trav or TraversalState()
|
225 | heap_id = id(self)
|
226 | if heap_id in trav.seen:
|
227 | return hnode.AlreadySeen(heap_id)
|
228 | trav.seen[heap_id] = True
|
229 | out_node = NewRecord('sh_lvalue.Keyed')
|
230 | L = out_node.fields
|
231 | x0 = NewLeaf(self.name, color_e.StringConst)
|
232 | L.append(Field('name', x0))
|
233 |
|
234 | x1 = NewLeaf(self.key, color_e.StringConst)
|
235 | L.append(Field('key', x1))
|
236 |
|
237 | assert self.blame_loc is not None
|
238 | x2 = self.blame_loc.AbbreviatedTree(trav=trav)
|
239 | L.append(Field('blame_loc', x2))
|
240 |
|
241 | return out_node
|
242 |
|
243 | def AbbreviatedTree(self, trav=None):
|
244 | # type: (Optional[TraversalState]) -> hnode_t
|
245 | return self._AbbreviatedTree(trav=trav)
|
246 |
|
247 | pass
|
248 |
|
249 | class eggex_ops_e(object):
|
250 | No = 1
|
251 | Yes = 2
|
252 |
|
253 | _eggex_ops_str = {
|
254 | 1: 'No',
|
255 | 2: 'Yes',
|
256 | }
|
257 |
|
258 | def eggex_ops_str(tag, dot=True):
|
259 | # type: (int, bool) -> str
|
260 | v = _eggex_ops_str[tag]
|
261 | if dot:
|
262 | return "eggex_ops.%s" % v
|
263 | else:
|
264 | return v
|
265 |
|
266 | class eggex_ops_t(pybase.CompoundObj):
|
267 | def tag(self):
|
268 | # type: () -> int
|
269 | return self._type_tag
|
270 | pass
|
271 |
|
272 | class eggex_ops__No(eggex_ops_t):
|
273 | _type_tag = 1
|
274 | __slots__ = ()
|
275 |
|
276 | def __init__(self, ):
|
277 | # type: () -> None
|
278 | pass
|
279 |
|
280 | def PrettyTree(self, trav=None):
|
281 | # type: (Optional[TraversalState]) -> hnode_t
|
282 | trav = trav or TraversalState()
|
283 | heap_id = id(self)
|
284 | if heap_id in trav.seen:
|
285 | return hnode.AlreadySeen(heap_id)
|
286 | trav.seen[heap_id] = True
|
287 | out_node = NewRecord('eggex_ops__No')
|
288 | L = out_node.fields
|
289 |
|
290 | return out_node
|
291 |
|
292 | def _AbbreviatedTree(self, trav=None):
|
293 | # type: (Optional[TraversalState]) -> hnode_t
|
294 | trav = trav or TraversalState()
|
295 | heap_id = id(self)
|
296 | if heap_id in trav.seen:
|
297 | return hnode.AlreadySeen(heap_id)
|
298 | trav.seen[heap_id] = True
|
299 | out_node = NewRecord('eggex_ops__No')
|
300 | L = out_node.fields
|
301 | return out_node
|
302 |
|
303 | def AbbreviatedTree(self, trav=None):
|
304 | # type: (Optional[TraversalState]) -> hnode_t
|
305 | return self._AbbreviatedTree(trav=trav)
|
306 |
|
307 | class eggex_ops(object):
|
308 | No = eggex_ops__No()
|
309 |
|
310 | class Yes(eggex_ops_t):
|
311 | _type_tag = 2
|
312 | __slots__ = ('convert_funcs', 'convert_toks', 'capture_names')
|
313 |
|
314 | def __init__(self, convert_funcs, convert_toks, capture_names):
|
315 | # type: (List[Optional[value_t]], List[Optional[Token]], List[Optional[str]]) -> None
|
316 | self.convert_funcs = convert_funcs
|
317 | self.convert_toks = convert_toks
|
318 | self.capture_names = capture_names
|
319 |
|
320 | @staticmethod
|
321 | def CreateNull(alloc_lists=False):
|
322 | # type: () -> eggex_ops.Yes
|
323 | return eggex_ops.Yes([] if alloc_lists else cast('List[Optional[value_t]]', None), [] if alloc_lists else cast('List[Optional[Token]]', None), [] if alloc_lists else cast('List[Optional[str]]', None))
|
324 |
|
325 | def PrettyTree(self, trav=None):
|
326 | # type: (Optional[TraversalState]) -> hnode_t
|
327 | trav = trav or TraversalState()
|
328 | heap_id = id(self)
|
329 | if heap_id in trav.seen:
|
330 | return hnode.AlreadySeen(heap_id)
|
331 | trav.seen[heap_id] = True
|
332 | out_node = NewRecord('eggex_ops.Yes')
|
333 | L = out_node.fields
|
334 |
|
335 | if self.convert_funcs is not None: # List
|
336 | x0 = hnode.Array([])
|
337 | for i0 in self.convert_funcs:
|
338 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
339 | i0.PrettyTree(trav=trav))
|
340 | x0.children.append(h)
|
341 | L.append(Field('convert_funcs', x0))
|
342 |
|
343 | if self.convert_toks is not None: # List
|
344 | x1 = hnode.Array([])
|
345 | for i1 in self.convert_toks:
|
346 | h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
|
347 | i1.PrettyTree(trav=trav))
|
348 | x1.children.append(h)
|
349 | L.append(Field('convert_toks', x1))
|
350 |
|
351 | if self.capture_names is not None: # List
|
352 | x2 = hnode.Array([])
|
353 | for i2 in self.capture_names:
|
354 | x2.children.append(NewLeaf(i2, color_e.StringConst))
|
355 | L.append(Field('capture_names', x2))
|
356 |
|
357 | return out_node
|
358 |
|
359 | def _AbbreviatedTree(self, trav=None):
|
360 | # type: (Optional[TraversalState]) -> hnode_t
|
361 | trav = trav or TraversalState()
|
362 | heap_id = id(self)
|
363 | if heap_id in trav.seen:
|
364 | return hnode.AlreadySeen(heap_id)
|
365 | trav.seen[heap_id] = True
|
366 | out_node = NewRecord('eggex_ops.Yes')
|
367 | L = out_node.fields
|
368 | if self.convert_funcs is not None: # List
|
369 | x0 = hnode.Array([])
|
370 | for i0 in self.convert_funcs:
|
371 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
372 | i0.AbbreviatedTree(trav=trav))
|
373 | x0.children.append(h)
|
374 | L.append(Field('convert_funcs', x0))
|
375 |
|
376 | if self.convert_toks is not None: # List
|
377 | x1 = hnode.Array([])
|
378 | for i1 in self.convert_toks:
|
379 | h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
|
380 | i1.AbbreviatedTree(trav=trav))
|
381 | x1.children.append(h)
|
382 | L.append(Field('convert_toks', x1))
|
383 |
|
384 | if self.capture_names is not None: # List
|
385 | x2 = hnode.Array([])
|
386 | for i2 in self.capture_names:
|
387 | x2.children.append(NewLeaf(i2, color_e.StringConst))
|
388 | L.append(Field('capture_names', x2))
|
389 |
|
390 | return out_node
|
391 |
|
392 | def AbbreviatedTree(self, trav=None):
|
393 | # type: (Optional[TraversalState]) -> hnode_t
|
394 | return self._AbbreviatedTree(trav=trav)
|
395 |
|
396 | pass
|
397 |
|
398 | class regex_match_e(object):
|
399 | No = 1
|
400 | Yes = 67
|
401 |
|
402 | _regex_match_str = {
|
403 | 1: 'No',
|
404 | 67: 'Yes',
|
405 | }
|
406 |
|
407 | def regex_match_str(tag, dot=True):
|
408 | # type: (int, bool) -> str
|
409 | v = _regex_match_str[tag]
|
410 | if dot:
|
411 | return "regex_match.%s" % v
|
412 | else:
|
413 | return v
|
414 |
|
415 | class regex_match_t(pybase.CompoundObj):
|
416 | def tag(self):
|
417 | # type: () -> int
|
418 | return self._type_tag
|
419 | pass
|
420 |
|
421 | class regex_match__No(regex_match_t):
|
422 | _type_tag = 1
|
423 | __slots__ = ()
|
424 |
|
425 | def __init__(self, ):
|
426 | # type: () -> None
|
427 | pass
|
428 |
|
429 | def PrettyTree(self, trav=None):
|
430 | # type: (Optional[TraversalState]) -> hnode_t
|
431 | trav = trav or TraversalState()
|
432 | heap_id = id(self)
|
433 | if heap_id in trav.seen:
|
434 | return hnode.AlreadySeen(heap_id)
|
435 | trav.seen[heap_id] = True
|
436 | out_node = NewRecord('regex_match__No')
|
437 | L = out_node.fields
|
438 |
|
439 | return out_node
|
440 |
|
441 | def _AbbreviatedTree(self, trav=None):
|
442 | # type: (Optional[TraversalState]) -> hnode_t
|
443 | trav = trav or TraversalState()
|
444 | heap_id = id(self)
|
445 | if heap_id in trav.seen:
|
446 | return hnode.AlreadySeen(heap_id)
|
447 | trav.seen[heap_id] = True
|
448 | out_node = NewRecord('regex_match__No')
|
449 | L = out_node.fields
|
450 | return out_node
|
451 |
|
452 | def AbbreviatedTree(self, trav=None):
|
453 | # type: (Optional[TraversalState]) -> hnode_t
|
454 | return self._AbbreviatedTree(trav=trav)
|
455 |
|
456 | class regex_match(object):
|
457 | No = regex_match__No()
|
458 |
|
459 | pass
|
460 |
|
461 | class value_e(object):
|
462 | Interrupted = 1
|
463 | Stdin = 2
|
464 | Undef = 3
|
465 | Str = 4
|
466 | BashArray = 5
|
467 | SparseArray = 6
|
468 | BashAssoc = 7
|
469 | Null = 8
|
470 | Bool = 9
|
471 | Int = 10
|
472 | Float = 11
|
473 | List = 12
|
474 | Dict = 13
|
475 | Obj = 68
|
476 | Eggex = 15
|
477 | Match = 67
|
478 | Expr = 17
|
479 | Command = 18
|
480 | Block = 19
|
481 | Place = 20
|
482 | Module = 21
|
483 | IO = 22
|
484 | Guts = 23
|
485 | BuiltinFunc = 24
|
486 | BoundFunc = 25
|
487 | Proc = 26
|
488 | Func = 27
|
489 | Slice = 28
|
490 | Range = 29
|
491 |
|
492 | _value_str = {
|
493 | 1: 'Interrupted',
|
494 | 2: 'Stdin',
|
495 | 3: 'Undef',
|
496 | 4: 'Str',
|
497 | 5: 'BashArray',
|
498 | 6: 'SparseArray',
|
499 | 7: 'BashAssoc',
|
500 | 8: 'Null',
|
501 | 9: 'Bool',
|
502 | 10: 'Int',
|
503 | 11: 'Float',
|
504 | 12: 'List',
|
505 | 13: 'Dict',
|
506 | 15: 'Eggex',
|
507 | 17: 'Expr',
|
508 | 18: 'Command',
|
509 | 19: 'Block',
|
510 | 20: 'Place',
|
511 | 21: 'Module',
|
512 | 22: 'IO',
|
513 | 23: 'Guts',
|
514 | 24: 'BuiltinFunc',
|
515 | 25: 'BoundFunc',
|
516 | 26: 'Proc',
|
517 | 27: 'Func',
|
518 | 28: 'Slice',
|
519 | 29: 'Range',
|
520 | 67: 'Match',
|
521 | 68: 'Obj',
|
522 | }
|
523 |
|
524 | def value_str(tag, dot=True):
|
525 | # type: (int, bool) -> str
|
526 | v = _value_str[tag]
|
527 | if dot:
|
528 | return "value.%s" % v
|
529 | else:
|
530 | return v
|
531 |
|
532 | class value_t(pybase.CompoundObj):
|
533 | def tag(self):
|
534 | # type: () -> int
|
535 | return self._type_tag
|
536 | pass
|
537 |
|
538 | class value__Interrupted(value_t):
|
539 | _type_tag = 1
|
540 | __slots__ = ()
|
541 |
|
542 | def __init__(self, ):
|
543 | # type: () -> None
|
544 | pass
|
545 |
|
546 | def PrettyTree(self, trav=None):
|
547 | # type: (Optional[TraversalState]) -> hnode_t
|
548 | trav = trav or TraversalState()
|
549 | heap_id = id(self)
|
550 | if heap_id in trav.seen:
|
551 | return hnode.AlreadySeen(heap_id)
|
552 | trav.seen[heap_id] = True
|
553 | out_node = NewRecord('value__Interrupted')
|
554 | L = out_node.fields
|
555 |
|
556 | return out_node
|
557 |
|
558 | def _AbbreviatedTree(self, trav=None):
|
559 | # type: (Optional[TraversalState]) -> hnode_t
|
560 | trav = trav or TraversalState()
|
561 | heap_id = id(self)
|
562 | if heap_id in trav.seen:
|
563 | return hnode.AlreadySeen(heap_id)
|
564 | trav.seen[heap_id] = True
|
565 | out_node = NewRecord('value__Interrupted')
|
566 | L = out_node.fields
|
567 | return out_node
|
568 |
|
569 | def AbbreviatedTree(self, trav=None):
|
570 | # type: (Optional[TraversalState]) -> hnode_t
|
571 | return self._AbbreviatedTree(trav=trav)
|
572 |
|
573 | class value__Stdin(value_t):
|
574 | _type_tag = 2
|
575 | __slots__ = ()
|
576 |
|
577 | def __init__(self, ):
|
578 | # type: () -> None
|
579 | pass
|
580 |
|
581 | def PrettyTree(self, trav=None):
|
582 | # type: (Optional[TraversalState]) -> hnode_t
|
583 | trav = trav or TraversalState()
|
584 | heap_id = id(self)
|
585 | if heap_id in trav.seen:
|
586 | return hnode.AlreadySeen(heap_id)
|
587 | trav.seen[heap_id] = True
|
588 | out_node = NewRecord('value__Stdin')
|
589 | L = out_node.fields
|
590 |
|
591 | return out_node
|
592 |
|
593 | def _AbbreviatedTree(self, trav=None):
|
594 | # type: (Optional[TraversalState]) -> hnode_t
|
595 | trav = trav or TraversalState()
|
596 | heap_id = id(self)
|
597 | if heap_id in trav.seen:
|
598 | return hnode.AlreadySeen(heap_id)
|
599 | trav.seen[heap_id] = True
|
600 | out_node = NewRecord('value__Stdin')
|
601 | L = out_node.fields
|
602 | return out_node
|
603 |
|
604 | def AbbreviatedTree(self, trav=None):
|
605 | # type: (Optional[TraversalState]) -> hnode_t
|
606 | return self._AbbreviatedTree(trav=trav)
|
607 |
|
608 | class value__Undef(value_t):
|
609 | _type_tag = 3
|
610 | __slots__ = ()
|
611 |
|
612 | def __init__(self, ):
|
613 | # type: () -> None
|
614 | pass
|
615 |
|
616 | def PrettyTree(self, trav=None):
|
617 | # type: (Optional[TraversalState]) -> hnode_t
|
618 | trav = trav or TraversalState()
|
619 | heap_id = id(self)
|
620 | if heap_id in trav.seen:
|
621 | return hnode.AlreadySeen(heap_id)
|
622 | trav.seen[heap_id] = True
|
623 | out_node = NewRecord('value__Undef')
|
624 | L = out_node.fields
|
625 |
|
626 | return out_node
|
627 |
|
628 | def _AbbreviatedTree(self, trav=None):
|
629 | # type: (Optional[TraversalState]) -> hnode_t
|
630 | trav = trav or TraversalState()
|
631 | heap_id = id(self)
|
632 | if heap_id in trav.seen:
|
633 | return hnode.AlreadySeen(heap_id)
|
634 | trav.seen[heap_id] = True
|
635 | out_node = NewRecord('value__Undef')
|
636 | L = out_node.fields
|
637 | return out_node
|
638 |
|
639 | def AbbreviatedTree(self, trav=None):
|
640 | # type: (Optional[TraversalState]) -> hnode_t
|
641 | return self._AbbreviatedTree(trav=trav)
|
642 |
|
643 | class value__Null(value_t):
|
644 | _type_tag = 8
|
645 | __slots__ = ()
|
646 |
|
647 | def __init__(self, ):
|
648 | # type: () -> None
|
649 | pass
|
650 |
|
651 | def PrettyTree(self, trav=None):
|
652 | # type: (Optional[TraversalState]) -> hnode_t
|
653 | trav = trav or TraversalState()
|
654 | heap_id = id(self)
|
655 | if heap_id in trav.seen:
|
656 | return hnode.AlreadySeen(heap_id)
|
657 | trav.seen[heap_id] = True
|
658 | out_node = NewRecord('value__Null')
|
659 | L = out_node.fields
|
660 |
|
661 | return out_node
|
662 |
|
663 | def _AbbreviatedTree(self, trav=None):
|
664 | # type: (Optional[TraversalState]) -> hnode_t
|
665 | trav = trav or TraversalState()
|
666 | heap_id = id(self)
|
667 | if heap_id in trav.seen:
|
668 | return hnode.AlreadySeen(heap_id)
|
669 | trav.seen[heap_id] = True
|
670 | out_node = NewRecord('value__Null')
|
671 | L = out_node.fields
|
672 | return out_node
|
673 |
|
674 | def AbbreviatedTree(self, trav=None):
|
675 | # type: (Optional[TraversalState]) -> hnode_t
|
676 | return self._AbbreviatedTree(trav=trav)
|
677 |
|
678 | class value(object):
|
679 | Interrupted = value__Interrupted()
|
680 |
|
681 | Stdin = value__Stdin()
|
682 |
|
683 | Undef = value__Undef()
|
684 |
|
685 | class Str(value_t):
|
686 | _type_tag = 4
|
687 | __slots__ = ('s',)
|
688 |
|
689 | def __init__(self, s):
|
690 | # type: (str) -> None
|
691 | self.s = s
|
692 |
|
693 | @staticmethod
|
694 | def CreateNull(alloc_lists=False):
|
695 | # type: () -> value.Str
|
696 | return value.Str('')
|
697 |
|
698 | def PrettyTree(self, trav=None):
|
699 | # type: (Optional[TraversalState]) -> hnode_t
|
700 | trav = trav or TraversalState()
|
701 | heap_id = id(self)
|
702 | if heap_id in trav.seen:
|
703 | return hnode.AlreadySeen(heap_id)
|
704 | trav.seen[heap_id] = True
|
705 | out_node = NewRecord('value.Str')
|
706 | L = out_node.fields
|
707 |
|
708 | x0 = NewLeaf(self.s, color_e.StringConst)
|
709 | L.append(Field('s', x0))
|
710 |
|
711 | return out_node
|
712 |
|
713 | def _AbbreviatedTree(self, trav=None):
|
714 | # type: (Optional[TraversalState]) -> hnode_t
|
715 | trav = trav or TraversalState()
|
716 | heap_id = id(self)
|
717 | if heap_id in trav.seen:
|
718 | return hnode.AlreadySeen(heap_id)
|
719 | trav.seen[heap_id] = True
|
720 | out_node = NewRecord('value.Str')
|
721 | L = out_node.fields
|
722 | x0 = NewLeaf(self.s, color_e.StringConst)
|
723 | L.append(Field('s', x0))
|
724 |
|
725 | return out_node
|
726 |
|
727 | def AbbreviatedTree(self, trav=None):
|
728 | # type: (Optional[TraversalState]) -> hnode_t
|
729 | return self._AbbreviatedTree(trav=trav)
|
730 |
|
731 | class BashArray(value_t):
|
732 | _type_tag = 5
|
733 | __slots__ = ('strs',)
|
734 |
|
735 | def __init__(self, strs):
|
736 | # type: (List[str]) -> None
|
737 | self.strs = strs
|
738 |
|
739 | @staticmethod
|
740 | def CreateNull(alloc_lists=False):
|
741 | # type: () -> value.BashArray
|
742 | return value.BashArray([] if alloc_lists else cast('List[str]', None))
|
743 |
|
744 | def PrettyTree(self, trav=None):
|
745 | # type: (Optional[TraversalState]) -> hnode_t
|
746 | trav = trav or TraversalState()
|
747 | heap_id = id(self)
|
748 | if heap_id in trav.seen:
|
749 | return hnode.AlreadySeen(heap_id)
|
750 | trav.seen[heap_id] = True
|
751 | out_node = NewRecord('value.BashArray')
|
752 | L = out_node.fields
|
753 |
|
754 | if self.strs is not None: # List
|
755 | x0 = hnode.Array([])
|
756 | for i0 in self.strs:
|
757 | x0.children.append(NewLeaf(i0, color_e.StringConst))
|
758 | L.append(Field('strs', x0))
|
759 |
|
760 | return out_node
|
761 |
|
762 | def _AbbreviatedTree(self, trav=None):
|
763 | # type: (Optional[TraversalState]) -> hnode_t
|
764 | trav = trav or TraversalState()
|
765 | heap_id = id(self)
|
766 | if heap_id in trav.seen:
|
767 | return hnode.AlreadySeen(heap_id)
|
768 | trav.seen[heap_id] = True
|
769 | out_node = NewRecord('value.BashArray')
|
770 | L = out_node.fields
|
771 | if self.strs is not None: # List
|
772 | x0 = hnode.Array([])
|
773 | for i0 in self.strs:
|
774 | x0.children.append(NewLeaf(i0, color_e.StringConst))
|
775 | L.append(Field('strs', x0))
|
776 |
|
777 | return out_node
|
778 |
|
779 | def AbbreviatedTree(self, trav=None):
|
780 | # type: (Optional[TraversalState]) -> hnode_t
|
781 | return self._AbbreviatedTree(trav=trav)
|
782 |
|
783 | class SparseArray(value_t):
|
784 | _type_tag = 6
|
785 | __slots__ = ('d', 'max_index')
|
786 |
|
787 | def __init__(self, d, max_index):
|
788 | # type: (Dict[mops.BigInt, str], mops.BigInt) -> None
|
789 | self.d = d
|
790 | self.max_index = max_index
|
791 |
|
792 | @staticmethod
|
793 | def CreateNull(alloc_lists=False):
|
794 | # type: () -> value.SparseArray
|
795 | return value.SparseArray(cast('Dict[mops.BigInt, str]', None), mops.BigInt(-1))
|
796 |
|
797 | def PrettyTree(self, trav=None):
|
798 | # type: (Optional[TraversalState]) -> hnode_t
|
799 | trav = trav or TraversalState()
|
800 | heap_id = id(self)
|
801 | if heap_id in trav.seen:
|
802 | return hnode.AlreadySeen(heap_id)
|
803 | trav.seen[heap_id] = True
|
804 | out_node = NewRecord('value.SparseArray')
|
805 | L = out_node.fields
|
806 |
|
807 | if self.d is not None: # Dict
|
808 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
809 | x0 = hnode.Array([m])
|
810 | for k0, v0 in self.d.iteritems():
|
811 | x0.children.append(hnode.Leaf(mops.ToStr(k0), color_e.OtherConst))
|
812 | x0.children.append(NewLeaf(v0, color_e.StringConst))
|
813 | L.append(Field('d', x0))
|
814 |
|
815 | x1 = hnode.Leaf(mops.ToStr(self.max_index), color_e.OtherConst)
|
816 | L.append(Field('max_index', x1))
|
817 |
|
818 | return out_node
|
819 |
|
820 | def _AbbreviatedTree(self, trav=None):
|
821 | # type: (Optional[TraversalState]) -> hnode_t
|
822 | trav = trav or TraversalState()
|
823 | heap_id = id(self)
|
824 | if heap_id in trav.seen:
|
825 | return hnode.AlreadySeen(heap_id)
|
826 | trav.seen[heap_id] = True
|
827 | out_node = NewRecord('value.SparseArray')
|
828 | L = out_node.fields
|
829 | if self.d is not None: # Dict
|
830 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
831 | x0 = hnode.Array([m])
|
832 | for k0, v0 in self.d.iteritems():
|
833 | x0.children.append(hnode.Leaf(mops.ToStr(k0), color_e.OtherConst))
|
834 | x0.children.append(NewLeaf(v0, color_e.StringConst))
|
835 | L.append(Field('d', x0))
|
836 |
|
837 | x1 = hnode.Leaf(mops.ToStr(self.max_index), color_e.OtherConst)
|
838 | L.append(Field('max_index', x1))
|
839 |
|
840 | return out_node
|
841 |
|
842 | def AbbreviatedTree(self, trav=None):
|
843 | # type: (Optional[TraversalState]) -> hnode_t
|
844 | return self._AbbreviatedTree(trav=trav)
|
845 |
|
846 | class BashAssoc(value_t):
|
847 | _type_tag = 7
|
848 | __slots__ = ('d',)
|
849 |
|
850 | def __init__(self, d):
|
851 | # type: (Dict[str, str]) -> None
|
852 | self.d = d
|
853 |
|
854 | @staticmethod
|
855 | def CreateNull(alloc_lists=False):
|
856 | # type: () -> value.BashAssoc
|
857 | return value.BashAssoc(cast('Dict[str, str]', None))
|
858 |
|
859 | def PrettyTree(self, trav=None):
|
860 | # type: (Optional[TraversalState]) -> hnode_t
|
861 | trav = trav or TraversalState()
|
862 | heap_id = id(self)
|
863 | if heap_id in trav.seen:
|
864 | return hnode.AlreadySeen(heap_id)
|
865 | trav.seen[heap_id] = True
|
866 | out_node = NewRecord('value.BashAssoc')
|
867 | L = out_node.fields
|
868 |
|
869 | if self.d is not None: # Dict
|
870 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
871 | x0 = hnode.Array([m])
|
872 | for k0, v0 in self.d.iteritems():
|
873 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
874 | x0.children.append(NewLeaf(v0, color_e.StringConst))
|
875 | L.append(Field('d', x0))
|
876 |
|
877 | return out_node
|
878 |
|
879 | def _AbbreviatedTree(self, trav=None):
|
880 | # type: (Optional[TraversalState]) -> hnode_t
|
881 | trav = trav or TraversalState()
|
882 | heap_id = id(self)
|
883 | if heap_id in trav.seen:
|
884 | return hnode.AlreadySeen(heap_id)
|
885 | trav.seen[heap_id] = True
|
886 | out_node = NewRecord('value.BashAssoc')
|
887 | L = out_node.fields
|
888 | if self.d is not None: # Dict
|
889 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
890 | x0 = hnode.Array([m])
|
891 | for k0, v0 in self.d.iteritems():
|
892 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
893 | x0.children.append(NewLeaf(v0, color_e.StringConst))
|
894 | L.append(Field('d', x0))
|
895 |
|
896 | return out_node
|
897 |
|
898 | def AbbreviatedTree(self, trav=None):
|
899 | # type: (Optional[TraversalState]) -> hnode_t
|
900 | return self._AbbreviatedTree(trav=trav)
|
901 |
|
902 | Null = value__Null()
|
903 |
|
904 | class Bool(value_t):
|
905 | _type_tag = 9
|
906 | __slots__ = ('b',)
|
907 |
|
908 | def __init__(self, b):
|
909 | # type: (bool) -> None
|
910 | self.b = b
|
911 |
|
912 | @staticmethod
|
913 | def CreateNull(alloc_lists=False):
|
914 | # type: () -> value.Bool
|
915 | return value.Bool(False)
|
916 |
|
917 | def PrettyTree(self, trav=None):
|
918 | # type: (Optional[TraversalState]) -> hnode_t
|
919 | trav = trav or TraversalState()
|
920 | heap_id = id(self)
|
921 | if heap_id in trav.seen:
|
922 | return hnode.AlreadySeen(heap_id)
|
923 | trav.seen[heap_id] = True
|
924 | out_node = NewRecord('value.Bool')
|
925 | L = out_node.fields
|
926 |
|
927 | x0 = hnode.Leaf('T' if self.b else 'F', color_e.OtherConst)
|
928 | L.append(Field('b', x0))
|
929 |
|
930 | return out_node
|
931 |
|
932 | def _AbbreviatedTree(self, trav=None):
|
933 | # type: (Optional[TraversalState]) -> hnode_t
|
934 | trav = trav or TraversalState()
|
935 | heap_id = id(self)
|
936 | if heap_id in trav.seen:
|
937 | return hnode.AlreadySeen(heap_id)
|
938 | trav.seen[heap_id] = True
|
939 | out_node = NewRecord('value.Bool')
|
940 | L = out_node.fields
|
941 | x0 = hnode.Leaf('T' if self.b else 'F', color_e.OtherConst)
|
942 | L.append(Field('b', x0))
|
943 |
|
944 | return out_node
|
945 |
|
946 | def AbbreviatedTree(self, trav=None):
|
947 | # type: (Optional[TraversalState]) -> hnode_t
|
948 | return self._AbbreviatedTree(trav=trav)
|
949 |
|
950 | class Int(value_t):
|
951 | _type_tag = 10
|
952 | __slots__ = ('i',)
|
953 |
|
954 | def __init__(self, i):
|
955 | # type: (mops.BigInt) -> None
|
956 | self.i = i
|
957 |
|
958 | @staticmethod
|
959 | def CreateNull(alloc_lists=False):
|
960 | # type: () -> value.Int
|
961 | return value.Int(mops.BigInt(-1))
|
962 |
|
963 | def PrettyTree(self, trav=None):
|
964 | # type: (Optional[TraversalState]) -> hnode_t
|
965 | trav = trav or TraversalState()
|
966 | heap_id = id(self)
|
967 | if heap_id in trav.seen:
|
968 | return hnode.AlreadySeen(heap_id)
|
969 | trav.seen[heap_id] = True
|
970 | out_node = NewRecord('value.Int')
|
971 | L = out_node.fields
|
972 |
|
973 | x0 = hnode.Leaf(mops.ToStr(self.i), color_e.OtherConst)
|
974 | L.append(Field('i', x0))
|
975 |
|
976 | return out_node
|
977 |
|
978 | def _AbbreviatedTree(self, trav=None):
|
979 | # type: (Optional[TraversalState]) -> hnode_t
|
980 | trav = trav or TraversalState()
|
981 | heap_id = id(self)
|
982 | if heap_id in trav.seen:
|
983 | return hnode.AlreadySeen(heap_id)
|
984 | trav.seen[heap_id] = True
|
985 | out_node = NewRecord('value.Int')
|
986 | L = out_node.fields
|
987 | x0 = hnode.Leaf(mops.ToStr(self.i), color_e.OtherConst)
|
988 | L.append(Field('i', x0))
|
989 |
|
990 | return out_node
|
991 |
|
992 | def AbbreviatedTree(self, trav=None):
|
993 | # type: (Optional[TraversalState]) -> hnode_t
|
994 | return self._AbbreviatedTree(trav=trav)
|
995 |
|
996 | class Float(value_t):
|
997 | _type_tag = 11
|
998 | __slots__ = ('f',)
|
999 |
|
1000 | def __init__(self, f):
|
1001 | # type: (float) -> None
|
1002 | self.f = f
|
1003 |
|
1004 | @staticmethod
|
1005 | def CreateNull(alloc_lists=False):
|
1006 | # type: () -> value.Float
|
1007 | return value.Float(0.0)
|
1008 |
|
1009 | def PrettyTree(self, trav=None):
|
1010 | # type: (Optional[TraversalState]) -> hnode_t
|
1011 | trav = trav or TraversalState()
|
1012 | heap_id = id(self)
|
1013 | if heap_id in trav.seen:
|
1014 | return hnode.AlreadySeen(heap_id)
|
1015 | trav.seen[heap_id] = True
|
1016 | out_node = NewRecord('value.Float')
|
1017 | L = out_node.fields
|
1018 |
|
1019 | x0 = hnode.Leaf(str(self.f), color_e.OtherConst)
|
1020 | L.append(Field('f', x0))
|
1021 |
|
1022 | return out_node
|
1023 |
|
1024 | def _AbbreviatedTree(self, trav=None):
|
1025 | # type: (Optional[TraversalState]) -> hnode_t
|
1026 | trav = trav or TraversalState()
|
1027 | heap_id = id(self)
|
1028 | if heap_id in trav.seen:
|
1029 | return hnode.AlreadySeen(heap_id)
|
1030 | trav.seen[heap_id] = True
|
1031 | out_node = NewRecord('value.Float')
|
1032 | L = out_node.fields
|
1033 | x0 = hnode.Leaf(str(self.f), color_e.OtherConst)
|
1034 | L.append(Field('f', x0))
|
1035 |
|
1036 | return out_node
|
1037 |
|
1038 | def AbbreviatedTree(self, trav=None):
|
1039 | # type: (Optional[TraversalState]) -> hnode_t
|
1040 | return self._AbbreviatedTree(trav=trav)
|
1041 |
|
1042 | class List(value_t):
|
1043 | _type_tag = 12
|
1044 | __slots__ = ('items',)
|
1045 |
|
1046 | def __init__(self, items):
|
1047 | # type: (List[value_t]) -> None
|
1048 | self.items = items
|
1049 |
|
1050 | @staticmethod
|
1051 | def CreateNull(alloc_lists=False):
|
1052 | # type: () -> value.List
|
1053 | return value.List([] if alloc_lists else cast('List[value_t]', None))
|
1054 |
|
1055 | def PrettyTree(self, trav=None):
|
1056 | # type: (Optional[TraversalState]) -> hnode_t
|
1057 | trav = trav or TraversalState()
|
1058 | heap_id = id(self)
|
1059 | if heap_id in trav.seen:
|
1060 | return hnode.AlreadySeen(heap_id)
|
1061 | trav.seen[heap_id] = True
|
1062 | out_node = NewRecord('value.List')
|
1063 | L = out_node.fields
|
1064 |
|
1065 | if self.items is not None: # List
|
1066 | x0 = hnode.Array([])
|
1067 | for i0 in self.items:
|
1068 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
1069 | i0.PrettyTree(trav=trav))
|
1070 | x0.children.append(h)
|
1071 | L.append(Field('items', x0))
|
1072 |
|
1073 | return out_node
|
1074 |
|
1075 | def _AbbreviatedTree(self, trav=None):
|
1076 | # type: (Optional[TraversalState]) -> hnode_t
|
1077 | trav = trav or TraversalState()
|
1078 | heap_id = id(self)
|
1079 | if heap_id in trav.seen:
|
1080 | return hnode.AlreadySeen(heap_id)
|
1081 | trav.seen[heap_id] = True
|
1082 | out_node = NewRecord('value.List')
|
1083 | L = out_node.fields
|
1084 | if self.items is not None: # List
|
1085 | x0 = hnode.Array([])
|
1086 | for i0 in self.items:
|
1087 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
1088 | i0.AbbreviatedTree(trav=trav))
|
1089 | x0.children.append(h)
|
1090 | L.append(Field('items', x0))
|
1091 |
|
1092 | return out_node
|
1093 |
|
1094 | def AbbreviatedTree(self, trav=None):
|
1095 | # type: (Optional[TraversalState]) -> hnode_t
|
1096 | return self._AbbreviatedTree(trav=trav)
|
1097 |
|
1098 | class Dict(value_t):
|
1099 | _type_tag = 13
|
1100 | __slots__ = ('d',)
|
1101 |
|
1102 | def __init__(self, d):
|
1103 | # type: (Dict[str, value_t]) -> None
|
1104 | self.d = d
|
1105 |
|
1106 | @staticmethod
|
1107 | def CreateNull(alloc_lists=False):
|
1108 | # type: () -> value.Dict
|
1109 | return value.Dict(cast('Dict[str, value_t]', None))
|
1110 |
|
1111 | def PrettyTree(self, trav=None):
|
1112 | # type: (Optional[TraversalState]) -> hnode_t
|
1113 | trav = trav or TraversalState()
|
1114 | heap_id = id(self)
|
1115 | if heap_id in trav.seen:
|
1116 | return hnode.AlreadySeen(heap_id)
|
1117 | trav.seen[heap_id] = True
|
1118 | out_node = NewRecord('value.Dict')
|
1119 | L = out_node.fields
|
1120 |
|
1121 | if self.d is not None: # Dict
|
1122 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1123 | x0 = hnode.Array([m])
|
1124 | for k0, v0 in self.d.iteritems():
|
1125 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
1126 | x0.children.append(v0.PrettyTree(trav=trav))
|
1127 | L.append(Field('d', x0))
|
1128 |
|
1129 | return out_node
|
1130 |
|
1131 | def _AbbreviatedTree(self, trav=None):
|
1132 | # type: (Optional[TraversalState]) -> hnode_t
|
1133 | trav = trav or TraversalState()
|
1134 | heap_id = id(self)
|
1135 | if heap_id in trav.seen:
|
1136 | return hnode.AlreadySeen(heap_id)
|
1137 | trav.seen[heap_id] = True
|
1138 | out_node = NewRecord('value.Dict')
|
1139 | L = out_node.fields
|
1140 | if self.d is not None: # Dict
|
1141 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1142 | x0 = hnode.Array([m])
|
1143 | for k0, v0 in self.d.iteritems():
|
1144 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
1145 | x0.children.append(v0.AbbreviatedTree(trav=trav))
|
1146 | L.append(Field('d', x0))
|
1147 |
|
1148 | return out_node
|
1149 |
|
1150 | def AbbreviatedTree(self, trav=None):
|
1151 | # type: (Optional[TraversalState]) -> hnode_t
|
1152 | return self._AbbreviatedTree(trav=trav)
|
1153 |
|
1154 | class Eggex(value_t):
|
1155 | _type_tag = 15
|
1156 | __slots__ = ('spliced', 'canonical_flags', 'convert_funcs', 'convert_toks',
|
1157 | 'as_ere', 'capture_names')
|
1158 |
|
1159 | def __init__(self, spliced, canonical_flags, convert_funcs, convert_toks,
|
1160 | as_ere, capture_names):
|
1161 | # type: (re_t, str, List[Optional[value_t]], List[Optional[Token]], Optional[str], List[Optional[str]]) -> None
|
1162 | self.spliced = spliced
|
1163 | self.canonical_flags = canonical_flags
|
1164 | self.convert_funcs = convert_funcs
|
1165 | self.convert_toks = convert_toks
|
1166 | self.as_ere = as_ere
|
1167 | self.capture_names = capture_names
|
1168 |
|
1169 | @staticmethod
|
1170 | def CreateNull(alloc_lists=False):
|
1171 | # type: () -> value.Eggex
|
1172 | return value.Eggex(cast(re_t, None), '', [] if alloc_lists else cast('List[Optional[value_t]]', None), [] if alloc_lists else cast('List[Optional[Token]]', None), cast('Optional[str]', None), [] if alloc_lists else cast('List[Optional[str]]', None))
|
1173 |
|
1174 | def PrettyTree(self, trav=None):
|
1175 | # type: (Optional[TraversalState]) -> hnode_t
|
1176 | trav = trav or TraversalState()
|
1177 | heap_id = id(self)
|
1178 | if heap_id in trav.seen:
|
1179 | return hnode.AlreadySeen(heap_id)
|
1180 | trav.seen[heap_id] = True
|
1181 | out_node = NewRecord('value.Eggex')
|
1182 | L = out_node.fields
|
1183 |
|
1184 | assert self.spliced is not None
|
1185 | x0 = self.spliced.PrettyTree(trav=trav)
|
1186 | L.append(Field('spliced', x0))
|
1187 |
|
1188 | x1 = NewLeaf(self.canonical_flags, color_e.StringConst)
|
1189 | L.append(Field('canonical_flags', x1))
|
1190 |
|
1191 | if self.convert_funcs is not None: # List
|
1192 | x2 = hnode.Array([])
|
1193 | for i2 in self.convert_funcs:
|
1194 | h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
|
1195 | i2.PrettyTree(trav=trav))
|
1196 | x2.children.append(h)
|
1197 | L.append(Field('convert_funcs', x2))
|
1198 |
|
1199 | if self.convert_toks is not None: # List
|
1200 | x3 = hnode.Array([])
|
1201 | for i3 in self.convert_toks:
|
1202 | h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
|
1203 | i3.PrettyTree(trav=trav))
|
1204 | x3.children.append(h)
|
1205 | L.append(Field('convert_toks', x3))
|
1206 |
|
1207 | if self.as_ere is not None: # Optional
|
1208 | x4 = NewLeaf(self.as_ere, color_e.StringConst)
|
1209 | L.append(Field('as_ere', x4))
|
1210 |
|
1211 | if self.capture_names is not None: # List
|
1212 | x5 = hnode.Array([])
|
1213 | for i5 in self.capture_names:
|
1214 | x5.children.append(NewLeaf(i5, color_e.StringConst))
|
1215 | L.append(Field('capture_names', x5))
|
1216 |
|
1217 | return out_node
|
1218 |
|
1219 | def _AbbreviatedTree(self, trav=None):
|
1220 | # type: (Optional[TraversalState]) -> hnode_t
|
1221 | trav = trav or TraversalState()
|
1222 | heap_id = id(self)
|
1223 | if heap_id in trav.seen:
|
1224 | return hnode.AlreadySeen(heap_id)
|
1225 | trav.seen[heap_id] = True
|
1226 | out_node = NewRecord('value.Eggex')
|
1227 | L = out_node.fields
|
1228 | assert self.spliced is not None
|
1229 | x0 = self.spliced.AbbreviatedTree(trav=trav)
|
1230 | L.append(Field('spliced', x0))
|
1231 |
|
1232 | x1 = NewLeaf(self.canonical_flags, color_e.StringConst)
|
1233 | L.append(Field('canonical_flags', x1))
|
1234 |
|
1235 | if self.convert_funcs is not None: # List
|
1236 | x2 = hnode.Array([])
|
1237 | for i2 in self.convert_funcs:
|
1238 | h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
|
1239 | i2.AbbreviatedTree(trav=trav))
|
1240 | x2.children.append(h)
|
1241 | L.append(Field('convert_funcs', x2))
|
1242 |
|
1243 | if self.convert_toks is not None: # List
|
1244 | x3 = hnode.Array([])
|
1245 | for i3 in self.convert_toks:
|
1246 | h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
|
1247 | i3.AbbreviatedTree(trav=trav))
|
1248 | x3.children.append(h)
|
1249 | L.append(Field('convert_toks', x3))
|
1250 |
|
1251 | if self.as_ere is not None: # Optional
|
1252 | x4 = NewLeaf(self.as_ere, color_e.StringConst)
|
1253 | L.append(Field('as_ere', x4))
|
1254 |
|
1255 | if self.capture_names is not None: # List
|
1256 | x5 = hnode.Array([])
|
1257 | for i5 in self.capture_names:
|
1258 | x5.children.append(NewLeaf(i5, color_e.StringConst))
|
1259 | L.append(Field('capture_names', x5))
|
1260 |
|
1261 | return out_node
|
1262 |
|
1263 | def AbbreviatedTree(self, trav=None):
|
1264 | # type: (Optional[TraversalState]) -> hnode_t
|
1265 | return self._AbbreviatedTree(trav=trav)
|
1266 |
|
1267 | class Expr(value_t):
|
1268 | _type_tag = 17
|
1269 | __slots__ = ('e',)
|
1270 |
|
1271 | def __init__(self, e):
|
1272 | # type: (expr_t) -> None
|
1273 | self.e = e
|
1274 |
|
1275 | @staticmethod
|
1276 | def CreateNull(alloc_lists=False):
|
1277 | # type: () -> value.Expr
|
1278 | return value.Expr(cast(expr_t, None))
|
1279 |
|
1280 | def PrettyTree(self, trav=None):
|
1281 | # type: (Optional[TraversalState]) -> hnode_t
|
1282 | trav = trav or TraversalState()
|
1283 | heap_id = id(self)
|
1284 | if heap_id in trav.seen:
|
1285 | return hnode.AlreadySeen(heap_id)
|
1286 | trav.seen[heap_id] = True
|
1287 | out_node = NewRecord('value.Expr')
|
1288 | L = out_node.fields
|
1289 |
|
1290 | assert self.e is not None
|
1291 | x0 = self.e.PrettyTree(trav=trav)
|
1292 | L.append(Field('e', x0))
|
1293 |
|
1294 | return out_node
|
1295 |
|
1296 | def _AbbreviatedTree(self, trav=None):
|
1297 | # type: (Optional[TraversalState]) -> hnode_t
|
1298 | trav = trav or TraversalState()
|
1299 | heap_id = id(self)
|
1300 | if heap_id in trav.seen:
|
1301 | return hnode.AlreadySeen(heap_id)
|
1302 | trav.seen[heap_id] = True
|
1303 | out_node = NewRecord('value.Expr')
|
1304 | L = out_node.fields
|
1305 | assert self.e is not None
|
1306 | x0 = self.e.AbbreviatedTree(trav=trav)
|
1307 | L.append(Field('e', x0))
|
1308 |
|
1309 | return out_node
|
1310 |
|
1311 | def AbbreviatedTree(self, trav=None):
|
1312 | # type: (Optional[TraversalState]) -> hnode_t
|
1313 | return self._AbbreviatedTree(trav=trav)
|
1314 |
|
1315 | class Command(value_t):
|
1316 | _type_tag = 18
|
1317 | __slots__ = ('c',)
|
1318 |
|
1319 | def __init__(self, c):
|
1320 | # type: (command_t) -> None
|
1321 | self.c = c
|
1322 |
|
1323 | @staticmethod
|
1324 | def CreateNull(alloc_lists=False):
|
1325 | # type: () -> value.Command
|
1326 | return value.Command(cast(command_t, None))
|
1327 |
|
1328 | def PrettyTree(self, trav=None):
|
1329 | # type: (Optional[TraversalState]) -> hnode_t
|
1330 | trav = trav or TraversalState()
|
1331 | heap_id = id(self)
|
1332 | if heap_id in trav.seen:
|
1333 | return hnode.AlreadySeen(heap_id)
|
1334 | trav.seen[heap_id] = True
|
1335 | out_node = NewRecord('value.Command')
|
1336 | L = out_node.fields
|
1337 |
|
1338 | assert self.c is not None
|
1339 | x0 = self.c.PrettyTree(trav=trav)
|
1340 | L.append(Field('c', x0))
|
1341 |
|
1342 | return out_node
|
1343 |
|
1344 | def _AbbreviatedTree(self, trav=None):
|
1345 | # type: (Optional[TraversalState]) -> hnode_t
|
1346 | trav = trav or TraversalState()
|
1347 | heap_id = id(self)
|
1348 | if heap_id in trav.seen:
|
1349 | return hnode.AlreadySeen(heap_id)
|
1350 | trav.seen[heap_id] = True
|
1351 | out_node = NewRecord('value.Command')
|
1352 | L = out_node.fields
|
1353 | assert self.c is not None
|
1354 | x0 = self.c.AbbreviatedTree(trav=trav)
|
1355 | L.append(Field('c', x0))
|
1356 |
|
1357 | return out_node
|
1358 |
|
1359 | def AbbreviatedTree(self, trav=None):
|
1360 | # type: (Optional[TraversalState]) -> hnode_t
|
1361 | return self._AbbreviatedTree(trav=trav)
|
1362 |
|
1363 | class Block(value_t):
|
1364 | _type_tag = 19
|
1365 | __slots__ = ('block',)
|
1366 |
|
1367 | def __init__(self, block):
|
1368 | # type: (LiteralBlock) -> None
|
1369 | self.block = block
|
1370 |
|
1371 | @staticmethod
|
1372 | def CreateNull(alloc_lists=False):
|
1373 | # type: () -> value.Block
|
1374 | return value.Block(cast(LiteralBlock, None))
|
1375 |
|
1376 | def PrettyTree(self, trav=None):
|
1377 | # type: (Optional[TraversalState]) -> hnode_t
|
1378 | trav = trav or TraversalState()
|
1379 | heap_id = id(self)
|
1380 | if heap_id in trav.seen:
|
1381 | return hnode.AlreadySeen(heap_id)
|
1382 | trav.seen[heap_id] = True
|
1383 | out_node = NewRecord('value.Block')
|
1384 | L = out_node.fields
|
1385 |
|
1386 | assert self.block is not None
|
1387 | x0 = self.block.PrettyTree(trav=trav)
|
1388 | L.append(Field('block', x0))
|
1389 |
|
1390 | return out_node
|
1391 |
|
1392 | def _AbbreviatedTree(self, trav=None):
|
1393 | # type: (Optional[TraversalState]) -> hnode_t
|
1394 | trav = trav or TraversalState()
|
1395 | heap_id = id(self)
|
1396 | if heap_id in trav.seen:
|
1397 | return hnode.AlreadySeen(heap_id)
|
1398 | trav.seen[heap_id] = True
|
1399 | out_node = NewRecord('value.Block')
|
1400 | L = out_node.fields
|
1401 | assert self.block is not None
|
1402 | x0 = self.block.AbbreviatedTree(trav=trav)
|
1403 | L.append(Field('block', x0))
|
1404 |
|
1405 | return out_node
|
1406 |
|
1407 | def AbbreviatedTree(self, trav=None):
|
1408 | # type: (Optional[TraversalState]) -> hnode_t
|
1409 | return self._AbbreviatedTree(trav=trav)
|
1410 |
|
1411 | class Place(value_t):
|
1412 | _type_tag = 20
|
1413 | __slots__ = ('lval', 'frame')
|
1414 |
|
1415 | def __init__(self, lval, frame):
|
1416 | # type: (y_lvalue_t, Dict[str, Cell]) -> None
|
1417 | self.lval = lval
|
1418 | self.frame = frame
|
1419 |
|
1420 | @staticmethod
|
1421 | def CreateNull(alloc_lists=False):
|
1422 | # type: () -> value.Place
|
1423 | return value.Place(cast(y_lvalue_t, None), cast('Dict[str, Cell]', None))
|
1424 |
|
1425 | def PrettyTree(self, trav=None):
|
1426 | # type: (Optional[TraversalState]) -> hnode_t
|
1427 | trav = trav or TraversalState()
|
1428 | heap_id = id(self)
|
1429 | if heap_id in trav.seen:
|
1430 | return hnode.AlreadySeen(heap_id)
|
1431 | trav.seen[heap_id] = True
|
1432 | out_node = NewRecord('value.Place')
|
1433 | L = out_node.fields
|
1434 |
|
1435 | assert self.lval is not None
|
1436 | x0 = self.lval.PrettyTree(trav=trav)
|
1437 | L.append(Field('lval', x0))
|
1438 |
|
1439 | if self.frame is not None: # Dict
|
1440 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1441 | x1 = hnode.Array([m])
|
1442 | for k1, v1 in self.frame.iteritems():
|
1443 | x1.children.append(NewLeaf(k1, color_e.StringConst))
|
1444 | x1.children.append(v1.PrettyTree(trav=trav))
|
1445 | L.append(Field('frame', x1))
|
1446 |
|
1447 | return out_node
|
1448 |
|
1449 | def _AbbreviatedTree(self, trav=None):
|
1450 | # type: (Optional[TraversalState]) -> hnode_t
|
1451 | trav = trav or TraversalState()
|
1452 | heap_id = id(self)
|
1453 | if heap_id in trav.seen:
|
1454 | return hnode.AlreadySeen(heap_id)
|
1455 | trav.seen[heap_id] = True
|
1456 | out_node = NewRecord('value.Place')
|
1457 | L = out_node.fields
|
1458 | assert self.lval is not None
|
1459 | x0 = self.lval.AbbreviatedTree(trav=trav)
|
1460 | L.append(Field('lval', x0))
|
1461 |
|
1462 | if self.frame is not None: # Dict
|
1463 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1464 | x1 = hnode.Array([m])
|
1465 | for k1, v1 in self.frame.iteritems():
|
1466 | x1.children.append(NewLeaf(k1, color_e.StringConst))
|
1467 | x1.children.append(v1.AbbreviatedTree(trav=trav))
|
1468 | L.append(Field('frame', x1))
|
1469 |
|
1470 | return out_node
|
1471 |
|
1472 | def AbbreviatedTree(self, trav=None):
|
1473 | # type: (Optional[TraversalState]) -> hnode_t
|
1474 | return self._AbbreviatedTree(trav=trav)
|
1475 |
|
1476 | class Module(value_t):
|
1477 | _type_tag = 21
|
1478 | __slots__ = ('defs',)
|
1479 |
|
1480 | def __init__(self, defs):
|
1481 | # type: (Dict[str, value_t]) -> None
|
1482 | self.defs = defs
|
1483 |
|
1484 | @staticmethod
|
1485 | def CreateNull(alloc_lists=False):
|
1486 | # type: () -> value.Module
|
1487 | return value.Module(cast('Dict[str, value_t]', None))
|
1488 |
|
1489 | def PrettyTree(self, trav=None):
|
1490 | # type: (Optional[TraversalState]) -> hnode_t
|
1491 | trav = trav or TraversalState()
|
1492 | heap_id = id(self)
|
1493 | if heap_id in trav.seen:
|
1494 | return hnode.AlreadySeen(heap_id)
|
1495 | trav.seen[heap_id] = True
|
1496 | out_node = NewRecord('value.Module')
|
1497 | L = out_node.fields
|
1498 |
|
1499 | if self.defs is not None: # Dict
|
1500 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1501 | x0 = hnode.Array([m])
|
1502 | for k0, v0 in self.defs.iteritems():
|
1503 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
1504 | x0.children.append(v0.PrettyTree(trav=trav))
|
1505 | L.append(Field('defs', x0))
|
1506 |
|
1507 | return out_node
|
1508 |
|
1509 | def _AbbreviatedTree(self, trav=None):
|
1510 | # type: (Optional[TraversalState]) -> hnode_t
|
1511 | trav = trav or TraversalState()
|
1512 | heap_id = id(self)
|
1513 | if heap_id in trav.seen:
|
1514 | return hnode.AlreadySeen(heap_id)
|
1515 | trav.seen[heap_id] = True
|
1516 | out_node = NewRecord('value.Module')
|
1517 | L = out_node.fields
|
1518 | if self.defs is not None: # Dict
|
1519 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1520 | x0 = hnode.Array([m])
|
1521 | for k0, v0 in self.defs.iteritems():
|
1522 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
1523 | x0.children.append(v0.AbbreviatedTree(trav=trav))
|
1524 | L.append(Field('defs', x0))
|
1525 |
|
1526 | return out_node
|
1527 |
|
1528 | def AbbreviatedTree(self, trav=None):
|
1529 | # type: (Optional[TraversalState]) -> hnode_t
|
1530 | return self._AbbreviatedTree(trav=trav)
|
1531 |
|
1532 | class IO(value_t):
|
1533 | _type_tag = 22
|
1534 | __slots__ = ('cmd_ev', 'prompt_ev')
|
1535 |
|
1536 | def __init__(self, cmd_ev, prompt_ev):
|
1537 | # type: (Any, Any) -> None
|
1538 | self.cmd_ev = cmd_ev
|
1539 | self.prompt_ev = prompt_ev
|
1540 |
|
1541 | @staticmethod
|
1542 | def CreateNull(alloc_lists=False):
|
1543 | # type: () -> value.IO
|
1544 | return value.IO(cast(Any, None), cast(Any, None))
|
1545 |
|
1546 | def PrettyTree(self, trav=None):
|
1547 | # type: (Optional[TraversalState]) -> hnode_t
|
1548 | trav = trav or TraversalState()
|
1549 | heap_id = id(self)
|
1550 | if heap_id in trav.seen:
|
1551 | return hnode.AlreadySeen(heap_id)
|
1552 | trav.seen[heap_id] = True
|
1553 | out_node = NewRecord('value.IO')
|
1554 | L = out_node.fields
|
1555 |
|
1556 | x0 = hnode.External(self.cmd_ev)
|
1557 | L.append(Field('cmd_ev', x0))
|
1558 |
|
1559 | x1 = hnode.External(self.prompt_ev)
|
1560 | L.append(Field('prompt_ev', x1))
|
1561 |
|
1562 | return out_node
|
1563 |
|
1564 | def _AbbreviatedTree(self, trav=None):
|
1565 | # type: (Optional[TraversalState]) -> hnode_t
|
1566 | trav = trav or TraversalState()
|
1567 | heap_id = id(self)
|
1568 | if heap_id in trav.seen:
|
1569 | return hnode.AlreadySeen(heap_id)
|
1570 | trav.seen[heap_id] = True
|
1571 | out_node = NewRecord('value.IO')
|
1572 | L = out_node.fields
|
1573 | x0 = hnode.External(self.cmd_ev)
|
1574 | L.append(Field('cmd_ev', x0))
|
1575 |
|
1576 | x1 = hnode.External(self.prompt_ev)
|
1577 | L.append(Field('prompt_ev', x1))
|
1578 |
|
1579 | return out_node
|
1580 |
|
1581 | def AbbreviatedTree(self, trav=None):
|
1582 | # type: (Optional[TraversalState]) -> hnode_t
|
1583 | return self._AbbreviatedTree(trav=trav)
|
1584 |
|
1585 | class Guts(value_t):
|
1586 | _type_tag = 23
|
1587 | __slots__ = ('vm',)
|
1588 |
|
1589 | def __init__(self, vm):
|
1590 | # type: (Any) -> None
|
1591 | self.vm = vm
|
1592 |
|
1593 | @staticmethod
|
1594 | def CreateNull(alloc_lists=False):
|
1595 | # type: () -> value.Guts
|
1596 | return value.Guts(cast(Any, None))
|
1597 |
|
1598 | def PrettyTree(self, trav=None):
|
1599 | # type: (Optional[TraversalState]) -> hnode_t
|
1600 | trav = trav or TraversalState()
|
1601 | heap_id = id(self)
|
1602 | if heap_id in trav.seen:
|
1603 | return hnode.AlreadySeen(heap_id)
|
1604 | trav.seen[heap_id] = True
|
1605 | out_node = NewRecord('value.Guts')
|
1606 | L = out_node.fields
|
1607 |
|
1608 | x0 = hnode.External(self.vm)
|
1609 | L.append(Field('vm', x0))
|
1610 |
|
1611 | return out_node
|
1612 |
|
1613 | def _AbbreviatedTree(self, trav=None):
|
1614 | # type: (Optional[TraversalState]) -> hnode_t
|
1615 | trav = trav or TraversalState()
|
1616 | heap_id = id(self)
|
1617 | if heap_id in trav.seen:
|
1618 | return hnode.AlreadySeen(heap_id)
|
1619 | trav.seen[heap_id] = True
|
1620 | out_node = NewRecord('value.Guts')
|
1621 | L = out_node.fields
|
1622 | x0 = hnode.External(self.vm)
|
1623 | L.append(Field('vm', x0))
|
1624 |
|
1625 | return out_node
|
1626 |
|
1627 | def AbbreviatedTree(self, trav=None):
|
1628 | # type: (Optional[TraversalState]) -> hnode_t
|
1629 | return self._AbbreviatedTree(trav=trav)
|
1630 |
|
1631 | class BuiltinFunc(value_t):
|
1632 | _type_tag = 24
|
1633 | __slots__ = ('callable',)
|
1634 |
|
1635 | def __init__(self, callable):
|
1636 | # type: (Any) -> None
|
1637 | self.callable = callable
|
1638 |
|
1639 | @staticmethod
|
1640 | def CreateNull(alloc_lists=False):
|
1641 | # type: () -> value.BuiltinFunc
|
1642 | return value.BuiltinFunc(cast(Any, None))
|
1643 |
|
1644 | def PrettyTree(self, trav=None):
|
1645 | # type: (Optional[TraversalState]) -> hnode_t
|
1646 | trav = trav or TraversalState()
|
1647 | heap_id = id(self)
|
1648 | if heap_id in trav.seen:
|
1649 | return hnode.AlreadySeen(heap_id)
|
1650 | trav.seen[heap_id] = True
|
1651 | out_node = NewRecord('value.BuiltinFunc')
|
1652 | L = out_node.fields
|
1653 |
|
1654 | x0 = hnode.External(self.callable)
|
1655 | L.append(Field('callable', x0))
|
1656 |
|
1657 | return out_node
|
1658 |
|
1659 | def _AbbreviatedTree(self, trav=None):
|
1660 | # type: (Optional[TraversalState]) -> hnode_t
|
1661 | trav = trav or TraversalState()
|
1662 | heap_id = id(self)
|
1663 | if heap_id in trav.seen:
|
1664 | return hnode.AlreadySeen(heap_id)
|
1665 | trav.seen[heap_id] = True
|
1666 | out_node = NewRecord('value.BuiltinFunc')
|
1667 | L = out_node.fields
|
1668 | x0 = hnode.External(self.callable)
|
1669 | L.append(Field('callable', x0))
|
1670 |
|
1671 | return out_node
|
1672 |
|
1673 | def AbbreviatedTree(self, trav=None):
|
1674 | # type: (Optional[TraversalState]) -> hnode_t
|
1675 | return self._AbbreviatedTree(trav=trav)
|
1676 |
|
1677 | class BoundFunc(value_t):
|
1678 | _type_tag = 25
|
1679 | __slots__ = ('me', 'func')
|
1680 |
|
1681 | def __init__(self, me, func):
|
1682 | # type: (value_t, value_t) -> None
|
1683 | self.me = me
|
1684 | self.func = func
|
1685 |
|
1686 | @staticmethod
|
1687 | def CreateNull(alloc_lists=False):
|
1688 | # type: () -> value.BoundFunc
|
1689 | return value.BoundFunc(cast(value_t, None), cast(value_t, None))
|
1690 |
|
1691 | def PrettyTree(self, trav=None):
|
1692 | # type: (Optional[TraversalState]) -> hnode_t
|
1693 | trav = trav or TraversalState()
|
1694 | heap_id = id(self)
|
1695 | if heap_id in trav.seen:
|
1696 | return hnode.AlreadySeen(heap_id)
|
1697 | trav.seen[heap_id] = True
|
1698 | out_node = NewRecord('value.BoundFunc')
|
1699 | L = out_node.fields
|
1700 |
|
1701 | assert self.me is not None
|
1702 | x0 = self.me.PrettyTree(trav=trav)
|
1703 | L.append(Field('me', x0))
|
1704 |
|
1705 | assert self.func is not None
|
1706 | x1 = self.func.PrettyTree(trav=trav)
|
1707 | L.append(Field('func', x1))
|
1708 |
|
1709 | return out_node
|
1710 |
|
1711 | def _AbbreviatedTree(self, trav=None):
|
1712 | # type: (Optional[TraversalState]) -> hnode_t
|
1713 | trav = trav or TraversalState()
|
1714 | heap_id = id(self)
|
1715 | if heap_id in trav.seen:
|
1716 | return hnode.AlreadySeen(heap_id)
|
1717 | trav.seen[heap_id] = True
|
1718 | out_node = NewRecord('value.BoundFunc')
|
1719 | L = out_node.fields
|
1720 | assert self.me is not None
|
1721 | x0 = self.me.AbbreviatedTree(trav=trav)
|
1722 | L.append(Field('me', x0))
|
1723 |
|
1724 | assert self.func is not None
|
1725 | x1 = self.func.AbbreviatedTree(trav=trav)
|
1726 | L.append(Field('func', x1))
|
1727 |
|
1728 | return out_node
|
1729 |
|
1730 | def AbbreviatedTree(self, trav=None):
|
1731 | # type: (Optional[TraversalState]) -> hnode_t
|
1732 | return self._AbbreviatedTree(trav=trav)
|
1733 |
|
1734 | class Proc(value_t):
|
1735 | _type_tag = 26
|
1736 | __slots__ = ('name', 'name_tok', 'sig', 'body', 'defaults', 'sh_compat')
|
1737 |
|
1738 | def __init__(self, name, name_tok, sig, body, defaults, sh_compat):
|
1739 | # type: (str, Token, proc_sig_t, command_t, Optional[ProcDefaults], bool) -> None
|
1740 | self.name = name
|
1741 | self.name_tok = name_tok
|
1742 | self.sig = sig
|
1743 | self.body = body
|
1744 | self.defaults = defaults
|
1745 | self.sh_compat = sh_compat
|
1746 |
|
1747 | @staticmethod
|
1748 | def CreateNull(alloc_lists=False):
|
1749 | # type: () -> value.Proc
|
1750 | return value.Proc('', cast(Token, None), cast(proc_sig_t, None), cast(command_t, None), cast('Optional[ProcDefaults]', None), False)
|
1751 |
|
1752 | def PrettyTree(self, trav=None):
|
1753 | # type: (Optional[TraversalState]) -> hnode_t
|
1754 | trav = trav or TraversalState()
|
1755 | heap_id = id(self)
|
1756 | if heap_id in trav.seen:
|
1757 | return hnode.AlreadySeen(heap_id)
|
1758 | trav.seen[heap_id] = True
|
1759 | out_node = NewRecord('value.Proc')
|
1760 | L = out_node.fields
|
1761 |
|
1762 | x0 = NewLeaf(self.name, color_e.StringConst)
|
1763 | L.append(Field('name', x0))
|
1764 |
|
1765 | assert self.name_tok is not None
|
1766 | x1 = self.name_tok.PrettyTree(trav=trav)
|
1767 | L.append(Field('name_tok', x1))
|
1768 |
|
1769 | assert self.sig is not None
|
1770 | x2 = self.sig.PrettyTree(trav=trav)
|
1771 | L.append(Field('sig', x2))
|
1772 |
|
1773 | assert self.body is not None
|
1774 | x3 = self.body.PrettyTree(trav=trav)
|
1775 | L.append(Field('body', x3))
|
1776 |
|
1777 | if self.defaults is not None: # Optional
|
1778 | x4 = self.defaults.PrettyTree(trav=trav)
|
1779 | L.append(Field('defaults', x4))
|
1780 |
|
1781 | x5 = hnode.Leaf('T' if self.sh_compat else 'F', color_e.OtherConst)
|
1782 | L.append(Field('sh_compat', x5))
|
1783 |
|
1784 | return out_node
|
1785 |
|
1786 | def _AbbreviatedTree(self, trav=None):
|
1787 | # type: (Optional[TraversalState]) -> hnode_t
|
1788 | trav = trav or TraversalState()
|
1789 | heap_id = id(self)
|
1790 | if heap_id in trav.seen:
|
1791 | return hnode.AlreadySeen(heap_id)
|
1792 | trav.seen[heap_id] = True
|
1793 | out_node = NewRecord('value.Proc')
|
1794 | L = out_node.fields
|
1795 | x0 = NewLeaf(self.name, color_e.StringConst)
|
1796 | L.append(Field('name', x0))
|
1797 |
|
1798 | assert self.name_tok is not None
|
1799 | x1 = self.name_tok.AbbreviatedTree(trav=trav)
|
1800 | L.append(Field('name_tok', x1))
|
1801 |
|
1802 | assert self.sig is not None
|
1803 | x2 = self.sig.AbbreviatedTree(trav=trav)
|
1804 | L.append(Field('sig', x2))
|
1805 |
|
1806 | assert self.body is not None
|
1807 | x3 = self.body.AbbreviatedTree(trav=trav)
|
1808 | L.append(Field('body', x3))
|
1809 |
|
1810 | if self.defaults is not None: # Optional
|
1811 | x4 = self.defaults.AbbreviatedTree(trav=trav)
|
1812 | L.append(Field('defaults', x4))
|
1813 |
|
1814 | x5 = hnode.Leaf('T' if self.sh_compat else 'F', color_e.OtherConst)
|
1815 | L.append(Field('sh_compat', x5))
|
1816 |
|
1817 | return out_node
|
1818 |
|
1819 | def AbbreviatedTree(self, trav=None):
|
1820 | # type: (Optional[TraversalState]) -> hnode_t
|
1821 | return self._AbbreviatedTree(trav=trav)
|
1822 |
|
1823 | class Func(value_t):
|
1824 | _type_tag = 27
|
1825 | __slots__ = ('name', 'parsed', 'pos_defaults', 'named_defaults', 'module_')
|
1826 |
|
1827 | def __init__(self, name, parsed, pos_defaults, named_defaults, module_):
|
1828 | # type: (str, Func, List[value_t], Dict[str, value_t], Optional[Dict[str, Cell]]) -> None
|
1829 | self.name = name
|
1830 | self.parsed = parsed
|
1831 | self.pos_defaults = pos_defaults
|
1832 | self.named_defaults = named_defaults
|
1833 | self.module_ = module_
|
1834 |
|
1835 | @staticmethod
|
1836 | def CreateNull(alloc_lists=False):
|
1837 | # type: () -> value.Func
|
1838 | return value.Func('', cast(Func, None), [] if alloc_lists else cast('List[value_t]', None), cast('Dict[str, value_t]', None), cast('Optional[Dict[str, Cell]]', None))
|
1839 |
|
1840 | def PrettyTree(self, trav=None):
|
1841 | # type: (Optional[TraversalState]) -> hnode_t
|
1842 | trav = trav or TraversalState()
|
1843 | heap_id = id(self)
|
1844 | if heap_id in trav.seen:
|
1845 | return hnode.AlreadySeen(heap_id)
|
1846 | trav.seen[heap_id] = True
|
1847 | out_node = NewRecord('value.Func')
|
1848 | L = out_node.fields
|
1849 |
|
1850 | x0 = NewLeaf(self.name, color_e.StringConst)
|
1851 | L.append(Field('name', x0))
|
1852 |
|
1853 | assert self.parsed is not None
|
1854 | x1 = self.parsed.PrettyTree(trav=trav)
|
1855 | L.append(Field('parsed', x1))
|
1856 |
|
1857 | if self.pos_defaults is not None: # List
|
1858 | x2 = hnode.Array([])
|
1859 | for i2 in self.pos_defaults:
|
1860 | h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
|
1861 | i2.PrettyTree(trav=trav))
|
1862 | x2.children.append(h)
|
1863 | L.append(Field('pos_defaults', x2))
|
1864 |
|
1865 | if self.named_defaults is not None: # Dict
|
1866 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1867 | x3 = hnode.Array([m])
|
1868 | for k3, v3 in self.named_defaults.iteritems():
|
1869 | x3.children.append(NewLeaf(k3, color_e.StringConst))
|
1870 | x3.children.append(v3.PrettyTree(trav=trav))
|
1871 | L.append(Field('named_defaults', x3))
|
1872 |
|
1873 | if self.module_ is not None: # Dict
|
1874 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1875 | x4 = hnode.Array([m])
|
1876 | for k4, v4 in self.module_.iteritems():
|
1877 | x4.children.append(NewLeaf(k4, color_e.StringConst))
|
1878 | x4.children.append(v4.PrettyTree(trav=trav))
|
1879 | L.append(Field('module_', x4))
|
1880 |
|
1881 | return out_node
|
1882 |
|
1883 | def _AbbreviatedTree(self, trav=None):
|
1884 | # type: (Optional[TraversalState]) -> hnode_t
|
1885 | trav = trav or TraversalState()
|
1886 | heap_id = id(self)
|
1887 | if heap_id in trav.seen:
|
1888 | return hnode.AlreadySeen(heap_id)
|
1889 | trav.seen[heap_id] = True
|
1890 | out_node = NewRecord('value.Func')
|
1891 | L = out_node.fields
|
1892 | x0 = NewLeaf(self.name, color_e.StringConst)
|
1893 | L.append(Field('name', x0))
|
1894 |
|
1895 | assert self.parsed is not None
|
1896 | x1 = self.parsed.AbbreviatedTree(trav=trav)
|
1897 | L.append(Field('parsed', x1))
|
1898 |
|
1899 | if self.pos_defaults is not None: # List
|
1900 | x2 = hnode.Array([])
|
1901 | for i2 in self.pos_defaults:
|
1902 | h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
|
1903 | i2.AbbreviatedTree(trav=trav))
|
1904 | x2.children.append(h)
|
1905 | L.append(Field('pos_defaults', x2))
|
1906 |
|
1907 | if self.named_defaults is not None: # Dict
|
1908 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1909 | x3 = hnode.Array([m])
|
1910 | for k3, v3 in self.named_defaults.iteritems():
|
1911 | x3.children.append(NewLeaf(k3, color_e.StringConst))
|
1912 | x3.children.append(v3.AbbreviatedTree(trav=trav))
|
1913 | L.append(Field('named_defaults', x3))
|
1914 |
|
1915 | if self.module_ is not None: # Dict
|
1916 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
1917 | x4 = hnode.Array([m])
|
1918 | for k4, v4 in self.module_.iteritems():
|
1919 | x4.children.append(NewLeaf(k4, color_e.StringConst))
|
1920 | x4.children.append(v4.AbbreviatedTree(trav=trav))
|
1921 | L.append(Field('module_', x4))
|
1922 |
|
1923 | return out_node
|
1924 |
|
1925 | def AbbreviatedTree(self, trav=None):
|
1926 | # type: (Optional[TraversalState]) -> hnode_t
|
1927 | return self._AbbreviatedTree(trav=trav)
|
1928 |
|
1929 | class Slice(value_t):
|
1930 | _type_tag = 28
|
1931 | __slots__ = ('lower', 'upper')
|
1932 |
|
1933 | def __init__(self, lower, upper):
|
1934 | # type: (Optional[IntBox], Optional[IntBox]) -> None
|
1935 | self.lower = lower
|
1936 | self.upper = upper
|
1937 |
|
1938 | @staticmethod
|
1939 | def CreateNull(alloc_lists=False):
|
1940 | # type: () -> value.Slice
|
1941 | return value.Slice(cast('Optional[IntBox]', None), cast('Optional[IntBox]', None))
|
1942 |
|
1943 | def PrettyTree(self, trav=None):
|
1944 | # type: (Optional[TraversalState]) -> hnode_t
|
1945 | trav = trav or TraversalState()
|
1946 | heap_id = id(self)
|
1947 | if heap_id in trav.seen:
|
1948 | return hnode.AlreadySeen(heap_id)
|
1949 | trav.seen[heap_id] = True
|
1950 | out_node = NewRecord('value.Slice')
|
1951 | L = out_node.fields
|
1952 |
|
1953 | if self.lower is not None: # Optional
|
1954 | x0 = self.lower.PrettyTree(trav=trav)
|
1955 | L.append(Field('lower', x0))
|
1956 |
|
1957 | if self.upper is not None: # Optional
|
1958 | x1 = self.upper.PrettyTree(trav=trav)
|
1959 | L.append(Field('upper', x1))
|
1960 |
|
1961 | return out_node
|
1962 |
|
1963 | def _AbbreviatedTree(self, trav=None):
|
1964 | # type: (Optional[TraversalState]) -> hnode_t
|
1965 | trav = trav or TraversalState()
|
1966 | heap_id = id(self)
|
1967 | if heap_id in trav.seen:
|
1968 | return hnode.AlreadySeen(heap_id)
|
1969 | trav.seen[heap_id] = True
|
1970 | out_node = NewRecord('value.Slice')
|
1971 | L = out_node.fields
|
1972 | if self.lower is not None: # Optional
|
1973 | x0 = self.lower.AbbreviatedTree(trav=trav)
|
1974 | L.append(Field('lower', x0))
|
1975 |
|
1976 | if self.upper is not None: # Optional
|
1977 | x1 = self.upper.AbbreviatedTree(trav=trav)
|
1978 | L.append(Field('upper', x1))
|
1979 |
|
1980 | return out_node
|
1981 |
|
1982 | def AbbreviatedTree(self, trav=None):
|
1983 | # type: (Optional[TraversalState]) -> hnode_t
|
1984 | return self._AbbreviatedTree(trav=trav)
|
1985 |
|
1986 | class Range(value_t):
|
1987 | _type_tag = 29
|
1988 | __slots__ = ('lower', 'upper')
|
1989 |
|
1990 | def __init__(self, lower, upper):
|
1991 | # type: (int, int) -> None
|
1992 | self.lower = lower
|
1993 | self.upper = upper
|
1994 |
|
1995 | @staticmethod
|
1996 | def CreateNull(alloc_lists=False):
|
1997 | # type: () -> value.Range
|
1998 | return value.Range(-1, -1)
|
1999 |
|
2000 | def PrettyTree(self, trav=None):
|
2001 | # type: (Optional[TraversalState]) -> hnode_t
|
2002 | trav = trav or TraversalState()
|
2003 | heap_id = id(self)
|
2004 | if heap_id in trav.seen:
|
2005 | return hnode.AlreadySeen(heap_id)
|
2006 | trav.seen[heap_id] = True
|
2007 | out_node = NewRecord('value.Range')
|
2008 | L = out_node.fields
|
2009 |
|
2010 | x0 = hnode.Leaf(str(self.lower), color_e.OtherConst)
|
2011 | L.append(Field('lower', x0))
|
2012 |
|
2013 | x1 = hnode.Leaf(str(self.upper), color_e.OtherConst)
|
2014 | L.append(Field('upper', x1))
|
2015 |
|
2016 | return out_node
|
2017 |
|
2018 | def _AbbreviatedTree(self, trav=None):
|
2019 | # type: (Optional[TraversalState]) -> hnode_t
|
2020 | trav = trav or TraversalState()
|
2021 | heap_id = id(self)
|
2022 | if heap_id in trav.seen:
|
2023 | return hnode.AlreadySeen(heap_id)
|
2024 | trav.seen[heap_id] = True
|
2025 | out_node = NewRecord('value.Range')
|
2026 | L = out_node.fields
|
2027 | x0 = hnode.Leaf(str(self.lower), color_e.OtherConst)
|
2028 | L.append(Field('lower', x0))
|
2029 |
|
2030 | x1 = hnode.Leaf(str(self.upper), color_e.OtherConst)
|
2031 | L.append(Field('upper', x1))
|
2032 |
|
2033 | return out_node
|
2034 |
|
2035 | def AbbreviatedTree(self, trav=None):
|
2036 | # type: (Optional[TraversalState]) -> hnode_t
|
2037 | return self._AbbreviatedTree(trav=trav)
|
2038 |
|
2039 | pass
|
2040 |
|
2041 | class IntBox(pybase.CompoundObj):
|
2042 | _type_tag = 64
|
2043 | __slots__ = ('i',)
|
2044 |
|
2045 | def __init__(self, i):
|
2046 | # type: (int) -> None
|
2047 | self.i = i
|
2048 |
|
2049 | @staticmethod
|
2050 | def CreateNull(alloc_lists=False):
|
2051 | # type: () -> IntBox
|
2052 | return IntBox(-1)
|
2053 |
|
2054 | def PrettyTree(self, trav=None):
|
2055 | # type: (Optional[TraversalState]) -> hnode_t
|
2056 | trav = trav or TraversalState()
|
2057 | heap_id = id(self)
|
2058 | if heap_id in trav.seen:
|
2059 | return hnode.AlreadySeen(heap_id)
|
2060 | trav.seen[heap_id] = True
|
2061 | out_node = NewRecord('IntBox')
|
2062 | L = out_node.fields
|
2063 |
|
2064 | x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
|
2065 | L.append(Field('i', x0))
|
2066 |
|
2067 | return out_node
|
2068 |
|
2069 | def _AbbreviatedTree(self, trav=None):
|
2070 | # type: (Optional[TraversalState]) -> hnode_t
|
2071 | trav = trav or TraversalState()
|
2072 | heap_id = id(self)
|
2073 | if heap_id in trav.seen:
|
2074 | return hnode.AlreadySeen(heap_id)
|
2075 | trav.seen[heap_id] = True
|
2076 | out_node = NewRecord('IntBox')
|
2077 | L = out_node.fields
|
2078 | x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
|
2079 | L.append(Field('i', x0))
|
2080 |
|
2081 | return out_node
|
2082 |
|
2083 | def AbbreviatedTree(self, trav=None):
|
2084 | # type: (Optional[TraversalState]) -> hnode_t
|
2085 | return self._AbbreviatedTree(trav=trav)
|
2086 |
|
2087 | class ProcDefaults(pybase.CompoundObj):
|
2088 | _type_tag = 65
|
2089 | __slots__ = ('for_word', 'for_typed', 'for_named', 'for_block')
|
2090 |
|
2091 | def __init__(self, for_word, for_typed, for_named, for_block):
|
2092 | # type: (Optional[List[value_t]], Optional[List[value_t]], Optional[Dict[str, value_t]], Optional[value_t]) -> None
|
2093 | self.for_word = for_word
|
2094 | self.for_typed = for_typed
|
2095 | self.for_named = for_named
|
2096 | self.for_block = for_block
|
2097 |
|
2098 | @staticmethod
|
2099 | def CreateNull(alloc_lists=False):
|
2100 | # type: () -> ProcDefaults
|
2101 | return ProcDefaults(cast('Optional[List[value_t]]', None), cast('Optional[List[value_t]]', None), cast('Optional[Dict[str, value_t]]', None), cast('Optional[value_t]', None))
|
2102 |
|
2103 | def PrettyTree(self, trav=None):
|
2104 | # type: (Optional[TraversalState]) -> hnode_t
|
2105 | trav = trav or TraversalState()
|
2106 | heap_id = id(self)
|
2107 | if heap_id in trav.seen:
|
2108 | return hnode.AlreadySeen(heap_id)
|
2109 | trav.seen[heap_id] = True
|
2110 | out_node = NewRecord('ProcDefaults')
|
2111 | L = out_node.fields
|
2112 |
|
2113 | if self.for_word is not None: # List
|
2114 | x0 = hnode.Array([])
|
2115 | for i0 in self.for_word:
|
2116 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
2117 | i0.PrettyTree(trav=trav))
|
2118 | x0.children.append(h)
|
2119 | L.append(Field('for_word', x0))
|
2120 |
|
2121 | if self.for_typed is not None: # List
|
2122 | x1 = hnode.Array([])
|
2123 | for i1 in self.for_typed:
|
2124 | h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
|
2125 | i1.PrettyTree(trav=trav))
|
2126 | x1.children.append(h)
|
2127 | L.append(Field('for_typed', x1))
|
2128 |
|
2129 | if self.for_named is not None: # Dict
|
2130 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
2131 | x2 = hnode.Array([m])
|
2132 | for k2, v2 in self.for_named.iteritems():
|
2133 | x2.children.append(NewLeaf(k2, color_e.StringConst))
|
2134 | x2.children.append(v2.PrettyTree(trav=trav))
|
2135 | L.append(Field('for_named', x2))
|
2136 |
|
2137 | if self.for_block is not None: # Optional
|
2138 | x3 = self.for_block.PrettyTree(trav=trav)
|
2139 | L.append(Field('for_block', x3))
|
2140 |
|
2141 | return out_node
|
2142 |
|
2143 | def _AbbreviatedTree(self, trav=None):
|
2144 | # type: (Optional[TraversalState]) -> hnode_t
|
2145 | trav = trav or TraversalState()
|
2146 | heap_id = id(self)
|
2147 | if heap_id in trav.seen:
|
2148 | return hnode.AlreadySeen(heap_id)
|
2149 | trav.seen[heap_id] = True
|
2150 | out_node = NewRecord('ProcDefaults')
|
2151 | L = out_node.fields
|
2152 | if self.for_word is not None: # List
|
2153 | x0 = hnode.Array([])
|
2154 | for i0 in self.for_word:
|
2155 | h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
|
2156 | i0.AbbreviatedTree(trav=trav))
|
2157 | x0.children.append(h)
|
2158 | L.append(Field('for_word', x0))
|
2159 |
|
2160 | if self.for_typed is not None: # List
|
2161 | x1 = hnode.Array([])
|
2162 | for i1 in self.for_typed:
|
2163 | h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
|
2164 | i1.AbbreviatedTree(trav=trav))
|
2165 | x1.children.append(h)
|
2166 | L.append(Field('for_typed', x1))
|
2167 |
|
2168 | if self.for_named is not None: # Dict
|
2169 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
2170 | x2 = hnode.Array([m])
|
2171 | for k2, v2 in self.for_named.iteritems():
|
2172 | x2.children.append(NewLeaf(k2, color_e.StringConst))
|
2173 | x2.children.append(v2.AbbreviatedTree(trav=trav))
|
2174 | L.append(Field('for_named', x2))
|
2175 |
|
2176 | if self.for_block is not None: # Optional
|
2177 | x3 = self.for_block.AbbreviatedTree(trav=trav)
|
2178 | L.append(Field('for_block', x3))
|
2179 |
|
2180 | return out_node
|
2181 |
|
2182 | def AbbreviatedTree(self, trav=None):
|
2183 | # type: (Optional[TraversalState]) -> hnode_t
|
2184 | return self._AbbreviatedTree(trav=trav)
|
2185 |
|
2186 | class LeftName(y_lvalue_t, sh_lvalue_t):
|
2187 | _type_tag = 66
|
2188 | __slots__ = ('name', 'blame_loc')
|
2189 |
|
2190 | def __init__(self, name, blame_loc):
|
2191 | # type: (str, loc_t) -> None
|
2192 | self.name = name
|
2193 | self.blame_loc = blame_loc
|
2194 |
|
2195 | @staticmethod
|
2196 | def CreateNull(alloc_lists=False):
|
2197 | # type: () -> LeftName
|
2198 | return LeftName('', cast(loc_t, None))
|
2199 |
|
2200 | def PrettyTree(self, trav=None):
|
2201 | # type: (Optional[TraversalState]) -> hnode_t
|
2202 | trav = trav or TraversalState()
|
2203 | heap_id = id(self)
|
2204 | if heap_id in trav.seen:
|
2205 | return hnode.AlreadySeen(heap_id)
|
2206 | trav.seen[heap_id] = True
|
2207 | out_node = NewRecord('LeftName')
|
2208 | L = out_node.fields
|
2209 |
|
2210 | x0 = NewLeaf(self.name, color_e.StringConst)
|
2211 | L.append(Field('name', x0))
|
2212 |
|
2213 | assert self.blame_loc is not None
|
2214 | x1 = self.blame_loc.PrettyTree(trav=trav)
|
2215 | L.append(Field('blame_loc', x1))
|
2216 |
|
2217 | return out_node
|
2218 |
|
2219 | def _AbbreviatedTree(self, trav=None):
|
2220 | # type: (Optional[TraversalState]) -> hnode_t
|
2221 | trav = trav or TraversalState()
|
2222 | heap_id = id(self)
|
2223 | if heap_id in trav.seen:
|
2224 | return hnode.AlreadySeen(heap_id)
|
2225 | trav.seen[heap_id] = True
|
2226 | out_node = NewRecord('LeftName')
|
2227 | L = out_node.fields
|
2228 | x0 = NewLeaf(self.name, color_e.StringConst)
|
2229 | L.append(Field('name', x0))
|
2230 |
|
2231 | assert self.blame_loc is not None
|
2232 | x1 = self.blame_loc.AbbreviatedTree(trav=trav)
|
2233 | L.append(Field('blame_loc', x1))
|
2234 |
|
2235 | return out_node
|
2236 |
|
2237 | def AbbreviatedTree(self, trav=None):
|
2238 | # type: (Optional[TraversalState]) -> hnode_t
|
2239 | return self._AbbreviatedTree(trav=trav)
|
2240 |
|
2241 | class RegexMatch(regex_match_t, value_t):
|
2242 | _type_tag = 67
|
2243 | __slots__ = ('s', 'indices', 'ops')
|
2244 |
|
2245 | def __init__(self, s, indices, ops):
|
2246 | # type: (str, List[int], eggex_ops_t) -> None
|
2247 | self.s = s
|
2248 | self.indices = indices
|
2249 | self.ops = ops
|
2250 |
|
2251 | @staticmethod
|
2252 | def CreateNull(alloc_lists=False):
|
2253 | # type: () -> RegexMatch
|
2254 | return RegexMatch('', [] if alloc_lists else cast('List[int]', None), cast(eggex_ops_t, None))
|
2255 |
|
2256 | def PrettyTree(self, trav=None):
|
2257 | # type: (Optional[TraversalState]) -> hnode_t
|
2258 | trav = trav or TraversalState()
|
2259 | heap_id = id(self)
|
2260 | if heap_id in trav.seen:
|
2261 | return hnode.AlreadySeen(heap_id)
|
2262 | trav.seen[heap_id] = True
|
2263 | out_node = NewRecord('RegexMatch')
|
2264 | L = out_node.fields
|
2265 |
|
2266 | x0 = NewLeaf(self.s, color_e.StringConst)
|
2267 | L.append(Field('s', x0))
|
2268 |
|
2269 | if self.indices is not None: # List
|
2270 | x1 = hnode.Array([])
|
2271 | for i1 in self.indices:
|
2272 | x1.children.append(hnode.Leaf(str(i1), color_e.OtherConst))
|
2273 | L.append(Field('indices', x1))
|
2274 |
|
2275 | assert self.ops is not None
|
2276 | x2 = self.ops.PrettyTree(trav=trav)
|
2277 | L.append(Field('ops', x2))
|
2278 |
|
2279 | return out_node
|
2280 |
|
2281 | def _AbbreviatedTree(self, trav=None):
|
2282 | # type: (Optional[TraversalState]) -> hnode_t
|
2283 | trav = trav or TraversalState()
|
2284 | heap_id = id(self)
|
2285 | if heap_id in trav.seen:
|
2286 | return hnode.AlreadySeen(heap_id)
|
2287 | trav.seen[heap_id] = True
|
2288 | out_node = NewRecord('RegexMatch')
|
2289 | L = out_node.fields
|
2290 | x0 = NewLeaf(self.s, color_e.StringConst)
|
2291 | L.append(Field('s', x0))
|
2292 |
|
2293 | if self.indices is not None: # List
|
2294 | x1 = hnode.Array([])
|
2295 | for i1 in self.indices:
|
2296 | x1.children.append(hnode.Leaf(str(i1), color_e.OtherConst))
|
2297 | L.append(Field('indices', x1))
|
2298 |
|
2299 | assert self.ops is not None
|
2300 | x2 = self.ops.AbbreviatedTree(trav=trav)
|
2301 | L.append(Field('ops', x2))
|
2302 |
|
2303 | return out_node
|
2304 |
|
2305 | def AbbreviatedTree(self, trav=None):
|
2306 | # type: (Optional[TraversalState]) -> hnode_t
|
2307 | return self._AbbreviatedTree(trav=trav)
|
2308 |
|
2309 | class Obj(value_t):
|
2310 | _type_tag = 68
|
2311 | __slots__ = ('d', 'prototype')
|
2312 |
|
2313 | def __init__(self, d, prototype):
|
2314 | # type: (Dict[str, value_t], Optional[Obj]) -> None
|
2315 | self.d = d
|
2316 | self.prototype = prototype
|
2317 |
|
2318 | @staticmethod
|
2319 | def CreateNull(alloc_lists=False):
|
2320 | # type: () -> Obj
|
2321 | return Obj(cast('Dict[str, value_t]', None), cast('Optional[Obj]', None))
|
2322 |
|
2323 | def PrettyTree(self, trav=None):
|
2324 | # type: (Optional[TraversalState]) -> hnode_t
|
2325 | trav = trav or TraversalState()
|
2326 | heap_id = id(self)
|
2327 | if heap_id in trav.seen:
|
2328 | return hnode.AlreadySeen(heap_id)
|
2329 | trav.seen[heap_id] = True
|
2330 | out_node = NewRecord('Obj')
|
2331 | L = out_node.fields
|
2332 |
|
2333 | if self.d is not None: # Dict
|
2334 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
2335 | x0 = hnode.Array([m])
|
2336 | for k0, v0 in self.d.iteritems():
|
2337 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
2338 | x0.children.append(v0.PrettyTree(trav=trav))
|
2339 | L.append(Field('d', x0))
|
2340 |
|
2341 | if self.prototype is not None: # Optional
|
2342 | x1 = self.prototype.PrettyTree(trav=trav)
|
2343 | L.append(Field('prototype', x1))
|
2344 |
|
2345 | return out_node
|
2346 |
|
2347 | def _AbbreviatedTree(self, trav=None):
|
2348 | # type: (Optional[TraversalState]) -> hnode_t
|
2349 | trav = trav or TraversalState()
|
2350 | heap_id = id(self)
|
2351 | if heap_id in trav.seen:
|
2352 | return hnode.AlreadySeen(heap_id)
|
2353 | trav.seen[heap_id] = True
|
2354 | out_node = NewRecord('Obj')
|
2355 | L = out_node.fields
|
2356 | if self.d is not None: # Dict
|
2357 | m = hnode.Leaf("Dict", color_e.OtherConst)
|
2358 | x0 = hnode.Array([m])
|
2359 | for k0, v0 in self.d.iteritems():
|
2360 | x0.children.append(NewLeaf(k0, color_e.StringConst))
|
2361 | x0.children.append(v0.AbbreviatedTree(trav=trav))
|
2362 | L.append(Field('d', x0))
|
2363 |
|
2364 | if self.prototype is not None: # Optional
|
2365 | x1 = self.prototype.AbbreviatedTree(trav=trav)
|
2366 | L.append(Field('prototype', x1))
|
2367 |
|
2368 | return out_node
|
2369 |
|
2370 | def AbbreviatedTree(self, trav=None):
|
2371 | # type: (Optional[TraversalState]) -> hnode_t
|
2372 | return self._AbbreviatedTree(trav=trav)
|
2373 |
|