1+ // sass.hpp must go before all system headers to get the
2+ // __EXTENSIONS__ fix on Solaris.
13#include " sass.hpp"
4+
25#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>
156#include < cctype>
167#include < locale>
178
@@ -69,7 +60,7 @@ namespace Sass {
6960 pstate_.offset += pstate - pstate_ + pstate.offset ;
7061 }
7162
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
7364 {
7465 Sass_Output_Options out (opt);
7566 Emitter emitter (out);
@@ -80,19 +71,21 @@ namespace Sass {
8071 return i.get_buffer ();
8172 }
8273
83- const std::string AST_Node::to_string ( ) const
74+ std::string AST_Node::to_css (Sass_Inspect_Options opt ) const
8475 {
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 ();
8684 }
8785
88- // ///////////////////////////////////////////////////////////////////////
89- // ///////////////////////////////////////////////////////////////////////
90-
91- Expression_Obj Hashed::at (Expression_Obj k) const
86+ std::string AST_Node::to_string () const
9287 {
93- if (elements_.count (k))
94- { return elements_.at (k); }
95- else { return {}; }
88+ return to_string ({ NESTED, 5 });
9689 }
9790
9891 // ///////////////////////////////////////////////////////////////////////
@@ -137,6 +130,14 @@ namespace Sass {
137130 is_root_(ptr->is_root_)
138131 { }
139132
133+ bool Block::isInvisible () const
134+ {
135+ for (auto & item : elements ()) {
136+ if (!item->is_invisible ()) return false ;
137+ }
138+ return true ;
139+ }
140+
140141 bool Block::has_content ()
141142 {
142143 for (size_t i = 0 , L = elements ().size (); i < L; ++i) {
@@ -163,19 +164,20 @@ namespace Sass {
163164 // ///////////////////////////////////////////////////////////////////////
164165 // ///////////////////////////////////////////////////////////////////////
165166
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 )
168169 { statement_type (RULESET); }
169170 Ruleset::Ruleset (const Ruleset* ptr)
170171 : Has_Block(ptr),
171172 selector_(ptr->selector_),
173+ schema_(ptr->schema_),
172174 is_root_(ptr->is_root_)
173175 { statement_type (RULESET); }
174176
175177 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 ;
179181 }
180182 return true ;
181183 }
@@ -212,30 +214,7 @@ namespace Sass {
212214 // ///////////////////////////////////////////////////////////////////////
213215 // ///////////////////////////////////////////////////////////////////////
214216
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)
239218 : Has_Block(pstate, b), keyword_(kwd), selector_(sel), value_(val) // set value manually if needed
240219 { statement_type (DIRECTIVE); }
241220 Directive::Directive (const Directive* ptr)
@@ -450,11 +429,19 @@ namespace Sass {
450429 // ///////////////////////////////////////////////////////////////////////
451430 // ///////////////////////////////////////////////////////////////////////
452431
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_( )
455434 { 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_)
458445 { statement_type (EXTEND); }
459446
460447 // ///////////////////////////////////////////////////////////////////////
@@ -923,8 +910,13 @@ namespace Sass {
923910 // ///////////////////////////////////////////////////////////////////////
924911 // ///////////////////////////////////////////////////////////////////////
925912
913+ // If you forget to add a class here you will get
914+ // undefined reference to `vtable for Sass::Class'
915+
926916 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);
928920 IMPLEMENT_AST_OPERATORS (Import);
929921 IMPLEMENT_AST_OPERATORS (Import_Stub);
930922 IMPLEMENT_AST_OPERATORS (Directive);
@@ -934,7 +926,7 @@ namespace Sass {
934926 IMPLEMENT_AST_OPERATORS (For);
935927 IMPLEMENT_AST_OPERATORS (If);
936928 IMPLEMENT_AST_OPERATORS (Mixin_Call);
937- IMPLEMENT_AST_OPERATORS (Extension );
929+ IMPLEMENT_AST_OPERATORS (ExtendRule );
938930 IMPLEMENT_AST_OPERATORS (Media_Query);
939931 IMPLEMENT_AST_OPERATORS (Media_Query_Expression);
940932 IMPLEMENT_AST_OPERATORS (Debug);
0 commit comments