]>
git.saurik.com Git - cycript.git/blob - ObjectiveC/Output.cpp
e2bb0f8e618c0e8ebdab28c028234fbcad2c8239
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 {
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 if (parameter
->type_
!= NULL
)
69 out
<< ':' << *parameter
->type_
->identifier_
;
75 void CYBox::Output(CYOutput
&out
, CYFlags flags
) const {
77 value_
->Output(out
, Precedence(), CYRight(flags
));
80 void CYObjCArray::Output(CYOutput
&out
, CYFlags flags
) const {
81 out
<< '@' << '[' << elements_
<< ']';
84 void CYObjCDictionary::Output(CYOutput
&out
, CYFlags flags
) const {
86 CYForEach (pair
, pairs_
)
88 bool large(count
> 8);
97 CYForEach (pair
, pairs_
) {
111 pair
->key_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
113 pair
->value_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
116 if (large
&& out
.pretty_
)
127 void CYObjCBlock::Output(CYOutput
&out
, CYFlags flags
) const {
128 out
<< '^' << ' ' << *typed_
<< ' ' << '(';
131 CYForEach (parameter
, parameters_
) {
136 out
<< *parameter
->typed_
;
139 out
<< ')' << ' ' << '{' << '\n';
146 void CYProtocol::Output(CYOutput
&out
) const {
147 name_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
149 out
<< ',' << ' ' << *next_
;
152 void CYSelector::Output(CYOutput
&out
, CYFlags flags
) const {
153 out
<< "@selector" << '(' << parts_
<< ')';
156 void CYSelectorPart::Output(CYOutput
&out
) const {
163 void CYSend::Output(CYOutput
&out
, CYFlags flags
) const {
164 CYForEach (argument
, arguments_
)
165 if (argument
->name_
!= NULL
) {
166 out
<< ' ' << *argument
->name_
;
167 if (argument
->value_
!= NULL
)
168 out
<< ':' << *argument
->value_
;
172 void CYSendDirect::Output(CYOutput
&out
, CYFlags flags
) const {
174 self_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
175 CYSend::Output(out
, flags
);
179 void CYSendSuper::Output(CYOutput
&out
, CYFlags flags
) const {
180 out
<< '[' << "super";
181 CYSend::Output(out
, flags
);