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

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