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

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