]>
git.saurik.com Git - cycript.git/blob - Output.cpp
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 void CYStringify(std::ostringstream
&str
, const char *data
, size_t size
, bool c
) {
33 unsigned quot(0), apos(0);
34 for (const char *value(data
), *end(data
+ size
); value
!= end
; ++value
)
37 else if (*value
== '\'')
43 str
<< (single
? '\'' : '"');
45 for (const char *value(data
), *end(data
+ size
); value
!= end
; ++value
)
46 switch (uint8_t next
= *value
) {
47 case '\\': str
<< "\\\\"; break;
48 case '\b': str
<< "\\b"; break;
49 case '\f': str
<< "\\f"; break;
50 case '\n': str
<< "\\n"; break;
51 case '\r': str
<< "\\r"; break;
52 case '\t': str
<< "\\t"; break;
53 case '\v': str
<< "\\v"; break;
68 if (value
[1] >= '0' && value
[1] <= '9')
75 if (next
>= 0x20 && next
< 0x7f) simple
:
79 if ((next
& 0x80) != 0)
80 while ((next
& 0x80 >> ++levels
) != 0);
82 unsigned point(next
& 0xff >> levels
);
84 point
= point
<< 6 | uint8_t(*++value
) & 0x3f;
87 str
<< "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << point
;
88 else if (point
< 0x10000)
89 str
<< "\\u" << std::setbase(16) << std::setw(4) << std::setfill('0') << point
;
92 str
<< "\\u" << std::setbase(16) << std::setw(4) << std::setfill('0') << (0xd800 | point
>> 0x0a);
93 str
<< "\\u" << std::setbase(16) << std::setw(4) << std::setfill('0') << (0xdc00 | point
& 0x3ff);
98 str
<< (single
? '\'' : '"');
101 void CYNumerify(std::ostringstream
&str
, double value
) {
102 if (std::isinf(value
)) {
110 // XXX: I want this to print 1e3 rather than 1000
111 sprintf(string
, "%.17g", value
);
115 void CYOutput::Terminate() {
120 CYOutput
&CYOutput::operator <<(char rhs
) {
121 if (rhs
== ' ' || rhs
== '\n')
125 else if (rhs
== '\t')
127 for (unsigned i(0); i
!= indent_
; ++i
)
130 else if (rhs
== '\r') {
142 if (mode_
== Terminated
&& rhs
!= '}') {
154 } else if (rhs
== '+') {
158 } else if (rhs
== '-') {
159 if (mode_
== NoHyphen
)
162 } else if (WordEndRange_
[rhs
]) {
163 if (mode_
== NoLetter
)
175 CYOutput
&CYOutput::operator <<(const char *rhs
) {
176 size_t size(strlen(rhs
));
179 return *this << *rhs
;
181 if (mode_
== Terminated
)
184 mode_
== NoPlus
&& *rhs
== '+' ||
185 mode_
== NoHyphen
&& *rhs
== '-' ||
186 mode_
== NoLetter
&& WordEndRange_
[*rhs
]
190 char last(rhs
[size
- 1]);
191 if (WordEndRange_
[last
] || last
== '/')
197 operator ()(rhs
, size
);
201 void CYArgument::Output(CYOutput
&out
) const {
208 value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
211 out
<< ' ' << *next_
;
215 void CYArray::Output(CYOutput
&out
, CYFlags flags
) const {
216 out
<< '[' << elements_
<< ']';
219 void CYArrayComprehension::Output(CYOutput
&out
, CYFlags flags
) const {
220 out
<< '[' << *expression_
<< ' ' << *comprehensions_
<< ']';
223 void CYAssignment::Output(CYOutput
&out
, CYFlags flags
) const {
224 lhs_
->Output(out
, Precedence() - 1, CYLeft(flags
) | CYNoRightHand
);
225 out
<< ' ' << Operator() << ' ';
226 rhs_
->Output(out
, Precedence(), CYRight(flags
));
229 void CYBlock::Output(CYOutput
&out
, CYFlags flags
) const {
237 void CYBoolean::Output(CYOutput
&out
, CYFlags flags
) const {
238 out
<< '!' << (Value() ? "0" : "1");
239 if ((flags
& CYNoInteger
) != 0)
243 void CYBreak::Output(CYOutput
&out
, CYFlags flags
) const {
246 out
<< ' ' << *label_
;
250 void CYCall::Output(CYOutput
&out
, CYFlags flags
) const {
251 bool protect((flags
& CYNoCall
) != 0);
254 function_
->Output(out
, Precedence(), protect
? CYNoFlags
: flags
);
255 out
<< '(' << arguments_
<< ')';
263 void Catch::Output(CYOutput
&out
) const {
264 out
<< ' ' << "catch" << ' ' << '(' << *name_
<< ')' << ' ';
274 void CYClassExpression::Output(CYOutput
&out
, CYFlags flags
) const {
275 bool protect((flags
& CYNoClass
) != 0);
280 out
<< ' ' << *name_
;
286 void CYClassStatement::Output(CYOutput
&out
, CYFlags flags
) const {
287 out
<< "class" << ' ' << *name_
<< *tail_
;
290 void CYClassTail::Output(CYOutput
&out
) const {
291 if (extends_
== NULL
)
296 out
<< "extends" << ' ';
297 extends_
->Output(out
, CYAssign::Precedence_
- 1, CYNoFlags
);
309 void CYCompound::Output(CYOutput
&out
, CYFlags flags
) const {
311 expression_
->Output(out
, flags
);
313 expression_
->Output(out
, CYLeft(flags
));
315 next_
->Output(out
, CYRight(flags
));
319 void CYComputed::PropertyName(CYOutput
&out
) const {
321 expression_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
325 void CYCondition::Output(CYOutput
&out
, CYFlags flags
) const {
326 test_
->Output(out
, Precedence() - 1, CYLeft(flags
));
327 out
<< ' ' << '?' << ' ';
329 true_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
330 out
<< ' ' << ':' << ' ';
331 false_
->Output(out
, CYAssign::Precedence_
, CYRight(flags
));
334 void CYContinue::Output(CYOutput
&out
, CYFlags flags
) const {
337 out
<< ' ' << *label_
;
341 void CYClause::Output(CYOutput
&out
) const {
344 out
<< "case" << ' ' << *value_
;
354 void CYDebugger::Output(CYOutput
&out
, CYFlags flags
) const {
355 out
<< "debugger" << ';';
358 void CYBinding::Output(CYOutput
&out
, CYFlags flags
) const {
360 //out.out_ << ':' << identifier_->usage_ << '#' << identifier_->offset_;
361 if (initializer_
!= NULL
) {
362 out
<< ' ' << '=' << ' ';
363 initializer_
->Output(out
, CYAssign::Precedence_
, CYRight(flags
));
367 void CYBindings::Output(CYOutput
&out
) const {
368 Output(out
, CYNoFlags
);
371 void CYBindings::Output(CYOutput
&out
, CYFlags flags
) const {
372 const CYBindings
*binding(this);
376 CYBindings
*next(binding
->next_
);
378 CYFlags
jacks(first
? CYLeft(flags
) : next
== NULL
? CYRight(flags
) : CYCenter(flags
));
380 binding
->binding_
->Output(out
, jacks
);
390 void CYDirectMember::Output(CYOutput
&out
, CYFlags flags
) const {
391 object_
->Output(out
, Precedence(), CYLeft(flags
) | CYNoInteger
);
392 if (const char *word
= property_
->Word())
395 out
<< '[' << *property_
<< ']';
398 void CYDoWhile::Output(CYOutput
&out
, CYFlags flags
) const {
401 unsigned line(out
.position_
.line
);
402 unsigned indent(out
.indent_
);
403 code_
->Single(out
, CYCenter(flags
), CYCompactLong
);
405 if (out
.position_
.line
!= line
&& out
.recent_
== indent
)
410 out
<< "while" << ' ' << '(' << *test_
<< ')';
413 void CYElementSpread::Output(CYOutput
&out
) const {
414 out
<< "..." << value_
;
417 void CYElementValue::Output(CYOutput
&out
) const {
419 value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
420 if (next_
!= NULL
|| value_
== NULL
) {
422 if (next_
!= NULL
&& !next_
->Elision())
429 void CYEmpty::Output(CYOutput
&out
, CYFlags flags
) const {
433 void CYEval::Output(CYOutput
&out
, CYFlags flags
) const {
437 void CYExpress::Output(CYOutput
&out
, CYFlags flags
) const {
438 expression_
->Output(out
, flags
| CYNoBFC
);
442 void CYExpression::Output(CYOutput
&out
) const {
443 Output(out
, CYNoFlags
);
446 void CYExpression::Output(CYOutput
&out
, int precedence
, CYFlags flags
) const {
447 if (precedence
< Precedence() || (flags
& CYNoRightHand
) != 0 && RightHand())
448 out
<< '(' << *this << ')';
453 void CYExternal::Output(CYOutput
&out
, CYFlags flags
) const {
454 out
<< "extern" << abi_
<< typed_
;
458 void CYFatArrow::Output(CYOutput
&out
, CYFlags flags
) const {
459 out
<< '(' << parameters_
<< ')' << ' ' << "=>" << ' ' << '{' << code_
<< '}';
462 void CYFinally::Output(CYOutput
&out
) const {
463 out
<< ' ' << "finally" << ' ';
471 void CYFor::Output(CYOutput
&out
, CYFlags flags
) const {
472 out
<< "for" << ' ' << '(';
473 if (initializer_
!= NULL
)
474 initializer_
->Output(out
, CYNoIn
);
480 if (increment_
!= NULL
)
484 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
487 void CYForLexical::Output(CYOutput
&out
, CYFlags flags
) const {
488 out
<< (constant_
? "const" : "let") << ' ';
489 binding_
->Output(out
, CYRight(flags
));
492 void CYForIn::Output(CYOutput
&out
, CYFlags flags
) const {
493 out
<< "for" << ' ' << '(';
494 initializer_
->Output(out
, CYNoIn
| CYNoRightHand
);
495 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
496 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
499 void CYForInitialized::Output(CYOutput
&out
, CYFlags flags
) const {
500 out
<< "for" << ' ' << '(' << "var" << ' ';
501 binding_
->Output(out
, CYNoIn
| CYNoRightHand
);
502 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
503 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
506 void CYForInComprehension::Output(CYOutput
&out
) const {
507 out
<< "for" << ' ' << '(';
508 binding_
->Output(out
, CYNoIn
| CYNoRightHand
);
509 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
512 void CYForOf::Output(CYOutput
&out
, CYFlags flags
) const {
513 out
<< "for" << ' ' << '(';
514 initializer_
->Output(out
, CYNoRightHand
);
515 out
<< ' ' << "of" << ' ' << *iterable_
<< ')';
516 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
519 void CYForOfComprehension::Output(CYOutput
&out
) const {
520 out
<< "for" << ' ' << '(';
521 binding_
->Output(out
, CYNoRightHand
);
522 out
<< ' ' << "of" << ' ' << *iterable_
<< ')' << next_
;
525 void CYForVariable::Output(CYOutput
&out
, CYFlags flags
) const {
527 binding_
->Output(out
, CYRight(flags
));
530 void CYFunction::Output(CYOutput
&out
) const {
531 out
<< '(' << parameters_
<< ')' << ' ';
539 void CYFunctionExpression::Output(CYOutput
&out
, CYFlags flags
) const {
540 // XXX: one could imagine using + here to save a byte
541 bool protect((flags
& CYNoFunction
) != 0);
546 out
<< ' ' << *name_
;
547 CYFunction::Output(out
);
552 void CYFunctionStatement::Output(CYOutput
&out
, CYFlags flags
) const {
553 out
<< "function" << ' ' << *name_
;
554 CYFunction::Output(out
);
557 void CYFunctionParameter::Output(CYOutput
&out
) const {
558 binding_
->Output(out
, CYNoFlags
);
560 out
<< ',' << ' ' << *next_
;
563 const char *CYIdentifier::Word() const {
564 return next_
== NULL
|| next_
== this ? CYWord::Word() : next_
->Word();
567 void CYIf::Output(CYOutput
&out
, CYFlags flags
) const {
569 if (false_
== NULL
&& (flags
& CYNoDangle
) != 0) {
574 out
<< "if" << ' ' << '(' << *test_
<< ')';
576 CYFlags
right(protect
? CYNoFlags
: CYRight(flags
));
578 CYFlags
jacks(CYNoDangle
);
582 jacks
|= protect
? CYNoFlags
: CYCenter(flags
);
584 unsigned line(out
.position_
.line
);
585 unsigned indent(out
.indent_
);
586 true_
->Single(out
, jacks
, CYCompactShort
);
588 if (false_
!= NULL
) {
589 if (out
.position_
.line
!= line
&& out
.recent_
== indent
)
595 false_
->Single(out
, right
, CYCompactLong
);
602 void CYIfComprehension::Output(CYOutput
&out
) const {
603 out
<< "if" << ' ' << '(' << *test_
<< ')' << next_
;
606 void CYImport::Output(CYOutput
&out
, CYFlags flags
) const {
610 void CYImportDeclaration::Output(CYOutput
&out
, CYFlags flags
) const {
614 void CYIndirect::Output(CYOutput
&out
, CYFlags flags
) const {
616 rhs_
->Output(out
, Precedence(), CYRight(flags
));
619 void CYIndirectMember::Output(CYOutput
&out
, CYFlags flags
) const {
620 object_
->Output(out
, Precedence(), CYLeft(flags
));
621 if (const char *word
= property_
->Word())
624 out
<< "->" << '[' << *property_
<< ']';
627 void CYInfix::Output(CYOutput
&out
, CYFlags flags
) const {
628 const char *name(Operator());
629 bool protect((flags
& CYNoIn
) != 0 && strcmp(name
, "in") == 0);
632 CYFlags
left(protect
? CYNoFlags
: CYLeft(flags
));
633 lhs_
->Output(out
, Precedence(), left
);
634 out
<< ' ' << name
<< ' ';
635 CYFlags
right(protect
? CYNoFlags
: CYRight(flags
));
636 rhs_
->Output(out
, Precedence() - 1, right
);
641 void CYLabel::Output(CYOutput
&out
, CYFlags flags
) const {
642 out
<< *name_
<< ':';
643 statement_
->Single(out
, CYRight(flags
), CYCompactShort
);
646 void CYParenthetical::Output(CYOutput
&out
, CYFlags flags
) const {
648 expression_
->Output(out
, CYCompound::Precedence_
, CYNoFlags
);
652 void CYStatement::Output(CYOutput
&out
) const {
656 void CYTemplate::Output(CYOutput
&out
, CYFlags flags
) const {
660 void CYTypeArrayOf::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
661 next_
->Output(out
, Precedence(), identifier
);
667 void CYTypeBlockWith::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
669 next_
->Output(out
, Precedence(), identifier
);
670 out
<< ')' << '(' << parameters_
<< ')';
673 void CYTypeConstant::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
674 out
<< "const" << ' ';
675 next_
->Output(out
, Precedence(), identifier
);
678 void CYTypeFunctionWith::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
679 next_
->Output(out
, Precedence(), identifier
);
680 out
<< '(' << parameters_
;
682 if (parameters_
!= NULL
)
689 void CYTypePointerTo::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
691 next_
->Output(out
, Precedence(), identifier
);
694 void CYTypeVolatile::Output(CYOutput
&out
, CYIdentifier
*identifier
) const {
696 next_
->Output(out
, Precedence(), identifier
);
699 void CYTypeModifier::Output(CYOutput
&out
, int precedence
, CYIdentifier
*identifier
) const {
705 bool protect(precedence
> Precedence());
709 Output(out
, identifier
);
714 void CYTypedIdentifier::Output(CYOutput
&out
) const {
715 specifier_
->Output(out
);
716 modifier_
->Output(out
, 0, identifier_
);
719 void CYEncodedType::Output(CYOutput
&out
, CYFlags flags
) const {
720 out
<< "@encode(" << typed_
<< ")";
723 void CYTypedParameter::Output(CYOutput
&out
) const {
726 out
<< ',' << ' ' << next_
;
729 void CYLambda::Output(CYOutput
&out
, CYFlags flags
) const {
730 // XXX: this is seriously wrong
737 void CYTypeDefinition::Output(CYOutput
&out
, CYFlags flags
) const {
738 out
<< "typedef" << ' ' << *typed_
;
742 void CYTypeExpression::Output(CYOutput
&out
, CYFlags flags
) const {
743 out
<< '(' << "typedef" << ' ' << *typed_
<< ')';
746 void CYLexical::Output(CYOutput
&out
, CYFlags flags
) const {
748 bindings_
->Output(out
, flags
); // XXX: flags
752 void CYModule::Output(CYOutput
&out
) const {
761 void New::Output(CYOutput
&out
, CYFlags flags
) const {
763 CYFlags
jacks(CYNoCall
| CYCenter(flags
));
764 constructor_
->Output(out
, Precedence(), jacks
);
765 if (arguments_
!= NULL
)
766 out
<< '(' << *arguments_
<< ')';
771 void CYNull::Output(CYOutput
&out
, CYFlags flags
) const {
775 void CYNumber::Output(CYOutput
&out
, CYFlags flags
) const {
776 std::ostringstream str
;
777 CYNumerify(str
, Value());
778 std::string
value(str
.str());
779 out
<< value
.c_str();
780 // XXX: this should probably also handle hex conversions and exponents
781 if ((flags
& CYNoInteger
) != 0 && value
.find('.') == std::string::npos
)
785 void CYNumber::PropertyName(CYOutput
&out
) const {
786 Output(out
, CYNoFlags
);
789 void CYObject::Output(CYOutput
&out
, CYFlags flags
) const {
790 bool protect((flags
& CYNoBrace
) != 0);
802 void CYPostfix::Output(CYOutput
&out
, CYFlags flags
) const {
803 lhs_
->Output(out
, Precedence(), CYLeft(flags
));
807 void CYPrefix::Output(CYOutput
&out
, CYFlags flags
) const {
808 const char *name(Operator());
812 rhs_
->Output(out
, Precedence(), CYRight(flags
));
815 void CYScript::Output(CYOutput
&out
) const {
819 void CYProperty::Output(CYOutput
&out
) const {
820 if (next_
!= NULL
|| out
.pretty_
)
822 out
<< '\n' << next_
;
825 void CYPropertyGetter::Output(CYOutput
&out
) const {
827 name_
->PropertyName(out
);
828 CYFunction::Output(out
);
829 CYProperty::Output(out
);
832 void CYPropertyMethod::Output(CYOutput
&out
) const {
833 name_
->PropertyName(out
);
834 CYFunction::Output(out
);
835 CYProperty::Output(out
);
838 void CYPropertySetter::Output(CYOutput
&out
) const {
840 name_
->PropertyName(out
);
841 CYFunction::Output(out
);
842 CYProperty::Output(out
);
845 void CYPropertyValue::Output(CYOutput
&out
) const {
847 name_
->PropertyName(out
);
849 value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
850 CYProperty::Output(out
);
853 void CYRegEx::Output(CYOutput
&out
, CYFlags flags
) const {
857 void CYReturn::Output(CYOutput
&out
, CYFlags flags
) const {
860 out
<< ' ' << *value_
;
864 void CYRubyBlock::Output(CYOutput
&out
, CYFlags flags
) const {
865 call_
->Output(out
, CYLeft(flags
));
867 proc_
->Output(out
, CYRight(flags
));
870 void CYRubyProc::Output(CYOutput
&out
, CYFlags flags
) const {
871 out
<< '{' << ' ' << '|' << parameters_
<< '|' << '\n';
878 void CYStatement::Multiple(CYOutput
&out
, CYFlags flags
) const {
880 CYForEach (next
, this) {
881 bool last(next
->next_
== NULL
);
882 CYFlags
jacks(first
? last
? flags
: CYLeft(flags
) : last
? CYRight(flags
) : CYCenter(flags
));
885 next
->Output(out
, jacks
);
890 void CYStatement::Single(CYOutput
&out
, CYFlags flags
, CYCompactType request
) const {
892 return out
.Terminate();
894 _assert(next_
== NULL
);
896 CYCompactType
compact(Compact());
898 if (compact
>= request
)
908 if (compact
< request
)
912 void CYString::Output(CYOutput
&out
, CYFlags flags
) const {
913 std::ostringstream str
;
914 CYStringify(str
, value_
, size_
);
915 out
<< str
.str().c_str();
918 void CYString::PropertyName(CYOutput
&out
) const {
919 if (const char *word
= Word())
925 static const char *Reserved_
[] = {
926 "false", "null", "true",
928 "break", "case", "catch", "continue", "default",
929 "delete", "do", "else", "finally", "for", "function",
930 "if", "in", "instanceof", "new", "return", "switch",
931 "this", "throw", "try", "typeof", "var", "void",
936 "class", "enum", "export", "extends", "import", "super",
938 "abstract", "boolean", "byte", "char", "double", "final",
939 "float", "goto", "int", "long", "native", "short",
940 "synchronized", "throws", "transient", "volatile",
947 const char *CYString::Word() const {
948 if (size_
== 0 || !WordStartRange_
[value_
[0]])
950 for (size_t i(1); i
!= size_
; ++i
)
951 if (!WordEndRange_
[value_
[i
]])
953 const char *value(Value());
954 for (const char **reserved(Reserved_
); *reserved
!= NULL
; ++reserved
)
955 if (strcmp(*reserved
, value
) == 0)
960 void CYStructDefinition::Output(CYOutput
&out
, CYFlags flags
) const {
961 out
<< "struct" << ' ' << *name_
<< *tail_
;
964 void CYStructTail::Output(CYOutput
&out
) const {
965 out
<< ' ' << '{' << '\n';
967 CYForEach (field
, fields_
) {
968 out
<< '\t' << *field
->typed_
;
976 void CYSuperAccess::Output(CYOutput
&out
, CYFlags flags
) const {
978 if (const char *word
= property_
->Word())
981 out
<< '[' << *property_
<< ']';
984 void CYSuperCall::Output(CYOutput
&out
, CYFlags flags
) const {
985 out
<< "super" << '(' << arguments_
<< ')';
988 void CYSwitch::Output(CYOutput
&out
, CYFlags flags
) const {
989 out
<< "switch" << ' ' << '(' << *value_
<< ')' << ' ' << '{' << '\n';
996 void CYThis::Output(CYOutput
&out
, CYFlags flags
) const {
1003 void Throw::Output(CYOutput
&out
, CYFlags flags
) const {
1006 out
<< ' ' << *value_
;
1010 void Try::Output(CYOutput
&out
, CYFlags flags
) const {
1011 out
<< "try" << ' ';
1017 out
<< catch_
<< finally_
;
1022 void CYTypeCharacter::Output(CYOutput
&out
) const {
1024 case CYTypeNeutral
: break;
1025 case CYTypeSigned
: out
<< "signed" << ' '; break;
1026 case CYTypeUnsigned
: out
<< "unsigned" << ' '; break;
1032 void CYTypeError::Output(CYOutput
&out
) const {
1036 void CYTypeIntegral::Output(CYOutput
&out
) const {
1037 if (signing_
== CYTypeUnsigned
)
1038 out
<< "unsigned" << ' ';
1040 case 0: out
<< "short"; break;
1041 case 1: out
<< "int"; break;
1042 case 2: out
<< "long"; break;
1043 case 3: out
<< "long" << ' ' << "long"; break;
1044 default: _assert(false);
1048 void CYTypeStruct::Output(CYOutput
&out
) const {
1051 out
<< ' ' << *name_
;
1056 void CYTypeReference::Output(CYOutput
&out
) const {
1057 out
<< "struct" << ' ' << *name_
;
1060 void CYTypeVariable::Output(CYOutput
&out
) const {
1064 void CYTypeVoid::Output(CYOutput
&out
) const {
1068 void CYVar::Output(CYOutput
&out
, CYFlags flags
) const {
1069 out
<< "var" << ' ';
1070 bindings_
->Output(out
, flags
); // XXX: flags
1074 void CYVariable::Output(CYOutput
&out
, CYFlags flags
) const {
1078 void CYWhile::Output(CYOutput
&out
, CYFlags flags
) const {
1079 out
<< "while" << ' ' << '(' << *test_
<< ')';
1080 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
1083 void CYWith::Output(CYOutput
&out
, CYFlags flags
) const {
1084 out
<< "with" << ' ' << '(' << *scope_
<< ')';
1085 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
1088 void CYWord::Output(CYOutput
&out
) const {
1090 if (out
.options_
.verbose_
) {
1093 sprintf(number
, "%p", this);
1098 void CYWord::PropertyName(CYOutput
&out
) const {
1102 const char *CYWord::Word() const {