]>
git.saurik.com Git - cycript.git/blob - Output.cpp
4e4040a5f00b36ed1fa923f5c85abf571f82325d
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 CYObject::Output(std::ostream
&out
) const {
254 if (property_
!= NULL
)
255 property_
->Output(out
);
259 void CYParameter::Output(std::ostream
&out
) const {
267 void CYPostfix::Output(std::ostream
&out
) const {
268 out
<< *lhs_
<< Operator();
271 void CYPrefix::Output(std::ostream
&out
) const {
272 out
<< Operator() << *rhs_
;
275 void CYProperty::Output(std::ostream
&out
) const {
276 out
<< *name_
<< ':' << *value_
;
283 void CYReturn::Output(std::ostream
&out
) const {
286 out
<< ' ' << *value_
;
290 void CYSelector::Output(std::ostream
&out
) const {
292 out
<< "<unimplemented>";
296 void CYSource::Show(std::ostream
&out
) const {
297 for (const CYSource
*next(this); next
!= NULL
; next
= next
->next_
)
301 void CYSource::Output(std::ostream
&out
, bool block
) const {
302 if (!block
&& next_
== NULL
)
311 void CYString::Output(std::ostream
&out
) const {
313 for (const char *value(value_
), *end(value_
+ size_
); value
!= end
; ++value
)
315 case '"': out
<< "\\\""; break;
316 case '\\': out
<< "\\\\"; break;
317 case '\b': out
<< "\\b"; break;
318 case '\f': out
<< "\\f"; break;
319 case '\n': out
<< "\\n"; break;
320 case '\r': out
<< "\\r"; break;
321 case '\t': out
<< "\\t"; break;
322 case '\v': out
<< "\\v"; break;
325 if (*value
< 0x20 || *value
>= 0x7f)
326 out
<< "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << unsigned(*value
);
333 void CYSwitch::Output(std::ostream
&out
) const {
334 out
<< "switch" << *value_
<< '{';
335 if (clauses_
!= NULL
)
340 void CYThis::Output(std::ostream
&out
) const {
344 void CYThrow::Output(std::ostream
&out
) const {
347 out
<< ' ' << *value_
;
351 void CYTry::Output(std::ostream
&out
) const {
353 try_
->Output(out
, true);
356 if (finally_
!= NULL
) {
358 finally_
->Output(out
, true);
362 void CYVariable::Output(std::ostream
&out
) const {
366 void CYWhile::Output(std::ostream
&out
) const {
367 out
<< "while" << *test_
;
368 code_
->Output(out
, false);
371 void CYWith::Output(std::ostream
&out
) const {
372 out
<< "with" << *scope_
;
373 code_
->Output(out
, false);
376 void CYWord::Output(std::ostream
&out
) const {