]>
git.saurik.com Git - cycript.git/blob - Output.cpp
647f47e0f0c34438ce3964c373d92a9a41c2fc19
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 CYArray::Output(std::ostream
&out
) const {
33 if (elements_
!= NULL
)
34 elements_
->Output(out
);
38 void CYBoolean::Output(std::ostream
&out
) const {
39 out
<< (Value() ? "true" : "false");
42 void CYBreak::Output(std::ostream
&out
) const {
45 out
<< ' ' << *label_
;
49 void CYCall::Output(std::ostream
&out
) const {
50 out
<< *function_
<< '(';
51 if (arguments_
!= NULL
)
52 arguments_
->Output(out
, false);
56 void CYCatch::Output(std::ostream
&out
) const {
57 out
<< "catch(" << *name_
<< ')';
58 code_
->Output(out
, true);
61 void CYCondition::Output(std::ostream
&out
) const {
65 out
<< ':' << *false_
;
68 void CYContinue::Output(std::ostream
&out
) const {
71 out
<< ' ' << *label_
;
75 void CYClause::Output(std::ostream
&out
) const {
77 out
<< "case" << *case_
;
82 code_
->Output(out
, false);
86 void CYDeclaration::Part(std::ostream
&out
) const {
91 void CYDeclaration::Output(std::ostream
&out
) const {
93 if (initialiser_
!= NULL
)
94 out
<< '=' << *initialiser_
;
97 void CYDeclarations::Part(std::ostream
&out
) const {
99 const CYDeclarations
*declaration(this);
101 out
<< *declaration
->declaration_
;
102 declaration
= declaration
->next_
;
103 } while (declaration
!= NULL
);
106 void CYDeclarations::Output(std::ostream
&out
) const {
111 void CYDoWhile::Output(std::ostream
&out
) const {
113 code_
->Output(out
, false);
114 out
<< "while" << *test_
<< ';';
117 void CYElement::Output(std::ostream
&out
) const {
119 value_
->Output(out
, true);
120 if (next_
!= NULL
|| value_
== NULL
)
126 void CYEmpty::Output(std::ostream
&out
) const {
130 void CYEmpty::Output(std::ostream
&out
, bool block
) const {
132 CYSource::Output(out
, block
);
137 void CYExpress::Output(std::ostream
&out
) const {
138 expression_
->Output(out
, true);
142 void CYExpression::Part(std::ostream
&out
) const {
146 void CYExpression::Output(std::ostream
&out
, bool raw
) const {
152 next_
->Output(out
, true);
158 void CYFor::Output(std::ostream
&out
) const {
160 if (initialiser_
!= NULL
)
161 initialiser_
->Part(out
);
164 test_
->Output(out
, true);
166 if (increment_
!= NULL
)
167 increment_
->Output(out
, true);
169 code_
->Output(out
, false);
172 void CYForIn::Output(std::ostream
&out
) const {
174 initialiser_
->Part(out
);
176 set_
->Output(out
, true);
178 code_
->Output(out
, false);
181 void CYFunction::Output(std::ostream
&out
) const {
182 CYLambda::Output(out
);
185 void CYIf::Output(std::ostream
&out
) const {
186 out
<< "if" << *test_
;
187 true_
->Output(out
, true);
188 if (false_
!= NULL
) {
190 false_
->Output(out
, false);
194 void CYIndirect::Output(std::ostream
&out
) const {
195 out
<< *rhs_
<< "[0]";
198 void CYInfix::Output(std::ostream
&out
) const {
199 out
<< *lhs_
<< Operator() << *rhs_
;
202 void CYLambda::Output(std::ostream
&out
) const {
205 out
<< ' ' << *name_
;
207 if (parameters_
!= NULL
)
210 body_
->Output(out
, true);
213 void CYMember::Output(std::ostream
&out
) const {
214 out
<< *object_
<< '[';
215 property_
->Output(out
, true);
219 void CYMessage::Output(std::ostream
&out
) const {
220 out
<< "objc_msgSend(";
221 self_
->Output(out
, true);
223 for (CYArgument
*argument(arguments_
); argument
!= NULL
; argument
= argument
->next_
)
224 if (argument
->name_
!= NULL
) {
225 out
<< *argument
->name_
;
226 if (argument
->value_
!= NULL
)
230 if (arguments_
!= NULL
)
231 arguments_
->Output(out
, true);
235 void CYNew::Output(std::ostream
&out
) const {
236 out
<< "new " << *constructor_
<< '(';
237 if (arguments_
!= NULL
)
238 arguments_
->Output(out
, false);
242 void CYNull::Output(std::ostream
&out
) const {
246 void CYNumber::Output(std::ostream
&out
) const {
247 // XXX: this is not a useful formatting
251 void CYObject::Output(std::ostream
&out
) const {
253 if (property_
!= NULL
)
254 property_
->Output(out
);
258 void CYParameter::Output(std::ostream
&out
) const {
266 void CYPostfix::Output(std::ostream
&out
) const {
267 out
<< *lhs_
<< Operator();
270 void CYPrefix::Output(std::ostream
&out
) const {
271 out
<< Operator() << *rhs_
;
274 void CYProperty::Output(std::ostream
&out
) const {
275 out
<< *name_
<< ':' << *value_
;
282 void CYReturn::Output(std::ostream
&out
) const {
285 out
<< ' ' << *value_
;
289 void CYSelector::Output(std::ostream
&out
) const {
296 void CYSelectorPart::Output(std::ostream
&out
) const {
305 void CYSource::Show(std::ostream
&out
) const {
306 for (const CYSource
*next(this); next
!= NULL
; next
= next
->next_
)
307 next
->Output(out
, false);
310 void CYSource::Output(std::ostream
&out
, bool block
) const {
311 if (!block
&& next_
== NULL
)
320 void CYString::Output(std::ostream
&out
) const {
322 for (const char *value(value_
), *end(value_
+ size_
); value
!= end
; ++value
)
324 case '"': out
<< "\\\""; break;
325 case '\\': out
<< "\\\\"; break;
326 case '\b': out
<< "\\b"; break;
327 case '\f': out
<< "\\f"; break;
328 case '\n': out
<< "\\n"; break;
329 case '\r': out
<< "\\r"; break;
330 case '\t': out
<< "\\t"; break;
331 case '\v': out
<< "\\v"; break;
334 if (*value
< 0x20 || *value
>= 0x7f)
335 out
<< "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << unsigned(*value
);
342 void CYSwitch::Output(std::ostream
&out
) const {
343 out
<< "switch" << *value_
<< '{';
344 if (clauses_
!= NULL
)
349 void CYThis::Output(std::ostream
&out
) const {
353 void CYThrow::Output(std::ostream
&out
) const {
356 out
<< ' ' << *value_
;
360 void CYTry::Output(std::ostream
&out
) const {
362 try_
->Output(out
, true);
365 if (finally_
!= NULL
) {
367 finally_
->Output(out
, true);
371 void CYVariable::Output(std::ostream
&out
) const {
375 void CYWhile::Output(std::ostream
&out
) const {
376 out
<< "while" << *test_
;
377 code_
->Output(out
, false);
380 void CYWith::Output(std::ostream
&out
) const {
381 out
<< "with" << *scope_
;
382 code_
->Output(out
, false);
385 void CYWord::Output(std::ostream
&out
) const {