]>
git.saurik.com Git - cycript.git/blob - Output.cpp
1 /* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 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_
, CYNoColon
);
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 {
346 out
<< "case" << ' ';
347 value_
->Output(out
, CYNoColon
);
356 void CYDebugger::Output(CYOutput
&out
, CYFlags flags
) const {
357 out
<< "debugger" << ';';
360 void CYBinding::Output(CYOutput
&out
, CYFlags flags
) const {
362 //out.out_ << ':' << identifier_->usage_ << '#' << identifier_->offset_;
363 if (initializer_
!= NULL
) {
364 out
<< ' ' << '=' << ' ';
365 initializer_
->Output(out
, CYAssign::Precedence_
, CYRight(flags
));
369 void CYBindings::Output(CYOutput
&out
) const {
370 Output(out
, CYNoFlags
);
373 void CYBindings::Output(CYOutput
&out
, CYFlags flags
) const {
374 const CYBindings
*binding(this);
378 CYBindings
*next(binding
->next_
);
380 CYFlags
jacks(first
? CYLeft(flags
) : next
== NULL
? CYRight(flags
) : CYCenter(flags
));
382 binding
->binding_
->Output(out
, jacks
);
392 void CYDirectMember::Output(CYOutput
&out
, CYFlags flags
) const {
393 object_
->Output(out
, Precedence(), CYLeft(flags
) | CYNoInteger
);
394 if (const char *word
= property_
->Word())
397 out
<< '[' << *property_
<< ']';
400 void CYDoWhile::Output(CYOutput
&out
, CYFlags flags
) const {
403 unsigned line(out
.position_
.line
);
404 unsigned indent(out
.indent_
);
405 code_
->Single(out
, CYCenter(flags
), CYCompactLong
);
407 if (out
.position_
.line
!= line
&& out
.recent_
== indent
)
412 out
<< "while" << ' ' << '(' << *test_
<< ')';
415 void CYElementSpread::Output(CYOutput
&out
) const {
416 out
<< "..." << value_
;
419 void CYElementValue::Output(CYOutput
&out
) const {
421 value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
422 if (next_
!= NULL
|| value_
== NULL
) {
424 if (next_
!= NULL
&& !next_
->Elision())
431 void CYEmpty::Output(CYOutput
&out
, CYFlags flags
) const {
435 void CYEval::Output(CYOutput
&out
, CYFlags flags
) const {
439 void CYExpress::Output(CYOutput
&out
, CYFlags flags
) const {
440 expression_
->Output(out
, flags
| CYNoBFC
);
444 void CYExpression::Output(CYOutput
&out
) const {
445 Output(out
, CYNoFlags
);
448 void CYExpression::Output(CYOutput
&out
, int precedence
, CYFlags flags
) const {
449 if (precedence
< Precedence() || (flags
& CYNoRightHand
) != 0 && RightHand())
450 out
<< '(' << *this << ')';
455 void CYExtend::Output(CYOutput
&out
, CYFlags flags
) const {
456 lhs_
->Output(out
, CYLeft(flags
));
457 out
<< ' ' << object_
;
460 void CYExternalDefinition::Output(CYOutput
&out
, CYFlags flags
) const {
461 out
<< "extern" << ' ' << abi_
<< ' ';
462 type_
->Output(out
, name_
);
466 void CYExternalExpression::Output(CYOutput
&out
, CYFlags flags
) const {
467 out
<< '(' << "extern" << ' ' << abi_
<< ' ';
468 type_
->Output(out
, name_
);
472 void CYFatArrow::Output(CYOutput
&out
, CYFlags flags
) const {
473 out
<< '(' << parameters_
<< ')' << ' ' << "=>" << ' ' << '{' << code_
<< '}';
476 void CYFinally::Output(CYOutput
&out
) const {
477 out
<< ' ' << "finally" << ' ';
485 void CYFor::Output(CYOutput
&out
, CYFlags flags
) const {
486 out
<< "for" << ' ' << '(';
487 if (initializer_
!= NULL
)
488 initializer_
->Output(out
, CYNoIn
);
494 if (increment_
!= NULL
)
498 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
501 void CYForLexical::Output(CYOutput
&out
, CYFlags flags
) const {
502 out
<< (constant_
? "const" : "let") << ' ';
503 binding_
->Output(out
, CYRight(flags
));
506 void CYForIn::Output(CYOutput
&out
, CYFlags flags
) const {
507 out
<< "for" << ' ' << '(';
508 initializer_
->Output(out
, CYNoIn
| CYNoRightHand
);
509 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
510 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
513 void CYForInitialized::Output(CYOutput
&out
, CYFlags flags
) const {
514 out
<< "for" << ' ' << '(' << "var" << ' ';
515 binding_
->Output(out
, CYNoIn
| CYNoRightHand
);
516 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
517 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
520 void CYForInComprehension::Output(CYOutput
&out
) const {
521 out
<< "for" << ' ' << '(';
522 binding_
->Output(out
, CYNoIn
| CYNoRightHand
);
523 out
<< ' ' << "in" << ' ' << *iterable_
<< ')';
526 void CYForOf::Output(CYOutput
&out
, CYFlags flags
) const {
527 out
<< "for" << ' ' << '(';
528 initializer_
->Output(out
, CYNoRightHand
);
529 out
<< ' ' << "of" << ' ' << *iterable_
<< ')';
530 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
533 void CYForOfComprehension::Output(CYOutput
&out
) const {
534 out
<< "for" << ' ' << '(';
535 binding_
->Output(out
, CYNoRightHand
);
536 out
<< ' ' << "of" << ' ' << *iterable_
<< ')' << next_
;
539 void CYForVariable::Output(CYOutput
&out
, CYFlags flags
) const {
541 binding_
->Output(out
, CYRight(flags
));
544 void CYFunction::Output(CYOutput
&out
) const {
545 out
<< '(' << parameters_
<< ')' << ' ';
553 void CYFunctionExpression::Output(CYOutput
&out
, CYFlags flags
) const {
554 // XXX: one could imagine using + here to save a byte
555 bool protect((flags
& CYNoFunction
) != 0);
560 out
<< ' ' << *name_
;
561 CYFunction::Output(out
);
566 void CYFunctionStatement::Output(CYOutput
&out
, CYFlags flags
) const {
567 out
<< "function" << ' ' << *name_
;
568 CYFunction::Output(out
);
571 void CYFunctionParameter::Output(CYOutput
&out
) const {
572 binding_
->Output(out
, CYNoFlags
);
574 out
<< ',' << ' ' << *next_
;
577 const char *CYIdentifier::Word() const {
578 return next_
== NULL
|| next_
== this ? CYWord::Word() : next_
->Word();
581 void CYIf::Output(CYOutput
&out
, CYFlags flags
) const {
583 if (false_
== NULL
&& (flags
& CYNoDangle
) != 0) {
588 out
<< "if" << ' ' << '(' << *test_
<< ')';
590 CYFlags
right(protect
? CYNoFlags
: CYRight(flags
));
592 CYFlags
jacks(CYNoDangle
);
596 jacks
|= protect
? CYNoFlags
: CYCenter(flags
);
598 unsigned line(out
.position_
.line
);
599 unsigned indent(out
.indent_
);
600 true_
->Single(out
, jacks
, CYCompactShort
);
602 if (false_
!= NULL
) {
603 if (out
.position_
.line
!= line
&& out
.recent_
== indent
)
609 false_
->Single(out
, right
, CYCompactLong
);
616 void CYIfComprehension::Output(CYOutput
&out
) const {
617 out
<< "if" << ' ' << '(' << *test_
<< ')' << next_
;
620 void CYImport::Output(CYOutput
&out
, CYFlags flags
) const {
624 void CYImportDeclaration::Output(CYOutput
&out
, CYFlags flags
) const {
628 void CYIndirect::Output(CYOutput
&out
, CYFlags flags
) const {
630 rhs_
->Output(out
, Precedence(), CYRight(flags
));
633 void CYIndirectMember::Output(CYOutput
&out
, CYFlags flags
) const {
634 object_
->Output(out
, Precedence(), CYLeft(flags
));
635 if (const char *word
= property_
->Word())
638 out
<< "->" << '[' << *property_
<< ']';
641 void CYInfix::Output(CYOutput
&out
, CYFlags flags
) const {
642 const char *name(Operator());
643 bool protect((flags
& CYNoIn
) != 0 && strcmp(name
, "in") == 0);
646 CYFlags
left(protect
? CYNoFlags
: CYLeft(flags
));
647 lhs_
->Output(out
, Precedence(), left
);
648 out
<< ' ' << name
<< ' ';
649 CYFlags
right(protect
? CYNoFlags
: CYRight(flags
));
650 rhs_
->Output(out
, Precedence() - 1, right
);
655 void CYLabel::Output(CYOutput
&out
, CYFlags flags
) const {
656 out
<< *name_
<< ':';
657 statement_
->Single(out
, CYRight(flags
), CYCompactShort
);
660 void CYParenthetical::Output(CYOutput
&out
, CYFlags flags
) const {
662 expression_
->Output(out
, CYCompound::Precedence_
, CYNoFlags
);
666 void CYStatement::Output(CYOutput
&out
) const {
670 void CYTemplate::Output(CYOutput
&out
, CYFlags flags
) const {
674 void CYTypeArrayOf::Output(CYOutput
&out
, CYPropertyName
*name
) const {
675 next_
->Output(out
, Precedence(), name
, false);
681 void CYTypeBlockWith::Output(CYOutput
&out
, CYPropertyName
*name
) const {
683 next_
->Output(out
, Precedence(), name
, false);
684 out
<< ')' << '(' << parameters_
<< ')';
687 void CYTypeConstant::Output(CYOutput
&out
, CYPropertyName
*name
) const {
689 next_
->Output(out
, Precedence(), name
, false);
692 void CYTypeFunctionWith::Output(CYOutput
&out
, CYPropertyName
*name
) const {
693 next_
->Output(out
, Precedence(), name
, false);
694 out
<< '(' << parameters_
;
696 if (parameters_
!= NULL
)
703 void CYTypePointerTo::Output(CYOutput
&out
, CYPropertyName
*name
) const {
705 next_
->Output(out
, Precedence(), name
, false);
708 void CYTypeVolatile::Output(CYOutput
&out
, CYPropertyName
*name
) const {
710 next_
->Output(out
, Precedence(), name
, true);
713 void CYTypeModifier::Output(CYOutput
&out
, int precedence
, CYPropertyName
*name
, bool space
) const {
714 if (this == NULL
&& name
== NULL
)
720 name
->PropertyName(out
);
724 bool protect(precedence
> Precedence());
733 void CYType::Output(CYOutput
&out
, CYPropertyName
*name
) const {
735 modifier_
->Output(out
, 0, name
, true);
738 void CYType::Output(CYOutput
&out
) const {
742 void CYEncodedType::Output(CYOutput
&out
, CYFlags flags
) const {
743 out
<< "@encode(" << typed_
<< ")";
746 void CYTypedParameter::Output(CYOutput
&out
) const {
747 type_
->Output(out
, name_
);
749 out
<< ',' << ' ' << next_
;
752 void CYLambda::Output(CYOutput
&out
, CYFlags flags
) const {
753 // XXX: this is seriously wrong
760 void CYTypeDefinition::Output(CYOutput
&out
, CYFlags flags
) const {
761 out
<< "typedef" << ' ';
762 type_
->Output(out
, name_
);
766 void CYTypeExpression::Output(CYOutput
&out
, CYFlags flags
) const {
767 out
<< '(' << "typedef" << ' ' << *typed_
<< ')';
770 void CYLexical::Output(CYOutput
&out
, CYFlags flags
) const {
772 bindings_
->Output(out
, flags
); // XXX: flags
776 void CYModule::Output(CYOutput
&out
) const {
785 void New::Output(CYOutput
&out
, CYFlags flags
) const {
787 CYFlags
jacks(CYNoCall
| CYCenter(flags
));
788 constructor_
->Output(out
, Precedence(), jacks
);
789 if (arguments_
!= NULL
)
790 out
<< '(' << *arguments_
<< ')';
795 void CYNull::Output(CYOutput
&out
, CYFlags flags
) const {
799 void CYNumber::Output(CYOutput
&out
, CYFlags flags
) const {
800 std::ostringstream str
;
801 CYNumerify(str
, Value());
802 std::string
value(str
.str());
803 out
<< value
.c_str();
804 // XXX: this should probably also handle hex conversions and exponents
805 if ((flags
& CYNoInteger
) != 0 && value
.find('.') == std::string::npos
)
809 void CYNumber::PropertyName(CYOutput
&out
) const {
810 Output(out
, CYNoFlags
);
813 void CYObject::Output(CYOutput
&out
, CYFlags flags
) const {
814 bool protect((flags
& CYNoBrace
) != 0);
826 void CYPostfix::Output(CYOutput
&out
, CYFlags flags
) const {
827 lhs_
->Output(out
, Precedence(), CYLeft(flags
));
831 void CYPrefix::Output(CYOutput
&out
, CYFlags flags
) const {
832 const char *name(Operator());
836 rhs_
->Output(out
, Precedence(), CYRight(flags
));
839 void CYScript::Output(CYOutput
&out
) const {
843 void CYProperty::Output(CYOutput
&out
) const {
844 if (next_
!= NULL
|| out
.pretty_
)
846 out
<< '\n' << next_
;
849 void CYPropertyGetter::Output(CYOutput
&out
) const {
851 name_
->PropertyName(out
);
852 CYFunction::Output(out
);
853 CYProperty::Output(out
);
856 void CYPropertyMethod::Output(CYOutput
&out
) const {
857 name_
->PropertyName(out
);
858 CYFunction::Output(out
);
859 CYProperty::Output(out
);
862 void CYPropertySetter::Output(CYOutput
&out
) const {
864 name_
->PropertyName(out
);
865 CYFunction::Output(out
);
866 CYProperty::Output(out
);
869 void CYPropertyValue::Output(CYOutput
&out
) const {
871 name_
->PropertyName(out
);
873 value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
874 CYProperty::Output(out
);
877 void CYRegEx::Output(CYOutput
&out
, CYFlags flags
) const {
881 void CYResolveMember::Output(CYOutput
&out
, CYFlags flags
) const {
882 object_
->Output(out
, Precedence(), CYLeft(flags
));
883 if (const char *word
= property_
->Word())
886 out
<< "::" << '[' << *property_
<< ']';
889 void CYReturn::Output(CYOutput
&out
, CYFlags flags
) const {
892 out
<< ' ' << *value_
;
896 void CYRubyBlock::Output(CYOutput
&out
, CYFlags flags
) const {
897 lhs_
->Output(out
, CYLeft(flags
));
899 proc_
->Output(out
, CYRight(flags
));
902 void CYRubyProc::Output(CYOutput
&out
, CYFlags flags
) const {
903 out
<< '{' << ' ' << '|' << parameters_
<< '|' << '\n';
910 void CYSubscriptMember::Output(CYOutput
&out
, CYFlags flags
) const {
911 object_
->Output(out
, Precedence(), CYLeft(flags
));
912 out
<< "." << '[' << *property_
<< ']';
915 void CYStatement::Multiple(CYOutput
&out
, CYFlags flags
) const {
917 CYForEach (next
, this) {
918 bool last(next
->next_
== NULL
);
919 CYFlags
jacks(first
? last
? flags
: CYLeft(flags
) : last
? CYRight(flags
) : CYCenter(flags
));
922 next
->Output(out
, jacks
);
927 void CYStatement::Single(CYOutput
&out
, CYFlags flags
, CYCompactType request
) const {
929 return out
.Terminate();
931 _assert(next_
== NULL
);
933 CYCompactType
compact(Compact());
935 if (compact
>= request
)
945 if (compact
< request
)
949 void CYString::Output(CYOutput
&out
, CYFlags flags
) const {
950 std::ostringstream str
;
951 CYStringify(str
, value_
, size_
);
952 out
<< str
.str().c_str();
955 void CYString::PropertyName(CYOutput
&out
) const {
956 if (const char *word
= Word())
962 static const char *Reserved_
[] = {
963 "false", "null", "true",
965 "break", "case", "catch", "continue", "default",
966 "delete", "do", "else", "finally", "for", "function",
967 "if", "in", "instanceof", "new", "return", "switch",
968 "this", "throw", "try", "typeof", "var", "void",
973 "class", "enum", "export", "extends", "import", "super",
975 "abstract", "boolean", "byte", "char", "double", "final",
976 "float", "goto", "int", "long", "native", "short",
977 "synchronized", "throws", "transient", "volatile",
984 const char *CYString::Word() const {
985 if (size_
== 0 || !WordStartRange_
[value_
[0]])
987 for (size_t i(1); i
!= size_
; ++i
)
988 if (!WordEndRange_
[value_
[i
]])
990 const char *value(Value());
991 for (const char **reserved(Reserved_
); *reserved
!= NULL
; ++reserved
)
992 if (strcmp(*reserved
, value
) == 0)
997 void CYStructDefinition::Output(CYOutput
&out
, CYFlags flags
) const {
998 out
<< "struct" << ' ' << *name_
<< *tail_
;
1001 void CYStructTail::Output(CYOutput
&out
) const {
1002 out
<< ' ' << '{' << '\n';
1004 CYForEach (field
, fields_
) {
1006 field
->type_
->Output(out
, field
->name_
);
1014 void CYSuperAccess::Output(CYOutput
&out
, CYFlags flags
) const {
1016 if (const char *word
= property_
->Word())
1019 out
<< '[' << *property_
<< ']';
1022 void CYSuperCall::Output(CYOutput
&out
, CYFlags flags
) const {
1023 out
<< "super" << '(' << arguments_
<< ')';
1026 void CYSwitch::Output(CYOutput
&out
, CYFlags flags
) const {
1027 out
<< "switch" << ' ' << '(' << *value_
<< ')' << ' ' << '{' << '\n';
1034 void CYSymbol::Output(CYOutput
&out
, CYFlags flags
) const {
1035 bool protect((flags
& CYNoColon
) != 0);
1038 out
<< ':' << name_
;
1043 void CYThis::Output(CYOutput
&out
, CYFlags flags
) const {
1050 void Throw::Output(CYOutput
&out
, CYFlags flags
) const {
1053 out
<< ' ' << *value_
;
1057 void Try::Output(CYOutput
&out
, CYFlags flags
) const {
1058 out
<< "try" << ' ';
1064 out
<< catch_
<< finally_
;
1069 void CYTypeCharacter::Output(CYOutput
&out
) const {
1071 case CYTypeNeutral
: break;
1072 case CYTypeSigned
: out
<< "signed" << ' '; break;
1073 case CYTypeUnsigned
: out
<< "unsigned" << ' '; break;
1079 void CYTypeEnum::Output(CYOutput
&out
) const {
1080 out
<< "enum" << ' ';
1084 if (specifier_
!= NULL
)
1085 out
<< ':' << ' ' << *specifier_
<< ' ';
1091 CYForEach (constant
, constants_
) {
1096 out
<< '\t' << constant
->name_
;
1097 out
<< ' ' << '=' << ' ' << constant
->value_
;
1108 void CYTypeError::Output(CYOutput
&out
) const {
1112 void CYTypeInt128::Output(CYOutput
&out
) const {
1114 case CYTypeNeutral
: break;
1115 case CYTypeSigned
: out
<< "signed" << ' '; break;
1116 case CYTypeUnsigned
: out
<< "unsigned" << ' '; break;
1122 void CYTypeIntegral::Output(CYOutput
&out
) const {
1123 if (signing_
== CYTypeUnsigned
)
1124 out
<< "unsigned" << ' ';
1126 case 0: out
<< "short"; break;
1127 case 1: out
<< "int"; break;
1128 case 2: out
<< "long"; break;
1129 case 3: out
<< "long" << ' ' << "long"; break;
1130 default: _assert(false);
1134 void CYTypeStruct::Output(CYOutput
&out
) const {
1137 out
<< ' ' << *name_
;
1142 void CYTypeReference::Output(CYOutput
&out
) const {
1144 case CYTypeReferenceStruct
: out
<< "struct"; break;
1145 case CYTypeReferenceEnum
: out
<< "enum"; break;
1146 default: _assert(false);
1149 out
<< ' ' << *name_
;
1152 void CYTypeVariable::Output(CYOutput
&out
) const {
1156 void CYTypeVoid::Output(CYOutput
&out
) const {
1160 void CYVar::Output(CYOutput
&out
, CYFlags flags
) const {
1161 out
<< "var" << ' ';
1162 bindings_
->Output(out
, flags
); // XXX: flags
1166 void CYVariable::Output(CYOutput
&out
, CYFlags flags
) const {
1170 void CYWhile::Output(CYOutput
&out
, CYFlags flags
) const {
1171 out
<< "while" << ' ' << '(' << *test_
<< ')';
1172 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
1175 void CYWith::Output(CYOutput
&out
, CYFlags flags
) const {
1176 out
<< "with" << ' ' << '(' << *scope_
<< ')';
1177 code_
->Single(out
, CYRight(flags
), CYCompactShort
);
1180 void CYWord::Output(CYOutput
&out
) const {
1182 if (out
.options_
.verbose_
) {
1185 sprintf(number
, "%p", this);
1190 void CYWord::PropertyName(CYOutput
&out
) const {
1194 const char *CYWord::Word() const {