OILS / prebuilt / asdl / runtime.mycpp.cc View on Github | oilshell.org

766 lines, 523 significant
1// prebuilt/asdl/runtime.mycpp.cc: GENERATED by mycpp
2
3#include "prebuilt/asdl/runtime.mycpp.h"
4// BEGIN mycpp output
5
6#include "mycpp/runtime.h"
7
8GLOBAL_STR(str0, "(");
9GLOBAL_STR(str1, ")");
10GLOBAL_STR(str2, "_");
11GLOBAL_STR(str3, "T");
12GLOBAL_STR(str4, "F");
13GLOBAL_STR(str5, "\n<html>\n <head>\n <title>oil AST</title>\n <style>\n .n { color: brown }\n .s { font-weight: bold }\n .o { color: darkgreen }\n </style>\n </head>\n <body>\n <pre>\n");
14GLOBAL_STR(str6, "\n </pre>\n </body>\n</html>\n ");
15GLOBAL_STR(str7, "n");
16GLOBAL_STR(str8, "s");
17GLOBAL_STR(str9, "o");
18GLOBAL_STR(str10, "o");
19GLOBAL_STR(str11, "o");
20GLOBAL_STR(str12, "<span class=\"%s\">");
21GLOBAL_STR(str13, "</span>");
22GLOBAL_STR(str14, " ");
23GLOBAL_STR(str15, "\n");
24GLOBAL_STR(str16, " ");
25GLOBAL_STR(str17, "]");
26GLOBAL_STR(str18, " ");
27GLOBAL_STR(str19, " ");
28GLOBAL_STR(str20, "\n");
29GLOBAL_STR(str21, "\n");
30GLOBAL_STR(str22, " ");
31GLOBAL_STR(str23, "%s%s: [");
32GLOBAL_STR(str24, "\n");
33GLOBAL_STR(str25, "\n");
34GLOBAL_STR(str26, "%s]");
35GLOBAL_STR(str27, "%s%s: ");
36GLOBAL_STR(str28, "\n");
37GLOBAL_STR(str29, "\n");
38GLOBAL_STR(str30, " ");
39GLOBAL_STR(str31, "UNTYPED any");
40GLOBAL_STR(str32, "...0x%s");
41GLOBAL_STR(str33, " ");
42GLOBAL_STR(str34, " ");
43GLOBAL_STR(str35, " %s:");
44GLOBAL_STR(str36, "UNTYPED any");
45GLOBAL_STR(str37, "[");
46GLOBAL_STR(str38, " ");
47GLOBAL_STR(str39, "]");
48GLOBAL_STR(str40, "...0x%s");
49GLOBAL_STR(str41, "\u001b[0;0m");
50GLOBAL_STR(str42, "\u001b[1m");
51GLOBAL_STR(str43, "\u001b[4m");
52GLOBAL_STR(str44, "\u001b[7m");
53GLOBAL_STR(str45, "\u001b[31m");
54GLOBAL_STR(str46, "\u001b[32m");
55GLOBAL_STR(str47, "\u001b[33m");
56GLOBAL_STR(str48, "\u001b[34m");
57GLOBAL_STR(str49, "&");
58GLOBAL_STR(str50, "&amp;");
59GLOBAL_STR(str51, "<");
60GLOBAL_STR(str52, "&lt;");
61GLOBAL_STR(str53, ">");
62GLOBAL_STR(str54, "&gt;");
63
64namespace ansi { // forward declare
65
66
67} // forward declare namespace ansi
68
69namespace cgi { // forward declare
70
71
72} // forward declare namespace cgi
73
74namespace j8_lite { // forward declare
75
76
77} // forward declare namespace j8_lite
78
79namespace ansi { // declare
80
81extern BigStr* RESET;
82extern BigStr* BOLD;
83extern BigStr* UNDERLINE;
84extern BigStr* REVERSE;
85extern BigStr* RED;
86extern BigStr* GREEN;
87extern BigStr* YELLOW;
88extern BigStr* BLUE;
89
90
91} // declare namespace ansi
92
93namespace cgi { // declare
94
95BigStr* escape(BigStr* s);
96
97
98} // declare namespace cgi
99
100namespace j8_lite { // declare
101
102BigStr* EncodeString(BigStr* s, bool unquoted_ok = false);
103BigStr* MaybeShellEncode(BigStr* s);
104BigStr* ShellEncode(BigStr* s);
105BigStr* YshEncode(BigStr* s, bool unquoted_ok = false);
106
107
108} // declare namespace j8_lite
109
110namespace runtime { // define
111
112using hnode_asdl::hnode;
113using hnode_asdl::color_t;
114using hnode_asdl::color_e;
115int NO_SPID = -1;
116
117hnode::Record* NewRecord(BigStr* node_type) {
118 StackRoot _root0(&node_type);
119
120 return Alloc<hnode::Record>(node_type, Alloc<List<hnode_asdl::Field*>>(), false, str0, str1, Alloc<List<hnode_asdl::hnode_t*>>());
121}
122
123hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color) {
124 StackRoot _root0(&s);
125
126 if (s == nullptr) {
127 return Alloc<hnode::Leaf>(str2, color_e::OtherConst);
128 }
129 else {
130 return Alloc<hnode::Leaf>(s, e_color);
131 }
132}
133
134TraversalState::TraversalState() {
135 this->seen = Alloc<Dict<int, bool>>();
136 this->ref_count = Alloc<Dict<int, int>>();
137}
138BigStr* TRUE_STR = str3;
139BigStr* FALSE_STR = str4;
140
141} // define namespace runtime
142
143namespace format { // define
144
145using hnode_asdl::hnode;
146using hnode_asdl::hnode_e;
147using hnode_asdl::hnode_t;
148using hnode_asdl::color_e;
149using hnode_asdl::color_t;
150
151format::ColorOutput* DetectConsoleOutput(mylib::Writer* f) {
152 StackRoot _root0(&f);
153
154 if (f->isatty()) {
155 return Alloc<AnsiOutput>(f);
156 }
157 else {
158 return Alloc<TextOutput>(f);
159 }
160}
161
162ColorOutput::ColorOutput(mylib::Writer* f) {
163 this->f = f;
164 this->num_chars = 0;
165}
166
167format::ColorOutput* ColorOutput::NewTempBuffer() {
168 FAIL(kNotImplemented); // Python NotImplementedError
169}
170
171void ColorOutput::FileHeader() {
172 ; // pass
173}
174
175void ColorOutput::FileFooter() {
176 ; // pass
177}
178
179void ColorOutput::PushColor(hnode_asdl::color_t e_color) {
180 FAIL(kNotImplemented); // Python NotImplementedError
181}
182
183void ColorOutput::PopColor() {
184 FAIL(kNotImplemented); // Python NotImplementedError
185}
186
187void ColorOutput::write(BigStr* s) {
188 StackRoot _root0(&s);
189
190 this->f->write(s);
191 this->num_chars += len(s);
192}
193
194void ColorOutput::WriteRaw(Tuple2<BigStr*, int>* raw) {
195 BigStr* s = nullptr;
196 int num_chars;
197 StackRoot _root0(&raw);
198 StackRoot _root1(&s);
199
200 Tuple2<BigStr*, int>* tup0 = raw;
201 s = tup0->at0();
202 num_chars = tup0->at1();
203 this->f->write(s);
204 this->num_chars += num_chars;
205}
206
207int ColorOutput::NumChars() {
208 return this->num_chars;
209}
210
211Tuple2<BigStr*, int> ColorOutput::GetRaw() {
212 mylib::BufWriter* f = static_cast<mylib::BufWriter*>(this->f);
213 return Tuple2<BigStr*, int>(f->getvalue(), this->num_chars);
214}
215
216TextOutput::TextOutput(mylib::Writer* f) : ColorOutput(f) {
217}
218
219format::TextOutput* TextOutput::NewTempBuffer() {
220 return Alloc<TextOutput>(Alloc<mylib::BufWriter>());
221}
222
223void TextOutput::PushColor(hnode_asdl::color_t e_color) {
224 ; // pass
225}
226
227void TextOutput::PopColor() {
228 ; // pass
229}
230
231HtmlOutput::HtmlOutput(mylib::Writer* f) : ColorOutput(f) {
232}
233
234format::HtmlOutput* HtmlOutput::NewTempBuffer() {
235 return Alloc<HtmlOutput>(Alloc<mylib::BufWriter>());
236}
237
238void HtmlOutput::FileHeader() {
239 this->f->write(str5);
240}
241
242void HtmlOutput::FileFooter() {
243 this->f->write(str6);
244}
245
246void HtmlOutput::PushColor(hnode_asdl::color_t e_color) {
247 BigStr* css_class = nullptr;
248 StackRoot _root0(&css_class);
249
250 if (e_color == color_e::TypeName) {
251 css_class = str7;
252 }
253 else {
254 if (e_color == color_e::StringConst) {
255 css_class = str8;
256 }
257 else {
258 if (e_color == color_e::OtherConst) {
259 css_class = str9;
260 }
261 else {
262 if (e_color == color_e::External) {
263 css_class = str10;
264 }
265 else {
266 if (e_color == color_e::UserType) {
267 css_class = str11;
268 }
269 else {
270 assert(0); // AssertionError
271 }
272 }
273 }
274 }
275 }
276 this->f->write(StrFormat("<span class=\"%s\">", css_class));
277}
278
279void HtmlOutput::PopColor() {
280 this->f->write(str13);
281}
282
283void HtmlOutput::write(BigStr* s) {
284 StackRoot _root0(&s);
285
286 this->f->write(cgi::escape(s));
287 this->num_chars += len(s);
288}
289
290AnsiOutput::AnsiOutput(mylib::Writer* f) : ColorOutput(f) {
291}
292
293format::AnsiOutput* AnsiOutput::NewTempBuffer() {
294 return Alloc<AnsiOutput>(Alloc<mylib::BufWriter>());
295}
296
297void AnsiOutput::PushColor(hnode_asdl::color_t e_color) {
298 if (e_color == color_e::TypeName) {
299 this->f->write(ansi::YELLOW);
300 }
301 else {
302 if (e_color == color_e::StringConst) {
303 this->f->write(ansi::BOLD);
304 }
305 else {
306 if (e_color == color_e::OtherConst) {
307 this->f->write(ansi::GREEN);
308 }
309 else {
310 if (e_color == color_e::External) {
311 this->f->write(str_concat(ansi::BOLD, ansi::BLUE));
312 }
313 else {
314 if (e_color == color_e::UserType) {
315 this->f->write(ansi::GREEN);
316 }
317 else {
318 assert(0); // AssertionError
319 }
320 }
321 }
322 }
323 }
324}
325
326void AnsiOutput::PopColor() {
327 this->f->write(ansi::RESET);
328}
329int INDENT = 2;
330
331_PrettyPrinter::_PrettyPrinter(int max_col) {
332 this->max_col = max_col;
333}
334
335bool _PrettyPrinter::_PrintWrappedArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent) {
336 bool all_fit;
337 int chars_so_far;
338 int i;
339 format::ColorOutput* single_f = nullptr;
340 BigStr* s = nullptr;
341 int num_chars;
342 StackRoot _root0(&array);
343 StackRoot _root1(&f);
344 StackRoot _root2(&single_f);
345 StackRoot _root3(&s);
346
347 all_fit = true;
348 chars_so_far = prefix_len;
349 i = 0;
350 for (ListIter<hnode_asdl::hnode_t*> it(array); !it.Done(); it.Next(), ++i) {
351 hnode_asdl::hnode_t* val = it.Value();
352 StackRoot _for(&val );
353 if (i != 0) {
354 f->write(str14);
355 }
356 single_f = f->NewTempBuffer();
357 if (_TrySingleLine(val, single_f, (this->max_col - chars_so_far))) {
358 Tuple2<BigStr*, int> tup1 = single_f->GetRaw();
359 s = tup1.at0();
360 num_chars = tup1.at1();
361 f->WriteRaw((Alloc<Tuple2<BigStr*, int>>(s, num_chars)));
362 chars_so_far += single_f->NumChars();
363 }
364 else {
365 f->write(str15);
366 this->PrintNode(val, f, (indent + INDENT));
367 chars_so_far = 0;
368 all_fit = false;
369 }
370 }
371 return all_fit;
372}
373
374bool _PrettyPrinter::_PrintWholeArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent) {
375 bool all_fit;
376 List<Tuple2<BigStr*, int>*>* pieces = nullptr;
377 int chars_so_far;
378 format::ColorOutput* single_f = nullptr;
379 BigStr* s = nullptr;
380 int num_chars;
381 int i;
382 StackRoot _root0(&array);
383 StackRoot _root1(&f);
384 StackRoot _root2(&pieces);
385 StackRoot _root3(&single_f);
386 StackRoot _root4(&s);
387
388 all_fit = true;
389 pieces = Alloc<List<Tuple2<BigStr*, int>*>>();
390 chars_so_far = prefix_len;
391 for (ListIter<hnode_asdl::hnode_t*> it(array); !it.Done(); it.Next()) {
392 hnode_asdl::hnode_t* item = it.Value();
393 StackRoot _for(&item );
394 single_f = f->NewTempBuffer();
395 if (_TrySingleLine(item, single_f, (this->max_col - chars_so_far))) {
396 Tuple2<BigStr*, int> tup2 = single_f->GetRaw();
397 s = tup2.at0();
398 num_chars = tup2.at1();
399 pieces->append((Alloc<Tuple2<BigStr*, int>>(s, num_chars)));
400 chars_so_far += single_f->NumChars();
401 }
402 else {
403 all_fit = false;
404 break;
405 }
406 }
407 if (all_fit) {
408 i = 0;
409 for (ListIter<Tuple2<BigStr*, int>*> it(pieces); !it.Done(); it.Next(), ++i) {
410 Tuple2<BigStr*, int>* p = it.Value();
411 StackRoot _for(&p );
412 if (i != 0) {
413 f->write(str16);
414 }
415 f->WriteRaw(p);
416 }
417 f->write(str17);
418 }
419 return all_fit;
420}
421
422void _PrettyPrinter::_PrintRecord(hnode::Record* node, format::ColorOutput* f, int indent) {
423 BigStr* ind = nullptr;
424 BigStr* prefix = nullptr;
425 int prefix_len;
426 bool all_fit;
427 BigStr* name = nullptr;
428 hnode_asdl::hnode_t* val = nullptr;
429 BigStr* ind1 = nullptr;
430 hnode_asdl::hnode_t* UP_val = nullptr;
431 int tag;
432 BigStr* name_str = nullptr;
433 format::ColorOutput* single_f = nullptr;
434 BigStr* s = nullptr;
435 int num_chars;
436 StackRoot _root0(&node);
437 StackRoot _root1(&f);
438 StackRoot _root2(&ind);
439 StackRoot _root3(&prefix);
440 StackRoot _root4(&name);
441 StackRoot _root5(&val);
442 StackRoot _root6(&ind1);
443 StackRoot _root7(&UP_val);
444 StackRoot _root8(&name_str);
445 StackRoot _root9(&single_f);
446 StackRoot _root10(&s);
447
448 ind = str_repeat(str18, indent);
449 if (node->abbrev) {
450 prefix = str_concat(ind, node->left);
451 f->write(prefix);
452 if (len(node->node_type)) {
453 f->PushColor(color_e::TypeName);
454 f->write(node->node_type);
455 f->PopColor();
456 f->write(str19);
457 }
458 prefix_len = ((len(prefix) + len(node->node_type)) + 1);
459 all_fit = this->_PrintWrappedArray(node->unnamed_fields, prefix_len, f, indent);
460 if (!all_fit) {
461 f->write(str20);
462 f->write(ind);
463 }
464 f->write(node->right);
465 }
466 else {
467 f->write(str_concat(ind, node->left));
468 f->PushColor(color_e::TypeName);
469 f->write(node->node_type);
470 f->PopColor();
471 f->write(str21);
472 for (ListIter<hnode_asdl::Field*> it(node->fields); !it.Done(); it.Next()) {
473 hnode_asdl::Field* field = it.Value();
474 StackRoot _for(&field );
475 name = field->name;
476 val = field->val;
477 ind1 = str_repeat(str22, (indent + INDENT));
478 UP_val = val;
479 tag = val->tag();
480 if (tag == hnode_e::Array) {
481 hnode::Array* val = static_cast<hnode::Array*>(UP_val);
482 name_str = StrFormat("%s%s: [", ind1, name);
483 f->write(name_str);
484 prefix_len = len(name_str);
485 if (!this->_PrintWholeArray(val->children, prefix_len, f, indent)) {
486 f->write(str24);
487 for (ListIter<hnode_asdl::hnode_t*> it(val->children); !it.Done(); it.Next()) {
488 hnode_asdl::hnode_t* child = it.Value();
489 StackRoot _for(&child );
490 this->PrintNode(child, f, ((indent + INDENT) + INDENT));
491 f->write(str25);
492 }
493 f->write(StrFormat("%s]", ind1));
494 }
495 }
496 else {
497 name_str = StrFormat("%s%s: ", ind1, name);
498 f->write(name_str);
499 prefix_len = len(name_str);
500 single_f = f->NewTempBuffer();
501 if (_TrySingleLine(val, single_f, (this->max_col - prefix_len))) {
502 Tuple2<BigStr*, int> tup3 = single_f->GetRaw();
503 s = tup3.at0();
504 num_chars = tup3.at1();
505 f->WriteRaw((Alloc<Tuple2<BigStr*, int>>(s, num_chars)));
506 }
507 else {
508 f->write(str28);
509 this->PrintNode(val, f, ((indent + INDENT) + INDENT));
510 }
511 }
512 f->write(str29);
513 }
514 f->write(str_concat(ind, node->right));
515 }
516}
517
518void _PrettyPrinter::PrintNode(hnode_asdl::hnode_t* node, format::ColorOutput* f, int indent) {
519 BigStr* ind = nullptr;
520 format::ColorOutput* single_f = nullptr;
521 BigStr* s = nullptr;
522 int num_chars;
523 hnode_asdl::hnode_t* UP_node = nullptr;
524 int tag;
525 StackRoot _root0(&node);
526 StackRoot _root1(&f);
527 StackRoot _root2(&ind);
528 StackRoot _root3(&single_f);
529 StackRoot _root4(&s);
530 StackRoot _root5(&UP_node);
531
532 ind = str_repeat(str30, indent);
533 single_f = f->NewTempBuffer();
534 single_f->write(ind);
535 if (_TrySingleLine(node, single_f, (this->max_col - indent))) {
536 Tuple2<BigStr*, int> tup4 = single_f->GetRaw();
537 s = tup4.at0();
538 num_chars = tup4.at1();
539 f->WriteRaw((Alloc<Tuple2<BigStr*, int>>(s, num_chars)));
540 return ;
541 }
542 UP_node = node;
543 tag = node->tag();
544 if (tag == hnode_e::Leaf) {
545 hnode::Leaf* node = static_cast<hnode::Leaf*>(UP_node);
546 f->PushColor(node->color);
547 f->write(j8_lite::EncodeString(node->s, true));
548 f->PopColor();
549 }
550 else {
551 if (tag == hnode_e::External) {
552 hnode::External* node = static_cast<hnode::External*>(UP_node);
553 f->PushColor(color_e::External);
554 // if not PYTHON
555 {
556 f->write(str31);
557 }
558 // endif MYCPP
559 f->PopColor();
560 }
561 else {
562 if (tag == hnode_e::Record) {
563 hnode::Record* node = static_cast<hnode::Record*>(UP_node);
564 this->_PrintRecord(node, f, indent);
565 }
566 else {
567 if (tag == hnode_e::AlreadySeen) {
568 hnode::AlreadySeen* node = static_cast<hnode::AlreadySeen*>(UP_node);
569 f->write(StrFormat("...0x%s", mylib::hex_lower(node->heap_id)));
570 }
571 else {
572 assert(0); // AssertionError
573 }
574 }
575 }
576 }
577}
578
579bool _TrySingleLineObj(hnode::Record* node, format::ColorOutput* f, int max_chars) {
580 int i;
581 StackRoot _root0(&node);
582 StackRoot _root1(&f);
583
584 f->write(node->left);
585 if (node->abbrev) {
586 if (len(node->node_type)) {
587 f->PushColor(color_e::TypeName);
588 f->write(node->node_type);
589 f->PopColor();
590 f->write(str33);
591 }
592 i = 0;
593 for (ListIter<hnode_asdl::hnode_t*> it(node->unnamed_fields); !it.Done(); it.Next(), ++i) {
594 hnode_asdl::hnode_t* val = it.Value();
595 StackRoot _for(&val );
596 if (i != 0) {
597 f->write(str34);
598 }
599 if (!_TrySingleLine(val, f, max_chars)) {
600 return false;
601 }
602 }
603 }
604 else {
605 f->PushColor(color_e::TypeName);
606 f->write(node->node_type);
607 f->PopColor();
608 for (ListIter<hnode_asdl::Field*> it(node->fields); !it.Done(); it.Next()) {
609 hnode_asdl::Field* field = it.Value();
610 StackRoot _for(&field );
611 f->write(StrFormat(" %s:", field->name));
612 if (!_TrySingleLine(field->val, f, max_chars)) {
613 return false;
614 }
615 }
616 }
617 f->write(node->right);
618 return true;
619}
620
621bool _TrySingleLine(hnode_asdl::hnode_t* node, format::ColorOutput* f, int max_chars) {
622 hnode_asdl::hnode_t* UP_node = nullptr;
623 int tag;
624 int i;
625 int num_chars_so_far;
626 StackRoot _root0(&node);
627 StackRoot _root1(&f);
628 StackRoot _root2(&UP_node);
629
630 UP_node = node;
631 tag = node->tag();
632 if (tag == hnode_e::Leaf) {
633 hnode::Leaf* node = static_cast<hnode::Leaf*>(UP_node);
634 f->PushColor(node->color);
635 f->write(j8_lite::EncodeString(node->s, true));
636 f->PopColor();
637 }
638 else {
639 if (tag == hnode_e::External) {
640 hnode::External* node = static_cast<hnode::External*>(UP_node);
641 f->PushColor(color_e::External);
642 // if not PYTHON
643 {
644 f->write(str36);
645 }
646 // endif MYCPP
647 f->PopColor();
648 }
649 else {
650 if (tag == hnode_e::Array) {
651 hnode::Array* node = static_cast<hnode::Array*>(UP_node);
652 f->write(str37);
653 i = 0;
654 for (ListIter<hnode_asdl::hnode_t*> it(node->children); !it.Done(); it.Next(), ++i) {
655 hnode_asdl::hnode_t* item = it.Value();
656 StackRoot _for(&item );
657 if (i != 0) {
658 f->write(str38);
659 }
660 if (!_TrySingleLine(item, f, max_chars)) {
661 return false;
662 }
663 }
664 f->write(str39);
665 }
666 else {
667 if (tag == hnode_e::Record) {
668 hnode::Record* node = static_cast<hnode::Record*>(UP_node);
669 return _TrySingleLineObj(node, f, max_chars);
670 }
671 else {
672 if (tag == hnode_e::AlreadySeen) {
673 hnode::AlreadySeen* node = static_cast<hnode::AlreadySeen*>(UP_node);
674 f->write(StrFormat("...0x%s", mylib::hex_lower(node->heap_id)));
675 }
676 else {
677 assert(0); // AssertionError
678 }
679 }
680 }
681 }
682 }
683 num_chars_so_far = f->NumChars();
684 if (num_chars_so_far > max_chars) {
685 return false;
686 }
687 return true;
688}
689
690void PrintTree(hnode_asdl::hnode_t* node, format::ColorOutput* f) {
691 format::_PrettyPrinter* pp = nullptr;
692 StackRoot _root0(&node);
693 StackRoot _root1(&f);
694 StackRoot _root2(&pp);
695
696 pp = Alloc<_PrettyPrinter>(100);
697 pp->PrintNode(node, f, 0);
698}
699
700} // define namespace format
701
702namespace ansi { // define
703
704BigStr* RESET = str41;
705BigStr* BOLD = str42;
706BigStr* UNDERLINE = str43;
707BigStr* REVERSE = str44;
708BigStr* RED = str45;
709BigStr* GREEN = str46;
710BigStr* YELLOW = str47;
711BigStr* BLUE = str48;
712
713} // define namespace ansi
714
715namespace cgi { // define
716
717
718BigStr* escape(BigStr* s) {
719 StackRoot _root0(&s);
720
721 s = s->replace(str49, str50);
722 s = s->replace(str51, str52);
723 s = s->replace(str53, str54);
724 return s;
725}
726
727} // define namespace cgi
728
729namespace j8_lite { // define
730
731
732BigStr* EncodeString(BigStr* s, bool unquoted_ok) {
733 StackRoot _root0(&s);
734
735 if ((unquoted_ok and fastfunc::CanOmitQuotes(s))) {
736 return s;
737 }
738 return fastfunc::J8EncodeString(s, 1);
739}
740
741BigStr* MaybeShellEncode(BigStr* s) {
742 StackRoot _root0(&s);
743
744 if (fastfunc::CanOmitQuotes(s)) {
745 return s;
746 }
747 return fastfunc::ShellEncodeString(s, 0);
748}
749
750BigStr* ShellEncode(BigStr* s) {
751 StackRoot _root0(&s);
752
753 return fastfunc::ShellEncodeString(s, 0);
754}
755
756BigStr* YshEncode(BigStr* s, bool unquoted_ok) {
757 StackRoot _root0(&s);
758
759 if ((unquoted_ok and fastfunc::CanOmitQuotes(s))) {
760 return s;
761 }
762 return fastfunc::ShellEncodeString(s, 1);
763}
764
765} // define namespace j8_lite
766