1
+ // sass.hpp must go before all system headers to get the
2
+ // __EXTENSIONS__ fix on Solaris.
1
3
#include " sass.hpp"
4
+
2
5
#include " ast.hpp"
3
- #include " context.hpp"
4
- #include " node.hpp"
5
- #include " eval.hpp"
6
- #include " extend.hpp"
7
- #include " emitter.hpp"
8
- #include " color_maps.hpp"
9
- #include " ast_fwd_decl.hpp"
10
- #include < set>
11
- #include < iomanip>
12
- #include < iostream>
13
- #include < algorithm>
14
- #include < functional>
15
6
#include < cctype>
16
7
#include < locale>
17
8
@@ -69,7 +60,7 @@ namespace Sass {
69
60
pstate_.offset += pstate - pstate_ + pstate.offset ;
70
61
}
71
62
72
- const std::string AST_Node::to_string (Sass_Inspect_Options opt) const
63
+ std::string AST_Node::to_string (Sass_Inspect_Options opt) const
73
64
{
74
65
Sass_Output_Options out (opt);
75
66
Emitter emitter (out);
@@ -80,19 +71,21 @@ namespace Sass {
80
71
return i.get_buffer ();
81
72
}
82
73
83
- const std::string AST_Node::to_string ( ) const
74
+ std::string AST_Node::to_css (Sass_Inspect_Options opt ) const
84
75
{
85
- return to_string ({ NESTED, 5 });
76
+ opt.output_style = TO_CSS;
77
+ Sass_Output_Options out (opt);
78
+ Emitter emitter (out);
79
+ Inspect i (emitter);
80
+ i.in_declaration = true ;
81
+ // ToDo: inspect should be const
82
+ const_cast <AST_Node*>(this )->perform (&i);
83
+ return i.get_buffer ();
86
84
}
87
85
88
- // ///////////////////////////////////////////////////////////////////////
89
- // ///////////////////////////////////////////////////////////////////////
90
-
91
- Expression_Obj Hashed::at (Expression_Obj k) const
86
+ std::string AST_Node::to_string () const
92
87
{
93
- if (elements_.count (k))
94
- { return elements_.at (k); }
95
- else { return {}; }
88
+ return to_string ({ NESTED, 5 });
96
89
}
97
90
98
91
// ///////////////////////////////////////////////////////////////////////
@@ -137,6 +130,14 @@ namespace Sass {
137
130
is_root_(ptr->is_root_)
138
131
{ }
139
132
133
+ bool Block::isInvisible () const
134
+ {
135
+ for (auto & item : elements ()) {
136
+ if (!item->is_invisible ()) return false ;
137
+ }
138
+ return true ;
139
+ }
140
+
140
141
bool Block::has_content ()
141
142
{
142
143
for (size_t i = 0 , L = elements ().size (); i < L; ++i) {
@@ -163,19 +164,20 @@ namespace Sass {
163
164
// ///////////////////////////////////////////////////////////////////////
164
165
// ///////////////////////////////////////////////////////////////////////
165
166
166
- Ruleset::Ruleset (ParserState pstate, Selector_List_Obj s, Block_Obj b)
167
- : Has_Block(pstate, b), selector_(s), is_root_(false )
167
+ Ruleset::Ruleset (ParserState pstate, SelectorListObj s, Block_Obj b)
168
+ : Has_Block(pstate, b), selector_(s), schema_(), is_root_(false )
168
169
{ statement_type (RULESET); }
169
170
Ruleset::Ruleset (const Ruleset* ptr)
170
171
: Has_Block(ptr),
171
172
selector_(ptr->selector_),
173
+ schema_(ptr->schema_),
172
174
is_root_(ptr->is_root_)
173
175
{ statement_type (RULESET); }
174
176
175
177
bool Ruleset::is_invisible () const {
176
- if (Selector_List * sl = Cast<Selector_List >(selector ())) {
177
- for (size_t i = 0 , L = sl->length (); i < L; ++i )
178
- if (!(*sl)[i]->has_placeholder ()) return false ;
178
+ if (const SelectorList * sl = Cast<SelectorList >(selector ())) {
179
+ for (size_t i = 0 , L = sl->length (); i < L; i += 1 )
180
+ if (!(*sl)[i]->isInvisible ()) return false ;
179
181
}
180
182
return true ;
181
183
}
@@ -212,30 +214,7 @@ namespace Sass {
212
214
// ///////////////////////////////////////////////////////////////////////
213
215
// ///////////////////////////////////////////////////////////////////////
214
216
215
- Media_Block::Media_Block (ParserState pstate, List_Obj mqs, Block_Obj b)
216
- : Has_Block(pstate, b), media_queries_(mqs)
217
- { statement_type (MEDIA); }
218
- Media_Block::Media_Block (const Media_Block* ptr)
219
- : Has_Block(ptr), media_queries_(ptr->media_queries_)
220
- { statement_type (MEDIA); }
221
-
222
- bool Media_Block::is_invisible () const {
223
- for (size_t i = 0 , L = block ()->length (); i < L; ++i) {
224
- Statement_Obj stm = block ()->at (i);
225
- if (!stm->is_invisible ()) return false ;
226
- }
227
- return true ;
228
- }
229
-
230
- bool Media_Block::bubbles ()
231
- {
232
- return true ;
233
- }
234
-
235
- // ///////////////////////////////////////////////////////////////////////
236
- // ///////////////////////////////////////////////////////////////////////
237
-
238
- Directive::Directive (ParserState pstate, std::string kwd, Selector_List_Obj sel, Block_Obj b, Expression_Obj val)
217
+ Directive::Directive (ParserState pstate, std::string kwd, SelectorListObj sel, Block_Obj b, Expression_Obj val)
239
218
: Has_Block(pstate, b), keyword_(kwd), selector_(sel), value_(val) // set value manually if needed
240
219
{ statement_type (DIRECTIVE); }
241
220
Directive::Directive (const Directive* ptr)
@@ -450,11 +429,19 @@ namespace Sass {
450
429
// ///////////////////////////////////////////////////////////////////////
451
430
// ///////////////////////////////////////////////////////////////////////
452
431
453
- Extension::Extension (ParserState pstate, Selector_List_Obj s)
454
- : Statement(pstate), selector_(s)
432
+ ExtendRule::ExtendRule (ParserState pstate, SelectorListObj s)
433
+ : Statement(pstate), isOptional_( false ), selector_(s), schema_( )
455
434
{ statement_type (EXTEND); }
456
- Extension::Extension (const Extension* ptr)
457
- : Statement(ptr), selector_(ptr->selector_)
435
+ ExtendRule::ExtendRule (ParserState pstate, Selector_Schema_Obj s)
436
+ : Statement(pstate), isOptional_(false ), selector_(), schema_(s)
437
+ {
438
+ statement_type (EXTEND);
439
+ }
440
+ ExtendRule::ExtendRule (const ExtendRule* ptr)
441
+ : Statement(ptr),
442
+ isOptional_(ptr->isOptional_),
443
+ selector_(ptr->selector_),
444
+ schema_(ptr->schema_)
458
445
{ statement_type (EXTEND); }
459
446
460
447
// ///////////////////////////////////////////////////////////////////////
@@ -923,8 +910,13 @@ namespace Sass {
923
910
// ///////////////////////////////////////////////////////////////////////
924
911
// ///////////////////////////////////////////////////////////////////////
925
912
913
+ // If you forget to add a class here you will get
914
+ // undefined reference to `vtable for Sass::Class'
915
+
926
916
IMPLEMENT_AST_OPERATORS (Ruleset);
927
- IMPLEMENT_AST_OPERATORS (Media_Block);
917
+ IMPLEMENT_AST_OPERATORS (MediaRule);
918
+ IMPLEMENT_AST_OPERATORS (CssMediaRule);
919
+ IMPLEMENT_AST_OPERATORS (CssMediaQuery);
928
920
IMPLEMENT_AST_OPERATORS (Import);
929
921
IMPLEMENT_AST_OPERATORS (Import_Stub);
930
922
IMPLEMENT_AST_OPERATORS (Directive);
@@ -934,7 +926,7 @@ namespace Sass {
934
926
IMPLEMENT_AST_OPERATORS (For);
935
927
IMPLEMENT_AST_OPERATORS (If);
936
928
IMPLEMENT_AST_OPERATORS (Mixin_Call);
937
- IMPLEMENT_AST_OPERATORS (Extension );
929
+ IMPLEMENT_AST_OPERATORS (ExtendRule );
938
930
IMPLEMENT_AST_OPERATORS (Media_Query);
939
931
IMPLEMENT_AST_OPERATORS (Media_Query_Expression);
940
932
IMPLEMENT_AST_OPERATORS (Debug);
0 commit comments