1 | #ifndef SASS_AST_FWD_DECL_H |
---|---|
2 | #define SASS_AST_FWD_DECL_H |
3 | |
4 | // sass.hpp must go before all system headers to get the |
5 | // __EXTENSIONS__ fix on Solaris. |
6 | #include "sass.hpp" |
7 | #include "memory.hpp" |
8 | #include "sass/functions.h" |
9 | |
10 | ///////////////////////////////////////////// |
11 | // Forward declarations for the AST visitors. |
12 | ///////////////////////////////////////////// |
13 | namespace Sass { |
14 | |
15 | class SourceData; |
16 | class SourceFile; |
17 | class SynthFile; |
18 | class ItplFile; |
19 | |
20 | class AST_Node; |
21 | |
22 | class ParentStatement; |
23 | |
24 | class SimpleSelector; |
25 | |
26 | class Parent_Reference; |
27 | |
28 | class PreValue; |
29 | class Block; |
30 | class Expression; |
31 | class Statement; |
32 | class Value; |
33 | class Declaration; |
34 | class StyleRule; |
35 | class Bubble; |
36 | class Trace; |
37 | |
38 | class MediaRule; |
39 | class CssMediaRule; |
40 | class CssMediaQuery; |
41 | |
42 | class SupportsRule; |
43 | class AtRule; |
44 | |
45 | class Keyframe_Rule; |
46 | class AtRootRule; |
47 | class Assignment; |
48 | |
49 | class Import; |
50 | class Import_Stub; |
51 | class WarningRule; |
52 | |
53 | class ErrorRule; |
54 | class DebugRule; |
55 | class Comment; |
56 | |
57 | class If; |
58 | class ForRule; |
59 | class EachRule; |
60 | class WhileRule; |
61 | class Return; |
62 | class Content; |
63 | class ExtendRule; |
64 | class Definition; |
65 | |
66 | class List; |
67 | class Map; |
68 | class Function; |
69 | |
70 | class Mixin_Call; |
71 | class Binary_Expression; |
72 | class Unary_Expression; |
73 | class Function_Call; |
74 | class Custom_Warning; |
75 | class Custom_Error; |
76 | |
77 | class Variable; |
78 | class Number; |
79 | class Color; |
80 | class Color_RGBA; |
81 | class Color_HSLA; |
82 | class Boolean; |
83 | class String; |
84 | class Null; |
85 | |
86 | class String_Schema; |
87 | class String_Constant; |
88 | class String_Quoted; |
89 | |
90 | class Media_Query; |
91 | class Media_Query_Expression; |
92 | class SupportsCondition; |
93 | class SupportsOperation; |
94 | class SupportsNegation; |
95 | class SupportsDeclaration; |
96 | class Supports_Interpolation; |
97 | |
98 | class At_Root_Query; |
99 | class Parameter; |
100 | class Parameters; |
101 | class Argument; |
102 | class Arguments; |
103 | class Selector; |
104 | |
105 | |
106 | class Selector_Schema; |
107 | class PlaceholderSelector; |
108 | class TypeSelector; |
109 | class ClassSelector; |
110 | class IDSelector; |
111 | class AttributeSelector; |
112 | |
113 | class PseudoSelector; |
114 | |
115 | class SelectorComponent; |
116 | class SelectorCombinator; |
117 | class CompoundSelector; |
118 | class ComplexSelector; |
119 | class SelectorList; |
120 | |
121 | // common classes |
122 | class Context; |
123 | class Expand; |
124 | class Eval; |
125 | |
126 | class Extension; |
127 | |
128 | // declare classes that are instances of memory nodes |
129 | // Note: also add a mapping without underscore |
130 | // ToDo: move to camelCase vars in the future |
131 | #define IMPL_MEM_OBJ(type) \ |
132 | typedef SharedImpl<type> type##Obj; \ |
133 | typedef SharedImpl<type> type##_Obj; \ |
134 | |
135 | IMPL_MEM_OBJ(SourceData); |
136 | IMPL_MEM_OBJ(SourceFile); |
137 | IMPL_MEM_OBJ(SynthFile); |
138 | IMPL_MEM_OBJ(ItplFile); |
139 | |
140 | IMPL_MEM_OBJ(AST_Node); |
141 | IMPL_MEM_OBJ(Statement); |
142 | IMPL_MEM_OBJ(Block); |
143 | IMPL_MEM_OBJ(StyleRule); |
144 | IMPL_MEM_OBJ(Bubble); |
145 | IMPL_MEM_OBJ(Trace); |
146 | IMPL_MEM_OBJ(MediaRule); |
147 | IMPL_MEM_OBJ(CssMediaRule); |
148 | IMPL_MEM_OBJ(CssMediaQuery); |
149 | IMPL_MEM_OBJ(SupportsRule); |
150 | IMPL_MEM_OBJ(AtRule); |
151 | IMPL_MEM_OBJ(Keyframe_Rule); |
152 | IMPL_MEM_OBJ(AtRootRule); |
153 | IMPL_MEM_OBJ(Declaration); |
154 | IMPL_MEM_OBJ(Assignment); |
155 | IMPL_MEM_OBJ(Import); |
156 | IMPL_MEM_OBJ(Import_Stub); |
157 | IMPL_MEM_OBJ(WarningRule); |
158 | IMPL_MEM_OBJ(ErrorRule); |
159 | IMPL_MEM_OBJ(DebugRule); |
160 | IMPL_MEM_OBJ(Comment); |
161 | IMPL_MEM_OBJ(PreValue); |
162 | IMPL_MEM_OBJ(ParentStatement); |
163 | IMPL_MEM_OBJ(If); |
164 | IMPL_MEM_OBJ(ForRule); |
165 | IMPL_MEM_OBJ(EachRule); |
166 | IMPL_MEM_OBJ(WhileRule); |
167 | IMPL_MEM_OBJ(Return); |
168 | IMPL_MEM_OBJ(Content); |
169 | IMPL_MEM_OBJ(ExtendRule); |
170 | IMPL_MEM_OBJ(Definition); |
171 | IMPL_MEM_OBJ(Mixin_Call); |
172 | IMPL_MEM_OBJ(Value); |
173 | IMPL_MEM_OBJ(Expression); |
174 | IMPL_MEM_OBJ(List); |
175 | IMPL_MEM_OBJ(Map); |
176 | IMPL_MEM_OBJ(Function); |
177 | IMPL_MEM_OBJ(Binary_Expression); |
178 | IMPL_MEM_OBJ(Unary_Expression); |
179 | IMPL_MEM_OBJ(Function_Call); |
180 | IMPL_MEM_OBJ(Custom_Warning); |
181 | IMPL_MEM_OBJ(Custom_Error); |
182 | IMPL_MEM_OBJ(Variable); |
183 | IMPL_MEM_OBJ(Number); |
184 | IMPL_MEM_OBJ(Color); |
185 | IMPL_MEM_OBJ(Color_RGBA); |
186 | IMPL_MEM_OBJ(Color_HSLA); |
187 | IMPL_MEM_OBJ(Boolean); |
188 | IMPL_MEM_OBJ(String_Schema); |
189 | IMPL_MEM_OBJ(String); |
190 | IMPL_MEM_OBJ(String_Constant); |
191 | IMPL_MEM_OBJ(String_Quoted); |
192 | IMPL_MEM_OBJ(Media_Query); |
193 | IMPL_MEM_OBJ(Media_Query_Expression); |
194 | IMPL_MEM_OBJ(SupportsCondition); |
195 | IMPL_MEM_OBJ(SupportsOperation); |
196 | IMPL_MEM_OBJ(SupportsNegation); |
197 | IMPL_MEM_OBJ(SupportsDeclaration); |
198 | IMPL_MEM_OBJ(Supports_Interpolation); |
199 | IMPL_MEM_OBJ(At_Root_Query); |
200 | IMPL_MEM_OBJ(Null); |
201 | IMPL_MEM_OBJ(Parent_Reference); |
202 | IMPL_MEM_OBJ(Parameter); |
203 | IMPL_MEM_OBJ(Parameters); |
204 | IMPL_MEM_OBJ(Argument); |
205 | IMPL_MEM_OBJ(Arguments); |
206 | IMPL_MEM_OBJ(Selector); |
207 | IMPL_MEM_OBJ(Selector_Schema); |
208 | IMPL_MEM_OBJ(SimpleSelector); |
209 | IMPL_MEM_OBJ(PlaceholderSelector); |
210 | IMPL_MEM_OBJ(TypeSelector); |
211 | IMPL_MEM_OBJ(ClassSelector); |
212 | IMPL_MEM_OBJ(IDSelector); |
213 | IMPL_MEM_OBJ(AttributeSelector); |
214 | IMPL_MEM_OBJ(PseudoSelector); |
215 | |
216 | IMPL_MEM_OBJ(SelectorComponent); |
217 | IMPL_MEM_OBJ(SelectorCombinator); |
218 | IMPL_MEM_OBJ(CompoundSelector); |
219 | IMPL_MEM_OBJ(ComplexSelector); |
220 | IMPL_MEM_OBJ(SelectorList); |
221 | |
222 | // ########################################################################### |
223 | // some often used typedefs |
224 | // ########################################################################### |
225 | |
226 | typedef sass::vector<Block*> BlockStack; |
227 | typedef sass::vector<Sass_Callee> CalleeStack; |
228 | typedef sass::vector<AST_Node_Obj> CallStack; |
229 | typedef sass::vector<CssMediaRuleObj> MediaStack; |
230 | typedef sass::vector<SelectorListObj> SelectorStack; |
231 | typedef sass::vector<Sass_Import_Entry> ImporterStack; |
232 | |
233 | // only to switch implementations for testing |
234 | #define environment_map std::map |
235 | |
236 | // ########################################################################### |
237 | // explicit type conversion functions |
238 | // ########################################################################### |
239 | |
240 | template<class T> |
241 | T* Cast(AST_Node* ptr); |
242 | |
243 | template<class T> |
244 | const T* Cast(const AST_Node* ptr); |
245 | |
246 | // sometimes you know the class you want to cast to is final |
247 | // in this case a simple typeid check is faster and safe to use |
248 | |
249 | #define DECLARE_BASE_CAST(T) \ |
250 | template<> T* Cast(AST_Node* ptr); \ |
251 | template<> const T* Cast(const AST_Node* ptr); \ |
252 | |
253 | // ########################################################################### |
254 | // implement specialization for final classes |
255 | // ########################################################################### |
256 | |
257 | DECLARE_BASE_CAST(AST_Node) |
258 | DECLARE_BASE_CAST(Expression) |
259 | DECLARE_BASE_CAST(Statement) |
260 | DECLARE_BASE_CAST(ParentStatement) |
261 | DECLARE_BASE_CAST(PreValue) |
262 | DECLARE_BASE_CAST(Value) |
263 | DECLARE_BASE_CAST(List) |
264 | DECLARE_BASE_CAST(Color) |
265 | DECLARE_BASE_CAST(String) |
266 | DECLARE_BASE_CAST(String_Constant) |
267 | DECLARE_BASE_CAST(SupportsCondition) |
268 | DECLARE_BASE_CAST(Selector) |
269 | DECLARE_BASE_CAST(SimpleSelector) |
270 | DECLARE_BASE_CAST(SelectorComponent) |
271 | |
272 | } |
273 | |
274 | #endif |
275 |