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

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