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

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