]>
git.saurik.com Git - cycript.git/blob - ObjectiveC/Output.cpp
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 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/>.
24 #include "Replace.hpp"
26 #include "ObjectiveC/Syntax.hpp"
28 void CYCategory::Output(CYOutput
&out
, CYFlags flags
) const {
29 out
<< "@implementation" << ' ' << *name_
<< ' ' << '(' << ')' << '\n';
32 CYForEach (message
, messages_
) {
41 void CYImplementation::Output(CYOutput
&out
, CYFlags flags
) const {
42 out
<< "@implementation" << ' ' << *name_
<< '\n';
51 void CYImplementationField::Output(CYOutput
&out
) const {
54 void CYInstanceLiteral::Output(CYOutput
&out
, CYFlags flags
) const {
56 number_
->Output(out
, CYRight(flags
));
59 void CYMessage::Output(CYOutput
&out
) const {
60 out
<< (instance_
? '-' : '+');
62 CYForEach (parameter
, parameters_
)
63 if (parameter
->name_
!= NULL
) {
64 out
<< ' ' << *parameter
->name_
;
65 if (parameter
->type_
!= NULL
)
66 out
<< ':' << *parameter
->type_
->identifier_
;
72 void CYBox::Output(CYOutput
&out
, CYFlags flags
) const {
74 value_
->Output(out
, Precedence(), CYRight(flags
));
77 void CYObjCBlock::Output(CYOutput
&out
, CYFlags flags
) const {
78 // XXX: this is seriously wrong
85 void CYProtocol::Output(CYOutput
&out
) const {
86 name_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
88 out
<< ',' << ' ' << *next_
;
91 void CYSelector::Output(CYOutput
&out
, CYFlags flags
) const {
92 out
<< "@selector" << '(' << parts_
<< ')';
95 void CYSelectorPart::Output(CYOutput
&out
) const {
102 void CYSend::Output(CYOutput
&out
, CYFlags flags
) const {
103 CYForEach (argument
, arguments_
)
104 if (argument
->name_
!= NULL
) {
105 out
<< ' ' << *argument
->name_
;
106 if (argument
->value_
!= NULL
)
107 out
<< ':' << *argument
->value_
;
111 void CYSendDirect::Output(CYOutput
&out
, CYFlags flags
) const {
113 self_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
114 CYSend::Output(out
, flags
);
118 void CYSendSuper::Output(CYOutput
&out
, CYFlags flags
) const {
119 out
<< '[' << "super";
120 CYSend::Output(out
, flags
);