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/>.
22 #ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23 #define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
25 #include "../Syntax.hpp"
27 struct CYInstanceLiteral :
32 CYInstanceLiteral(CYNumber *number) :
39 virtual CYTarget *Replace(CYContext &context);
40 virtual void Output(CYOutput &out, CYFlags flags) const;
46 CYTypedIdentifier *typed_;
47 CYTypedParameter *parameters_;
50 CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *code) :
52 parameters_(parameters),
59 virtual CYTarget *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
68 CYBox(CYExpression *value) :
75 virtual CYTarget *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
84 CYObjCArray(CYElement *elements = NULL) :
91 virtual CYTarget *Replace(CYContext &context);
92 virtual void Output(CYOutput &out, CYFlags flags) const;
95 struct CYObjCKeyValue :
96 CYNext<CYObjCKeyValue>
101 CYObjCKeyValue(CYExpression *key, CYExpression *value, CYObjCKeyValue *next) :
102 CYNext<CYObjCKeyValue>(next),
109 struct CYObjCDictionary :
112 CYObjCKeyValue *pairs_;
114 CYObjCDictionary(CYObjCKeyValue *pairs) :
121 virtual CYTarget *Replace(CYContext &context);
122 virtual void Output(CYOutput &out, CYFlags flags) const;
125 struct CYSelectorPart :
126 CYNext<CYSelectorPart>,
132 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
133 CYNext<CYSelectorPart>(next),
139 CYString *Replace(CYContext &context);
140 virtual void Output(CYOutput &out) const;
146 CYSelectorPart *parts_;
148 CYSelector(CYSelectorPart *parts) :
155 virtual CYTarget *Replace(CYContext &context);
156 virtual void Output(CYOutput &out, CYFlags flags) const;
159 struct CYImplementationField :
160 CYNext<CYImplementationField>
162 CYTypedIdentifier *typed_;
164 CYImplementationField(CYTypedIdentifier *typed, CYImplementationField *next = NULL) :
165 CYNext<CYImplementationField>(next),
170 CYStatement *Replace(CYContext &context) const;
171 void Output(CYOutput &out) const;
174 struct CYMessageParameter :
175 CYNext<CYMessageParameter>
178 CYTypedIdentifier *type_;
180 CYMessageParameter(CYWord *name, CYTypedIdentifier *type) :
186 CYFunctionParameter *Parameters(CYContext &context) const;
187 CYSelector *Selector(CYContext &context) const;
188 CYSelectorPart *SelectorPart(CYContext &context) const;
189 CYExpression *TypeSignature(CYContext &context) const;
196 CYTypedIdentifier *type_;
197 CYMessageParameter *parameters_;
200 CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameters, CYStatement *code) :
203 parameters_(parameters),
208 CYStatement *Replace(CYContext &context, bool replace) const;
209 void Output(CYOutput &out) const;
211 CYExpression *TypeSignature(CYContext &context) const;
220 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
221 CYNext<CYProtocol>(next),
226 CYStatement *Replace(CYContext &context) const;
227 void Output(CYOutput &out) const;
230 struct CYImplementation :
234 CYExpression *extends_;
235 CYProtocol *protocols_;
236 CYImplementationField *fields_;
237 CYMessage *messages_;
239 CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) :
242 protocols_(protocols),
250 virtual CYStatement *Replace(CYContext &context);
251 virtual void Output(CYOutput &out, CYFlags flags) const;
258 CYMessage *messages_;
260 CYCategory(CYIdentifier *name, CYMessage *messages) :
268 virtual CYStatement *Replace(CYContext &context);
269 virtual void Output(CYOutput &out, CYFlags flags) const;
275 CYArgument *arguments_;
277 CYSend(CYArgument *arguments) :
278 arguments_(arguments)
284 virtual void Output(CYOutput &out, CYFlags flags) const;
287 struct CYSendDirect :
292 CYSendDirect(CYExpression *self, CYArgument *arguments) :
298 virtual CYTarget *Replace(CYContext &context);
299 virtual void Output(CYOutput &out, CYFlags flags) const;
305 CYSendSuper(CYArgument *arguments) :
310 virtual CYTarget *Replace(CYContext &context);
311 virtual void Output(CYOutput &out, CYFlags flags) const;
314 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/