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