]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Syntax.hpp
Add a new ?gc to run GC without running a script.
[cycript.git] / ObjectiveC / Syntax.hpp
CommitLineData
b3378a02 1/* Cycript - Optimizing JavaScript Compiler/Runtime
c15969fd 2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
4644480a
JF
3*/
4
c15969fd 5/* GNU General Public License, Version 3 {{{ */
4644480a 6/*
c15969fd
JF
7 * Cycript is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
4644480a 11 *
c15969fd
JF
12 * Cycript is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
4644480a 16 *
c15969fd 17 * You should have received a copy of the GNU General Public License
b3378a02
JF
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
19**/
4644480a
JF
20/* }}} */
21
3c1c3635
JF
22#ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23#define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
4de0686f
JF
24
25#include "Parser.hpp"
26
56e02e5b
JF
27struct CYObjCBlock :
28 CYExpression
29{
9a39f705 30 CYTypedIdentifier *typed_;
56e02e5b
JF
31 CYTypedParameter *parameters_;
32 CYStatement *statements_;
33
9a39f705
JF
34 CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) :
35 typed_(typed),
56e02e5b
JF
36 parameters_(parameters),
37 statements_(statements)
38 {
39 }
40
41 CYPrecedence(1)
42
43 virtual CYExpression *Replace(CYContext &context);
44 virtual void Output(CYOutput &out, CYFlags flags) const;
45};
46
f2f0d1d1
JF
47struct CYBox :
48 CYExpression
49{
50 CYExpression *value_;
51
52 CYBox(CYExpression *value) :
53 value_(value)
54 {
55 }
56
57 CYPrecedence(1)
58
59 virtual CYExpression *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
61};
62
4de0686f
JF
63struct CYSelectorPart :
64 CYNext<CYSelectorPart>,
65 CYThing
66{
67 CYWord *name_;
68 bool value_;
69
2385c806 70 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
4de0686f
JF
71 CYNext<CYSelectorPart>(next),
72 name_(name),
73 value_(value)
74 {
75 }
76
77 CYString *Replace(CYContext &context);
78 virtual void Output(CYOutput &out) const;
79};
80
81struct CYSelector :
82 CYLiteral
83{
84 CYSelectorPart *name_;
85
86 CYSelector(CYSelectorPart *name) :
87 name_(name)
88 {
89 }
90
91 CYPrecedence(1)
92
93 virtual CYExpression *Replace(CYContext &context);
94 virtual void Output(CYOutput &out, CYFlags flags) const;
95};
96
97struct CYField :
98 CYNext<CYField>
99{
cfd73c6d
JF
100 CYExpression *type_;
101 CYIdentifier *name_;
102
103 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
104 CYNext<CYField>(next),
105 type_(type),
106 name_(name)
107 {
108 }
109
4de0686f
JF
110 CYStatement *Replace(CYContext &context) const;
111 void Output(CYOutput &out) const;
112};
113
114struct CYMessageParameter :
115 CYNext<CYMessageParameter>
116{
117 CYWord *tag_;
118 CYExpression *type_;
119 CYIdentifier *name_;
120
121 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
122 tag_(tag),
123 type_(type),
124 name_(name)
125 {
126 }
127
128 CYFunctionParameter *Parameters(CYContext &context) const;
129 CYSelector *Selector(CYContext &context) const;
130 CYSelectorPart *SelectorPart(CYContext &context) const;
9a7c375c 131 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
132};
133
134struct CYMessage :
135 CYNext<CYMessage>
136{
137 bool instance_;
138 CYExpression *type_;
139 CYMessageParameter *parameters_;
4644480a 140 CYBlock code_;
4de0686f
JF
141
142 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
143 instance_(instance),
144 type_(type),
145 parameters_(parameter),
4644480a 146 code_(statements)
4de0686f
JF
147 {
148 }
149
150 CYStatement *Replace(CYContext &context, bool replace) const;
151 void Output(CYOutput &out, bool replace) const;
9a7c375c
JF
152
153 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
154};
155
64b8d29f
JF
156struct CYProtocol :
157 CYNext<CYProtocol>,
158 CYThing
159{
160 CYExpression *name_;
161
162 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
163 CYNext<CYProtocol>(next),
164 name_(name)
165 {
166 }
167
168 CYStatement *Replace(CYContext &context) const;
169 void Output(CYOutput &out) const;
170};
171
417dcc12
JF
172struct CYModule :
173 CYNext<CYModule>,
174 CYThing
175{
176 CYWord *part_;
177
178 CYModule(CYWord *part, CYModule *next = NULL) :
179 CYNext<CYModule>(next),
180 part_(part)
181 {
182 }
183
184 CYString *Replace(CYContext &context, const char *separator) const;
185 void Output(CYOutput &out) const;
186};
187
1ba6903e
JF
188struct CYImport :
189 CYStatement
190{
417dcc12
JF
191 CYModule *module_;
192
193 CYImport(CYModule *module) :
194 module_(module)
195 {
196 }
197
1ba6903e
JF
198 virtual CYStatement *Replace(CYContext &context);
199 virtual void Output(CYOutput &out, CYFlags flags) const;
200};
201
4de0686f
JF
202struct CYClass {
203 CYClassName *name_;
204 CYExpression *super_;
64b8d29f 205 CYProtocol *protocols_;
4de0686f
JF
206 CYField *fields_;
207 CYMessage *messages_;
208
64b8d29f 209 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
4de0686f
JF
210 name_(name),
211 super_(super),
64b8d29f 212 protocols_(protocols),
4de0686f
JF
213 fields_(fields),
214 messages_(messages)
215 {
216 }
217
7c6c5b0a
JF
218 virtual ~CYClass() {
219 }
220
4de0686f
JF
221 CYExpression *Replace_(CYContext &context);
222 virtual void Output(CYOutput &out, CYFlags flags) const;
223};
224
225struct CYClassExpression :
226 CYClass,
227 CYExpression
228{
64b8d29f
JF
229 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
230 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
231 {
232 }
233
234 CYPrecedence(0)
235
236 virtual CYExpression *Replace(CYContext &context);
237 virtual void Output(CYOutput &out, CYFlags flags) const;
238};
239
240struct CYClassStatement :
241 CYClass,
242 CYStatement
243{
64b8d29f
JF
244 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
245 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
246 {
247 }
248
249 virtual CYStatement *Replace(CYContext &context);
250 virtual void Output(CYOutput &out, CYFlags flags) const;
251};
252
253struct CYCategory :
254 CYStatement
255{
256 CYClassName *name_;
257 CYMessage *messages_;
258
259 CYCategory(CYClassName *name, CYMessage *messages) :
260 name_(name),
261 messages_(messages)
262 {
263 }
264
265 virtual CYStatement *Replace(CYContext &context);
266 virtual void Output(CYOutput &out, CYFlags flags) const;
267};
268
269struct CYSend :
270 CYExpression
271{
4de0686f
JF
272 CYArgument *arguments_;
273
cacd1a88 274 CYSend(CYArgument *arguments) :
4de0686f
JF
275 arguments_(arguments)
276 {
277 }
278
279 CYPrecedence(0)
280
cacd1a88
JF
281 virtual void Output(CYOutput &out, CYFlags flags) const;
282};
283
284struct CYSendDirect :
285 CYSend
286{
287 CYExpression *self_;
288
289 CYSendDirect(CYExpression *self, CYArgument *arguments) :
290 CYSend(arguments),
291 self_(self)
292 {
293 }
294
295 virtual CYExpression *Replace(CYContext &context);
296 virtual void Output(CYOutput &out, CYFlags flags) const;
297};
298
299struct CYSendSuper :
300 CYSend
301{
302 CYSendSuper(CYArgument *arguments) :
303 CYSend(arguments)
304 {
305 }
306
4de0686f
JF
307 virtual CYExpression *Replace(CYContext &context);
308 virtual void Output(CYOutput &out, CYFlags flags) const;
309};
310
3c1c3635 311#endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/