]>
git.saurik.com Git - cycript.git/blob - Output.cpp
b45703f1ebe9fd685282b7a799783b71e65038c4
6 void CYAddressOf::Output(std::ostream
&out
) const {
7 out
<< *rhs_
<< ".$()";
10 void CYArgument::Output(std::ostream
&out
, bool send
) const {
11 if (!send
&& name_
!= NULL
) {
19 value_
->Output(out
, true);
23 if (next_
->name_
!= NULL
)
27 next_
->Output(out
, send
);
31 void CYBoolean::Output(std::ostream
&out
) const {
32 out
<< (Value() ? "true" : "false");
35 void CYBreak::Output(std::ostream
&out
) const {
38 out
<< ' ' << *label_
;
42 void CYCall::Output(std::ostream
&out
) const {
43 out
<< *function_
<< '(';
44 if (arguments_
!= NULL
)
45 arguments_
->Output(out
, false);
49 void CYCatch::Output(std::ostream
&out
) const {
50 out
<< "catch(" << *name_
<< ')';
51 code_
->Output(out
, true);
54 void CYCondition::Output(std::ostream
&out
) const {
58 out
<< ':' << *false_
;
61 void CYContinue::Output(std::ostream
&out
) const {
64 out
<< ' ' << *label_
;
68 void CYClause::Output(std::ostream
&out
) const {
70 out
<< "case" << *case_
;
75 code_
->Output(out
, false);
79 void CYDeclaration::Part(std::ostream
&out
) const {
84 void CYDeclaration::Output(std::ostream
&out
) const {
86 if (initialiser_
!= NULL
)
87 out
<< '=' << *initialiser_
;
90 void CYDeclarations::Part(std::ostream
&out
) const {
92 const CYDeclarations
*declaration(this);
94 out
<< *declaration
->declaration_
;
95 declaration
= declaration
->next_
;
96 } while (declaration
!= NULL
);
99 void CYDeclarations::Output(std::ostream
&out
) const {
104 void CYDoWhile::Output(std::ostream
&out
) const {
106 code_
->Output(out
, false);
107 out
<< "while" << *test_
<< ';';
110 void CYElement::Output(std::ostream
&out
, bool raw
) const {
114 value_
->Output(out
, true);
117 next_
->Output(out
, true);
123 void CYElement::Output(std::ostream
&out
) const {
127 void CYEmpty::Output(std::ostream
&out
) const {
131 void CYEmpty::Output(std::ostream
&out
, bool block
) const {
133 CYSource::Output(out
, block
);
138 void CYExpress::Output(std::ostream
&out
) const {
139 expression_
->Output(out
, true);
143 void CYExpression::Part(std::ostream
&out
) const {
147 void CYExpression::Output(std::ostream
&out
, bool raw
) const {
153 next_
->Output(out
, true);
159 void CYFor::Output(std::ostream
&out
) const {
161 if (initialiser_
!= NULL
)
162 initialiser_
->Part(out
);
165 test_
->Output(out
, true);
167 if (increment_
!= NULL
)
168 increment_
->Output(out
, true);
170 code_
->Output(out
, false);
173 void CYForIn::Output(std::ostream
&out
) const {
175 initialiser_
->Part(out
);
177 set_
->Output(out
, true);
179 code_
->Output(out
, false);
182 void CYFunction::Output(std::ostream
&out
) const {
183 CYLambda::Output(out
);
186 void CYIf::Output(std::ostream
&out
) const {
187 out
<< "if" << *test_
;
188 true_
->Output(out
, true);
189 if (false_
!= NULL
) {
191 false_
->Output(out
, false);
195 void CYIndirect::Output(std::ostream
&out
) const {
196 out
<< *rhs_
<< "[0]";
199 void CYInfix::Output(std::ostream
&out
) const {
200 out
<< *lhs_
<< Operator() << *rhs_
;
203 void CYLambda::Output(std::ostream
&out
) const {
206 out
<< ' ' << *name_
;
208 if (parameters_
!= NULL
)
211 body_
->Output(out
, true);
214 void CYMember::Output(std::ostream
&out
) const {
215 out
<< *object_
<< '[';
216 property_
->Output(out
, true);
220 void CYMessage::Output(std::ostream
&out
) const {
221 out
<< "objc_msgSend(";
222 self_
->Output(out
, true);
224 for (CYArgument
*argument(arguments_
); argument
!= NULL
; argument
= argument
->next_
)
225 if (argument
->name_
!= NULL
) {
226 out
<< *argument
->name_
;
227 if (argument
->value_
!= NULL
)
231 if (arguments_
!= NULL
)
232 arguments_
->Output(out
, true);
236 void CYNew::Output(std::ostream
&out
) const {
237 out
<< "new " << *constructor_
<< '(';
238 if (arguments_
!= NULL
)
239 arguments_
->Output(out
, false);
243 void CYNull::Output(std::ostream
&out
) const {
247 void CYNumber::Output(std::ostream
&out
) const {
248 // XXX: this is not a useful formatting
252 void CYParameter::Output(std::ostream
&out
) const {
260 void CYPostfix::Output(std::ostream
&out
) const {
261 out
<< *lhs_
<< Operator();
264 void CYPrefix::Output(std::ostream
&out
) const {
265 out
<< Operator() << *rhs_
;
268 void CYProperty::Output(std::ostream
&out
, bool raw
) const {
271 out
<< *name_
<< ':' << *value_
;
274 next_
->Output(out
, true);
280 void CYProperty::Output(std::ostream
&out
) const {
284 void CYReturn::Output(std::ostream
&out
) const {
287 out
<< ' ' << *value_
;
291 void CYSource::Part(std::ostream
&out
) const {
292 for (const CYSource
*next(this); next
!= NULL
; next
= next
->next_
)
296 void CYSource::Output(std::ostream
&out
, bool block
) const {
297 if (!block
&& next_
== NULL
)
306 void CYString::Output(std::ostream
&out
) const {
308 for (const char *value(value_
), *end(value_
+ size_
); value
!= end
; ++value
)
310 case '"': out
<< "\\\""; break;
311 case '\\': out
<< "\\\\"; break;
312 case '\b': out
<< "\\b"; break;
313 case '\f': out
<< "\\f"; break;
314 case '\n': out
<< "\\n"; break;
315 case '\r': out
<< "\\r"; break;
316 case '\t': out
<< "\\t"; break;
317 case '\v': out
<< "\\v"; break;
320 if (*value
< 0x20 || *value
>= 0x7f)
321 out
<< "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << unsigned(*value
);
328 void CYSwitch::Output(std::ostream
&out
) const {
329 out
<< "switch" << *value_
<< '{';
330 if (clauses_
!= NULL
)
335 void CYThis::Output(std::ostream
&out
) const {
339 void CYThrow::Output(std::ostream
&out
) const {
342 out
<< ' ' << *value_
;
346 void CYTry::Output(std::ostream
&out
) const {
348 try_
->Output(out
, true);
351 if (finally_
!= NULL
) {
353 finally_
->Output(out
, true);
357 void CYVariable::Output(std::ostream
&out
) const {
361 void CYWhile::Output(std::ostream
&out
) const {
362 out
<< "while" << *test_
;
363 code_
->Output(out
, false);
366 void CYWith::Output(std::ostream
&out
) const {
367 out
<< "with" << *scope_
;
368 code_
->Output(out
, false);
371 void CYWord::Output(std::ostream
&out
) const {