OILS / _devbuild / gen / value_asdl.py View on Github | oilshell.org

2546 lines, 1894 significant
1from asdl import pybase
2from mycpp import mops
3from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
4
5if TYPE_CHECKING:
6 from _devbuild.gen.syntax_asdl import loc_t, Token, expr_t, command_t, DoubleQuoted, re_t, proc_sig_t, Func, NameType, EggexFlag, BraceGroup, SourceLine
7 from _devbuild.gen.runtime_asdl import Cell
8
9
10from asdl import runtime # For runtime.NO_SPID
11from asdl.runtime import NewRecord, NewLeaf, TraversalState
12from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
13
14class y_lvalue_e(object):
15 Local = 66
16 Container = 2
17
18_y_lvalue_str = {
19 2: 'Container',
20 66: 'Local',
21}
22
23def 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
31class y_lvalue_t(pybase.CompoundObj):
32 def tag(self):
33 # type: () -> int
34 return self._type_tag
35 pass
36
37class 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
97class 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
108def 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
116class sh_lvalue_t(pybase.CompoundObj):
117 def tag(self):
118 # type: () -> int
119 return self._type_tag
120 pass
121
122class 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
249class eggex_ops_e(object):
250 No = 1
251 Yes = 2
252
253_eggex_ops_str = {
254 1: 'No',
255 2: 'Yes',
256}
257
258def 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
266class eggex_ops_t(pybase.CompoundObj):
267 def tag(self):
268 # type: () -> int
269 return self._type_tag
270 pass
271
272class 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
307class 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
398class regex_match_e(object):
399 No = 1
400 Yes = 67
401
402_regex_match_str = {
403 1: 'No',
404 67: 'Yes',
405}
406
407def 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
415class regex_match_t(pybase.CompoundObj):
416 def tag(self):
417 # type: () -> int
418 return self._type_tag
419 pass
420
421class 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
456class regex_match(object):
457 No = regex_match__No()
458
459 pass
460
461class cmd_frag_e(object):
462 LiteralBlock = 68
463 Expr = 2
464
465_cmd_frag_str = {
466 2: 'Expr',
467 68: 'LiteralBlock',
468}
469
470def cmd_frag_str(tag, dot=True):
471 # type: (int, bool) -> str
472 v = _cmd_frag_str[tag]
473 if dot:
474 return "cmd_frag.%s" % v
475 else:
476 return v
477
478class cmd_frag_t(pybase.CompoundObj):
479 def tag(self):
480 # type: () -> int
481 return self._type_tag
482 pass
483
484class cmd_frag(object):
485 class Expr(cmd_frag_t):
486 _type_tag = 2
487 __slots__ = ('c',)
488
489 def __init__(self, c):
490 # type: (command_t) -> None
491 self.c = c
492
493 @staticmethod
494 def CreateNull(alloc_lists=False):
495 # type: () -> cmd_frag.Expr
496 return cmd_frag.Expr(cast(command_t, None))
497
498 def PrettyTree(self, trav=None):
499 # type: (Optional[TraversalState]) -> hnode_t
500 trav = trav or TraversalState()
501 heap_id = id(self)
502 if heap_id in trav.seen:
503 return hnode.AlreadySeen(heap_id)
504 trav.seen[heap_id] = True
505 out_node = NewRecord('cmd_frag.Expr')
506 L = out_node.fields
507
508 assert self.c is not None
509 x0 = self.c.PrettyTree(trav=trav)
510 L.append(Field('c', x0))
511
512 return out_node
513
514 def _AbbreviatedTree(self, trav=None):
515 # type: (Optional[TraversalState]) -> hnode_t
516 trav = trav or TraversalState()
517 heap_id = id(self)
518 if heap_id in trav.seen:
519 return hnode.AlreadySeen(heap_id)
520 trav.seen[heap_id] = True
521 out_node = NewRecord('cmd_frag.Expr')
522 L = out_node.fields
523 assert self.c is not None
524 x0 = self.c.AbbreviatedTree(trav=trav)
525 L.append(Field('c', x0))
526
527 return out_node
528
529 def AbbreviatedTree(self, trav=None):
530 # type: (Optional[TraversalState]) -> hnode_t
531 return self._AbbreviatedTree(trav=trav)
532
533 pass
534
535class value_e(object):
536 Interrupted = 1
537 Stdin = 2
538 Slice = 3
539 Undef = 4
540 Str = 5
541 BashArray = 6
542 SparseArray = 7
543 BashAssoc = 8
544 Null = 9
545 Bool = 10
546 Int = 11
547 Float = 12
548 List = 13
549 Dict = 14
550 Obj = 69
551 Range = 16
552 Eggex = 17
553 Match = 67
554 Place = 19
555 Frame = 20
556 BoundFunc = 21
557 BuiltinFunc = 22
558 Func = 23
559 BuiltinProc = 24
560 Proc = 25
561 Expr = 26
562 CommandFrag = 27
563 Command = 28
564
565_value_str = {
566 1: 'Interrupted',
567 2: 'Stdin',
568 3: 'Slice',
569 4: 'Undef',
570 5: 'Str',
571 6: 'BashArray',
572 7: 'SparseArray',
573 8: 'BashAssoc',
574 9: 'Null',
575 10: 'Bool',
576 11: 'Int',
577 12: 'Float',
578 13: 'List',
579 14: 'Dict',
580 16: 'Range',
581 17: 'Eggex',
582 19: 'Place',
583 20: 'Frame',
584 21: 'BoundFunc',
585 22: 'BuiltinFunc',
586 23: 'Func',
587 24: 'BuiltinProc',
588 25: 'Proc',
589 26: 'Expr',
590 27: 'CommandFrag',
591 28: 'Command',
592 67: 'Match',
593 69: 'Obj',
594}
595
596def value_str(tag, dot=True):
597 # type: (int, bool) -> str
598 v = _value_str[tag]
599 if dot:
600 return "value.%s" % v
601 else:
602 return v
603
604class value_t(pybase.CompoundObj):
605 def tag(self):
606 # type: () -> int
607 return self._type_tag
608 pass
609
610class value__Interrupted(value_t):
611 _type_tag = 1
612 __slots__ = ()
613
614 def __init__(self, ):
615 # type: () -> None
616 pass
617
618 def PrettyTree(self, trav=None):
619 # type: (Optional[TraversalState]) -> hnode_t
620 trav = trav or TraversalState()
621 heap_id = id(self)
622 if heap_id in trav.seen:
623 return hnode.AlreadySeen(heap_id)
624 trav.seen[heap_id] = True
625 out_node = NewRecord('value__Interrupted')
626 L = out_node.fields
627
628 return out_node
629
630 def _AbbreviatedTree(self, trav=None):
631 # type: (Optional[TraversalState]) -> hnode_t
632 trav = trav or TraversalState()
633 heap_id = id(self)
634 if heap_id in trav.seen:
635 return hnode.AlreadySeen(heap_id)
636 trav.seen[heap_id] = True
637 out_node = NewRecord('value__Interrupted')
638 L = out_node.fields
639 return out_node
640
641 def AbbreviatedTree(self, trav=None):
642 # type: (Optional[TraversalState]) -> hnode_t
643 return self._AbbreviatedTree(trav=trav)
644
645class value__Stdin(value_t):
646 _type_tag = 2
647 __slots__ = ()
648
649 def __init__(self, ):
650 # type: () -> None
651 pass
652
653 def PrettyTree(self, trav=None):
654 # type: (Optional[TraversalState]) -> hnode_t
655 trav = trav or TraversalState()
656 heap_id = id(self)
657 if heap_id in trav.seen:
658 return hnode.AlreadySeen(heap_id)
659 trav.seen[heap_id] = True
660 out_node = NewRecord('value__Stdin')
661 L = out_node.fields
662
663 return out_node
664
665 def _AbbreviatedTree(self, trav=None):
666 # type: (Optional[TraversalState]) -> hnode_t
667 trav = trav or TraversalState()
668 heap_id = id(self)
669 if heap_id in trav.seen:
670 return hnode.AlreadySeen(heap_id)
671 trav.seen[heap_id] = True
672 out_node = NewRecord('value__Stdin')
673 L = out_node.fields
674 return out_node
675
676 def AbbreviatedTree(self, trav=None):
677 # type: (Optional[TraversalState]) -> hnode_t
678 return self._AbbreviatedTree(trav=trav)
679
680class value__Undef(value_t):
681 _type_tag = 4
682 __slots__ = ()
683
684 def __init__(self, ):
685 # type: () -> None
686 pass
687
688 def PrettyTree(self, trav=None):
689 # type: (Optional[TraversalState]) -> hnode_t
690 trav = trav or TraversalState()
691 heap_id = id(self)
692 if heap_id in trav.seen:
693 return hnode.AlreadySeen(heap_id)
694 trav.seen[heap_id] = True
695 out_node = NewRecord('value__Undef')
696 L = out_node.fields
697
698 return out_node
699
700 def _AbbreviatedTree(self, trav=None):
701 # type: (Optional[TraversalState]) -> hnode_t
702 trav = trav or TraversalState()
703 heap_id = id(self)
704 if heap_id in trav.seen:
705 return hnode.AlreadySeen(heap_id)
706 trav.seen[heap_id] = True
707 out_node = NewRecord('value__Undef')
708 L = out_node.fields
709 return out_node
710
711 def AbbreviatedTree(self, trav=None):
712 # type: (Optional[TraversalState]) -> hnode_t
713 return self._AbbreviatedTree(trav=trav)
714
715class value__Null(value_t):
716 _type_tag = 9
717 __slots__ = ()
718
719 def __init__(self, ):
720 # type: () -> None
721 pass
722
723 def PrettyTree(self, trav=None):
724 # type: (Optional[TraversalState]) -> hnode_t
725 trav = trav or TraversalState()
726 heap_id = id(self)
727 if heap_id in trav.seen:
728 return hnode.AlreadySeen(heap_id)
729 trav.seen[heap_id] = True
730 out_node = NewRecord('value__Null')
731 L = out_node.fields
732
733 return out_node
734
735 def _AbbreviatedTree(self, trav=None):
736 # type: (Optional[TraversalState]) -> hnode_t
737 trav = trav or TraversalState()
738 heap_id = id(self)
739 if heap_id in trav.seen:
740 return hnode.AlreadySeen(heap_id)
741 trav.seen[heap_id] = True
742 out_node = NewRecord('value__Null')
743 L = out_node.fields
744 return out_node
745
746 def AbbreviatedTree(self, trav=None):
747 # type: (Optional[TraversalState]) -> hnode_t
748 return self._AbbreviatedTree(trav=trav)
749
750class value(object):
751 Interrupted = value__Interrupted()
752
753 Stdin = value__Stdin()
754
755 class Slice(value_t):
756 _type_tag = 3
757 __slots__ = ('lower', 'upper')
758
759 def __init__(self, lower, upper):
760 # type: (Optional[IntBox], Optional[IntBox]) -> None
761 self.lower = lower
762 self.upper = upper
763
764 @staticmethod
765 def CreateNull(alloc_lists=False):
766 # type: () -> value.Slice
767 return value.Slice(cast('Optional[IntBox]', None), cast('Optional[IntBox]', None))
768
769 def PrettyTree(self, trav=None):
770 # type: (Optional[TraversalState]) -> hnode_t
771 trav = trav or TraversalState()
772 heap_id = id(self)
773 if heap_id in trav.seen:
774 return hnode.AlreadySeen(heap_id)
775 trav.seen[heap_id] = True
776 out_node = NewRecord('value.Slice')
777 L = out_node.fields
778
779 if self.lower is not None: # Optional
780 x0 = self.lower.PrettyTree(trav=trav)
781 L.append(Field('lower', x0))
782
783 if self.upper is not None: # Optional
784 x1 = self.upper.PrettyTree(trav=trav)
785 L.append(Field('upper', x1))
786
787 return out_node
788
789 def _AbbreviatedTree(self, trav=None):
790 # type: (Optional[TraversalState]) -> hnode_t
791 trav = trav or TraversalState()
792 heap_id = id(self)
793 if heap_id in trav.seen:
794 return hnode.AlreadySeen(heap_id)
795 trav.seen[heap_id] = True
796 out_node = NewRecord('value.Slice')
797 L = out_node.fields
798 if self.lower is not None: # Optional
799 x0 = self.lower.AbbreviatedTree(trav=trav)
800 L.append(Field('lower', x0))
801
802 if self.upper is not None: # Optional
803 x1 = self.upper.AbbreviatedTree(trav=trav)
804 L.append(Field('upper', x1))
805
806 return out_node
807
808 def AbbreviatedTree(self, trav=None):
809 # type: (Optional[TraversalState]) -> hnode_t
810 return self._AbbreviatedTree(trav=trav)
811
812 Undef = value__Undef()
813
814 class Str(value_t):
815 _type_tag = 5
816 __slots__ = ('s',)
817
818 def __init__(self, s):
819 # type: (str) -> None
820 self.s = s
821
822 @staticmethod
823 def CreateNull(alloc_lists=False):
824 # type: () -> value.Str
825 return value.Str('')
826
827 def PrettyTree(self, trav=None):
828 # type: (Optional[TraversalState]) -> hnode_t
829 trav = trav or TraversalState()
830 heap_id = id(self)
831 if heap_id in trav.seen:
832 return hnode.AlreadySeen(heap_id)
833 trav.seen[heap_id] = True
834 out_node = NewRecord('value.Str')
835 L = out_node.fields
836
837 x0 = NewLeaf(self.s, color_e.StringConst)
838 L.append(Field('s', x0))
839
840 return out_node
841
842 def _AbbreviatedTree(self, trav=None):
843 # type: (Optional[TraversalState]) -> hnode_t
844 trav = trav or TraversalState()
845 heap_id = id(self)
846 if heap_id in trav.seen:
847 return hnode.AlreadySeen(heap_id)
848 trav.seen[heap_id] = True
849 out_node = NewRecord('value.Str')
850 L = out_node.fields
851 x0 = NewLeaf(self.s, color_e.StringConst)
852 L.append(Field('s', x0))
853
854 return out_node
855
856 def AbbreviatedTree(self, trav=None):
857 # type: (Optional[TraversalState]) -> hnode_t
858 return self._AbbreviatedTree(trav=trav)
859
860 class BashArray(value_t):
861 _type_tag = 6
862 __slots__ = ('strs',)
863
864 def __init__(self, strs):
865 # type: (List[str]) -> None
866 self.strs = strs
867
868 @staticmethod
869 def CreateNull(alloc_lists=False):
870 # type: () -> value.BashArray
871 return value.BashArray([] if alloc_lists else cast('List[str]', None))
872
873 def PrettyTree(self, trav=None):
874 # type: (Optional[TraversalState]) -> hnode_t
875 trav = trav or TraversalState()
876 heap_id = id(self)
877 if heap_id in trav.seen:
878 return hnode.AlreadySeen(heap_id)
879 trav.seen[heap_id] = True
880 out_node = NewRecord('value.BashArray')
881 L = out_node.fields
882
883 if self.strs is not None: # List
884 x0 = hnode.Array([])
885 for i0 in self.strs:
886 x0.children.append(NewLeaf(i0, color_e.StringConst))
887 L.append(Field('strs', x0))
888
889 return out_node
890
891 def _AbbreviatedTree(self, trav=None):
892 # type: (Optional[TraversalState]) -> hnode_t
893 trav = trav or TraversalState()
894 heap_id = id(self)
895 if heap_id in trav.seen:
896 return hnode.AlreadySeen(heap_id)
897 trav.seen[heap_id] = True
898 out_node = NewRecord('value.BashArray')
899 L = out_node.fields
900 if self.strs is not None: # List
901 x0 = hnode.Array([])
902 for i0 in self.strs:
903 x0.children.append(NewLeaf(i0, color_e.StringConst))
904 L.append(Field('strs', x0))
905
906 return out_node
907
908 def AbbreviatedTree(self, trav=None):
909 # type: (Optional[TraversalState]) -> hnode_t
910 return self._AbbreviatedTree(trav=trav)
911
912 class SparseArray(value_t):
913 _type_tag = 7
914 __slots__ = ('d', 'max_index')
915
916 def __init__(self, d, max_index):
917 # type: (Dict[mops.BigInt, str], mops.BigInt) -> None
918 self.d = d
919 self.max_index = max_index
920
921 @staticmethod
922 def CreateNull(alloc_lists=False):
923 # type: () -> value.SparseArray
924 return value.SparseArray(cast('Dict[mops.BigInt, str]', None), mops.BigInt(-1))
925
926 def PrettyTree(self, trav=None):
927 # type: (Optional[TraversalState]) -> hnode_t
928 trav = trav or TraversalState()
929 heap_id = id(self)
930 if heap_id in trav.seen:
931 return hnode.AlreadySeen(heap_id)
932 trav.seen[heap_id] = True
933 out_node = NewRecord('value.SparseArray')
934 L = out_node.fields
935
936 if self.d is not None: # Dict
937 m = hnode.Leaf("Dict", color_e.OtherConst)
938 x0 = hnode.Array([m])
939 for k0, v0 in self.d.iteritems():
940 x0.children.append(hnode.Leaf(mops.ToStr(k0), color_e.OtherConst))
941 x0.children.append(NewLeaf(v0, color_e.StringConst))
942 L.append(Field('d', x0))
943
944 x1 = hnode.Leaf(mops.ToStr(self.max_index), color_e.OtherConst)
945 L.append(Field('max_index', x1))
946
947 return out_node
948
949 def _AbbreviatedTree(self, trav=None):
950 # type: (Optional[TraversalState]) -> hnode_t
951 trav = trav or TraversalState()
952 heap_id = id(self)
953 if heap_id in trav.seen:
954 return hnode.AlreadySeen(heap_id)
955 trav.seen[heap_id] = True
956 out_node = NewRecord('value.SparseArray')
957 L = out_node.fields
958 if self.d is not None: # Dict
959 m = hnode.Leaf("Dict", color_e.OtherConst)
960 x0 = hnode.Array([m])
961 for k0, v0 in self.d.iteritems():
962 x0.children.append(hnode.Leaf(mops.ToStr(k0), color_e.OtherConst))
963 x0.children.append(NewLeaf(v0, color_e.StringConst))
964 L.append(Field('d', x0))
965
966 x1 = hnode.Leaf(mops.ToStr(self.max_index), color_e.OtherConst)
967 L.append(Field('max_index', x1))
968
969 return out_node
970
971 def AbbreviatedTree(self, trav=None):
972 # type: (Optional[TraversalState]) -> hnode_t
973 return self._AbbreviatedTree(trav=trav)
974
975 class BashAssoc(value_t):
976 _type_tag = 8
977 __slots__ = ('d',)
978
979 def __init__(self, d):
980 # type: (Dict[str, str]) -> None
981 self.d = d
982
983 @staticmethod
984 def CreateNull(alloc_lists=False):
985 # type: () -> value.BashAssoc
986 return value.BashAssoc(cast('Dict[str, str]', None))
987
988 def PrettyTree(self, trav=None):
989 # type: (Optional[TraversalState]) -> hnode_t
990 trav = trav or TraversalState()
991 heap_id = id(self)
992 if heap_id in trav.seen:
993 return hnode.AlreadySeen(heap_id)
994 trav.seen[heap_id] = True
995 out_node = NewRecord('value.BashAssoc')
996 L = out_node.fields
997
998 if self.d is not None: # Dict
999 m = hnode.Leaf("Dict", color_e.OtherConst)
1000 x0 = hnode.Array([m])
1001 for k0, v0 in self.d.iteritems():
1002 x0.children.append(NewLeaf(k0, color_e.StringConst))
1003 x0.children.append(NewLeaf(v0, color_e.StringConst))
1004 L.append(Field('d', x0))
1005
1006 return out_node
1007
1008 def _AbbreviatedTree(self, trav=None):
1009 # type: (Optional[TraversalState]) -> hnode_t
1010 trav = trav or TraversalState()
1011 heap_id = id(self)
1012 if heap_id in trav.seen:
1013 return hnode.AlreadySeen(heap_id)
1014 trav.seen[heap_id] = True
1015 out_node = NewRecord('value.BashAssoc')
1016 L = out_node.fields
1017 if self.d is not None: # Dict
1018 m = hnode.Leaf("Dict", color_e.OtherConst)
1019 x0 = hnode.Array([m])
1020 for k0, v0 in self.d.iteritems():
1021 x0.children.append(NewLeaf(k0, color_e.StringConst))
1022 x0.children.append(NewLeaf(v0, color_e.StringConst))
1023 L.append(Field('d', x0))
1024
1025 return out_node
1026
1027 def AbbreviatedTree(self, trav=None):
1028 # type: (Optional[TraversalState]) -> hnode_t
1029 return self._AbbreviatedTree(trav=trav)
1030
1031 Null = value__Null()
1032
1033 class Bool(value_t):
1034 _type_tag = 10
1035 __slots__ = ('b',)
1036
1037 def __init__(self, b):
1038 # type: (bool) -> None
1039 self.b = b
1040
1041 @staticmethod
1042 def CreateNull(alloc_lists=False):
1043 # type: () -> value.Bool
1044 return value.Bool(False)
1045
1046 def PrettyTree(self, trav=None):
1047 # type: (Optional[TraversalState]) -> hnode_t
1048 trav = trav or TraversalState()
1049 heap_id = id(self)
1050 if heap_id in trav.seen:
1051 return hnode.AlreadySeen(heap_id)
1052 trav.seen[heap_id] = True
1053 out_node = NewRecord('value.Bool')
1054 L = out_node.fields
1055
1056 x0 = hnode.Leaf('T' if self.b else 'F', color_e.OtherConst)
1057 L.append(Field('b', x0))
1058
1059 return out_node
1060
1061 def _AbbreviatedTree(self, trav=None):
1062 # type: (Optional[TraversalState]) -> hnode_t
1063 trav = trav or TraversalState()
1064 heap_id = id(self)
1065 if heap_id in trav.seen:
1066 return hnode.AlreadySeen(heap_id)
1067 trav.seen[heap_id] = True
1068 out_node = NewRecord('value.Bool')
1069 L = out_node.fields
1070 x0 = hnode.Leaf('T' if self.b else 'F', color_e.OtherConst)
1071 L.append(Field('b', x0))
1072
1073 return out_node
1074
1075 def AbbreviatedTree(self, trav=None):
1076 # type: (Optional[TraversalState]) -> hnode_t
1077 return self._AbbreviatedTree(trav=trav)
1078
1079 class Int(value_t):
1080 _type_tag = 11
1081 __slots__ = ('i',)
1082
1083 def __init__(self, i):
1084 # type: (mops.BigInt) -> None
1085 self.i = i
1086
1087 @staticmethod
1088 def CreateNull(alloc_lists=False):
1089 # type: () -> value.Int
1090 return value.Int(mops.BigInt(-1))
1091
1092 def PrettyTree(self, trav=None):
1093 # type: (Optional[TraversalState]) -> hnode_t
1094 trav = trav or TraversalState()
1095 heap_id = id(self)
1096 if heap_id in trav.seen:
1097 return hnode.AlreadySeen(heap_id)
1098 trav.seen[heap_id] = True
1099 out_node = NewRecord('value.Int')
1100 L = out_node.fields
1101
1102 x0 = hnode.Leaf(mops.ToStr(self.i), color_e.OtherConst)
1103 L.append(Field('i', x0))
1104
1105 return out_node
1106
1107 def _AbbreviatedTree(self, trav=None):
1108 # type: (Optional[TraversalState]) -> hnode_t
1109 trav = trav or TraversalState()
1110 heap_id = id(self)
1111 if heap_id in trav.seen:
1112 return hnode.AlreadySeen(heap_id)
1113 trav.seen[heap_id] = True
1114 out_node = NewRecord('value.Int')
1115 L = out_node.fields
1116 x0 = hnode.Leaf(mops.ToStr(self.i), color_e.OtherConst)
1117 L.append(Field('i', x0))
1118
1119 return out_node
1120
1121 def AbbreviatedTree(self, trav=None):
1122 # type: (Optional[TraversalState]) -> hnode_t
1123 return self._AbbreviatedTree(trav=trav)
1124
1125 class Float(value_t):
1126 _type_tag = 12
1127 __slots__ = ('f',)
1128
1129 def __init__(self, f):
1130 # type: (float) -> None
1131 self.f = f
1132
1133 @staticmethod
1134 def CreateNull(alloc_lists=False):
1135 # type: () -> value.Float
1136 return value.Float(0.0)
1137
1138 def PrettyTree(self, trav=None):
1139 # type: (Optional[TraversalState]) -> hnode_t
1140 trav = trav or TraversalState()
1141 heap_id = id(self)
1142 if heap_id in trav.seen:
1143 return hnode.AlreadySeen(heap_id)
1144 trav.seen[heap_id] = True
1145 out_node = NewRecord('value.Float')
1146 L = out_node.fields
1147
1148 x0 = hnode.Leaf(str(self.f), color_e.OtherConst)
1149 L.append(Field('f', x0))
1150
1151 return out_node
1152
1153 def _AbbreviatedTree(self, trav=None):
1154 # type: (Optional[TraversalState]) -> hnode_t
1155 trav = trav or TraversalState()
1156 heap_id = id(self)
1157 if heap_id in trav.seen:
1158 return hnode.AlreadySeen(heap_id)
1159 trav.seen[heap_id] = True
1160 out_node = NewRecord('value.Float')
1161 L = out_node.fields
1162 x0 = hnode.Leaf(str(self.f), color_e.OtherConst)
1163 L.append(Field('f', x0))
1164
1165 return out_node
1166
1167 def AbbreviatedTree(self, trav=None):
1168 # type: (Optional[TraversalState]) -> hnode_t
1169 return self._AbbreviatedTree(trav=trav)
1170
1171 class List(value_t):
1172 _type_tag = 13
1173 __slots__ = ('items',)
1174
1175 def __init__(self, items):
1176 # type: (List[value_t]) -> None
1177 self.items = items
1178
1179 @staticmethod
1180 def CreateNull(alloc_lists=False):
1181 # type: () -> value.List
1182 return value.List([] if alloc_lists else cast('List[value_t]', None))
1183
1184 def PrettyTree(self, trav=None):
1185 # type: (Optional[TraversalState]) -> hnode_t
1186 trav = trav or TraversalState()
1187 heap_id = id(self)
1188 if heap_id in trav.seen:
1189 return hnode.AlreadySeen(heap_id)
1190 trav.seen[heap_id] = True
1191 out_node = NewRecord('value.List')
1192 L = out_node.fields
1193
1194 if self.items is not None: # List
1195 x0 = hnode.Array([])
1196 for i0 in self.items:
1197 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
1198 i0.PrettyTree(trav=trav))
1199 x0.children.append(h)
1200 L.append(Field('items', x0))
1201
1202 return out_node
1203
1204 def _AbbreviatedTree(self, trav=None):
1205 # type: (Optional[TraversalState]) -> hnode_t
1206 trav = trav or TraversalState()
1207 heap_id = id(self)
1208 if heap_id in trav.seen:
1209 return hnode.AlreadySeen(heap_id)
1210 trav.seen[heap_id] = True
1211 out_node = NewRecord('value.List')
1212 L = out_node.fields
1213 if self.items is not None: # List
1214 x0 = hnode.Array([])
1215 for i0 in self.items:
1216 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
1217 i0.AbbreviatedTree(trav=trav))
1218 x0.children.append(h)
1219 L.append(Field('items', x0))
1220
1221 return out_node
1222
1223 def AbbreviatedTree(self, trav=None):
1224 # type: (Optional[TraversalState]) -> hnode_t
1225 return self._AbbreviatedTree(trav=trav)
1226
1227 class Dict(value_t):
1228 _type_tag = 14
1229 __slots__ = ('d',)
1230
1231 def __init__(self, d):
1232 # type: (Dict[str, value_t]) -> None
1233 self.d = d
1234
1235 @staticmethod
1236 def CreateNull(alloc_lists=False):
1237 # type: () -> value.Dict
1238 return value.Dict(cast('Dict[str, value_t]', None))
1239
1240 def PrettyTree(self, trav=None):
1241 # type: (Optional[TraversalState]) -> hnode_t
1242 trav = trav or TraversalState()
1243 heap_id = id(self)
1244 if heap_id in trav.seen:
1245 return hnode.AlreadySeen(heap_id)
1246 trav.seen[heap_id] = True
1247 out_node = NewRecord('value.Dict')
1248 L = out_node.fields
1249
1250 if self.d is not None: # Dict
1251 m = hnode.Leaf("Dict", color_e.OtherConst)
1252 x0 = hnode.Array([m])
1253 for k0, v0 in self.d.iteritems():
1254 x0.children.append(NewLeaf(k0, color_e.StringConst))
1255 x0.children.append(v0.PrettyTree(trav=trav))
1256 L.append(Field('d', x0))
1257
1258 return out_node
1259
1260 def _AbbreviatedTree(self, trav=None):
1261 # type: (Optional[TraversalState]) -> hnode_t
1262 trav = trav or TraversalState()
1263 heap_id = id(self)
1264 if heap_id in trav.seen:
1265 return hnode.AlreadySeen(heap_id)
1266 trav.seen[heap_id] = True
1267 out_node = NewRecord('value.Dict')
1268 L = out_node.fields
1269 if self.d is not None: # Dict
1270 m = hnode.Leaf("Dict", color_e.OtherConst)
1271 x0 = hnode.Array([m])
1272 for k0, v0 in self.d.iteritems():
1273 x0.children.append(NewLeaf(k0, color_e.StringConst))
1274 x0.children.append(v0.AbbreviatedTree(trav=trav))
1275 L.append(Field('d', x0))
1276
1277 return out_node
1278
1279 def AbbreviatedTree(self, trav=None):
1280 # type: (Optional[TraversalState]) -> hnode_t
1281 return self._AbbreviatedTree(trav=trav)
1282
1283 class Range(value_t):
1284 _type_tag = 16
1285 __slots__ = ('lower', 'upper')
1286
1287 def __init__(self, lower, upper):
1288 # type: (int, int) -> None
1289 self.lower = lower
1290 self.upper = upper
1291
1292 @staticmethod
1293 def CreateNull(alloc_lists=False):
1294 # type: () -> value.Range
1295 return value.Range(-1, -1)
1296
1297 def PrettyTree(self, trav=None):
1298 # type: (Optional[TraversalState]) -> hnode_t
1299 trav = trav or TraversalState()
1300 heap_id = id(self)
1301 if heap_id in trav.seen:
1302 return hnode.AlreadySeen(heap_id)
1303 trav.seen[heap_id] = True
1304 out_node = NewRecord('value.Range')
1305 L = out_node.fields
1306
1307 x0 = hnode.Leaf(str(self.lower), color_e.OtherConst)
1308 L.append(Field('lower', x0))
1309
1310 x1 = hnode.Leaf(str(self.upper), color_e.OtherConst)
1311 L.append(Field('upper', x1))
1312
1313 return out_node
1314
1315 def _AbbreviatedTree(self, trav=None):
1316 # type: (Optional[TraversalState]) -> hnode_t
1317 trav = trav or TraversalState()
1318 heap_id = id(self)
1319 if heap_id in trav.seen:
1320 return hnode.AlreadySeen(heap_id)
1321 trav.seen[heap_id] = True
1322 out_node = NewRecord('value.Range')
1323 L = out_node.fields
1324 x0 = hnode.Leaf(str(self.lower), color_e.OtherConst)
1325 L.append(Field('lower', x0))
1326
1327 x1 = hnode.Leaf(str(self.upper), color_e.OtherConst)
1328 L.append(Field('upper', x1))
1329
1330 return out_node
1331
1332 def AbbreviatedTree(self, trav=None):
1333 # type: (Optional[TraversalState]) -> hnode_t
1334 return self._AbbreviatedTree(trav=trav)
1335
1336 class Eggex(value_t):
1337 _type_tag = 17
1338 __slots__ = ('spliced', 'canonical_flags', 'convert_funcs', 'convert_toks',
1339 'as_ere', 'capture_names')
1340
1341 def __init__(self, spliced, canonical_flags, convert_funcs, convert_toks,
1342 as_ere, capture_names):
1343 # type: (re_t, str, List[Optional[value_t]], List[Optional[Token]], Optional[str], List[Optional[str]]) -> None
1344 self.spliced = spliced
1345 self.canonical_flags = canonical_flags
1346 self.convert_funcs = convert_funcs
1347 self.convert_toks = convert_toks
1348 self.as_ere = as_ere
1349 self.capture_names = capture_names
1350
1351 @staticmethod
1352 def CreateNull(alloc_lists=False):
1353 # type: () -> value.Eggex
1354 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))
1355
1356 def PrettyTree(self, trav=None):
1357 # type: (Optional[TraversalState]) -> hnode_t
1358 trav = trav or TraversalState()
1359 heap_id = id(self)
1360 if heap_id in trav.seen:
1361 return hnode.AlreadySeen(heap_id)
1362 trav.seen[heap_id] = True
1363 out_node = NewRecord('value.Eggex')
1364 L = out_node.fields
1365
1366 assert self.spliced is not None
1367 x0 = self.spliced.PrettyTree(trav=trav)
1368 L.append(Field('spliced', x0))
1369
1370 x1 = NewLeaf(self.canonical_flags, color_e.StringConst)
1371 L.append(Field('canonical_flags', x1))
1372
1373 if self.convert_funcs is not None: # List
1374 x2 = hnode.Array([])
1375 for i2 in self.convert_funcs:
1376 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
1377 i2.PrettyTree(trav=trav))
1378 x2.children.append(h)
1379 L.append(Field('convert_funcs', x2))
1380
1381 if self.convert_toks is not None: # List
1382 x3 = hnode.Array([])
1383 for i3 in self.convert_toks:
1384 h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
1385 i3.PrettyTree(trav=trav))
1386 x3.children.append(h)
1387 L.append(Field('convert_toks', x3))
1388
1389 if self.as_ere is not None: # Optional
1390 x4 = NewLeaf(self.as_ere, color_e.StringConst)
1391 L.append(Field('as_ere', x4))
1392
1393 if self.capture_names is not None: # List
1394 x5 = hnode.Array([])
1395 for i5 in self.capture_names:
1396 x5.children.append(NewLeaf(i5, color_e.StringConst))
1397 L.append(Field('capture_names', x5))
1398
1399 return out_node
1400
1401 def _AbbreviatedTree(self, trav=None):
1402 # type: (Optional[TraversalState]) -> hnode_t
1403 trav = trav or TraversalState()
1404 heap_id = id(self)
1405 if heap_id in trav.seen:
1406 return hnode.AlreadySeen(heap_id)
1407 trav.seen[heap_id] = True
1408 out_node = NewRecord('value.Eggex')
1409 L = out_node.fields
1410 assert self.spliced is not None
1411 x0 = self.spliced.AbbreviatedTree(trav=trav)
1412 L.append(Field('spliced', x0))
1413
1414 x1 = NewLeaf(self.canonical_flags, color_e.StringConst)
1415 L.append(Field('canonical_flags', x1))
1416
1417 if self.convert_funcs is not None: # List
1418 x2 = hnode.Array([])
1419 for i2 in self.convert_funcs:
1420 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
1421 i2.AbbreviatedTree(trav=trav))
1422 x2.children.append(h)
1423 L.append(Field('convert_funcs', x2))
1424
1425 if self.convert_toks is not None: # List
1426 x3 = hnode.Array([])
1427 for i3 in self.convert_toks:
1428 h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
1429 i3.AbbreviatedTree(trav=trav))
1430 x3.children.append(h)
1431 L.append(Field('convert_toks', x3))
1432
1433 if self.as_ere is not None: # Optional
1434 x4 = NewLeaf(self.as_ere, color_e.StringConst)
1435 L.append(Field('as_ere', x4))
1436
1437 if self.capture_names is not None: # List
1438 x5 = hnode.Array([])
1439 for i5 in self.capture_names:
1440 x5.children.append(NewLeaf(i5, color_e.StringConst))
1441 L.append(Field('capture_names', x5))
1442
1443 return out_node
1444
1445 def AbbreviatedTree(self, trav=None):
1446 # type: (Optional[TraversalState]) -> hnode_t
1447 return self._AbbreviatedTree(trav=trav)
1448
1449 class Place(value_t):
1450 _type_tag = 19
1451 __slots__ = ('lval', 'frame')
1452
1453 def __init__(self, lval, frame):
1454 # type: (y_lvalue_t, Dict[str, Cell]) -> None
1455 self.lval = lval
1456 self.frame = frame
1457
1458 @staticmethod
1459 def CreateNull(alloc_lists=False):
1460 # type: () -> value.Place
1461 return value.Place(cast(y_lvalue_t, None), cast('Dict[str, Cell]', None))
1462
1463 def PrettyTree(self, trav=None):
1464 # type: (Optional[TraversalState]) -> hnode_t
1465 trav = trav or TraversalState()
1466 heap_id = id(self)
1467 if heap_id in trav.seen:
1468 return hnode.AlreadySeen(heap_id)
1469 trav.seen[heap_id] = True
1470 out_node = NewRecord('value.Place')
1471 L = out_node.fields
1472
1473 assert self.lval is not None
1474 x0 = self.lval.PrettyTree(trav=trav)
1475 L.append(Field('lval', x0))
1476
1477 if self.frame is not None: # Dict
1478 m = hnode.Leaf("Dict", color_e.OtherConst)
1479 x1 = hnode.Array([m])
1480 for k1, v1 in self.frame.iteritems():
1481 x1.children.append(NewLeaf(k1, color_e.StringConst))
1482 x1.children.append(v1.PrettyTree(trav=trav))
1483 L.append(Field('frame', x1))
1484
1485 return out_node
1486
1487 def _AbbreviatedTree(self, trav=None):
1488 # type: (Optional[TraversalState]) -> hnode_t
1489 trav = trav or TraversalState()
1490 heap_id = id(self)
1491 if heap_id in trav.seen:
1492 return hnode.AlreadySeen(heap_id)
1493 trav.seen[heap_id] = True
1494 out_node = NewRecord('value.Place')
1495 L = out_node.fields
1496 assert self.lval is not None
1497 x0 = self.lval.AbbreviatedTree(trav=trav)
1498 L.append(Field('lval', x0))
1499
1500 if self.frame is not None: # Dict
1501 m = hnode.Leaf("Dict", color_e.OtherConst)
1502 x1 = hnode.Array([m])
1503 for k1, v1 in self.frame.iteritems():
1504 x1.children.append(NewLeaf(k1, color_e.StringConst))
1505 x1.children.append(v1.AbbreviatedTree(trav=trav))
1506 L.append(Field('frame', x1))
1507
1508 return out_node
1509
1510 def AbbreviatedTree(self, trav=None):
1511 # type: (Optional[TraversalState]) -> hnode_t
1512 return self._AbbreviatedTree(trav=trav)
1513
1514 class Frame(value_t):
1515 _type_tag = 20
1516 __slots__ = ('frame',)
1517
1518 def __init__(self, frame):
1519 # type: (Dict[str, Cell]) -> None
1520 self.frame = frame
1521
1522 @staticmethod
1523 def CreateNull(alloc_lists=False):
1524 # type: () -> value.Frame
1525 return value.Frame(cast('Dict[str, Cell]', None))
1526
1527 def PrettyTree(self, trav=None):
1528 # type: (Optional[TraversalState]) -> hnode_t
1529 trav = trav or TraversalState()
1530 heap_id = id(self)
1531 if heap_id in trav.seen:
1532 return hnode.AlreadySeen(heap_id)
1533 trav.seen[heap_id] = True
1534 out_node = NewRecord('value.Frame')
1535 L = out_node.fields
1536
1537 if self.frame is not None: # Dict
1538 m = hnode.Leaf("Dict", color_e.OtherConst)
1539 x0 = hnode.Array([m])
1540 for k0, v0 in self.frame.iteritems():
1541 x0.children.append(NewLeaf(k0, color_e.StringConst))
1542 x0.children.append(v0.PrettyTree(trav=trav))
1543 L.append(Field('frame', x0))
1544
1545 return out_node
1546
1547 def _AbbreviatedTree(self, trav=None):
1548 # type: (Optional[TraversalState]) -> hnode_t
1549 trav = trav or TraversalState()
1550 heap_id = id(self)
1551 if heap_id in trav.seen:
1552 return hnode.AlreadySeen(heap_id)
1553 trav.seen[heap_id] = True
1554 out_node = NewRecord('value.Frame')
1555 L = out_node.fields
1556 if self.frame is not None: # Dict
1557 m = hnode.Leaf("Dict", color_e.OtherConst)
1558 x0 = hnode.Array([m])
1559 for k0, v0 in self.frame.iteritems():
1560 x0.children.append(NewLeaf(k0, color_e.StringConst))
1561 x0.children.append(v0.AbbreviatedTree(trav=trav))
1562 L.append(Field('frame', x0))
1563
1564 return out_node
1565
1566 def AbbreviatedTree(self, trav=None):
1567 # type: (Optional[TraversalState]) -> hnode_t
1568 return self._AbbreviatedTree(trav=trav)
1569
1570 class BoundFunc(value_t):
1571 _type_tag = 21
1572 __slots__ = ('me', 'func')
1573
1574 def __init__(self, me, func):
1575 # type: (value_t, value_t) -> None
1576 self.me = me
1577 self.func = func
1578
1579 @staticmethod
1580 def CreateNull(alloc_lists=False):
1581 # type: () -> value.BoundFunc
1582 return value.BoundFunc(cast(value_t, None), cast(value_t, None))
1583
1584 def PrettyTree(self, trav=None):
1585 # type: (Optional[TraversalState]) -> hnode_t
1586 trav = trav or TraversalState()
1587 heap_id = id(self)
1588 if heap_id in trav.seen:
1589 return hnode.AlreadySeen(heap_id)
1590 trav.seen[heap_id] = True
1591 out_node = NewRecord('value.BoundFunc')
1592 L = out_node.fields
1593
1594 assert self.me is not None
1595 x0 = self.me.PrettyTree(trav=trav)
1596 L.append(Field('me', x0))
1597
1598 assert self.func is not None
1599 x1 = self.func.PrettyTree(trav=trav)
1600 L.append(Field('func', x1))
1601
1602 return out_node
1603
1604 def _AbbreviatedTree(self, trav=None):
1605 # type: (Optional[TraversalState]) -> hnode_t
1606 trav = trav or TraversalState()
1607 heap_id = id(self)
1608 if heap_id in trav.seen:
1609 return hnode.AlreadySeen(heap_id)
1610 trav.seen[heap_id] = True
1611 out_node = NewRecord('value.BoundFunc')
1612 L = out_node.fields
1613 assert self.me is not None
1614 x0 = self.me.AbbreviatedTree(trav=trav)
1615 L.append(Field('me', x0))
1616
1617 assert self.func is not None
1618 x1 = self.func.AbbreviatedTree(trav=trav)
1619 L.append(Field('func', x1))
1620
1621 return out_node
1622
1623 def AbbreviatedTree(self, trav=None):
1624 # type: (Optional[TraversalState]) -> hnode_t
1625 return self._AbbreviatedTree(trav=trav)
1626
1627 class BuiltinFunc(value_t):
1628 _type_tag = 22
1629 __slots__ = ('callable',)
1630
1631 def __init__(self, callable):
1632 # type: (Any) -> None
1633 self.callable = callable
1634
1635 @staticmethod
1636 def CreateNull(alloc_lists=False):
1637 # type: () -> value.BuiltinFunc
1638 return value.BuiltinFunc(cast(Any, None))
1639
1640 def PrettyTree(self, trav=None):
1641 # type: (Optional[TraversalState]) -> hnode_t
1642 trav = trav or TraversalState()
1643 heap_id = id(self)
1644 if heap_id in trav.seen:
1645 return hnode.AlreadySeen(heap_id)
1646 trav.seen[heap_id] = True
1647 out_node = NewRecord('value.BuiltinFunc')
1648 L = out_node.fields
1649
1650 x0 = hnode.External(self.callable)
1651 L.append(Field('callable', x0))
1652
1653 return out_node
1654
1655 def _AbbreviatedTree(self, trav=None):
1656 # type: (Optional[TraversalState]) -> hnode_t
1657 trav = trav or TraversalState()
1658 heap_id = id(self)
1659 if heap_id in trav.seen:
1660 return hnode.AlreadySeen(heap_id)
1661 trav.seen[heap_id] = True
1662 out_node = NewRecord('value.BuiltinFunc')
1663 L = out_node.fields
1664 x0 = hnode.External(self.callable)
1665 L.append(Field('callable', x0))
1666
1667 return out_node
1668
1669 def AbbreviatedTree(self, trav=None):
1670 # type: (Optional[TraversalState]) -> hnode_t
1671 return self._AbbreviatedTree(trav=trav)
1672
1673 class Func(value_t):
1674 _type_tag = 23
1675 __slots__ = ('name', 'parsed', 'pos_defaults', 'named_defaults',
1676 'module_frame')
1677
1678 def __init__(self, name, parsed, pos_defaults, named_defaults,
1679 module_frame):
1680 # type: (str, Func, List[value_t], Dict[str, value_t], Dict[str, Cell]) -> None
1681 self.name = name
1682 self.parsed = parsed
1683 self.pos_defaults = pos_defaults
1684 self.named_defaults = named_defaults
1685 self.module_frame = module_frame
1686
1687 @staticmethod
1688 def CreateNull(alloc_lists=False):
1689 # type: () -> value.Func
1690 return value.Func('', cast(Func, None), [] if alloc_lists else cast('List[value_t]', None), cast('Dict[str, value_t]', None), cast('Dict[str, Cell]', None))
1691
1692 def PrettyTree(self, trav=None):
1693 # type: (Optional[TraversalState]) -> hnode_t
1694 trav = trav or TraversalState()
1695 heap_id = id(self)
1696 if heap_id in trav.seen:
1697 return hnode.AlreadySeen(heap_id)
1698 trav.seen[heap_id] = True
1699 out_node = NewRecord('value.Func')
1700 L = out_node.fields
1701
1702 x0 = NewLeaf(self.name, color_e.StringConst)
1703 L.append(Field('name', x0))
1704
1705 assert self.parsed is not None
1706 x1 = self.parsed.PrettyTree(trav=trav)
1707 L.append(Field('parsed', x1))
1708
1709 if self.pos_defaults is not None: # List
1710 x2 = hnode.Array([])
1711 for i2 in self.pos_defaults:
1712 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
1713 i2.PrettyTree(trav=trav))
1714 x2.children.append(h)
1715 L.append(Field('pos_defaults', x2))
1716
1717 if self.named_defaults is not None: # Dict
1718 m = hnode.Leaf("Dict", color_e.OtherConst)
1719 x3 = hnode.Array([m])
1720 for k3, v3 in self.named_defaults.iteritems():
1721 x3.children.append(NewLeaf(k3, color_e.StringConst))
1722 x3.children.append(v3.PrettyTree(trav=trav))
1723 L.append(Field('named_defaults', x3))
1724
1725 if self.module_frame is not None: # Dict
1726 m = hnode.Leaf("Dict", color_e.OtherConst)
1727 x4 = hnode.Array([m])
1728 for k4, v4 in self.module_frame.iteritems():
1729 x4.children.append(NewLeaf(k4, color_e.StringConst))
1730 x4.children.append(v4.PrettyTree(trav=trav))
1731 L.append(Field('module_frame', x4))
1732
1733 return out_node
1734
1735 def _AbbreviatedTree(self, trav=None):
1736 # type: (Optional[TraversalState]) -> hnode_t
1737 trav = trav or TraversalState()
1738 heap_id = id(self)
1739 if heap_id in trav.seen:
1740 return hnode.AlreadySeen(heap_id)
1741 trav.seen[heap_id] = True
1742 out_node = NewRecord('value.Func')
1743 L = out_node.fields
1744 x0 = NewLeaf(self.name, color_e.StringConst)
1745 L.append(Field('name', x0))
1746
1747 assert self.parsed is not None
1748 x1 = self.parsed.AbbreviatedTree(trav=trav)
1749 L.append(Field('parsed', x1))
1750
1751 if self.pos_defaults is not None: # List
1752 x2 = hnode.Array([])
1753 for i2 in self.pos_defaults:
1754 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
1755 i2.AbbreviatedTree(trav=trav))
1756 x2.children.append(h)
1757 L.append(Field('pos_defaults', x2))
1758
1759 if self.named_defaults is not None: # Dict
1760 m = hnode.Leaf("Dict", color_e.OtherConst)
1761 x3 = hnode.Array([m])
1762 for k3, v3 in self.named_defaults.iteritems():
1763 x3.children.append(NewLeaf(k3, color_e.StringConst))
1764 x3.children.append(v3.AbbreviatedTree(trav=trav))
1765 L.append(Field('named_defaults', x3))
1766
1767 if self.module_frame is not None: # Dict
1768 m = hnode.Leaf("Dict", color_e.OtherConst)
1769 x4 = hnode.Array([m])
1770 for k4, v4 in self.module_frame.iteritems():
1771 x4.children.append(NewLeaf(k4, color_e.StringConst))
1772 x4.children.append(v4.AbbreviatedTree(trav=trav))
1773 L.append(Field('module_frame', x4))
1774
1775 return out_node
1776
1777 def AbbreviatedTree(self, trav=None):
1778 # type: (Optional[TraversalState]) -> hnode_t
1779 return self._AbbreviatedTree(trav=trav)
1780
1781 class BuiltinProc(value_t):
1782 _type_tag = 24
1783 __slots__ = ('builtin',)
1784
1785 def __init__(self, builtin):
1786 # type: (Any) -> None
1787 self.builtin = builtin
1788
1789 @staticmethod
1790 def CreateNull(alloc_lists=False):
1791 # type: () -> value.BuiltinProc
1792 return value.BuiltinProc(cast(Any, None))
1793
1794 def PrettyTree(self, trav=None):
1795 # type: (Optional[TraversalState]) -> hnode_t
1796 trav = trav or TraversalState()
1797 heap_id = id(self)
1798 if heap_id in trav.seen:
1799 return hnode.AlreadySeen(heap_id)
1800 trav.seen[heap_id] = True
1801 out_node = NewRecord('value.BuiltinProc')
1802 L = out_node.fields
1803
1804 x0 = hnode.External(self.builtin)
1805 L.append(Field('builtin', x0))
1806
1807 return out_node
1808
1809 def _AbbreviatedTree(self, trav=None):
1810 # type: (Optional[TraversalState]) -> hnode_t
1811 trav = trav or TraversalState()
1812 heap_id = id(self)
1813 if heap_id in trav.seen:
1814 return hnode.AlreadySeen(heap_id)
1815 trav.seen[heap_id] = True
1816 out_node = NewRecord('value.BuiltinProc')
1817 L = out_node.fields
1818 x0 = hnode.External(self.builtin)
1819 L.append(Field('builtin', x0))
1820
1821 return out_node
1822
1823 def AbbreviatedTree(self, trav=None):
1824 # type: (Optional[TraversalState]) -> hnode_t
1825 return self._AbbreviatedTree(trav=trav)
1826
1827 class Proc(value_t):
1828 _type_tag = 25
1829 __slots__ = ('name', 'name_tok', 'sig', 'body', 'defaults', 'sh_compat',
1830 'module_frame')
1831
1832 def __init__(self, name, name_tok, sig, body, defaults, sh_compat,
1833 module_frame):
1834 # type: (str, Token, proc_sig_t, command_t, Optional[ProcDefaults], bool, Dict[str, Cell]) -> None
1835 self.name = name
1836 self.name_tok = name_tok
1837 self.sig = sig
1838 self.body = body
1839 self.defaults = defaults
1840 self.sh_compat = sh_compat
1841 self.module_frame = module_frame
1842
1843 @staticmethod
1844 def CreateNull(alloc_lists=False):
1845 # type: () -> value.Proc
1846 return value.Proc('', cast(Token, None), cast(proc_sig_t, None), cast(command_t, None), cast('Optional[ProcDefaults]', None), False, cast('Dict[str, Cell]', None))
1847
1848 def PrettyTree(self, trav=None):
1849 # type: (Optional[TraversalState]) -> hnode_t
1850 trav = trav or TraversalState()
1851 heap_id = id(self)
1852 if heap_id in trav.seen:
1853 return hnode.AlreadySeen(heap_id)
1854 trav.seen[heap_id] = True
1855 out_node = NewRecord('value.Proc')
1856 L = out_node.fields
1857
1858 x0 = NewLeaf(self.name, color_e.StringConst)
1859 L.append(Field('name', x0))
1860
1861 assert self.name_tok is not None
1862 x1 = self.name_tok.PrettyTree(trav=trav)
1863 L.append(Field('name_tok', x1))
1864
1865 assert self.sig is not None
1866 x2 = self.sig.PrettyTree(trav=trav)
1867 L.append(Field('sig', x2))
1868
1869 assert self.body is not None
1870 x3 = self.body.PrettyTree(trav=trav)
1871 L.append(Field('body', x3))
1872
1873 if self.defaults is not None: # Optional
1874 x4 = self.defaults.PrettyTree(trav=trav)
1875 L.append(Field('defaults', x4))
1876
1877 x5 = hnode.Leaf('T' if self.sh_compat else 'F', color_e.OtherConst)
1878 L.append(Field('sh_compat', x5))
1879
1880 if self.module_frame is not None: # Dict
1881 m = hnode.Leaf("Dict", color_e.OtherConst)
1882 x6 = hnode.Array([m])
1883 for k6, v6 in self.module_frame.iteritems():
1884 x6.children.append(NewLeaf(k6, color_e.StringConst))
1885 x6.children.append(v6.PrettyTree(trav=trav))
1886 L.append(Field('module_frame', x6))
1887
1888 return out_node
1889
1890 def _AbbreviatedTree(self, trav=None):
1891 # type: (Optional[TraversalState]) -> hnode_t
1892 trav = trav or TraversalState()
1893 heap_id = id(self)
1894 if heap_id in trav.seen:
1895 return hnode.AlreadySeen(heap_id)
1896 trav.seen[heap_id] = True
1897 out_node = NewRecord('value.Proc')
1898 L = out_node.fields
1899 x0 = NewLeaf(self.name, color_e.StringConst)
1900 L.append(Field('name', x0))
1901
1902 assert self.name_tok is not None
1903 x1 = self.name_tok.AbbreviatedTree(trav=trav)
1904 L.append(Field('name_tok', x1))
1905
1906 assert self.sig is not None
1907 x2 = self.sig.AbbreviatedTree(trav=trav)
1908 L.append(Field('sig', x2))
1909
1910 assert self.body is not None
1911 x3 = self.body.AbbreviatedTree(trav=trav)
1912 L.append(Field('body', x3))
1913
1914 if self.defaults is not None: # Optional
1915 x4 = self.defaults.AbbreviatedTree(trav=trav)
1916 L.append(Field('defaults', x4))
1917
1918 x5 = hnode.Leaf('T' if self.sh_compat else 'F', color_e.OtherConst)
1919 L.append(Field('sh_compat', x5))
1920
1921 if self.module_frame is not None: # Dict
1922 m = hnode.Leaf("Dict", color_e.OtherConst)
1923 x6 = hnode.Array([m])
1924 for k6, v6 in self.module_frame.iteritems():
1925 x6.children.append(NewLeaf(k6, color_e.StringConst))
1926 x6.children.append(v6.AbbreviatedTree(trav=trav))
1927 L.append(Field('module_frame', x6))
1928
1929 return out_node
1930
1931 def AbbreviatedTree(self, trav=None):
1932 # type: (Optional[TraversalState]) -> hnode_t
1933 return self._AbbreviatedTree(trav=trav)
1934
1935 class Expr(value_t):
1936 _type_tag = 26
1937 __slots__ = ('e', 'captured_frame', 'module_frame')
1938
1939 def __init__(self, e, captured_frame, module_frame):
1940 # type: (expr_t, Dict[str, Cell], Dict[str, Cell]) -> None
1941 self.e = e
1942 self.captured_frame = captured_frame
1943 self.module_frame = module_frame
1944
1945 @staticmethod
1946 def CreateNull(alloc_lists=False):
1947 # type: () -> value.Expr
1948 return value.Expr(cast(expr_t, None), cast('Dict[str, Cell]', None), cast('Dict[str, Cell]', None))
1949
1950 def PrettyTree(self, trav=None):
1951 # type: (Optional[TraversalState]) -> hnode_t
1952 trav = trav or TraversalState()
1953 heap_id = id(self)
1954 if heap_id in trav.seen:
1955 return hnode.AlreadySeen(heap_id)
1956 trav.seen[heap_id] = True
1957 out_node = NewRecord('value.Expr')
1958 L = out_node.fields
1959
1960 assert self.e is not None
1961 x0 = self.e.PrettyTree(trav=trav)
1962 L.append(Field('e', x0))
1963
1964 if self.captured_frame is not None: # Dict
1965 m = hnode.Leaf("Dict", color_e.OtherConst)
1966 x1 = hnode.Array([m])
1967 for k1, v1 in self.captured_frame.iteritems():
1968 x1.children.append(NewLeaf(k1, color_e.StringConst))
1969 x1.children.append(v1.PrettyTree(trav=trav))
1970 L.append(Field('captured_frame', x1))
1971
1972 if self.module_frame is not None: # Dict
1973 m = hnode.Leaf("Dict", color_e.OtherConst)
1974 x2 = hnode.Array([m])
1975 for k2, v2 in self.module_frame.iteritems():
1976 x2.children.append(NewLeaf(k2, color_e.StringConst))
1977 x2.children.append(v2.PrettyTree(trav=trav))
1978 L.append(Field('module_frame', x2))
1979
1980 return out_node
1981
1982 def _AbbreviatedTree(self, trav=None):
1983 # type: (Optional[TraversalState]) -> hnode_t
1984 trav = trav or TraversalState()
1985 heap_id = id(self)
1986 if heap_id in trav.seen:
1987 return hnode.AlreadySeen(heap_id)
1988 trav.seen[heap_id] = True
1989 out_node = NewRecord('value.Expr')
1990 L = out_node.fields
1991 assert self.e is not None
1992 x0 = self.e.AbbreviatedTree(trav=trav)
1993 L.append(Field('e', x0))
1994
1995 if self.captured_frame is not None: # Dict
1996 m = hnode.Leaf("Dict", color_e.OtherConst)
1997 x1 = hnode.Array([m])
1998 for k1, v1 in self.captured_frame.iteritems():
1999 x1.children.append(NewLeaf(k1, color_e.StringConst))
2000 x1.children.append(v1.AbbreviatedTree(trav=trav))
2001 L.append(Field('captured_frame', x1))
2002
2003 if self.module_frame is not None: # Dict
2004 m = hnode.Leaf("Dict", color_e.OtherConst)
2005 x2 = hnode.Array([m])
2006 for k2, v2 in self.module_frame.iteritems():
2007 x2.children.append(NewLeaf(k2, color_e.StringConst))
2008 x2.children.append(v2.AbbreviatedTree(trav=trav))
2009 L.append(Field('module_frame', x2))
2010
2011 return out_node
2012
2013 def AbbreviatedTree(self, trav=None):
2014 # type: (Optional[TraversalState]) -> hnode_t
2015 return self._AbbreviatedTree(trav=trav)
2016
2017 class CommandFrag(value_t):
2018 _type_tag = 27
2019 __slots__ = ('c',)
2020
2021 def __init__(self, c):
2022 # type: (command_t) -> None
2023 self.c = c
2024
2025 @staticmethod
2026 def CreateNull(alloc_lists=False):
2027 # type: () -> value.CommandFrag
2028 return value.CommandFrag(cast(command_t, None))
2029
2030 def PrettyTree(self, trav=None):
2031 # type: (Optional[TraversalState]) -> hnode_t
2032 trav = trav or TraversalState()
2033 heap_id = id(self)
2034 if heap_id in trav.seen:
2035 return hnode.AlreadySeen(heap_id)
2036 trav.seen[heap_id] = True
2037 out_node = NewRecord('value.CommandFrag')
2038 L = out_node.fields
2039
2040 assert self.c is not None
2041 x0 = self.c.PrettyTree(trav=trav)
2042 L.append(Field('c', x0))
2043
2044 return out_node
2045
2046 def _AbbreviatedTree(self, trav=None):
2047 # type: (Optional[TraversalState]) -> hnode_t
2048 trav = trav or TraversalState()
2049 heap_id = id(self)
2050 if heap_id in trav.seen:
2051 return hnode.AlreadySeen(heap_id)
2052 trav.seen[heap_id] = True
2053 out_node = NewRecord('value.CommandFrag')
2054 L = out_node.fields
2055 assert self.c is not None
2056 x0 = self.c.AbbreviatedTree(trav=trav)
2057 L.append(Field('c', x0))
2058
2059 return out_node
2060
2061 def AbbreviatedTree(self, trav=None):
2062 # type: (Optional[TraversalState]) -> hnode_t
2063 return self._AbbreviatedTree(trav=trav)
2064
2065 class Command(value_t):
2066 _type_tag = 28
2067 __slots__ = ('frag', 'captured_frame', 'module_frame')
2068
2069 def __init__(self, frag, captured_frame, module_frame):
2070 # type: (cmd_frag_t, Dict[str, Cell], Dict[str, Cell]) -> None
2071 self.frag = frag
2072 self.captured_frame = captured_frame
2073 self.module_frame = module_frame
2074
2075 @staticmethod
2076 def CreateNull(alloc_lists=False):
2077 # type: () -> value.Command
2078 return value.Command(cast(cmd_frag_t, None), cast('Dict[str, Cell]', None), cast('Dict[str, Cell]', None))
2079
2080 def PrettyTree(self, trav=None):
2081 # type: (Optional[TraversalState]) -> hnode_t
2082 trav = trav or TraversalState()
2083 heap_id = id(self)
2084 if heap_id in trav.seen:
2085 return hnode.AlreadySeen(heap_id)
2086 trav.seen[heap_id] = True
2087 out_node = NewRecord('value.Command')
2088 L = out_node.fields
2089
2090 assert self.frag is not None
2091 x0 = self.frag.PrettyTree(trav=trav)
2092 L.append(Field('frag', x0))
2093
2094 if self.captured_frame is not None: # Dict
2095 m = hnode.Leaf("Dict", color_e.OtherConst)
2096 x1 = hnode.Array([m])
2097 for k1, v1 in self.captured_frame.iteritems():
2098 x1.children.append(NewLeaf(k1, color_e.StringConst))
2099 x1.children.append(v1.PrettyTree(trav=trav))
2100 L.append(Field('captured_frame', x1))
2101
2102 if self.module_frame is not None: # Dict
2103 m = hnode.Leaf("Dict", color_e.OtherConst)
2104 x2 = hnode.Array([m])
2105 for k2, v2 in self.module_frame.iteritems():
2106 x2.children.append(NewLeaf(k2, color_e.StringConst))
2107 x2.children.append(v2.PrettyTree(trav=trav))
2108 L.append(Field('module_frame', x2))
2109
2110 return out_node
2111
2112 def _AbbreviatedTree(self, trav=None):
2113 # type: (Optional[TraversalState]) -> hnode_t
2114 trav = trav or TraversalState()
2115 heap_id = id(self)
2116 if heap_id in trav.seen:
2117 return hnode.AlreadySeen(heap_id)
2118 trav.seen[heap_id] = True
2119 out_node = NewRecord('value.Command')
2120 L = out_node.fields
2121 assert self.frag is not None
2122 x0 = self.frag.AbbreviatedTree(trav=trav)
2123 L.append(Field('frag', x0))
2124
2125 if self.captured_frame is not None: # Dict
2126 m = hnode.Leaf("Dict", color_e.OtherConst)
2127 x1 = hnode.Array([m])
2128 for k1, v1 in self.captured_frame.iteritems():
2129 x1.children.append(NewLeaf(k1, color_e.StringConst))
2130 x1.children.append(v1.AbbreviatedTree(trav=trav))
2131 L.append(Field('captured_frame', x1))
2132
2133 if self.module_frame is not None: # Dict
2134 m = hnode.Leaf("Dict", color_e.OtherConst)
2135 x2 = hnode.Array([m])
2136 for k2, v2 in self.module_frame.iteritems():
2137 x2.children.append(NewLeaf(k2, color_e.StringConst))
2138 x2.children.append(v2.AbbreviatedTree(trav=trav))
2139 L.append(Field('module_frame', x2))
2140
2141 return out_node
2142
2143 def AbbreviatedTree(self, trav=None):
2144 # type: (Optional[TraversalState]) -> hnode_t
2145 return self._AbbreviatedTree(trav=trav)
2146
2147 pass
2148
2149class IntBox(pybase.CompoundObj):
2150 _type_tag = 64
2151 __slots__ = ('i',)
2152
2153 def __init__(self, i):
2154 # type: (int) -> None
2155 self.i = i
2156
2157 @staticmethod
2158 def CreateNull(alloc_lists=False):
2159 # type: () -> IntBox
2160 return IntBox(-1)
2161
2162 def PrettyTree(self, trav=None):
2163 # type: (Optional[TraversalState]) -> hnode_t
2164 trav = trav or TraversalState()
2165 heap_id = id(self)
2166 if heap_id in trav.seen:
2167 return hnode.AlreadySeen(heap_id)
2168 trav.seen[heap_id] = True
2169 out_node = NewRecord('IntBox')
2170 L = out_node.fields
2171
2172 x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
2173 L.append(Field('i', x0))
2174
2175 return out_node
2176
2177 def _AbbreviatedTree(self, trav=None):
2178 # type: (Optional[TraversalState]) -> hnode_t
2179 trav = trav or TraversalState()
2180 heap_id = id(self)
2181 if heap_id in trav.seen:
2182 return hnode.AlreadySeen(heap_id)
2183 trav.seen[heap_id] = True
2184 out_node = NewRecord('IntBox')
2185 L = out_node.fields
2186 x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
2187 L.append(Field('i', x0))
2188
2189 return out_node
2190
2191 def AbbreviatedTree(self, trav=None):
2192 # type: (Optional[TraversalState]) -> hnode_t
2193 return self._AbbreviatedTree(trav=trav)
2194
2195class ProcDefaults(pybase.CompoundObj):
2196 _type_tag = 65
2197 __slots__ = ('for_word', 'for_typed', 'for_named', 'for_block')
2198
2199 def __init__(self, for_word, for_typed, for_named, for_block):
2200 # type: (Optional[List[value_t]], Optional[List[value_t]], Optional[Dict[str, value_t]], Optional[value_t]) -> None
2201 self.for_word = for_word
2202 self.for_typed = for_typed
2203 self.for_named = for_named
2204 self.for_block = for_block
2205
2206 @staticmethod
2207 def CreateNull(alloc_lists=False):
2208 # type: () -> ProcDefaults
2209 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))
2210
2211 def PrettyTree(self, trav=None):
2212 # type: (Optional[TraversalState]) -> hnode_t
2213 trav = trav or TraversalState()
2214 heap_id = id(self)
2215 if heap_id in trav.seen:
2216 return hnode.AlreadySeen(heap_id)
2217 trav.seen[heap_id] = True
2218 out_node = NewRecord('ProcDefaults')
2219 L = out_node.fields
2220
2221 if self.for_word is not None: # List
2222 x0 = hnode.Array([])
2223 for i0 in self.for_word:
2224 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
2225 i0.PrettyTree(trav=trav))
2226 x0.children.append(h)
2227 L.append(Field('for_word', x0))
2228
2229 if self.for_typed is not None: # List
2230 x1 = hnode.Array([])
2231 for i1 in self.for_typed:
2232 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
2233 i1.PrettyTree(trav=trav))
2234 x1.children.append(h)
2235 L.append(Field('for_typed', x1))
2236
2237 if self.for_named is not None: # Dict
2238 m = hnode.Leaf("Dict", color_e.OtherConst)
2239 x2 = hnode.Array([m])
2240 for k2, v2 in self.for_named.iteritems():
2241 x2.children.append(NewLeaf(k2, color_e.StringConst))
2242 x2.children.append(v2.PrettyTree(trav=trav))
2243 L.append(Field('for_named', x2))
2244
2245 if self.for_block is not None: # Optional
2246 x3 = self.for_block.PrettyTree(trav=trav)
2247 L.append(Field('for_block', x3))
2248
2249 return out_node
2250
2251 def _AbbreviatedTree(self, trav=None):
2252 # type: (Optional[TraversalState]) -> hnode_t
2253 trav = trav or TraversalState()
2254 heap_id = id(self)
2255 if heap_id in trav.seen:
2256 return hnode.AlreadySeen(heap_id)
2257 trav.seen[heap_id] = True
2258 out_node = NewRecord('ProcDefaults')
2259 L = out_node.fields
2260 if self.for_word is not None: # List
2261 x0 = hnode.Array([])
2262 for i0 in self.for_word:
2263 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
2264 i0.AbbreviatedTree(trav=trav))
2265 x0.children.append(h)
2266 L.append(Field('for_word', x0))
2267
2268 if self.for_typed is not None: # List
2269 x1 = hnode.Array([])
2270 for i1 in self.for_typed:
2271 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
2272 i1.AbbreviatedTree(trav=trav))
2273 x1.children.append(h)
2274 L.append(Field('for_typed', x1))
2275
2276 if self.for_named is not None: # Dict
2277 m = hnode.Leaf("Dict", color_e.OtherConst)
2278 x2 = hnode.Array([m])
2279 for k2, v2 in self.for_named.iteritems():
2280 x2.children.append(NewLeaf(k2, color_e.StringConst))
2281 x2.children.append(v2.AbbreviatedTree(trav=trav))
2282 L.append(Field('for_named', x2))
2283
2284 if self.for_block is not None: # Optional
2285 x3 = self.for_block.AbbreviatedTree(trav=trav)
2286 L.append(Field('for_block', x3))
2287
2288 return out_node
2289
2290 def AbbreviatedTree(self, trav=None):
2291 # type: (Optional[TraversalState]) -> hnode_t
2292 return self._AbbreviatedTree(trav=trav)
2293
2294class LeftName(y_lvalue_t, sh_lvalue_t):
2295 _type_tag = 66
2296 __slots__ = ('name', 'blame_loc')
2297
2298 def __init__(self, name, blame_loc):
2299 # type: (str, loc_t) -> None
2300 self.name = name
2301 self.blame_loc = blame_loc
2302
2303 @staticmethod
2304 def CreateNull(alloc_lists=False):
2305 # type: () -> LeftName
2306 return LeftName('', cast(loc_t, None))
2307
2308 def PrettyTree(self, trav=None):
2309 # type: (Optional[TraversalState]) -> hnode_t
2310 trav = trav or TraversalState()
2311 heap_id = id(self)
2312 if heap_id in trav.seen:
2313 return hnode.AlreadySeen(heap_id)
2314 trav.seen[heap_id] = True
2315 out_node = NewRecord('LeftName')
2316 L = out_node.fields
2317
2318 x0 = NewLeaf(self.name, color_e.StringConst)
2319 L.append(Field('name', x0))
2320
2321 assert self.blame_loc is not None
2322 x1 = self.blame_loc.PrettyTree(trav=trav)
2323 L.append(Field('blame_loc', x1))
2324
2325 return out_node
2326
2327 def _AbbreviatedTree(self, trav=None):
2328 # type: (Optional[TraversalState]) -> hnode_t
2329 trav = trav or TraversalState()
2330 heap_id = id(self)
2331 if heap_id in trav.seen:
2332 return hnode.AlreadySeen(heap_id)
2333 trav.seen[heap_id] = True
2334 out_node = NewRecord('LeftName')
2335 L = out_node.fields
2336 x0 = NewLeaf(self.name, color_e.StringConst)
2337 L.append(Field('name', x0))
2338
2339 assert self.blame_loc is not None
2340 x1 = self.blame_loc.AbbreviatedTree(trav=trav)
2341 L.append(Field('blame_loc', x1))
2342
2343 return out_node
2344
2345 def AbbreviatedTree(self, trav=None):
2346 # type: (Optional[TraversalState]) -> hnode_t
2347 return self._AbbreviatedTree(trav=trav)
2348
2349class RegexMatch(regex_match_t, value_t):
2350 _type_tag = 67
2351 __slots__ = ('s', 'indices', 'ops')
2352
2353 def __init__(self, s, indices, ops):
2354 # type: (str, List[int], eggex_ops_t) -> None
2355 self.s = s
2356 self.indices = indices
2357 self.ops = ops
2358
2359 @staticmethod
2360 def CreateNull(alloc_lists=False):
2361 # type: () -> RegexMatch
2362 return RegexMatch('', [] if alloc_lists else cast('List[int]', None), cast(eggex_ops_t, None))
2363
2364 def PrettyTree(self, trav=None):
2365 # type: (Optional[TraversalState]) -> hnode_t
2366 trav = trav or TraversalState()
2367 heap_id = id(self)
2368 if heap_id in trav.seen:
2369 return hnode.AlreadySeen(heap_id)
2370 trav.seen[heap_id] = True
2371 out_node = NewRecord('RegexMatch')
2372 L = out_node.fields
2373
2374 x0 = NewLeaf(self.s, color_e.StringConst)
2375 L.append(Field('s', x0))
2376
2377 if self.indices is not None: # List
2378 x1 = hnode.Array([])
2379 for i1 in self.indices:
2380 x1.children.append(hnode.Leaf(str(i1), color_e.OtherConst))
2381 L.append(Field('indices', x1))
2382
2383 assert self.ops is not None
2384 x2 = self.ops.PrettyTree(trav=trav)
2385 L.append(Field('ops', x2))
2386
2387 return out_node
2388
2389 def _AbbreviatedTree(self, trav=None):
2390 # type: (Optional[TraversalState]) -> hnode_t
2391 trav = trav or TraversalState()
2392 heap_id = id(self)
2393 if heap_id in trav.seen:
2394 return hnode.AlreadySeen(heap_id)
2395 trav.seen[heap_id] = True
2396 out_node = NewRecord('RegexMatch')
2397 L = out_node.fields
2398 x0 = NewLeaf(self.s, color_e.StringConst)
2399 L.append(Field('s', x0))
2400
2401 if self.indices is not None: # List
2402 x1 = hnode.Array([])
2403 for i1 in self.indices:
2404 x1.children.append(hnode.Leaf(str(i1), color_e.OtherConst))
2405 L.append(Field('indices', x1))
2406
2407 assert self.ops is not None
2408 x2 = self.ops.AbbreviatedTree(trav=trav)
2409 L.append(Field('ops', x2))
2410
2411 return out_node
2412
2413 def AbbreviatedTree(self, trav=None):
2414 # type: (Optional[TraversalState]) -> hnode_t
2415 return self._AbbreviatedTree(trav=trav)
2416
2417class LiteralBlock(cmd_frag_t):
2418 _type_tag = 68
2419 __slots__ = ('brace_group', 'lines')
2420
2421 def __init__(self, brace_group, lines):
2422 # type: (BraceGroup, List[SourceLine]) -> None
2423 self.brace_group = brace_group
2424 self.lines = lines
2425
2426 @staticmethod
2427 def CreateNull(alloc_lists=False):
2428 # type: () -> LiteralBlock
2429 return LiteralBlock(cast(BraceGroup, None), [] if alloc_lists else cast('List[SourceLine]', None))
2430
2431 def PrettyTree(self, trav=None):
2432 # type: (Optional[TraversalState]) -> hnode_t
2433 trav = trav or TraversalState()
2434 heap_id = id(self)
2435 if heap_id in trav.seen:
2436 return hnode.AlreadySeen(heap_id)
2437 trav.seen[heap_id] = True
2438 out_node = NewRecord('LiteralBlock')
2439 L = out_node.fields
2440
2441 assert self.brace_group is not None
2442 x0 = self.brace_group.PrettyTree(trav=trav)
2443 L.append(Field('brace_group', x0))
2444
2445 if self.lines is not None: # List
2446 x1 = hnode.Array([])
2447 for i1 in self.lines:
2448 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
2449 i1.PrettyTree(trav=trav))
2450 x1.children.append(h)
2451 L.append(Field('lines', x1))
2452
2453 return out_node
2454
2455 def _AbbreviatedTree(self, trav=None):
2456 # type: (Optional[TraversalState]) -> hnode_t
2457 trav = trav or TraversalState()
2458 heap_id = id(self)
2459 if heap_id in trav.seen:
2460 return hnode.AlreadySeen(heap_id)
2461 trav.seen[heap_id] = True
2462 out_node = NewRecord('LiteralBlock')
2463 L = out_node.fields
2464 assert self.brace_group is not None
2465 x0 = self.brace_group.AbbreviatedTree(trav=trav)
2466 L.append(Field('brace_group', x0))
2467
2468 if self.lines is not None: # List
2469 x1 = hnode.Array([])
2470 for i1 in self.lines:
2471 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
2472 i1.AbbreviatedTree(trav=trav))
2473 x1.children.append(h)
2474 L.append(Field('lines', x1))
2475
2476 return out_node
2477
2478 def AbbreviatedTree(self, trav=None):
2479 # type: (Optional[TraversalState]) -> hnode_t
2480 return self._AbbreviatedTree(trav=trav)
2481
2482class Obj(value_t):
2483 _type_tag = 69
2484 __slots__ = ('prototype', 'd')
2485
2486 def __init__(self, prototype, d):
2487 # type: (Optional[Obj], Dict[str, value_t]) -> None
2488 self.prototype = prototype
2489 self.d = d
2490
2491 @staticmethod
2492 def CreateNull(alloc_lists=False):
2493 # type: () -> Obj
2494 return Obj(cast('Optional[Obj]', None), cast('Dict[str, value_t]', None))
2495
2496 def PrettyTree(self, trav=None):
2497 # type: (Optional[TraversalState]) -> hnode_t
2498 trav = trav or TraversalState()
2499 heap_id = id(self)
2500 if heap_id in trav.seen:
2501 return hnode.AlreadySeen(heap_id)
2502 trav.seen[heap_id] = True
2503 out_node = NewRecord('Obj')
2504 L = out_node.fields
2505
2506 if self.prototype is not None: # Optional
2507 x0 = self.prototype.PrettyTree(trav=trav)
2508 L.append(Field('prototype', x0))
2509
2510 if self.d is not None: # Dict
2511 m = hnode.Leaf("Dict", color_e.OtherConst)
2512 x1 = hnode.Array([m])
2513 for k1, v1 in self.d.iteritems():
2514 x1.children.append(NewLeaf(k1, color_e.StringConst))
2515 x1.children.append(v1.PrettyTree(trav=trav))
2516 L.append(Field('d', x1))
2517
2518 return out_node
2519
2520 def _AbbreviatedTree(self, trav=None):
2521 # type: (Optional[TraversalState]) -> hnode_t
2522 trav = trav or TraversalState()
2523 heap_id = id(self)
2524 if heap_id in trav.seen:
2525 return hnode.AlreadySeen(heap_id)
2526 trav.seen[heap_id] = True
2527 out_node = NewRecord('Obj')
2528 L = out_node.fields
2529 if self.prototype is not None: # Optional
2530 x0 = self.prototype.AbbreviatedTree(trav=trav)
2531 L.append(Field('prototype', x0))
2532
2533 if self.d is not None: # Dict
2534 m = hnode.Leaf("Dict", color_e.OtherConst)
2535 x1 = hnode.Array([m])
2536 for k1, v1 in self.d.iteritems():
2537 x1.children.append(NewLeaf(k1, color_e.StringConst))
2538 x1.children.append(v1.AbbreviatedTree(trav=trav))
2539 L.append(Field('d', x1))
2540
2541 return out_node
2542
2543 def AbbreviatedTree(self, trav=None):
2544 # type: (Optional[TraversalState]) -> hnode_t
2545 return self._AbbreviatedTree(trav=trav)
2546