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

2131 lines, 1560 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, word_t, command_t, CompoundWord, DoubleQuoted, ArgList, re_t, redir_loc_t, proc_sig_t, LiteralBlock, Func
7 from _devbuild.gen.value_asdl import value_t
8
9from _devbuild.gen.id_kind_asdl import Id_t
10from _devbuild.gen.id_kind_asdl import Id_str
11
12
13from asdl import runtime # For runtime.NO_SPID
14from asdl.runtime import NewRecord, NewLeaf, TraversalState
15from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
16
17class cmd_value_e(object):
18 Argv = 1
19 Assign = 2
20
21_cmd_value_str = {
22 1: 'Argv',
23 2: 'Assign',
24}
25
26def cmd_value_str(tag, dot=True):
27 # type: (int, bool) -> str
28 v = _cmd_value_str[tag]
29 if dot:
30 return "cmd_value.%s" % v
31 else:
32 return v
33
34class cmd_value_t(pybase.CompoundObj):
35 def tag(self):
36 # type: () -> int
37 return self._type_tag
38 pass
39
40class cmd_value(object):
41 class Argv(cmd_value_t):
42 _type_tag = 1
43 __slots__ = ('argv', 'arg_locs', 'is_last_cmd', 'proc_args')
44
45 def __init__(self, argv, arg_locs, is_last_cmd, proc_args):
46 # type: (List[str], List[CompoundWord], bool, Optional[ProcArgs]) -> None
47 self.argv = argv
48 self.arg_locs = arg_locs
49 self.is_last_cmd = is_last_cmd
50 self.proc_args = proc_args
51
52 @staticmethod
53 def CreateNull(alloc_lists=False):
54 # type: () -> cmd_value.Argv
55 return cmd_value.Argv([] if alloc_lists else cast('List[str]', None), [] if alloc_lists else cast('List[CompoundWord]', None), False, cast('Optional[ProcArgs]', None))
56
57 def PrettyTree(self, trav=None):
58 # type: (Optional[TraversalState]) -> hnode_t
59 trav = trav or TraversalState()
60 heap_id = id(self)
61 if heap_id in trav.seen:
62 return hnode.AlreadySeen(heap_id)
63 trav.seen[heap_id] = True
64 out_node = NewRecord('cmd_value.Argv')
65 L = out_node.fields
66
67 if self.argv is not None: # List
68 x0 = hnode.Array([])
69 for i0 in self.argv:
70 x0.children.append(NewLeaf(i0, color_e.StringConst))
71 L.append(Field('argv', x0))
72
73 if self.arg_locs is not None: # List
74 x1 = hnode.Array([])
75 for i1 in self.arg_locs:
76 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
77 i1.PrettyTree(trav=trav))
78 x1.children.append(h)
79 L.append(Field('arg_locs', x1))
80
81 x2 = hnode.Leaf('T' if self.is_last_cmd else 'F', color_e.OtherConst)
82 L.append(Field('is_last_cmd', x2))
83
84 if self.proc_args is not None: # Optional
85 x3 = self.proc_args.PrettyTree(trav=trav)
86 L.append(Field('proc_args', x3))
87
88 return out_node
89
90 def _AbbreviatedTree(self, trav=None):
91 # type: (Optional[TraversalState]) -> hnode_t
92 trav = trav or TraversalState()
93 heap_id = id(self)
94 if heap_id in trav.seen:
95 return hnode.AlreadySeen(heap_id)
96 trav.seen[heap_id] = True
97 out_node = NewRecord('cmd_value.Argv')
98 L = out_node.fields
99 if self.argv is not None: # List
100 x0 = hnode.Array([])
101 for i0 in self.argv:
102 x0.children.append(NewLeaf(i0, color_e.StringConst))
103 L.append(Field('argv', x0))
104
105 if self.arg_locs is not None: # List
106 x1 = hnode.Array([])
107 for i1 in self.arg_locs:
108 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
109 i1.AbbreviatedTree(trav=trav))
110 x1.children.append(h)
111 L.append(Field('arg_locs', x1))
112
113 x2 = hnode.Leaf('T' if self.is_last_cmd else 'F', color_e.OtherConst)
114 L.append(Field('is_last_cmd', x2))
115
116 if self.proc_args is not None: # Optional
117 x3 = self.proc_args.AbbreviatedTree(trav=trav)
118 L.append(Field('proc_args', x3))
119
120 return out_node
121
122 def AbbreviatedTree(self, trav=None):
123 # type: (Optional[TraversalState]) -> hnode_t
124 return self._AbbreviatedTree(trav=trav)
125
126 class Assign(cmd_value_t):
127 _type_tag = 2
128 __slots__ = ('builtin_id', 'argv', 'arg_locs', 'pairs')
129
130 def __init__(self, builtin_id, argv, arg_locs, pairs):
131 # type: (int, List[str], List[CompoundWord], List[AssignArg]) -> None
132 self.builtin_id = builtin_id
133 self.argv = argv
134 self.arg_locs = arg_locs
135 self.pairs = pairs
136
137 @staticmethod
138 def CreateNull(alloc_lists=False):
139 # type: () -> cmd_value.Assign
140 return cmd_value.Assign(-1, [] if alloc_lists else cast('List[str]', None), [] if alloc_lists else cast('List[CompoundWord]', None), [] if alloc_lists else cast('List[AssignArg]', None))
141
142 def PrettyTree(self, trav=None):
143 # type: (Optional[TraversalState]) -> hnode_t
144 trav = trav or TraversalState()
145 heap_id = id(self)
146 if heap_id in trav.seen:
147 return hnode.AlreadySeen(heap_id)
148 trav.seen[heap_id] = True
149 out_node = NewRecord('cmd_value.Assign')
150 L = out_node.fields
151
152 x0 = hnode.Leaf(str(self.builtin_id), color_e.OtherConst)
153 L.append(Field('builtin_id', x0))
154
155 if self.argv is not None: # List
156 x1 = hnode.Array([])
157 for i1 in self.argv:
158 x1.children.append(NewLeaf(i1, color_e.StringConst))
159 L.append(Field('argv', x1))
160
161 if self.arg_locs is not None: # List
162 x2 = hnode.Array([])
163 for i2 in self.arg_locs:
164 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
165 i2.PrettyTree(trav=trav))
166 x2.children.append(h)
167 L.append(Field('arg_locs', x2))
168
169 if self.pairs is not None: # List
170 x3 = hnode.Array([])
171 for i3 in self.pairs:
172 h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
173 i3.PrettyTree(trav=trav))
174 x3.children.append(h)
175 L.append(Field('pairs', x3))
176
177 return out_node
178
179 def _AbbreviatedTree(self, trav=None):
180 # type: (Optional[TraversalState]) -> hnode_t
181 trav = trav or TraversalState()
182 heap_id = id(self)
183 if heap_id in trav.seen:
184 return hnode.AlreadySeen(heap_id)
185 trav.seen[heap_id] = True
186 out_node = NewRecord('cmd_value.Assign')
187 L = out_node.fields
188 x0 = hnode.Leaf(str(self.builtin_id), color_e.OtherConst)
189 L.append(Field('builtin_id', x0))
190
191 if self.argv is not None: # List
192 x1 = hnode.Array([])
193 for i1 in self.argv:
194 x1.children.append(NewLeaf(i1, color_e.StringConst))
195 L.append(Field('argv', x1))
196
197 if self.arg_locs is not None: # List
198 x2 = hnode.Array([])
199 for i2 in self.arg_locs:
200 h = (hnode.Leaf("_", color_e.OtherConst) if i2 is None else
201 i2.AbbreviatedTree(trav=trav))
202 x2.children.append(h)
203 L.append(Field('arg_locs', x2))
204
205 if self.pairs is not None: # List
206 x3 = hnode.Array([])
207 for i3 in self.pairs:
208 h = (hnode.Leaf("_", color_e.OtherConst) if i3 is None else
209 i3.AbbreviatedTree(trav=trav))
210 x3.children.append(h)
211 L.append(Field('pairs', x3))
212
213 return out_node
214
215 def AbbreviatedTree(self, trav=None):
216 # type: (Optional[TraversalState]) -> hnode_t
217 return self._AbbreviatedTree(trav=trav)
218
219 pass
220
221class part_value_e(object):
222 String = 66
223 Array = 2
224 ExtGlob = 3
225
226_part_value_str = {
227 2: 'Array',
228 3: 'ExtGlob',
229 66: 'String',
230}
231
232def part_value_str(tag, dot=True):
233 # type: (int, bool) -> str
234 v = _part_value_str[tag]
235 if dot:
236 return "part_value.%s" % v
237 else:
238 return v
239
240class part_value_t(pybase.CompoundObj):
241 def tag(self):
242 # type: () -> int
243 return self._type_tag
244 pass
245
246class part_value(object):
247 class Array(part_value_t):
248 _type_tag = 2
249 __slots__ = ('strs',)
250
251 def __init__(self, strs):
252 # type: (List[str]) -> None
253 self.strs = strs
254
255 @staticmethod
256 def CreateNull(alloc_lists=False):
257 # type: () -> part_value.Array
258 return part_value.Array([] if alloc_lists else cast('List[str]', None))
259
260 def PrettyTree(self, trav=None):
261 # type: (Optional[TraversalState]) -> hnode_t
262 trav = trav or TraversalState()
263 heap_id = id(self)
264 if heap_id in trav.seen:
265 return hnode.AlreadySeen(heap_id)
266 trav.seen[heap_id] = True
267 out_node = NewRecord('part_value.Array')
268 L = out_node.fields
269
270 if self.strs is not None: # List
271 x0 = hnode.Array([])
272 for i0 in self.strs:
273 x0.children.append(NewLeaf(i0, color_e.StringConst))
274 L.append(Field('strs', x0))
275
276 return out_node
277
278 def _AbbreviatedTree(self, trav=None):
279 # type: (Optional[TraversalState]) -> hnode_t
280 trav = trav or TraversalState()
281 heap_id = id(self)
282 if heap_id in trav.seen:
283 return hnode.AlreadySeen(heap_id)
284 trav.seen[heap_id] = True
285 out_node = NewRecord('part_value.Array')
286 L = out_node.fields
287 if self.strs is not None: # List
288 x0 = hnode.Array([])
289 for i0 in self.strs:
290 x0.children.append(NewLeaf(i0, color_e.StringConst))
291 L.append(Field('strs', x0))
292
293 return out_node
294
295 def AbbreviatedTree(self, trav=None):
296 # type: (Optional[TraversalState]) -> hnode_t
297 return self._AbbreviatedTree(trav=trav)
298
299 class ExtGlob(part_value_t):
300 _type_tag = 3
301 __slots__ = ('part_vals',)
302
303 def __init__(self, part_vals):
304 # type: (List[part_value_t]) -> None
305 self.part_vals = part_vals
306
307 @staticmethod
308 def CreateNull(alloc_lists=False):
309 # type: () -> part_value.ExtGlob
310 return part_value.ExtGlob([] if alloc_lists else cast('List[part_value_t]', None))
311
312 def PrettyTree(self, trav=None):
313 # type: (Optional[TraversalState]) -> hnode_t
314 trav = trav or TraversalState()
315 heap_id = id(self)
316 if heap_id in trav.seen:
317 return hnode.AlreadySeen(heap_id)
318 trav.seen[heap_id] = True
319 out_node = NewRecord('part_value.ExtGlob')
320 L = out_node.fields
321
322 if self.part_vals is not None: # List
323 x0 = hnode.Array([])
324 for i0 in self.part_vals:
325 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
326 i0.PrettyTree(trav=trav))
327 x0.children.append(h)
328 L.append(Field('part_vals', x0))
329
330 return out_node
331
332 def _AbbreviatedTree(self, trav=None):
333 # type: (Optional[TraversalState]) -> hnode_t
334 trav = trav or TraversalState()
335 heap_id = id(self)
336 if heap_id in trav.seen:
337 return hnode.AlreadySeen(heap_id)
338 trav.seen[heap_id] = True
339 out_node = NewRecord('part_value.ExtGlob')
340 L = out_node.fields
341 if self.part_vals is not None: # List
342 x0 = hnode.Array([])
343 for i0 in self.part_vals:
344 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
345 i0.AbbreviatedTree(trav=trav))
346 x0.children.append(h)
347 L.append(Field('part_vals', x0))
348
349 return out_node
350
351 def AbbreviatedTree(self, trav=None):
352 # type: (Optional[TraversalState]) -> hnode_t
353 return self._AbbreviatedTree(trav=trav)
354
355 pass
356
357class coerced_t(pybase.SimpleObj):
358 pass
359
360class coerced_e(object):
361 Int = coerced_t(1)
362 Float = coerced_t(2)
363 Neither = coerced_t(3)
364
365_coerced_str = {
366 1: 'coerced.Int',
367 2: 'coerced.Float',
368 3: 'coerced.Neither',
369}
370
371def coerced_str(val):
372 # type: (coerced_t) -> str
373 return _coerced_str[val]
374
375class scope_t(pybase.SimpleObj):
376 pass
377
378class scope_e(object):
379 Shopt = scope_t(1)
380 Dynamic = scope_t(2)
381 LocalOrGlobal = scope_t(3)
382 LocalOnly = scope_t(4)
383 GlobalOnly = scope_t(5)
384
385_scope_str = {
386 1: 'scope.Shopt',
387 2: 'scope.Dynamic',
388 3: 'scope.LocalOrGlobal',
389 4: 'scope.LocalOnly',
390 5: 'scope.GlobalOnly',
391}
392
393def scope_str(val):
394 # type: (scope_t) -> str
395 return _scope_str[val]
396
397class a_index_e(object):
398 Str = 1
399 Int = 2
400
401_a_index_str = {
402 1: 'Str',
403 2: 'Int',
404}
405
406def a_index_str(tag, dot=True):
407 # type: (int, bool) -> str
408 v = _a_index_str[tag]
409 if dot:
410 return "a_index.%s" % v
411 else:
412 return v
413
414class a_index_t(pybase.CompoundObj):
415 def tag(self):
416 # type: () -> int
417 return self._type_tag
418 pass
419
420class a_index(object):
421 class Str(a_index_t):
422 _type_tag = 1
423 __slots__ = ('s',)
424
425 def __init__(self, s):
426 # type: (str) -> None
427 self.s = s
428
429 @staticmethod
430 def CreateNull(alloc_lists=False):
431 # type: () -> a_index.Str
432 return a_index.Str('')
433
434 def PrettyTree(self, trav=None):
435 # type: (Optional[TraversalState]) -> hnode_t
436 trav = trav or TraversalState()
437 heap_id = id(self)
438 if heap_id in trav.seen:
439 return hnode.AlreadySeen(heap_id)
440 trav.seen[heap_id] = True
441 out_node = NewRecord('a_index.Str')
442 L = out_node.fields
443
444 x0 = NewLeaf(self.s, color_e.StringConst)
445 L.append(Field('s', x0))
446
447 return out_node
448
449 def _AbbreviatedTree(self, trav=None):
450 # type: (Optional[TraversalState]) -> hnode_t
451 trav = trav or TraversalState()
452 heap_id = id(self)
453 if heap_id in trav.seen:
454 return hnode.AlreadySeen(heap_id)
455 trav.seen[heap_id] = True
456 out_node = NewRecord('a_index.Str')
457 L = out_node.fields
458 x0 = NewLeaf(self.s, color_e.StringConst)
459 L.append(Field('s', x0))
460
461 return out_node
462
463 def AbbreviatedTree(self, trav=None):
464 # type: (Optional[TraversalState]) -> hnode_t
465 return self._AbbreviatedTree(trav=trav)
466
467 class Int(a_index_t):
468 _type_tag = 2
469 __slots__ = ('i',)
470
471 def __init__(self, i):
472 # type: (int) -> None
473 self.i = i
474
475 @staticmethod
476 def CreateNull(alloc_lists=False):
477 # type: () -> a_index.Int
478 return a_index.Int(-1)
479
480 def PrettyTree(self, trav=None):
481 # type: (Optional[TraversalState]) -> hnode_t
482 trav = trav or TraversalState()
483 heap_id = id(self)
484 if heap_id in trav.seen:
485 return hnode.AlreadySeen(heap_id)
486 trav.seen[heap_id] = True
487 out_node = NewRecord('a_index.Int')
488 L = out_node.fields
489
490 x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
491 L.append(Field('i', x0))
492
493 return out_node
494
495 def _AbbreviatedTree(self, trav=None):
496 # type: (Optional[TraversalState]) -> hnode_t
497 trav = trav or TraversalState()
498 heap_id = id(self)
499 if heap_id in trav.seen:
500 return hnode.AlreadySeen(heap_id)
501 trav.seen[heap_id] = True
502 out_node = NewRecord('a_index.Int')
503 L = out_node.fields
504 x0 = hnode.Leaf(str(self.i), color_e.OtherConst)
505 L.append(Field('i', x0))
506
507 return out_node
508
509 def AbbreviatedTree(self, trav=None):
510 # type: (Optional[TraversalState]) -> hnode_t
511 return self._AbbreviatedTree(trav=trav)
512
513 pass
514
515class redirect_arg_e(object):
516 Path = 1
517 CopyFd = 2
518 MoveFd = 3
519 CloseFd = 4
520 HereDoc = 5
521
522_redirect_arg_str = {
523 1: 'Path',
524 2: 'CopyFd',
525 3: 'MoveFd',
526 4: 'CloseFd',
527 5: 'HereDoc',
528}
529
530def redirect_arg_str(tag, dot=True):
531 # type: (int, bool) -> str
532 v = _redirect_arg_str[tag]
533 if dot:
534 return "redirect_arg.%s" % v
535 else:
536 return v
537
538class redirect_arg_t(pybase.CompoundObj):
539 def tag(self):
540 # type: () -> int
541 return self._type_tag
542 pass
543
544class redirect_arg__CloseFd(redirect_arg_t):
545 _type_tag = 4
546 __slots__ = ()
547
548 def __init__(self, ):
549 # type: () -> None
550 pass
551
552 def PrettyTree(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('redirect_arg__CloseFd')
560 L = out_node.fields
561
562 return out_node
563
564 def _AbbreviatedTree(self, trav=None):
565 # type: (Optional[TraversalState]) -> hnode_t
566 trav = trav or TraversalState()
567 heap_id = id(self)
568 if heap_id in trav.seen:
569 return hnode.AlreadySeen(heap_id)
570 trav.seen[heap_id] = True
571 out_node = NewRecord('redirect_arg__CloseFd')
572 L = out_node.fields
573 return out_node
574
575 def AbbreviatedTree(self, trav=None):
576 # type: (Optional[TraversalState]) -> hnode_t
577 return self._AbbreviatedTree(trav=trav)
578
579class redirect_arg(object):
580 class Path(redirect_arg_t):
581 _type_tag = 1
582 __slots__ = ('filename',)
583
584 def __init__(self, filename):
585 # type: (str) -> None
586 self.filename = filename
587
588 @staticmethod
589 def CreateNull(alloc_lists=False):
590 # type: () -> redirect_arg.Path
591 return redirect_arg.Path('')
592
593 def PrettyTree(self, trav=None):
594 # type: (Optional[TraversalState]) -> hnode_t
595 trav = trav or TraversalState()
596 heap_id = id(self)
597 if heap_id in trav.seen:
598 return hnode.AlreadySeen(heap_id)
599 trav.seen[heap_id] = True
600 out_node = NewRecord('redirect_arg.Path')
601 L = out_node.fields
602
603 x0 = NewLeaf(self.filename, color_e.StringConst)
604 L.append(Field('filename', x0))
605
606 return out_node
607
608 def _AbbreviatedTree(self, trav=None):
609 # type: (Optional[TraversalState]) -> hnode_t
610 trav = trav or TraversalState()
611 heap_id = id(self)
612 if heap_id in trav.seen:
613 return hnode.AlreadySeen(heap_id)
614 trav.seen[heap_id] = True
615 out_node = NewRecord('redirect_arg.Path')
616 L = out_node.fields
617 x0 = NewLeaf(self.filename, color_e.StringConst)
618 L.append(Field('filename', x0))
619
620 return out_node
621
622 def AbbreviatedTree(self, trav=None):
623 # type: (Optional[TraversalState]) -> hnode_t
624 return self._AbbreviatedTree(trav=trav)
625
626 class CopyFd(redirect_arg_t):
627 _type_tag = 2
628 __slots__ = ('target_fd',)
629
630 def __init__(self, target_fd):
631 # type: (int) -> None
632 self.target_fd = target_fd
633
634 @staticmethod
635 def CreateNull(alloc_lists=False):
636 # type: () -> redirect_arg.CopyFd
637 return redirect_arg.CopyFd(-1)
638
639 def PrettyTree(self, trav=None):
640 # type: (Optional[TraversalState]) -> hnode_t
641 trav = trav or TraversalState()
642 heap_id = id(self)
643 if heap_id in trav.seen:
644 return hnode.AlreadySeen(heap_id)
645 trav.seen[heap_id] = True
646 out_node = NewRecord('redirect_arg.CopyFd')
647 L = out_node.fields
648
649 x0 = hnode.Leaf(str(self.target_fd), color_e.OtherConst)
650 L.append(Field('target_fd', x0))
651
652 return out_node
653
654 def _AbbreviatedTree(self, trav=None):
655 # type: (Optional[TraversalState]) -> hnode_t
656 trav = trav or TraversalState()
657 heap_id = id(self)
658 if heap_id in trav.seen:
659 return hnode.AlreadySeen(heap_id)
660 trav.seen[heap_id] = True
661 out_node = NewRecord('redirect_arg.CopyFd')
662 L = out_node.fields
663 x0 = hnode.Leaf(str(self.target_fd), color_e.OtherConst)
664 L.append(Field('target_fd', x0))
665
666 return out_node
667
668 def AbbreviatedTree(self, trav=None):
669 # type: (Optional[TraversalState]) -> hnode_t
670 return self._AbbreviatedTree(trav=trav)
671
672 class MoveFd(redirect_arg_t):
673 _type_tag = 3
674 __slots__ = ('target_fd',)
675
676 def __init__(self, target_fd):
677 # type: (int) -> None
678 self.target_fd = target_fd
679
680 @staticmethod
681 def CreateNull(alloc_lists=False):
682 # type: () -> redirect_arg.MoveFd
683 return redirect_arg.MoveFd(-1)
684
685 def PrettyTree(self, trav=None):
686 # type: (Optional[TraversalState]) -> hnode_t
687 trav = trav or TraversalState()
688 heap_id = id(self)
689 if heap_id in trav.seen:
690 return hnode.AlreadySeen(heap_id)
691 trav.seen[heap_id] = True
692 out_node = NewRecord('redirect_arg.MoveFd')
693 L = out_node.fields
694
695 x0 = hnode.Leaf(str(self.target_fd), color_e.OtherConst)
696 L.append(Field('target_fd', x0))
697
698 return out_node
699
700 def _AbbreviatedTree(self, trav=None):
701 # type: (Optional[TraversalState]) -> hnode_t
702 trav = trav or TraversalState()
703 heap_id = id(self)
704 if heap_id in trav.seen:
705 return hnode.AlreadySeen(heap_id)
706 trav.seen[heap_id] = True
707 out_node = NewRecord('redirect_arg.MoveFd')
708 L = out_node.fields
709 x0 = hnode.Leaf(str(self.target_fd), color_e.OtherConst)
710 L.append(Field('target_fd', x0))
711
712 return out_node
713
714 def AbbreviatedTree(self, trav=None):
715 # type: (Optional[TraversalState]) -> hnode_t
716 return self._AbbreviatedTree(trav=trav)
717
718 CloseFd = redirect_arg__CloseFd()
719
720 class HereDoc(redirect_arg_t):
721 _type_tag = 5
722 __slots__ = ('body',)
723
724 def __init__(self, body):
725 # type: (str) -> None
726 self.body = body
727
728 @staticmethod
729 def CreateNull(alloc_lists=False):
730 # type: () -> redirect_arg.HereDoc
731 return redirect_arg.HereDoc('')
732
733 def PrettyTree(self, trav=None):
734 # type: (Optional[TraversalState]) -> hnode_t
735 trav = trav or TraversalState()
736 heap_id = id(self)
737 if heap_id in trav.seen:
738 return hnode.AlreadySeen(heap_id)
739 trav.seen[heap_id] = True
740 out_node = NewRecord('redirect_arg.HereDoc')
741 L = out_node.fields
742
743 x0 = NewLeaf(self.body, color_e.StringConst)
744 L.append(Field('body', x0))
745
746 return out_node
747
748 def _AbbreviatedTree(self, trav=None):
749 # type: (Optional[TraversalState]) -> hnode_t
750 trav = trav or TraversalState()
751 heap_id = id(self)
752 if heap_id in trav.seen:
753 return hnode.AlreadySeen(heap_id)
754 trav.seen[heap_id] = True
755 out_node = NewRecord('redirect_arg.HereDoc')
756 L = out_node.fields
757 x0 = NewLeaf(self.body, color_e.StringConst)
758 L.append(Field('body', x0))
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 pass
767
768class wait_status_e(object):
769 Proc = 1
770 Pipeline = 2
771 Cancelled = 3
772
773_wait_status_str = {
774 1: 'Proc',
775 2: 'Pipeline',
776 3: 'Cancelled',
777}
778
779def wait_status_str(tag, dot=True):
780 # type: (int, bool) -> str
781 v = _wait_status_str[tag]
782 if dot:
783 return "wait_status.%s" % v
784 else:
785 return v
786
787class wait_status_t(pybase.CompoundObj):
788 def tag(self):
789 # type: () -> int
790 return self._type_tag
791 pass
792
793class wait_status(object):
794 class Proc(wait_status_t):
795 _type_tag = 1
796 __slots__ = ('code',)
797
798 def __init__(self, code):
799 # type: (int) -> None
800 self.code = code
801
802 @staticmethod
803 def CreateNull(alloc_lists=False):
804 # type: () -> wait_status.Proc
805 return wait_status.Proc(-1)
806
807 def PrettyTree(self, trav=None):
808 # type: (Optional[TraversalState]) -> hnode_t
809 trav = trav or TraversalState()
810 heap_id = id(self)
811 if heap_id in trav.seen:
812 return hnode.AlreadySeen(heap_id)
813 trav.seen[heap_id] = True
814 out_node = NewRecord('wait_status.Proc')
815 L = out_node.fields
816
817 x0 = hnode.Leaf(str(self.code), color_e.OtherConst)
818 L.append(Field('code', x0))
819
820 return out_node
821
822 def _AbbreviatedTree(self, trav=None):
823 # type: (Optional[TraversalState]) -> hnode_t
824 trav = trav or TraversalState()
825 heap_id = id(self)
826 if heap_id in trav.seen:
827 return hnode.AlreadySeen(heap_id)
828 trav.seen[heap_id] = True
829 out_node = NewRecord('wait_status.Proc')
830 L = out_node.fields
831 x0 = hnode.Leaf(str(self.code), color_e.OtherConst)
832 L.append(Field('code', x0))
833
834 return out_node
835
836 def AbbreviatedTree(self, trav=None):
837 # type: (Optional[TraversalState]) -> hnode_t
838 return self._AbbreviatedTree(trav=trav)
839
840 class Pipeline(wait_status_t):
841 _type_tag = 2
842 __slots__ = ('codes',)
843
844 def __init__(self, codes):
845 # type: (List[int]) -> None
846 self.codes = codes
847
848 @staticmethod
849 def CreateNull(alloc_lists=False):
850 # type: () -> wait_status.Pipeline
851 return wait_status.Pipeline([] if alloc_lists else cast('List[int]', None))
852
853 def PrettyTree(self, trav=None):
854 # type: (Optional[TraversalState]) -> hnode_t
855 trav = trav or TraversalState()
856 heap_id = id(self)
857 if heap_id in trav.seen:
858 return hnode.AlreadySeen(heap_id)
859 trav.seen[heap_id] = True
860 out_node = NewRecord('wait_status.Pipeline')
861 L = out_node.fields
862
863 if self.codes is not None: # List
864 x0 = hnode.Array([])
865 for i0 in self.codes:
866 x0.children.append(hnode.Leaf(str(i0), color_e.OtherConst))
867 L.append(Field('codes', x0))
868
869 return out_node
870
871 def _AbbreviatedTree(self, trav=None):
872 # type: (Optional[TraversalState]) -> hnode_t
873 trav = trav or TraversalState()
874 heap_id = id(self)
875 if heap_id in trav.seen:
876 return hnode.AlreadySeen(heap_id)
877 trav.seen[heap_id] = True
878 out_node = NewRecord('wait_status.Pipeline')
879 L = out_node.fields
880 if self.codes is not None: # List
881 x0 = hnode.Array([])
882 for i0 in self.codes:
883 x0.children.append(hnode.Leaf(str(i0), color_e.OtherConst))
884 L.append(Field('codes', x0))
885
886 return out_node
887
888 def AbbreviatedTree(self, trav=None):
889 # type: (Optional[TraversalState]) -> hnode_t
890 return self._AbbreviatedTree(trav=trav)
891
892 class Cancelled(wait_status_t):
893 _type_tag = 3
894 __slots__ = ('sig_num',)
895
896 def __init__(self, sig_num):
897 # type: (int) -> None
898 self.sig_num = sig_num
899
900 @staticmethod
901 def CreateNull(alloc_lists=False):
902 # type: () -> wait_status.Cancelled
903 return wait_status.Cancelled(-1)
904
905 def PrettyTree(self, trav=None):
906 # type: (Optional[TraversalState]) -> hnode_t
907 trav = trav or TraversalState()
908 heap_id = id(self)
909 if heap_id in trav.seen:
910 return hnode.AlreadySeen(heap_id)
911 trav.seen[heap_id] = True
912 out_node = NewRecord('wait_status.Cancelled')
913 L = out_node.fields
914
915 x0 = hnode.Leaf(str(self.sig_num), color_e.OtherConst)
916 L.append(Field('sig_num', x0))
917
918 return out_node
919
920 def _AbbreviatedTree(self, trav=None):
921 # type: (Optional[TraversalState]) -> hnode_t
922 trav = trav or TraversalState()
923 heap_id = id(self)
924 if heap_id in trav.seen:
925 return hnode.AlreadySeen(heap_id)
926 trav.seen[heap_id] = True
927 out_node = NewRecord('wait_status.Cancelled')
928 L = out_node.fields
929 x0 = hnode.Leaf(str(self.sig_num), color_e.OtherConst)
930 L.append(Field('sig_num', x0))
931
932 return out_node
933
934 def AbbreviatedTree(self, trav=None):
935 # type: (Optional[TraversalState]) -> hnode_t
936 return self._AbbreviatedTree(trav=trav)
937
938 pass
939
940class flow_t(pybase.SimpleObj):
941 pass
942
943class flow_e(object):
944 Nothing = flow_t(1)
945 Break = flow_t(2)
946 Raise = flow_t(3)
947
948_flow_str = {
949 1: 'flow.Nothing',
950 2: 'flow.Break',
951 3: 'flow.Raise',
952}
953
954def flow_str(val):
955 # type: (flow_t) -> str
956 return _flow_str[val]
957
958class span_t(pybase.SimpleObj):
959 pass
960
961class span_e(object):
962 Black = span_t(1)
963 Delim = span_t(2)
964 Backslash = span_t(3)
965
966_span_str = {
967 1: 'span.Black',
968 2: 'span.Delim',
969 3: 'span.Backslash',
970}
971
972def span_str(val):
973 # type: (span_t) -> str
974 return _span_str[val]
975
976emit_t = int # type alias for integer
977
978class emit_i(object):
979 Part = 1
980 Delim = 2
981 Empty = 3
982 Escape = 4
983 Nothing = 5
984 ARRAY_SIZE = 6
985
986_emit_str = {
987 1: 'emit.Part',
988 2: 'emit.Delim',
989 3: 'emit.Empty',
990 4: 'emit.Escape',
991 5: 'emit.Nothing',
992}
993
994def emit_str(val):
995 # type: (emit_t) -> str
996 return _emit_str[val]
997
998state_t = int # type alias for integer
999
1000class state_i(object):
1001 Invalid = 1
1002 Start = 2
1003 DE_White1 = 3
1004 DE_Gray = 4
1005 DE_White2 = 5
1006 Black = 6
1007 Backslash = 7
1008 Done = 8
1009 ARRAY_SIZE = 9
1010
1011_state_str = {
1012 1: 'state.Invalid',
1013 2: 'state.Start',
1014 3: 'state.DE_White1',
1015 4: 'state.DE_Gray',
1016 5: 'state.DE_White2',
1017 6: 'state.Black',
1018 7: 'state.Backslash',
1019 8: 'state.Done',
1020}
1021
1022def state_str(val):
1023 # type: (state_t) -> str
1024 return _state_str[val]
1025
1026char_kind_t = int # type alias for integer
1027
1028class char_kind_i(object):
1029 DE_White = 1
1030 DE_Gray = 2
1031 Black = 3
1032 Backslash = 4
1033 Sentinel = 5
1034 ARRAY_SIZE = 6
1035
1036_char_kind_str = {
1037 1: 'char_kind.DE_White',
1038 2: 'char_kind.DE_Gray',
1039 3: 'char_kind.Black',
1040 4: 'char_kind.Backslash',
1041 5: 'char_kind.Sentinel',
1042}
1043
1044def char_kind_str(val):
1045 # type: (char_kind_t) -> str
1046 return _char_kind_str[val]
1047
1048class job_state_t(pybase.SimpleObj):
1049 pass
1050
1051class job_state_e(object):
1052 Running = job_state_t(1)
1053 Done = job_state_t(2)
1054 Stopped = job_state_t(3)
1055
1056_job_state_str = {
1057 1: 'job_state.Running',
1058 2: 'job_state.Done',
1059 3: 'job_state.Stopped',
1060}
1061
1062def job_state_str(val):
1063 # type: (job_state_t) -> str
1064 return _job_state_str[val]
1065
1066class flag_type_t(pybase.SimpleObj):
1067 pass
1068
1069class flag_type_e(object):
1070 Bool = flag_type_t(1)
1071 Int = flag_type_t(2)
1072 Float = flag_type_t(3)
1073 Str = flag_type_t(4)
1074
1075_flag_type_str = {
1076 1: 'flag_type.Bool',
1077 2: 'flag_type.Int',
1078 3: 'flag_type.Float',
1079 4: 'flag_type.Str',
1080}
1081
1082def flag_type_str(val):
1083 # type: (flag_type_t) -> str
1084 return _flag_type_str[val]
1085
1086class trace_e(object):
1087 External = 1
1088 CommandSub = 2
1089 ForkWait = 3
1090 Fork = 4
1091 PipelinePart = 5
1092 ProcessSub = 6
1093 HereDoc = 7
1094
1095_trace_str = {
1096 1: 'External',
1097 2: 'CommandSub',
1098 3: 'ForkWait',
1099 4: 'Fork',
1100 5: 'PipelinePart',
1101 6: 'ProcessSub',
1102 7: 'HereDoc',
1103}
1104
1105def trace_str(tag, dot=True):
1106 # type: (int, bool) -> str
1107 v = _trace_str[tag]
1108 if dot:
1109 return "trace.%s" % v
1110 else:
1111 return v
1112
1113class trace_t(pybase.CompoundObj):
1114 def tag(self):
1115 # type: () -> int
1116 return self._type_tag
1117 pass
1118
1119class trace__CommandSub(trace_t):
1120 _type_tag = 2
1121 __slots__ = ()
1122
1123 def __init__(self, ):
1124 # type: () -> None
1125 pass
1126
1127 def PrettyTree(self, trav=None):
1128 # type: (Optional[TraversalState]) -> hnode_t
1129 trav = trav or TraversalState()
1130 heap_id = id(self)
1131 if heap_id in trav.seen:
1132 return hnode.AlreadySeen(heap_id)
1133 trav.seen[heap_id] = True
1134 out_node = NewRecord('trace__CommandSub')
1135 L = out_node.fields
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('trace__CommandSub')
1147 L = out_node.fields
1148 return out_node
1149
1150 def AbbreviatedTree(self, trav=None):
1151 # type: (Optional[TraversalState]) -> hnode_t
1152 return self._AbbreviatedTree(trav=trav)
1153
1154class trace__ForkWait(trace_t):
1155 _type_tag = 3
1156 __slots__ = ()
1157
1158 def __init__(self, ):
1159 # type: () -> None
1160 pass
1161
1162 def PrettyTree(self, trav=None):
1163 # type: (Optional[TraversalState]) -> hnode_t
1164 trav = trav or TraversalState()
1165 heap_id = id(self)
1166 if heap_id in trav.seen:
1167 return hnode.AlreadySeen(heap_id)
1168 trav.seen[heap_id] = True
1169 out_node = NewRecord('trace__ForkWait')
1170 L = out_node.fields
1171
1172 return out_node
1173
1174 def _AbbreviatedTree(self, trav=None):
1175 # type: (Optional[TraversalState]) -> hnode_t
1176 trav = trav or TraversalState()
1177 heap_id = id(self)
1178 if heap_id in trav.seen:
1179 return hnode.AlreadySeen(heap_id)
1180 trav.seen[heap_id] = True
1181 out_node = NewRecord('trace__ForkWait')
1182 L = out_node.fields
1183 return out_node
1184
1185 def AbbreviatedTree(self, trav=None):
1186 # type: (Optional[TraversalState]) -> hnode_t
1187 return self._AbbreviatedTree(trav=trav)
1188
1189class trace__Fork(trace_t):
1190 _type_tag = 4
1191 __slots__ = ()
1192
1193 def __init__(self, ):
1194 # type: () -> None
1195 pass
1196
1197 def PrettyTree(self, trav=None):
1198 # type: (Optional[TraversalState]) -> hnode_t
1199 trav = trav or TraversalState()
1200 heap_id = id(self)
1201 if heap_id in trav.seen:
1202 return hnode.AlreadySeen(heap_id)
1203 trav.seen[heap_id] = True
1204 out_node = NewRecord('trace__Fork')
1205 L = out_node.fields
1206
1207 return out_node
1208
1209 def _AbbreviatedTree(self, trav=None):
1210 # type: (Optional[TraversalState]) -> hnode_t
1211 trav = trav or TraversalState()
1212 heap_id = id(self)
1213 if heap_id in trav.seen:
1214 return hnode.AlreadySeen(heap_id)
1215 trav.seen[heap_id] = True
1216 out_node = NewRecord('trace__Fork')
1217 L = out_node.fields
1218 return out_node
1219
1220 def AbbreviatedTree(self, trav=None):
1221 # type: (Optional[TraversalState]) -> hnode_t
1222 return self._AbbreviatedTree(trav=trav)
1223
1224class trace__PipelinePart(trace_t):
1225 _type_tag = 5
1226 __slots__ = ()
1227
1228 def __init__(self, ):
1229 # type: () -> None
1230 pass
1231
1232 def PrettyTree(self, trav=None):
1233 # type: (Optional[TraversalState]) -> hnode_t
1234 trav = trav or TraversalState()
1235 heap_id = id(self)
1236 if heap_id in trav.seen:
1237 return hnode.AlreadySeen(heap_id)
1238 trav.seen[heap_id] = True
1239 out_node = NewRecord('trace__PipelinePart')
1240 L = out_node.fields
1241
1242 return out_node
1243
1244 def _AbbreviatedTree(self, trav=None):
1245 # type: (Optional[TraversalState]) -> hnode_t
1246 trav = trav or TraversalState()
1247 heap_id = id(self)
1248 if heap_id in trav.seen:
1249 return hnode.AlreadySeen(heap_id)
1250 trav.seen[heap_id] = True
1251 out_node = NewRecord('trace__PipelinePart')
1252 L = out_node.fields
1253 return out_node
1254
1255 def AbbreviatedTree(self, trav=None):
1256 # type: (Optional[TraversalState]) -> hnode_t
1257 return self._AbbreviatedTree(trav=trav)
1258
1259class trace__ProcessSub(trace_t):
1260 _type_tag = 6
1261 __slots__ = ()
1262
1263 def __init__(self, ):
1264 # type: () -> None
1265 pass
1266
1267 def PrettyTree(self, trav=None):
1268 # type: (Optional[TraversalState]) -> hnode_t
1269 trav = trav or TraversalState()
1270 heap_id = id(self)
1271 if heap_id in trav.seen:
1272 return hnode.AlreadySeen(heap_id)
1273 trav.seen[heap_id] = True
1274 out_node = NewRecord('trace__ProcessSub')
1275 L = out_node.fields
1276
1277 return out_node
1278
1279 def _AbbreviatedTree(self, trav=None):
1280 # type: (Optional[TraversalState]) -> hnode_t
1281 trav = trav or TraversalState()
1282 heap_id = id(self)
1283 if heap_id in trav.seen:
1284 return hnode.AlreadySeen(heap_id)
1285 trav.seen[heap_id] = True
1286 out_node = NewRecord('trace__ProcessSub')
1287 L = out_node.fields
1288 return out_node
1289
1290 def AbbreviatedTree(self, trav=None):
1291 # type: (Optional[TraversalState]) -> hnode_t
1292 return self._AbbreviatedTree(trav=trav)
1293
1294class trace__HereDoc(trace_t):
1295 _type_tag = 7
1296 __slots__ = ()
1297
1298 def __init__(self, ):
1299 # type: () -> None
1300 pass
1301
1302 def PrettyTree(self, trav=None):
1303 # type: (Optional[TraversalState]) -> hnode_t
1304 trav = trav or TraversalState()
1305 heap_id = id(self)
1306 if heap_id in trav.seen:
1307 return hnode.AlreadySeen(heap_id)
1308 trav.seen[heap_id] = True
1309 out_node = NewRecord('trace__HereDoc')
1310 L = out_node.fields
1311
1312 return out_node
1313
1314 def _AbbreviatedTree(self, trav=None):
1315 # type: (Optional[TraversalState]) -> hnode_t
1316 trav = trav or TraversalState()
1317 heap_id = id(self)
1318 if heap_id in trav.seen:
1319 return hnode.AlreadySeen(heap_id)
1320 trav.seen[heap_id] = True
1321 out_node = NewRecord('trace__HereDoc')
1322 L = out_node.fields
1323 return out_node
1324
1325 def AbbreviatedTree(self, trav=None):
1326 # type: (Optional[TraversalState]) -> hnode_t
1327 return self._AbbreviatedTree(trav=trav)
1328
1329class trace(object):
1330 class External(trace_t):
1331 _type_tag = 1
1332 __slots__ = ('argv',)
1333
1334 def __init__(self, argv):
1335 # type: (List[str]) -> None
1336 self.argv = argv
1337
1338 @staticmethod
1339 def CreateNull(alloc_lists=False):
1340 # type: () -> trace.External
1341 return trace.External([] if alloc_lists else cast('List[str]', None))
1342
1343 def PrettyTree(self, trav=None):
1344 # type: (Optional[TraversalState]) -> hnode_t
1345 trav = trav or TraversalState()
1346 heap_id = id(self)
1347 if heap_id in trav.seen:
1348 return hnode.AlreadySeen(heap_id)
1349 trav.seen[heap_id] = True
1350 out_node = NewRecord('trace.External')
1351 L = out_node.fields
1352
1353 if self.argv is not None: # List
1354 x0 = hnode.Array([])
1355 for i0 in self.argv:
1356 x0.children.append(NewLeaf(i0, color_e.StringConst))
1357 L.append(Field('argv', x0))
1358
1359 return out_node
1360
1361 def _AbbreviatedTree(self, trav=None):
1362 # type: (Optional[TraversalState]) -> hnode_t
1363 trav = trav or TraversalState()
1364 heap_id = id(self)
1365 if heap_id in trav.seen:
1366 return hnode.AlreadySeen(heap_id)
1367 trav.seen[heap_id] = True
1368 out_node = NewRecord('trace.External')
1369 L = out_node.fields
1370 if self.argv is not None: # List
1371 x0 = hnode.Array([])
1372 for i0 in self.argv:
1373 x0.children.append(NewLeaf(i0, color_e.StringConst))
1374 L.append(Field('argv', x0))
1375
1376 return out_node
1377
1378 def AbbreviatedTree(self, trav=None):
1379 # type: (Optional[TraversalState]) -> hnode_t
1380 return self._AbbreviatedTree(trav=trav)
1381
1382 CommandSub = trace__CommandSub()
1383
1384 ForkWait = trace__ForkWait()
1385
1386 Fork = trace__Fork()
1387
1388 PipelinePart = trace__PipelinePart()
1389
1390 ProcessSub = trace__ProcessSub()
1391
1392 HereDoc = trace__HereDoc()
1393
1394 pass
1395
1396class word_style_t(pybase.SimpleObj):
1397 pass
1398
1399class word_style_e(object):
1400 Expr = word_style_t(1)
1401 Unquoted = word_style_t(2)
1402 DQ = word_style_t(3)
1403 SQ = word_style_t(4)
1404
1405_word_style_str = {
1406 1: 'word_style.Expr',
1407 2: 'word_style.Unquoted',
1408 3: 'word_style.DQ',
1409 4: 'word_style.SQ',
1410}
1411
1412def word_style_str(val):
1413 # type: (word_style_t) -> str
1414 return _word_style_str[val]
1415
1416class comp_action_t(pybase.SimpleObj):
1417 pass
1418
1419class comp_action_e(object):
1420 Other = comp_action_t(1)
1421 FileSystem = comp_action_t(2)
1422 BashFunc = comp_action_t(3)
1423
1424_comp_action_str = {
1425 1: 'comp_action.Other',
1426 2: 'comp_action.FileSystem',
1427 3: 'comp_action.BashFunc',
1428}
1429
1430def comp_action_str(val):
1431 # type: (comp_action_t) -> str
1432 return _comp_action_str[val]
1433
1434class AssignArg(pybase.CompoundObj):
1435 _type_tag = 64
1436 __slots__ = ('var_name', 'rval', 'plus_eq', 'blame_word')
1437
1438 def __init__(self, var_name, rval, plus_eq, blame_word):
1439 # type: (str, Optional[value_t], bool, CompoundWord) -> None
1440 self.var_name = var_name
1441 self.rval = rval
1442 self.plus_eq = plus_eq
1443 self.blame_word = blame_word
1444
1445 @staticmethod
1446 def CreateNull(alloc_lists=False):
1447 # type: () -> AssignArg
1448 return AssignArg('', cast('Optional[value_t]', None), False, cast(CompoundWord, None))
1449
1450 def PrettyTree(self, trav=None):
1451 # type: (Optional[TraversalState]) -> hnode_t
1452 trav = trav or TraversalState()
1453 heap_id = id(self)
1454 if heap_id in trav.seen:
1455 return hnode.AlreadySeen(heap_id)
1456 trav.seen[heap_id] = True
1457 out_node = NewRecord('AssignArg')
1458 L = out_node.fields
1459
1460 x0 = NewLeaf(self.var_name, color_e.StringConst)
1461 L.append(Field('var_name', x0))
1462
1463 if self.rval is not None: # Optional
1464 x1 = self.rval.PrettyTree(trav=trav)
1465 L.append(Field('rval', x1))
1466
1467 x2 = hnode.Leaf('T' if self.plus_eq else 'F', color_e.OtherConst)
1468 L.append(Field('plus_eq', x2))
1469
1470 assert self.blame_word is not None
1471 x3 = self.blame_word.PrettyTree(trav=trav)
1472 L.append(Field('blame_word', x3))
1473
1474 return out_node
1475
1476 def _AbbreviatedTree(self, trav=None):
1477 # type: (Optional[TraversalState]) -> hnode_t
1478 trav = trav or TraversalState()
1479 heap_id = id(self)
1480 if heap_id in trav.seen:
1481 return hnode.AlreadySeen(heap_id)
1482 trav.seen[heap_id] = True
1483 out_node = NewRecord('AssignArg')
1484 L = out_node.fields
1485 x0 = NewLeaf(self.var_name, color_e.StringConst)
1486 L.append(Field('var_name', x0))
1487
1488 if self.rval is not None: # Optional
1489 x1 = self.rval.AbbreviatedTree(trav=trav)
1490 L.append(Field('rval', x1))
1491
1492 x2 = hnode.Leaf('T' if self.plus_eq else 'F', color_e.OtherConst)
1493 L.append(Field('plus_eq', x2))
1494
1495 assert self.blame_word is not None
1496 x3 = self.blame_word.AbbreviatedTree(trav=trav)
1497 L.append(Field('blame_word', x3))
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
1505class ProcArgs(pybase.CompoundObj):
1506 _type_tag = 65
1507 __slots__ = ('typed_args', 'pos_args', 'named_args', 'block_arg')
1508
1509 def __init__(self, typed_args, pos_args, named_args, block_arg):
1510 # type: (ArgList, Optional[List[value_t]], Optional[Dict[str, value_t]], Optional[value_t]) -> None
1511 self.typed_args = typed_args
1512 self.pos_args = pos_args
1513 self.named_args = named_args
1514 self.block_arg = block_arg
1515
1516 @staticmethod
1517 def CreateNull(alloc_lists=False):
1518 # type: () -> ProcArgs
1519 return ProcArgs(cast(ArgList, None), cast('Optional[List[value_t]]', None), cast('Optional[Dict[str, value_t]]', None), cast('Optional[value_t]', None))
1520
1521 def PrettyTree(self, trav=None):
1522 # type: (Optional[TraversalState]) -> hnode_t
1523 trav = trav or TraversalState()
1524 heap_id = id(self)
1525 if heap_id in trav.seen:
1526 return hnode.AlreadySeen(heap_id)
1527 trav.seen[heap_id] = True
1528 out_node = NewRecord('ProcArgs')
1529 L = out_node.fields
1530
1531 assert self.typed_args is not None
1532 x0 = self.typed_args.PrettyTree(trav=trav)
1533 L.append(Field('typed_args', x0))
1534
1535 if self.pos_args is not None: # List
1536 x1 = hnode.Array([])
1537 for i1 in self.pos_args:
1538 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
1539 i1.PrettyTree(trav=trav))
1540 x1.children.append(h)
1541 L.append(Field('pos_args', x1))
1542
1543 if self.named_args is not None: # Dict
1544 m = hnode.Leaf("Dict", color_e.OtherConst)
1545 x2 = hnode.Array([m])
1546 for k2, v2 in self.named_args.iteritems():
1547 x2.children.append(NewLeaf(k2, color_e.StringConst))
1548 x2.children.append(v2.PrettyTree(trav=trav))
1549 L.append(Field('named_args', x2))
1550
1551 if self.block_arg is not None: # Optional
1552 x3 = self.block_arg.PrettyTree(trav=trav)
1553 L.append(Field('block_arg', x3))
1554
1555 return out_node
1556
1557 def _AbbreviatedTree(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('ProcArgs')
1565 L = out_node.fields
1566 assert self.typed_args is not None
1567 x0 = self.typed_args.AbbreviatedTree(trav=trav)
1568 L.append(Field('typed_args', x0))
1569
1570 if self.pos_args is not None: # List
1571 x1 = hnode.Array([])
1572 for i1 in self.pos_args:
1573 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
1574 i1.AbbreviatedTree(trav=trav))
1575 x1.children.append(h)
1576 L.append(Field('pos_args', x1))
1577
1578 if self.named_args is not None: # Dict
1579 m = hnode.Leaf("Dict", color_e.OtherConst)
1580 x2 = hnode.Array([m])
1581 for k2, v2 in self.named_args.iteritems():
1582 x2.children.append(NewLeaf(k2, color_e.StringConst))
1583 x2.children.append(v2.AbbreviatedTree(trav=trav))
1584 L.append(Field('named_args', x2))
1585
1586 if self.block_arg is not None: # Optional
1587 x3 = self.block_arg.AbbreviatedTree(trav=trav)
1588 L.append(Field('block_arg', x3))
1589
1590 return out_node
1591
1592 def AbbreviatedTree(self, trav=None):
1593 # type: (Optional[TraversalState]) -> hnode_t
1594 return self._AbbreviatedTree(trav=trav)
1595
1596class Piece(part_value_t):
1597 _type_tag = 66
1598 __slots__ = ('s', 'quoted', 'do_split')
1599
1600 def __init__(self, s, quoted, do_split):
1601 # type: (str, bool, bool) -> None
1602 self.s = s
1603 self.quoted = quoted
1604 self.do_split = do_split
1605
1606 @staticmethod
1607 def CreateNull(alloc_lists=False):
1608 # type: () -> Piece
1609 return Piece('', False, False)
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('Piece')
1619 L = out_node.fields
1620
1621 x0 = NewLeaf(self.s, color_e.StringConst)
1622 L.append(Field('s', x0))
1623
1624 x1 = hnode.Leaf('T' if self.quoted else 'F', color_e.OtherConst)
1625 L.append(Field('quoted', x1))
1626
1627 x2 = hnode.Leaf('T' if self.do_split else 'F', color_e.OtherConst)
1628 L.append(Field('do_split', x2))
1629
1630 return out_node
1631
1632 def _AbbreviatedTree(self, trav=None):
1633 # type: (Optional[TraversalState]) -> hnode_t
1634 trav = trav or TraversalState()
1635 heap_id = id(self)
1636 if heap_id in trav.seen:
1637 return hnode.AlreadySeen(heap_id)
1638 trav.seen[heap_id] = True
1639 out_node = NewRecord('Piece')
1640 L = out_node.fields
1641 x0 = NewLeaf(self.s, color_e.StringConst)
1642 L.append(Field('s', x0))
1643
1644 x1 = hnode.Leaf('T' if self.quoted else 'F', color_e.OtherConst)
1645 L.append(Field('quoted', x1))
1646
1647 x2 = hnode.Leaf('T' if self.do_split else 'F', color_e.OtherConst)
1648 L.append(Field('do_split', x2))
1649
1650 return out_node
1651
1652 def AbbreviatedTree(self, trav=None):
1653 # type: (Optional[TraversalState]) -> hnode_t
1654 return self._AbbreviatedTree(trav=trav)
1655
1656class VarSubState(pybase.CompoundObj):
1657 _type_tag = 67
1658 __slots__ = ('join_array', 'is_type_query', 'has_test_op')
1659
1660 def __init__(self, join_array, is_type_query, has_test_op):
1661 # type: (bool, bool, bool) -> None
1662 self.join_array = join_array
1663 self.is_type_query = is_type_query
1664 self.has_test_op = has_test_op
1665
1666 @staticmethod
1667 def CreateNull(alloc_lists=False):
1668 # type: () -> VarSubState
1669 return VarSubState(False, False, False)
1670
1671 def PrettyTree(self, trav=None):
1672 # type: (Optional[TraversalState]) -> hnode_t
1673 trav = trav or TraversalState()
1674 heap_id = id(self)
1675 if heap_id in trav.seen:
1676 return hnode.AlreadySeen(heap_id)
1677 trav.seen[heap_id] = True
1678 out_node = NewRecord('VarSubState')
1679 L = out_node.fields
1680
1681 x0 = hnode.Leaf('T' if self.join_array else 'F', color_e.OtherConst)
1682 L.append(Field('join_array', x0))
1683
1684 x1 = hnode.Leaf('T' if self.is_type_query else 'F', color_e.OtherConst)
1685 L.append(Field('is_type_query', x1))
1686
1687 x2 = hnode.Leaf('T' if self.has_test_op else 'F', color_e.OtherConst)
1688 L.append(Field('has_test_op', x2))
1689
1690 return out_node
1691
1692 def _AbbreviatedTree(self, trav=None):
1693 # type: (Optional[TraversalState]) -> hnode_t
1694 trav = trav or TraversalState()
1695 heap_id = id(self)
1696 if heap_id in trav.seen:
1697 return hnode.AlreadySeen(heap_id)
1698 trav.seen[heap_id] = True
1699 out_node = NewRecord('VarSubState')
1700 L = out_node.fields
1701 x0 = hnode.Leaf('T' if self.join_array else 'F', color_e.OtherConst)
1702 L.append(Field('join_array', x0))
1703
1704 x1 = hnode.Leaf('T' if self.is_type_query else 'F', color_e.OtherConst)
1705 L.append(Field('is_type_query', x1))
1706
1707 x2 = hnode.Leaf('T' if self.has_test_op else 'F', color_e.OtherConst)
1708 L.append(Field('has_test_op', x2))
1709
1710 return out_node
1711
1712 def AbbreviatedTree(self, trav=None):
1713 # type: (Optional[TraversalState]) -> hnode_t
1714 return self._AbbreviatedTree(trav=trav)
1715
1716class Cell(pybase.CompoundObj):
1717 _type_tag = 68
1718 __slots__ = ('exported', 'readonly', 'nameref', 'val')
1719
1720 def __init__(self, exported, readonly, nameref, val):
1721 # type: (bool, bool, bool, value_t) -> None
1722 self.exported = exported
1723 self.readonly = readonly
1724 self.nameref = nameref
1725 self.val = val
1726
1727 @staticmethod
1728 def CreateNull(alloc_lists=False):
1729 # type: () -> Cell
1730 return Cell(False, False, False, cast(value_t, None))
1731
1732 def PrettyTree(self, trav=None):
1733 # type: (Optional[TraversalState]) -> hnode_t
1734 trav = trav or TraversalState()
1735 heap_id = id(self)
1736 if heap_id in trav.seen:
1737 return hnode.AlreadySeen(heap_id)
1738 trav.seen[heap_id] = True
1739 out_node = NewRecord('Cell')
1740 L = out_node.fields
1741
1742 x0 = hnode.Leaf('T' if self.exported else 'F', color_e.OtherConst)
1743 L.append(Field('exported', x0))
1744
1745 x1 = hnode.Leaf('T' if self.readonly else 'F', color_e.OtherConst)
1746 L.append(Field('readonly', x1))
1747
1748 x2 = hnode.Leaf('T' if self.nameref else 'F', color_e.OtherConst)
1749 L.append(Field('nameref', x2))
1750
1751 assert self.val is not None
1752 x3 = self.val.PrettyTree(trav=trav)
1753 L.append(Field('val', x3))
1754
1755 return out_node
1756
1757 def _AbbreviatedTree(self, trav=None):
1758 # type: (Optional[TraversalState]) -> hnode_t
1759 trav = trav or TraversalState()
1760 heap_id = id(self)
1761 if heap_id in trav.seen:
1762 return hnode.AlreadySeen(heap_id)
1763 trav.seen[heap_id] = True
1764 out_node = NewRecord('Cell')
1765 L = out_node.fields
1766 x0 = hnode.Leaf('T' if self.exported else 'F', color_e.OtherConst)
1767 L.append(Field('exported', x0))
1768
1769 x1 = hnode.Leaf('T' if self.readonly else 'F', color_e.OtherConst)
1770 L.append(Field('readonly', x1))
1771
1772 x2 = hnode.Leaf('T' if self.nameref else 'F', color_e.OtherConst)
1773 L.append(Field('nameref', x2))
1774
1775 assert self.val is not None
1776 x3 = self.val.AbbreviatedTree(trav=trav)
1777 L.append(Field('val', x3))
1778
1779 return out_node
1780
1781 def AbbreviatedTree(self, trav=None):
1782 # type: (Optional[TraversalState]) -> hnode_t
1783 return self._AbbreviatedTree(trav=trav)
1784
1785class VTestPlace(pybase.CompoundObj):
1786 _type_tag = 69
1787 __slots__ = ('name', 'index')
1788
1789 def __init__(self, name, index):
1790 # type: (Optional[str], Optional[a_index_t]) -> None
1791 self.name = name
1792 self.index = index
1793
1794 @staticmethod
1795 def CreateNull(alloc_lists=False):
1796 # type: () -> VTestPlace
1797 return VTestPlace(cast('Optional[str]', None), cast('Optional[a_index_t]', 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('VTestPlace')
1807 L = out_node.fields
1808
1809 if self.name is not None: # Optional
1810 x0 = NewLeaf(self.name, color_e.StringConst)
1811 L.append(Field('name', x0))
1812
1813 if self.index is not None: # Optional
1814 x1 = self.index.PrettyTree(trav=trav)
1815 L.append(Field('index', x1))
1816
1817 return out_node
1818
1819 def _AbbreviatedTree(self, trav=None):
1820 # type: (Optional[TraversalState]) -> hnode_t
1821 trav = trav or TraversalState()
1822 heap_id = id(self)
1823 if heap_id in trav.seen:
1824 return hnode.AlreadySeen(heap_id)
1825 trav.seen[heap_id] = True
1826 out_node = NewRecord('VTestPlace')
1827 L = out_node.fields
1828 if self.name is not None: # Optional
1829 x0 = NewLeaf(self.name, color_e.StringConst)
1830 L.append(Field('name', x0))
1831
1832 if self.index is not None: # Optional
1833 x1 = self.index.AbbreviatedTree(trav=trav)
1834 L.append(Field('index', x1))
1835
1836 return out_node
1837
1838 def AbbreviatedTree(self, trav=None):
1839 # type: (Optional[TraversalState]) -> hnode_t
1840 return self._AbbreviatedTree(trav=trav)
1841
1842class RedirValue(pybase.CompoundObj):
1843 _type_tag = 70
1844 __slots__ = ('op_id', 'op_loc', 'loc', 'arg')
1845
1846 def __init__(self, op_id, op_loc, loc, arg):
1847 # type: (Id_t, loc_t, redir_loc_t, redirect_arg_t) -> None
1848 self.op_id = op_id
1849 self.op_loc = op_loc
1850 self.loc = loc
1851 self.arg = arg
1852
1853 @staticmethod
1854 def CreateNull(alloc_lists=False):
1855 # type: () -> RedirValue
1856 return RedirValue(-1, cast(loc_t, None), cast(redir_loc_t, None), cast(redirect_arg_t, None))
1857
1858 def PrettyTree(self, trav=None):
1859 # type: (Optional[TraversalState]) -> hnode_t
1860 trav = trav or TraversalState()
1861 heap_id = id(self)
1862 if heap_id in trav.seen:
1863 return hnode.AlreadySeen(heap_id)
1864 trav.seen[heap_id] = True
1865 out_node = NewRecord('RedirValue')
1866 L = out_node.fields
1867
1868 x0 = hnode.Leaf(Id_str(self.op_id), color_e.UserType)
1869 L.append(Field('op_id', x0))
1870
1871 assert self.op_loc is not None
1872 x1 = self.op_loc.PrettyTree(trav=trav)
1873 L.append(Field('op_loc', x1))
1874
1875 assert self.loc is not None
1876 x2 = self.loc.PrettyTree(trav=trav)
1877 L.append(Field('loc', x2))
1878
1879 assert self.arg is not None
1880 x3 = self.arg.PrettyTree(trav=trav)
1881 L.append(Field('arg', x3))
1882
1883 return out_node
1884
1885 def _AbbreviatedTree(self, trav=None):
1886 # type: (Optional[TraversalState]) -> hnode_t
1887 trav = trav or TraversalState()
1888 heap_id = id(self)
1889 if heap_id in trav.seen:
1890 return hnode.AlreadySeen(heap_id)
1891 trav.seen[heap_id] = True
1892 out_node = NewRecord('RedirValue')
1893 L = out_node.fields
1894 x0 = hnode.Leaf(Id_str(self.op_id), color_e.UserType)
1895 L.append(Field('op_id', x0))
1896
1897 assert self.op_loc is not None
1898 x1 = self.op_loc.AbbreviatedTree(trav=trav)
1899 L.append(Field('op_loc', x1))
1900
1901 assert self.loc is not None
1902 x2 = self.loc.AbbreviatedTree(trav=trav)
1903 L.append(Field('loc', x2))
1904
1905 assert self.arg is not None
1906 x3 = self.arg.AbbreviatedTree(trav=trav)
1907 L.append(Field('arg', x3))
1908
1909 return out_node
1910
1911 def AbbreviatedTree(self, trav=None):
1912 # type: (Optional[TraversalState]) -> hnode_t
1913 return self._AbbreviatedTree(trav=trav)
1914
1915class StatusArray(pybase.CompoundObj):
1916 _type_tag = 71
1917 __slots__ = ('codes', 'locs')
1918
1919 def __init__(self, codes, locs):
1920 # type: (Optional[List[int]], Optional[List[loc_t]]) -> None
1921 self.codes = codes
1922 self.locs = locs
1923
1924 @staticmethod
1925 def CreateNull(alloc_lists=False):
1926 # type: () -> StatusArray
1927 return StatusArray(cast('Optional[List[int]]', None), cast('Optional[List[loc_t]]', None))
1928
1929 def PrettyTree(self, trav=None):
1930 # type: (Optional[TraversalState]) -> hnode_t
1931 trav = trav or TraversalState()
1932 heap_id = id(self)
1933 if heap_id in trav.seen:
1934 return hnode.AlreadySeen(heap_id)
1935 trav.seen[heap_id] = True
1936 out_node = NewRecord('StatusArray')
1937 L = out_node.fields
1938
1939 if self.codes is not None: # List
1940 x0 = hnode.Array([])
1941 for i0 in self.codes:
1942 x0.children.append(hnode.Leaf(str(i0), color_e.OtherConst))
1943 L.append(Field('codes', x0))
1944
1945 if self.locs is not None: # List
1946 x1 = hnode.Array([])
1947 for i1 in self.locs:
1948 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
1949 i1.PrettyTree(trav=trav))
1950 x1.children.append(h)
1951 L.append(Field('locs', x1))
1952
1953 return out_node
1954
1955 def _AbbreviatedTree(self, trav=None):
1956 # type: (Optional[TraversalState]) -> hnode_t
1957 trav = trav or TraversalState()
1958 heap_id = id(self)
1959 if heap_id in trav.seen:
1960 return hnode.AlreadySeen(heap_id)
1961 trav.seen[heap_id] = True
1962 out_node = NewRecord('StatusArray')
1963 L = out_node.fields
1964 if self.codes is not None: # List
1965 x0 = hnode.Array([])
1966 for i0 in self.codes:
1967 x0.children.append(hnode.Leaf(str(i0), color_e.OtherConst))
1968 L.append(Field('codes', x0))
1969
1970 if self.locs is not None: # List
1971 x1 = hnode.Array([])
1972 for i1 in self.locs:
1973 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
1974 i1.AbbreviatedTree(trav=trav))
1975 x1.children.append(h)
1976 L.append(Field('locs', x1))
1977
1978 return out_node
1979
1980 def AbbreviatedTree(self, trav=None):
1981 # type: (Optional[TraversalState]) -> hnode_t
1982 return self._AbbreviatedTree(trav=trav)
1983
1984class CommandStatus(pybase.CompoundObj):
1985 _type_tag = 72
1986 __slots__ = ('check_errexit', 'show_code', 'pipe_negated', 'pipe_status',
1987 'pipe_locs')
1988
1989 def __init__(self, check_errexit, show_code, pipe_negated, pipe_status,
1990 pipe_locs):
1991 # type: (bool, bool, bool, Optional[List[int]], Optional[List[loc_t]]) -> None
1992 self.check_errexit = check_errexit
1993 self.show_code = show_code
1994 self.pipe_negated = pipe_negated
1995 self.pipe_status = pipe_status
1996 self.pipe_locs = pipe_locs
1997
1998 @staticmethod
1999 def CreateNull(alloc_lists=False):
2000 # type: () -> CommandStatus
2001 return CommandStatus(False, False, False, cast('Optional[List[int]]', None), cast('Optional[List[loc_t]]', None))
2002
2003 def PrettyTree(self, trav=None):
2004 # type: (Optional[TraversalState]) -> hnode_t
2005 trav = trav or TraversalState()
2006 heap_id = id(self)
2007 if heap_id in trav.seen:
2008 return hnode.AlreadySeen(heap_id)
2009 trav.seen[heap_id] = True
2010 out_node = NewRecord('CommandStatus')
2011 L = out_node.fields
2012
2013 x0 = hnode.Leaf('T' if self.check_errexit else 'F', color_e.OtherConst)
2014 L.append(Field('check_errexit', x0))
2015
2016 x1 = hnode.Leaf('T' if self.show_code else 'F', color_e.OtherConst)
2017 L.append(Field('show_code', x1))
2018
2019 x2 = hnode.Leaf('T' if self.pipe_negated else 'F', color_e.OtherConst)
2020 L.append(Field('pipe_negated', x2))
2021
2022 if self.pipe_status is not None: # List
2023 x3 = hnode.Array([])
2024 for i3 in self.pipe_status:
2025 x3.children.append(hnode.Leaf(str(i3), color_e.OtherConst))
2026 L.append(Field('pipe_status', x3))
2027
2028 if self.pipe_locs is not None: # List
2029 x4 = hnode.Array([])
2030 for i4 in self.pipe_locs:
2031 h = (hnode.Leaf("_", color_e.OtherConst) if i4 is None else
2032 i4.PrettyTree(trav=trav))
2033 x4.children.append(h)
2034 L.append(Field('pipe_locs', x4))
2035
2036 return out_node
2037
2038 def _AbbreviatedTree(self, trav=None):
2039 # type: (Optional[TraversalState]) -> hnode_t
2040 trav = trav or TraversalState()
2041 heap_id = id(self)
2042 if heap_id in trav.seen:
2043 return hnode.AlreadySeen(heap_id)
2044 trav.seen[heap_id] = True
2045 out_node = NewRecord('CommandStatus')
2046 L = out_node.fields
2047 x0 = hnode.Leaf('T' if self.check_errexit else 'F', color_e.OtherConst)
2048 L.append(Field('check_errexit', x0))
2049
2050 x1 = hnode.Leaf('T' if self.show_code else 'F', color_e.OtherConst)
2051 L.append(Field('show_code', x1))
2052
2053 x2 = hnode.Leaf('T' if self.pipe_negated else 'F', color_e.OtherConst)
2054 L.append(Field('pipe_negated', x2))
2055
2056 if self.pipe_status is not None: # List
2057 x3 = hnode.Array([])
2058 for i3 in self.pipe_status:
2059 x3.children.append(hnode.Leaf(str(i3), color_e.OtherConst))
2060 L.append(Field('pipe_status', x3))
2061
2062 if self.pipe_locs is not None: # List
2063 x4 = hnode.Array([])
2064 for i4 in self.pipe_locs:
2065 h = (hnode.Leaf("_", color_e.OtherConst) if i4 is None else
2066 i4.AbbreviatedTree(trav=trav))
2067 x4.children.append(h)
2068 L.append(Field('pipe_locs', x4))
2069
2070 return out_node
2071
2072 def AbbreviatedTree(self, trav=None):
2073 # type: (Optional[TraversalState]) -> hnode_t
2074 return self._AbbreviatedTree(trav=trav)
2075
2076class HayNode(pybase.CompoundObj):
2077 _type_tag = 73
2078 __slots__ = ('children',)
2079
2080 def __init__(self, children):
2081 # type: (Dict[str, HayNode]) -> None
2082 self.children = children
2083
2084 @staticmethod
2085 def CreateNull(alloc_lists=False):
2086 # type: () -> HayNode
2087 return HayNode(cast('Dict[str, HayNode]', None))
2088
2089 def PrettyTree(self, trav=None):
2090 # type: (Optional[TraversalState]) -> hnode_t
2091 trav = trav or TraversalState()
2092 heap_id = id(self)
2093 if heap_id in trav.seen:
2094 return hnode.AlreadySeen(heap_id)
2095 trav.seen[heap_id] = True
2096 out_node = NewRecord('HayNode')
2097 L = out_node.fields
2098
2099 if self.children is not None: # Dict
2100 m = hnode.Leaf("Dict", color_e.OtherConst)
2101 x0 = hnode.Array([m])
2102 for k0, v0 in self.children.iteritems():
2103 x0.children.append(NewLeaf(k0, color_e.StringConst))
2104 x0.children.append(v0.PrettyTree(trav=trav))
2105 L.append(Field('children', x0))
2106
2107 return out_node
2108
2109 def _AbbreviatedTree(self, trav=None):
2110 # type: (Optional[TraversalState]) -> hnode_t
2111 trav = trav or TraversalState()
2112 heap_id = id(self)
2113 if heap_id in trav.seen:
2114 return hnode.AlreadySeen(heap_id)
2115 trav.seen[heap_id] = True
2116 out_node = NewRecord('HayNode')
2117 L = out_node.fields
2118 if self.children is not None: # Dict
2119 m = hnode.Leaf("Dict", color_e.OtherConst)
2120 x0 = hnode.Array([m])
2121 for k0, v0 in self.children.iteritems():
2122 x0.children.append(NewLeaf(k0, color_e.StringConst))
2123 x0.children.append(v0.AbbreviatedTree(trav=trav))
2124 L.append(Field('children', x0))
2125
2126 return out_node
2127
2128 def AbbreviatedTree(self, trav=None):
2129 # type: (Optional[TraversalState]) -> hnode_t
2130 return self._AbbreviatedTree(trav=trav)
2131