]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Syntax.hpp
CYDisplay{Start,Finish} obsolete by rl_redisplay.
[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{
30 CYTypeModifier *type_;
31 CYTypedParameter *parameters_;
32 CYStatement *statements_;
33
34 CYObjCBlock(CYTypeModifier *type, CYTypedParameter *parameters, CYStatement *statements) :
35 type_(type),
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
46f4f308
JF
47struct CYEncodedType :
48 CYExpression
49{
561e7f1c 50 CYTypeModifier *type_;
46f4f308 51
561e7f1c
JF
52 CYEncodedType(CYTypeModifier *type) :
53 type_(type)
46f4f308
JF
54 {
55 }
56
57 CYPrecedence(1)
58
59 virtual CYExpression *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
61};
62
f2f0d1d1
JF
63struct CYBox :
64 CYExpression
65{
66 CYExpression *value_;
67
68 CYBox(CYExpression *value) :
69 value_(value)
70 {
71 }
72
73 CYPrecedence(1)
74
75 virtual CYExpression *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
77};
78
4de0686f
JF
79struct CYSelectorPart :
80 CYNext<CYSelectorPart>,
81 CYThing
82{
83 CYWord *name_;
84 bool value_;
85
2385c806 86 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
4de0686f
JF
87 CYNext<CYSelectorPart>(next),
88 name_(name),
89 value_(value)
90 {
91 }
92
93 CYString *Replace(CYContext &context);
94 virtual void Output(CYOutput &out) const;
95};
96
97struct CYSelector :
98 CYLiteral
99{
100 CYSelectorPart *name_;
101
102 CYSelector(CYSelectorPart *name) :
103 name_(name)
104 {
105 }
106
107 CYPrecedence(1)
108
109 virtual CYExpression *Replace(CYContext &context);
110 virtual void Output(CYOutput &out, CYFlags flags) const;
111};
112
113struct CYField :
114 CYNext<CYField>
115{
cfd73c6d
JF
116 CYExpression *type_;
117 CYIdentifier *name_;
118
119 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
120 CYNext<CYField>(next),
121 type_(type),
122 name_(name)
123 {
124 }
125
4de0686f
JF
126 CYStatement *Replace(CYContext &context) const;
127 void Output(CYOutput &out) const;
128};
129
130struct CYMessageParameter :
131 CYNext<CYMessageParameter>
132{
133 CYWord *tag_;
134 CYExpression *type_;
135 CYIdentifier *name_;
136
137 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
138 tag_(tag),
139 type_(type),
140 name_(name)
141 {
142 }
143
144 CYFunctionParameter *Parameters(CYContext &context) const;
145 CYSelector *Selector(CYContext &context) const;
146 CYSelectorPart *SelectorPart(CYContext &context) const;
9a7c375c 147 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
148};
149
150struct CYMessage :
151 CYNext<CYMessage>
152{
153 bool instance_;
154 CYExpression *type_;
155 CYMessageParameter *parameters_;
4644480a 156 CYBlock code_;
4de0686f
JF
157
158 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
159 instance_(instance),
160 type_(type),
161 parameters_(parameter),
4644480a 162 code_(statements)
4de0686f
JF
163 {
164 }
165
166 CYStatement *Replace(CYContext &context, bool replace) const;
167 void Output(CYOutput &out, bool replace) const;
9a7c375c
JF
168
169 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
170};
171
64b8d29f
JF
172struct CYProtocol :
173 CYNext<CYProtocol>,
174 CYThing
175{
176 CYExpression *name_;
177
178 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
179 CYNext<CYProtocol>(next),
180 name_(name)
181 {
182 }
183
184 CYStatement *Replace(CYContext &context) const;
185 void Output(CYOutput &out) const;
186};
187
1ba6903e
JF
188struct CYImport :
189 CYStatement
190{
191 virtual CYStatement *Replace(CYContext &context);
192 virtual void Output(CYOutput &out, CYFlags flags) const;
193};
194
4de0686f
JF
195struct CYClass {
196 CYClassName *name_;
197 CYExpression *super_;
64b8d29f 198 CYProtocol *protocols_;
4de0686f
JF
199 CYField *fields_;
200 CYMessage *messages_;
201
64b8d29f 202 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
4de0686f
JF
203 name_(name),
204 super_(super),
64b8d29f 205 protocols_(protocols),
4de0686f
JF
206 fields_(fields),
207 messages_(messages)
208 {
209 }
210
7c6c5b0a
JF
211 virtual ~CYClass() {
212 }
213
4de0686f
JF
214 CYExpression *Replace_(CYContext &context);
215 virtual void Output(CYOutput &out, CYFlags flags) const;
216};
217
218struct CYClassExpression :
219 CYClass,
220 CYExpression
221{
64b8d29f
JF
222 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
223 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
224 {
225 }
226
227 CYPrecedence(0)
228
229 virtual CYExpression *Replace(CYContext &context);
230 virtual void Output(CYOutput &out, CYFlags flags) const;
231};
232
233struct CYClassStatement :
234 CYClass,
235 CYStatement
236{
64b8d29f
JF
237 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
238 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
239 {
240 }
241
242 virtual CYStatement *Replace(CYContext &context);
243 virtual void Output(CYOutput &out, CYFlags flags) const;
244};
245
246struct CYCategory :
247 CYStatement
248{
249 CYClassName *name_;
250 CYMessage *messages_;
251
252 CYCategory(CYClassName *name, CYMessage *messages) :
253 name_(name),
254 messages_(messages)
255 {
256 }
257
258 virtual CYStatement *Replace(CYContext &context);
259 virtual void Output(CYOutput &out, CYFlags flags) const;
260};
261
262struct CYSend :
263 CYExpression
264{
4de0686f
JF
265 CYArgument *arguments_;
266
cacd1a88 267 CYSend(CYArgument *arguments) :
4de0686f
JF
268 arguments_(arguments)
269 {
270 }
271
272 CYPrecedence(0)
273
cacd1a88
JF
274 virtual void Output(CYOutput &out, CYFlags flags) const;
275};
276
277struct CYSendDirect :
278 CYSend
279{
280 CYExpression *self_;
281
282 CYSendDirect(CYExpression *self, CYArgument *arguments) :
283 CYSend(arguments),
284 self_(self)
285 {
286 }
287
288 virtual CYExpression *Replace(CYContext &context);
289 virtual void Output(CYOutput &out, CYFlags flags) const;
290};
291
292struct CYSendSuper :
293 CYSend
294{
295 CYSendSuper(CYArgument *arguments) :
296 CYSend(arguments)
297 {
298 }
299
4de0686f
JF
300 virtual CYExpression *Replace(CYContext &context);
301 virtual void Output(CYOutput &out, CYFlags flags) const;
302};
303
3c1c3635 304#endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/