]>
git.saurik.com Git - cycript.git/blob - Output.cpp
8 void CYAddressOf::Output(std::ostream
&out
) const {
13 void CYArgument::Output(std::ostream
&out
) const {
20 value_
->Output(out
, false);
22 if (next_
->name_
== NULL
)
30 void CYArray::Output(std::ostream
&out
) const {
32 if (elements_
!= NULL
)
33 elements_
->Output(out
);
37 void CYAssignment::Output(std::ostream
&out
) const {
38 lhs_
->Output(out
, Precedence() - 1);
40 rhs_
->Output(out
, Precedence());
43 void CYBoolean::Output(std::ostream
&out
) const {
44 out
<< (Value() ? "true" : "false");
47 void CYBreak::Output(std::ostream
&out
) const {
50 out
<< ' ' << *label_
;
54 void CYCall::Output(std::ostream
&out
) const {
55 function_
->Output(out
, Precedence());
57 if (arguments_
!= NULL
)
58 arguments_
->Output(out
);
62 void CYCatch::Output(std::ostream
&out
) const {
63 out
<< "catch(" << *name_
<< ')';
64 code_
->Output(out
, true);
67 void CYCondition::Output(std::ostream
&out
) const {
68 test_
->Output(out
, Precedence() - 1);
71 true_
->Output(out
, CYPA
);
73 false_
->Output(out
, CYPA
);
76 void CYContinue::Output(std::ostream
&out
) const {
79 out
<< ' ' << *label_
;
83 void CYClause::Output(std::ostream
&out
) const {
91 code_
->Output(out
, false);
95 void CYDeclaration::Part(std::ostream
&out
) const {
100 void CYDeclaration::Output(std::ostream
&out
) const {
102 if (initialiser_
!= NULL
) {
104 initialiser_
->Output(out
, CYPA
);
108 void CYDeclarations::Part(std::ostream
&out
) const {
111 const CYDeclarations
*declaration(this);
113 out
<< *declaration
->declaration_
;
114 declaration
= declaration
->next_
;
116 if (declaration
!= NULL
) {
122 void CYDeclarations::Output(std::ostream
&out
) const {
127 void CYDoWhile::Output(std::ostream
&out
) const {
129 code_
->Output(out
, false);
135 void CYElement::Output(std::ostream
&out
) const {
137 value_
->Output(out
, CYPA
);
138 if (next_
!= NULL
|| value_
== NULL
)
144 void CYEmpty::Output(std::ostream
&out
) const {
148 void CYEmpty::Output(std::ostream
&out
, bool block
) const {
150 CYSource::Output(out
, block
);
155 void CYExpress::Output(std::ostream
&out
) const {
156 expression_
->Output(out
);
160 void CYExpression::Part(std::ostream
&out
) const {
161 // XXX: this should notice "in" expressions
162 // XXX: this should handle LeftHandSideExpression
166 void CYCompound::Output(std::ostream
&out
) const {
167 if (CYExpression
*expression
= expressions_
)
169 expression
->Output(out
);
170 expression
= expression
->next_
;
171 if (expression
== NULL
)
177 void CYExpression::Output(std::ostream
&out
, unsigned precedence
) const {
178 bool protect(precedence
< Precedence());
186 void CYFor::Output(std::ostream
&out
) const {
188 if (initialiser_
!= NULL
)
189 initialiser_
->Part(out
);
194 if (increment_
!= NULL
)
195 increment_
->Output(out
);
197 code_
->Output(out
, false);
200 void CYForIn::Output(std::ostream
&out
) const {
202 initialiser_
->Part(out
);
206 code_
->Output(out
, false);
209 void CYFunction::Output(std::ostream
&out
) const {
210 CYLambda::Output(out
);
213 void CYIf::Output(std::ostream
&out
) const {
217 true_
->Output(out
, true);
218 if (false_
!= NULL
) {
220 false_
->Output(out
, false);
224 void CYIndirect::Output(std::ostream
&out
) const {
225 rhs_
->Output(out
, 1);
229 void CYInfix::Output(std::ostream
&out
) const {
230 lhs_
->Output(out
, Precedence());
232 rhs_
->Output(out
, Precedence() - 1);
235 void CYLambda::Output(std::ostream
&out
) const {
238 out
<< ' ' << *name_
;
240 if (parameters_
!= NULL
)
243 body_
->Output(out
, true);
246 void CYMember::Output(std::ostream
&out
) const {
247 object_
->Output(out
, Precedence());
248 if (const char *word
= property_
->Word())
252 property_
->Output(out
);
257 void CYMessage::Output(std::ostream
&out
) const {
258 out
<< "objc_msgSend(";
259 self_
->Output(out
, CYPA
);
261 for (CYArgument
*argument(arguments_
); argument
!= NULL
; argument
= argument
->next_
)
262 if (argument
->name_
!= NULL
) {
263 out
<< *argument
->name_
;
264 if (argument
->value_
!= NULL
)
268 for (CYArgument
*argument(arguments_
); argument
!= NULL
; argument
= argument
->next_
)
269 if (argument
->value_
!= NULL
) {
271 argument
->value_
->Output(out
, CYPA
);
276 void CYNew::Output(std::ostream
&out
) const {
278 // XXX: I don't /always/ need this character
280 constructor_
->Output(out
, Precedence());
282 if (arguments_
!= NULL
)
283 arguments_
->Output(out
);
287 void CYNull::Output(std::ostream
&out
) const {
291 void CYNumber::Output(std::ostream
&out
) const {
292 // XXX: this is not a useful formatting
296 void CYObject::Output(std::ostream
&out
) const {
298 if (property_
!= NULL
)
299 property_
->Output(out
);
303 void CYParameter::Output(std::ostream
&out
) const {
311 void CYPostfix::Output(std::ostream
&out
) const {
312 lhs_
->Output(out
, Precedence());
316 void CYPrefix::Output(std::ostream
&out
) const {
318 rhs_
->Output(out
, Precedence());
321 void CYProperty::Output(std::ostream
&out
) const {
322 out
<< *name_
<< ':';
323 value_
->Output(out
, CYPA
);
330 void CYReturn::Output(std::ostream
&out
) const {
332 if (value_
!= NULL
) {
339 void CYSelector::Output(std::ostream
&out
) const {
346 void CYSelectorPart::Output(std::ostream
&out
) const {
355 void CYSource::Show(std::ostream
&out
) const {
356 for (const CYSource
*next(this); next
!= NULL
; next
= next
->next_
)
357 next
->Output(out
, false);
360 void CYSource::Output(std::ostream
&out
, bool block
) const {
361 if (!block
&& next_
== NULL
)
370 void CYString::Output(std::ostream
&out
) const {
372 for (const char *value(value_
), *end(value_
+ size_
); value
!= end
; ++value
)
374 case '"': out
<< "\\\""; break;
375 case '\\': out
<< "\\\\"; break;
376 case '\b': out
<< "\\b"; break;
377 case '\f': out
<< "\\f"; break;
378 case '\n': out
<< "\\n"; break;
379 case '\r': out
<< "\\r"; break;
380 case '\t': out
<< "\\t"; break;
381 case '\v': out
<< "\\v"; break;
384 if (*value
< 0x20 || *value
>= 0x7f)
385 out
<< "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << unsigned(*value
);
392 void CYSwitch::Output(std::ostream
&out
) const {
396 if (clauses_
!= NULL
)
401 void CYThis::Output(std::ostream
&out
) const {
405 void CYThrow::Output(std::ostream
&out
) const {
407 if (value_
!= NULL
) {
414 void CYTry::Output(std::ostream
&out
) const {
416 try_
->Output(out
, true);
419 if (finally_
!= NULL
) {
421 finally_
->Output(out
, true);
425 void CYVariable::Output(std::ostream
&out
) const {
429 void CYWhile::Output(std::ostream
&out
) const {
433 code_
->Output(out
, false);
436 void CYWith::Output(std::ostream
&out
) const {
440 code_
->Output(out
, false);
443 void CYWord::Output(std::ostream
&out
) const {