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