@@ -8,6 +8,27 @@ namespace Sass {
88
99 static Null sass_null (ParserState(" null" ));
1010
11+ uint8_t sass_op_to_precedence (enum Sass_OP op) {
12+ switch (op) {
13+ case OR: return 1 ;
14+ case AND: return 2 ;
15+ case EQ: return 3 ;
16+ case NEQ: return 3 ;
17+ case GT: return 4 ;
18+ case GTE: return 4 ;
19+ case LT: return 4 ;
20+ case LTE: return 4 ;
21+ case ADD: return 5 ;
22+ case SUB: return 5 ;
23+ case MUL: return 6 ;
24+ case DIV: return 6 ;
25+ case MOD: return 6 ;
26+ // this is only used internally!
27+ case NUM_OPS: return 99 ;
28+ default : return 255 ;
29+ }
30+ }
31+
1132 const char * sass_op_to_name (enum Sass_OP op) {
1233 switch (op) {
1334 case AND: return " and" ;
@@ -29,6 +50,24 @@ namespace Sass {
2950 }
3051 }
3152
53+ Sass_OP sass_name_to_op (std::string op)
54+ {
55+ if (op == " &&" ) return AND;
56+ if (op == " ||" ) return OR;
57+ if (op == " ==" ) return EQ;
58+ if (op == " !=" ) return NEQ;
59+ if (op == " >" ) return GT;
60+ if (op == " >=" ) return GTE;
61+ if (op == " <" ) return LT;
62+ if (op == " <=" ) return LTE;
63+ if (op == " +" ) return ADD;
64+ if (op == " ." ) return SUB;
65+ if (op == " *" ) return MUL;
66+ if (op == " /" ) return DIV;
67+ if (op == " &" ) return MOD;
68+ return NUM_OPS;
69+ }
70+
3271 const char * sass_op_separator (enum Sass_OP op) {
3372 switch (op) {
3473 case AND: return " &&" ;
@@ -128,6 +167,12 @@ namespace Sass {
128167 is_root_(ptr->is_root_)
129168 { }
130169
170+ Block::Block (ParserState pstate, std::vector<StatementObj> vec, bool r) :
171+ Statement(pstate),
172+ Vectorized<StatementObj>(vec),
173+ is_root_(r)
174+ { }
175+
131176 bool Block::isInvisible () const
132177 {
133178 for (auto & item : elements ()) {
@@ -165,6 +210,11 @@ namespace Sass {
165210 Ruleset::Ruleset (ParserState pstate, SelectorListObj s, Block_Obj b)
166211 : Has_Block(pstate, b), selector_(s), schema_(), is_root_(false )
167212 { statement_type (RULESET); }
213+
214+ Ruleset::Ruleset (ParserState pstate, Selector_Schema* s, Block_Obj b)
215+ : Has_Block(pstate, b), selector_(), schema_(s), is_root_(false )
216+ { statement_type (RULESET); }
217+
168218 Ruleset::Ruleset (const Ruleset* ptr)
169219 : Has_Block(ptr),
170220 selector_(ptr->selector_),
@@ -213,12 +263,13 @@ namespace Sass {
213263 // ///////////////////////////////////////////////////////////////////////
214264
215265 Directive::Directive (ParserState pstate, std::string kwd, SelectorListObj sel, Block_Obj b, Expression_Obj val)
216- : Has_Block(pstate, b), keyword_(kwd), selector_(sel), value_(val) // set value manually if needed
266+ : Has_Block(pstate, b), keyword_(kwd), selector_(sel), selSchema_(), value_(val) // set value manually if needed
217267 { statement_type (DIRECTIVE); }
218268 Directive::Directive (const Directive* ptr)
219269 : Has_Block(ptr),
220270 keyword_(ptr->keyword_),
221271 selector_(ptr->selector_),
272+ selSchema_(ptr->selSchema_),
222273 value_(ptr->value_) // set value manually if needed
223274 { statement_type (DIRECTIVE); }
224275
@@ -285,14 +336,80 @@ namespace Sass {
285336 // ///////////////////////////////////////////////////////////////////////
286337 // ///////////////////////////////////////////////////////////////////////
287338
339+ ImportBase::ImportBase (
340+ ParserState pstate) :
341+ Statement(pstate)
342+ {}
343+
344+ ImportBase::ImportBase (
345+ const ImportBase* ptr) :
346+ Statement(ptr)
347+ {}
348+
349+ // ///////////////////////////////////////////////////////////////////////
350+ // ///////////////////////////////////////////////////////////////////////
351+
352+ StaticImport::StaticImport (
353+ ParserState pstate,
354+ String_Schema_Obj url,
355+ Supports_Condition_Obj supports,
356+ String_Schema_Obj media) :
357+ ImportBase(pstate),
358+ url_(url),
359+ supports_(supports),
360+ media_(media)
361+ {}
362+
363+ StaticImport::StaticImport (
364+ const StaticImport* ptr) :
365+ ImportBase(ptr),
366+ url_(ptr->url_),
367+ supports_(ptr->supports_),
368+ media_(ptr->media_)
369+ {}
370+
371+ // ///////////////////////////////////////////////////////////////////////
372+ // ///////////////////////////////////////////////////////////////////////
373+
374+ DynamicImport::DynamicImport (
375+ ParserState pstate,
376+ std::string url) :
377+ ImportBase(pstate),
378+ url_(url)
379+ {}
380+
381+ DynamicImport::DynamicImport (
382+ const DynamicImport* ptr) :
383+ ImportBase(ptr),
384+ url_(ptr->url_)
385+ {}
386+
387+ // ///////////////////////////////////////////////////////////////////////
388+ // ///////////////////////////////////////////////////////////////////////
389+
390+ ImportRule::ImportRule (
391+ ParserState pstate) :
392+ Statement(pstate),
393+ Vectorized()
394+ {}
395+
396+ ImportRule::ImportRule (
397+ const ImportRule* ptr) :
398+ Statement(ptr),
399+ Vectorized(ptr)
400+ {}
401+
402+ // ///////////////////////////////////////////////////////////////////////
403+ // ///////////////////////////////////////////////////////////////////////
404+
288405 Import::Import (ParserState pstate)
289- : Statement (pstate),
406+ : ImportBase (pstate),
290407 urls_(std::vector<Expression_Obj>()),
291408 incs_(std::vector<Include>()),
292409 import_queries_()
293410 { statement_type (IMPORT); }
294411 Import::Import (const Import* ptr)
295- : Statement (ptr),
412+ : ImportBase (ptr),
296413 urls_(ptr->urls_),
297414 incs_(ptr->incs_),
298415 import_queries_(ptr->import_queries_)
@@ -305,10 +422,10 @@ namespace Sass {
305422 // ///////////////////////////////////////////////////////////////////////
306423
307424 Import_Stub::Import_Stub (ParserState pstate, Include res)
308- : Statement (pstate), resource_(res)
425+ : ImportBase (pstate), resource_(res)
309426 { statement_type (IMPORT_STUB); }
310427 Import_Stub::Import_Stub (const Import_Stub* ptr)
311- : Statement (ptr), resource_(ptr->resource_)
428+ : ImportBase (ptr), resource_(ptr->resource_)
312429 { statement_type (IMPORT_STUB); }
313430 Include Import_Stub::resource () { return resource_; };
314431 std::string Import_Stub::imp_path () { return resource_.imp_path ; };
@@ -427,16 +544,27 @@ namespace Sass {
427544 // ///////////////////////////////////////////////////////////////////////
428545 // ///////////////////////////////////////////////////////////////////////
429546
430- ExtendRule::ExtendRule (ParserState pstate, SelectorListObj s)
431- : Statement(pstate), isOptional_(false ), selector_(s), schema_()
432- { statement_type (EXTEND); }
433- ExtendRule::ExtendRule (ParserState pstate, Selector_Schema_Obj s)
434- : Statement(pstate), isOptional_(false ), selector_(), schema_(s)
547+ ExtendRule::ExtendRule (ParserState pstate, SelectorListObj s, bool optional) :
548+ Statement(pstate), isOptional_(optional), selector_(s), schema_()
549+ {
550+ statement_type (EXTEND);
551+ }
552+
553+ ExtendRule::ExtendRule (ParserState pstate, Selector_Schema_Obj s, bool optional) :
554+ Statement(pstate), isOptional_(optional), selector_(), schema_(s)
555+ {
556+ statement_type (EXTEND);
557+ }
558+
559+ ExtendRule::ExtendRule (ParserState pstate, String_Schema_Obj s, bool optional) :
560+ Statement(pstate), isOptional_(optional), selector_(), schema_()
435561 {
562+ schema (SASS_MEMORY_NEW (Selector_Schema, s->pstate (), s));
436563 statement_type (EXTEND);
437564 }
565+
438566 ExtendRule::ExtendRule (const ExtendRule* ptr)
439- : Statement(ptr),
567+ : Statement(ptr),
440568 isOptional_(ptr->isOptional_),
441569 selector_(ptr->selector_),
442570 schema_(ptr->schema_)
@@ -459,11 +587,11 @@ namespace Sass {
459587 { }
460588
461589 Definition::Definition (ParserState pstate,
462- std::string n,
463- Parameters_Obj params,
464- Block_Obj b,
465- Type t)
466- : Has_Block(pstate, b),
590+ std::string n,
591+ Parameters_Obj params,
592+ Block_Obj b,
593+ Type t)
594+ : Has_Block(pstate, b),
467595 name_(n),
468596 parameters_(params),
469597 environment_(0 ),
@@ -557,6 +685,30 @@ namespace Sass {
557685 // ///////////////////////////////////////////////////////////////////////
558686 // ///////////////////////////////////////////////////////////////////////
559687
688+ ParenthesizedExpression::ParenthesizedExpression (
689+ ParserState pstate,
690+ Expression* expression) :
691+ Expression(pstate),
692+ expression_(expression)
693+ {}
694+
695+ ParenthesizedExpression::ParenthesizedExpression (
696+ const ParenthesizedExpression* ptr) :
697+ Expression(ptr),
698+ expression_(ptr->expression ())
699+ {}
700+
701+ size_t ParenthesizedExpression::hash () const
702+ {
703+ if (expression ()) {
704+ return expression ()->hash ();
705+ }
706+ return 0 ;
707+ }
708+
709+ // ///////////////////////////////////////////////////////////////////////
710+ // ///////////////////////////////////////////////////////////////////////
711+
560712 Unary_Expression::Unary_Expression (ParserState pstate, Type t, Expression_Obj o)
561713 : Expression(pstate), optype_(t), operand_(o), hash_(0 )
562714 { }
@@ -807,7 +959,7 @@ namespace Sass {
807959 // ///////////////////////////////////////////////////////////////////////
808960 // ///////////////////////////////////////////////////////////////////////
809961
810- At_Root_Block::At_Root_Block (ParserState pstate, Block_Obj b, At_Root_Query_Obj e )
962+ At_Root_Block::At_Root_Block (ParserState pstate, At_Root_Query_Obj e, Block_Obj b )
811963 : Has_Block(pstate, b), expression_(e)
812964 { statement_type (ATROOT); }
813965 At_Root_Block::At_Root_Block (const At_Root_Block* ptr)
@@ -917,6 +1069,9 @@ namespace Sass {
9171069 IMPLEMENT_AST_OPERATORS (CssMediaQuery);
9181070 IMPLEMENT_AST_OPERATORS (Import);
9191071 IMPLEMENT_AST_OPERATORS (Import_Stub);
1072+ IMPLEMENT_AST_OPERATORS (ImportRule);
1073+ IMPLEMENT_AST_OPERATORS (StaticImport);
1074+ IMPLEMENT_AST_OPERATORS (DynamicImport);
9201075 IMPLEMENT_AST_OPERATORS (Directive);
9211076 IMPLEMENT_AST_OPERATORS (At_Root_Block);
9221077 IMPLEMENT_AST_OPERATORS (While);
@@ -939,6 +1094,7 @@ namespace Sass {
9391094 IMPLEMENT_AST_OPERATORS (Arguments);
9401095 IMPLEMENT_AST_OPERATORS (Argument);
9411096 IMPLEMENT_AST_OPERATORS (Unary_Expression);
1097+ IMPLEMENT_AST_OPERATORS (ParenthesizedExpression);
9421098 IMPLEMENT_AST_OPERATORS (Block);
9431099 IMPLEMENT_AST_OPERATORS (Content);
9441100 IMPLEMENT_AST_OPERATORS (Trace);
0 commit comments