]>
git.saurik.com Git - cycript.git/blob - ObjectiveC/Output.cpp
37f86b1b08dffbd332e9b52f9bb0818265ddcbb0
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 {
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 {
85 out
<< '@' << '{' << '}';
88 void CYObjCBlock::Output(CYOutput
&out
, CYFlags flags
) const {
89 out
<< '^' << ' ' << *typed_
<< ' ' << '(';
92 CYForEach (parameter
, parameters_
) {
97 out
<< *parameter
->typed_
;
100 out
<< ')' << ' ' << '{' << '\n';
107 void CYProtocol::Output(CYOutput
&out
) const {
108 name_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
110 out
<< ',' << ' ' << *next_
;
113 void CYSelector::Output(CYOutput
&out
, CYFlags flags
) const {
114 out
<< "@selector" << '(' << parts_
<< ')';
117 void CYSelectorPart::Output(CYOutput
&out
) const {
124 void CYSend::Output(CYOutput
&out
, CYFlags flags
) const {
125 CYForEach (argument
, arguments_
)
126 if (argument
->name_
!= NULL
) {
127 out
<< ' ' << *argument
->name_
;
128 if (argument
->value_
!= NULL
)
129 out
<< ':' << *argument
->value_
;
133 void CYSendDirect::Output(CYOutput
&out
, CYFlags flags
) const {
135 self_
->Output(out
, CYAssign::Precedence_
, CYNoFlags
);
136 CYSend::Output(out
, flags
);
140 void CYSendSuper::Output(CYOutput
&out
, CYFlags flags
) const {
141 out
<< '[' << "super";
142 CYSend::Output(out
, flags
);