]>
git.saurik.com Git - cycript.git/blob - ObjectiveC/Output.cpp
1 /* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 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 {
52 type_
->Output(out
, name_
);
57 void CYInstanceLiteral::Output(CYOutput
&out
, CYFlags flags
) const {
59 number_
->Output(out
, CYRight(flags
));
62 void CYMessage::Output(CYOutput
&out
) const {
63 out
<< (instance_
? '-' : '+');
65 CYForEach (parameter
, parameters_
)
66 if (parameter
->name_
!= NULL
) {
67 out
<< ' ' << *parameter
->name_
;
68 // XXX: this is off somehow
69 if (parameter
->identifier_
!= NULL
) {
71 if (parameter
->type_
!= NULL
)
72 out
<< '(' << *parameter
->type_
<< ')';
73 out
<< *parameter
->identifier_
;
80 void CYBox::Output(CYOutput
&out
, CYFlags flags
) const {
82 value_
->Output(out
, Precedence(), CYRight(flags
));
85 void CYObjCArray::Output(CYOutput
&out
, CYFlags flags
) const {
86 out
<< '@' << '[' << elements_
<< ']';
89 void CYObjCDictionary::Output(CYOutput
&out
, CYFlags flags
) const {
91 CYForEach (pair
, pairs_
)
93 bool large(count
> 8);
102 CYForEach (pair
, pairs_
) {
116 pair
->key_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
118 pair
->value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
121 if (large
&& out
.pretty_
)
132 void CYObjCBlock::Output(CYOutput
&out
, CYFlags flags
) const {
133 out
<< '^' << ' ' << *typed_
<< ' ' << '(';
136 CYForEach (parameter
, parameters_
) {
141 parameter
->type_
->Output(out
, parameter
->name_
);
144 out
<< ')' << ' ' << '{' << '\n';
151 void CYProtocol::Output(CYOutput
&out
) const {
152 name_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
154 out
<< ',' << ' ' << *next_
;
157 void CYSelector::Output(CYOutput
&out
, CYFlags flags
) const {
158 out
<< "@selector" << '(' << parts_
<< ')';
161 void CYSelectorPart::Output(CYOutput
&out
) const {
168 void CYSend::Output(CYOutput
&out
, CYFlags flags
) const {
169 CYForEach (argument
, arguments_
)
170 if (argument
->name_
!= NULL
) {
171 out
<< ' ' << *argument
->name_
;
172 if (argument
->value_
!= NULL
)
173 out
<< ':' << *argument
->value_
;
177 void CYSendDirect::Output(CYOutput
&out
, CYFlags flags
) const {
179 self_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
180 CYSend::Output(out
, flags
);
184 void CYSendSuper::Output(CYOutput
&out
, CYFlags flags
) const {
185 out
<< '[' << "super";
186 CYSend::Output(out
, flags
);