sassc 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +13 -0
- data/Rakefile +1 -3
- data/ext/extconf.rb +13 -5
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/base.h +2 -1
- data/ext/libsass/include/sass/context.h +1 -0
- data/ext/libsass/src/ast.cpp +49 -59
- data/ext/libsass/src/ast.hpp +263 -102
- data/ext/libsass/src/ast_def_macros.hpp +8 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -1
- data/ext/libsass/src/ast_fwd_decl.hpp +40 -116
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +209 -722
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +207 -212
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +559 -1001
- data/ext/libsass/src/ast_selectors.hpp +311 -367
- data/ext/libsass/src/ast_supports.cpp +1 -17
- data/ext/libsass/src/ast_values.cpp +216 -29
- data/ext/libsass/src/ast_values.hpp +42 -33
- data/ext/libsass/src/bind.cpp +1 -1
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +5 -6
- data/ext/libsass/src/check_nesting.hpp +4 -0
- data/ext/libsass/src/color_maps.cpp +11 -10
- data/ext/libsass/src/color_maps.hpp +0 -8
- data/ext/libsass/src/constants.cpp +5 -0
- data/ext/libsass/src/constants.hpp +6 -0
- data/ext/libsass/src/context.cpp +30 -60
- data/ext/libsass/src/context.hpp +8 -20
- data/ext/libsass/src/cssize.cpp +36 -120
- data/ext/libsass/src/cssize.hpp +4 -10
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +364 -207
- data/ext/libsass/src/emitter.cpp +3 -4
- data/ext/libsass/src/emitter.hpp +0 -2
- data/ext/libsass/src/environment.hpp +5 -0
- data/ext/libsass/src/error_handling.cpp +21 -0
- data/ext/libsass/src/error_handling.hpp +25 -3
- data/ext/libsass/src/eval.cpp +33 -153
- data/ext/libsass/src/eval.hpp +11 -13
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +214 -167
- data/ext/libsass/src/expand.hpp +26 -6
- data/ext/libsass/src/extender.cpp +1186 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +15 -14
- data/ext/libsass/src/file.hpp +5 -12
- data/ext/libsass/src/fn_colors.cpp +12 -10
- data/ext/libsass/src/fn_lists.cpp +12 -11
- data/ext/libsass/src/fn_miscs.cpp +22 -34
- data/ext/libsass/src/fn_numbers.cpp +13 -6
- data/ext/libsass/src/fn_selectors.cpp +94 -124
- data/ext/libsass/src/fn_strings.cpp +16 -14
- data/ext/libsass/src/fn_utils.cpp +5 -6
- data/ext/libsass/src/fn_utils.hpp +9 -3
- data/ext/libsass/src/inspect.cpp +154 -117
- data/ext/libsass/src/inspect.hpp +10 -8
- data/ext/libsass/src/lexer.cpp +17 -81
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +22 -36
- data/ext/libsass/src/listize.hpp +8 -9
- data/ext/libsass/src/memory/SharedPtr.hpp +39 -5
- data/ext/libsass/src/operation.hpp +27 -17
- data/ext/libsass/src/operators.cpp +1 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +30 -49
- data/ext/libsass/src/output.hpp +1 -1
- data/ext/libsass/src/parser.cpp +211 -381
- data/ext/libsass/src/parser.hpp +17 -15
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +140 -0
- data/ext/libsass/src/position.hpp +1 -1
- data/ext/libsass/src/prelexer.cpp +6 -6
- data/ext/libsass/src/remove_placeholders.cpp +55 -56
- data/ext/libsass/src/remove_placeholders.hpp +21 -18
- data/ext/libsass/src/sass.hpp +1 -0
- data/ext/libsass/src/sass2scss.cpp +4 -4
- data/ext/libsass/src/sass_context.cpp +42 -91
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +1 -1
- data/ext/libsass/src/sass_values.cpp +0 -1
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +2 -2
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +5 -3
- data/ext/libsass/src/util.cpp +10 -12
- data/ext/libsass/src/util.hpp +2 -3
- data/ext/libsass/src/util_string.cpp +111 -61
- data/ext/libsass/src/util_string.hpp +61 -8
- data/lib/sassc/engine.rb +5 -3
- data/lib/sassc/functions_handler.rb +8 -8
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/script.rb +4 -4
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +18 -1
- data/test/native_test.rb +1 -1
- metadata +17 -12
- data/ext/libsass/src/extend.cpp +0 -2132
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/node.cpp +0 -322
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -152
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -58
- data/ext/libsass/src/subset_map.hpp +0 -76
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
|
3
3
|
#include "sass.hpp"
|
|
4
|
-
|
|
5
4
|
#include "ast.hpp"
|
|
6
|
-
|
|
7
|
-
#include "node.hpp"
|
|
8
|
-
#include "eval.hpp"
|
|
9
|
-
#include "extend.hpp"
|
|
10
|
-
#include "emitter.hpp"
|
|
11
|
-
#include "color_maps.hpp"
|
|
12
|
-
#include "ast_fwd_decl.hpp"
|
|
13
|
-
#include <set>
|
|
14
|
-
#include <iomanip>
|
|
15
|
-
#include <iostream>
|
|
16
|
-
#include <algorithm>
|
|
17
|
-
#include <functional>
|
|
18
|
-
#include <cctype>
|
|
19
|
-
#include <locale>
|
|
20
|
-
|
|
21
|
-
#include "ast_values.hpp"
|
|
5
|
+
|
|
22
6
|
|
|
23
7
|
namespace Sass {
|
|
24
8
|
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
|
3
3
|
#include "sass.hpp"
|
|
4
|
-
|
|
5
4
|
#include "ast.hpp"
|
|
6
|
-
#include "context.hpp"
|
|
7
|
-
#include "node.hpp"
|
|
8
|
-
#include "eval.hpp"
|
|
9
|
-
#include "extend.hpp"
|
|
10
|
-
#include "emitter.hpp"
|
|
11
|
-
#include "color_maps.hpp"
|
|
12
|
-
#include "ast_fwd_decl.hpp"
|
|
13
|
-
#include <set>
|
|
14
|
-
#include <iomanip>
|
|
15
|
-
#include <iostream>
|
|
16
|
-
#include <algorithm>
|
|
17
|
-
#include <functional>
|
|
18
|
-
#include <cctype>
|
|
19
|
-
#include <locale>
|
|
20
|
-
|
|
21
|
-
#include "ast_values.hpp"
|
|
22
5
|
|
|
23
6
|
namespace Sass {
|
|
24
7
|
|
|
@@ -85,6 +68,24 @@ namespace Sass {
|
|
|
85
68
|
// don't set children
|
|
86
69
|
}
|
|
87
70
|
|
|
71
|
+
bool List::operator< (const Expression& rhs) const
|
|
72
|
+
{
|
|
73
|
+
if (auto r = Cast<List>(&rhs)) {
|
|
74
|
+
if (length() < r->length()) return true;
|
|
75
|
+
if (length() > r->length()) return false;
|
|
76
|
+
const auto& left = elements();
|
|
77
|
+
const auto& right = r->elements();
|
|
78
|
+
for (size_t i = 0; i < left.size(); i += 1) {
|
|
79
|
+
if (*left[i] < *right[i]) return true;
|
|
80
|
+
if (*left[i] == *right[i]) continue;
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// compare/sort by type
|
|
86
|
+
return type() < rhs.type();
|
|
87
|
+
}
|
|
88
|
+
|
|
88
89
|
bool List::operator== (const Expression& rhs) const
|
|
89
90
|
{
|
|
90
91
|
if (auto r = Cast<List>(&rhs)) {
|
|
@@ -143,6 +144,31 @@ namespace Sass {
|
|
|
143
144
|
Hashed(*ptr)
|
|
144
145
|
{ concrete_type(MAP); }
|
|
145
146
|
|
|
147
|
+
bool Map::operator< (const Expression& rhs) const
|
|
148
|
+
{
|
|
149
|
+
if (auto r = Cast<Map>(&rhs)) {
|
|
150
|
+
if (length() < r->length()) return true;
|
|
151
|
+
if (length() > r->length()) return false;
|
|
152
|
+
const auto& lkeys = keys();
|
|
153
|
+
const auto& rkeys = r->keys();
|
|
154
|
+
for (size_t i = 0; i < lkeys.size(); i += 1) {
|
|
155
|
+
if (*lkeys[i] < *rkeys[i]) return true;
|
|
156
|
+
if (*lkeys[i] == *rkeys[i]) continue;
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const auto& lvals = values();
|
|
160
|
+
const auto& rvals = r->values();
|
|
161
|
+
for (size_t i = 0; i < lvals.size(); i += 1) {
|
|
162
|
+
if (*lvals[i] < *rvals[i]) return true;
|
|
163
|
+
if (*lvals[i] == *rvals[i]) continue;
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
// compare/sort by type
|
|
169
|
+
return type() < rhs.type();
|
|
170
|
+
}
|
|
171
|
+
|
|
146
172
|
bool Map::operator== (const Expression& rhs) const
|
|
147
173
|
{
|
|
148
174
|
if (auto r = Cast<Map>(&rhs)) {
|
|
@@ -232,6 +258,17 @@ namespace Sass {
|
|
|
232
258
|
is_delayed(delayed);
|
|
233
259
|
}
|
|
234
260
|
|
|
261
|
+
bool Binary_Expression::operator<(const Expression& rhs) const
|
|
262
|
+
{
|
|
263
|
+
if (auto m = Cast<Binary_Expression>(&rhs)) {
|
|
264
|
+
return type() < m->type() ||
|
|
265
|
+
*left() < *m->left() ||
|
|
266
|
+
*right() < *m->right();
|
|
267
|
+
}
|
|
268
|
+
// compare/sort by type
|
|
269
|
+
return type() < rhs.type();
|
|
270
|
+
}
|
|
271
|
+
|
|
235
272
|
bool Binary_Expression::operator==(const Expression& rhs) const
|
|
236
273
|
{
|
|
237
274
|
if (auto m = Cast<Binary_Expression>(&rhs)) {
|
|
@@ -263,6 +300,22 @@ namespace Sass {
|
|
|
263
300
|
: Value(ptr), definition_(ptr->definition_), is_css_(ptr->is_css_)
|
|
264
301
|
{ concrete_type(FUNCTION_VAL); }
|
|
265
302
|
|
|
303
|
+
bool Function::operator< (const Expression& rhs) const
|
|
304
|
+
{
|
|
305
|
+
if (auto r = Cast<Function>(&rhs)) {
|
|
306
|
+
auto d1 = Cast<Definition>(definition());
|
|
307
|
+
auto d2 = Cast<Definition>(r->definition());
|
|
308
|
+
if (d1 == nullptr) return d2 != nullptr;
|
|
309
|
+
else if (d2 == nullptr) return false;
|
|
310
|
+
if (is_css() == r->is_css()) {
|
|
311
|
+
return d1 < d2;
|
|
312
|
+
}
|
|
313
|
+
return r->is_css();
|
|
314
|
+
}
|
|
315
|
+
// compare/sort by type
|
|
316
|
+
return type() < rhs.type();
|
|
317
|
+
}
|
|
318
|
+
|
|
266
319
|
bool Function::operator== (const Expression& rhs) const
|
|
267
320
|
{
|
|
268
321
|
if (auto r = Cast<Function>(&rhs)) {
|
|
@@ -436,6 +489,14 @@ namespace Sass {
|
|
|
436
489
|
return hash_;
|
|
437
490
|
}
|
|
438
491
|
|
|
492
|
+
bool Number::operator< (const Expression& rhs) const
|
|
493
|
+
{
|
|
494
|
+
if (auto n = Cast<Number>(&rhs)) {
|
|
495
|
+
return *this < *n;
|
|
496
|
+
}
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
|
|
439
500
|
bool Number::operator== (const Expression& rhs) const
|
|
440
501
|
{
|
|
441
502
|
if (auto n = Cast<Number>(&rhs)) {
|
|
@@ -475,7 +536,7 @@ namespace Sass {
|
|
|
475
536
|
l.normalize(); r.normalize();
|
|
476
537
|
Units &lhs_unit = l, &rhs_unit = r;
|
|
477
538
|
if (!(lhs_unit == rhs_unit)) {
|
|
478
|
-
/* ToDo: do we always get
|
|
539
|
+
/* ToDo: do we always get useful backtraces? */
|
|
479
540
|
throw Exception::IncompatibleUnits(rhs, *this);
|
|
480
541
|
}
|
|
481
542
|
if (lhs_unit == rhs_unit) {
|
|
@@ -502,6 +563,21 @@ namespace Sass {
|
|
|
502
563
|
hash_(ptr->hash_)
|
|
503
564
|
{ concrete_type(COLOR); }
|
|
504
565
|
|
|
566
|
+
bool Color::operator< (const Expression& rhs) const
|
|
567
|
+
{
|
|
568
|
+
if (auto r = Cast<Color_RGBA>(&rhs)) {
|
|
569
|
+
return *this < *r;
|
|
570
|
+
}
|
|
571
|
+
else if (auto r = Cast<Color_HSLA>(&rhs)) {
|
|
572
|
+
return *this < *r;
|
|
573
|
+
}
|
|
574
|
+
else if (auto r = Cast<Color>(&rhs)) {
|
|
575
|
+
return a_ < r->a();
|
|
576
|
+
}
|
|
577
|
+
// compare/sort by type
|
|
578
|
+
return type() < rhs.type();
|
|
579
|
+
}
|
|
580
|
+
|
|
505
581
|
bool Color::operator== (const Expression& rhs) const
|
|
506
582
|
{
|
|
507
583
|
if (auto r = Cast<Color_RGBA>(&rhs)) {
|
|
@@ -531,6 +607,23 @@ namespace Sass {
|
|
|
531
607
|
b_(ptr->b_)
|
|
532
608
|
{ concrete_type(COLOR); }
|
|
533
609
|
|
|
610
|
+
bool Color_RGBA::operator< (const Expression& rhs) const
|
|
611
|
+
{
|
|
612
|
+
if (auto r = Cast<Color_RGBA>(&rhs)) {
|
|
613
|
+
if (r_ < r->r()) return true;
|
|
614
|
+
if (r_ > r->r()) return false;
|
|
615
|
+
if (g_ < r->g()) return true;
|
|
616
|
+
if (g_ > r->g()) return false;
|
|
617
|
+
if (b_ < r->b()) return true;
|
|
618
|
+
if (b_ > r->b()) return false;
|
|
619
|
+
if (a_ < r->a()) return true;
|
|
620
|
+
if (a_ > r->a()) return false;
|
|
621
|
+
return false; // is equal
|
|
622
|
+
}
|
|
623
|
+
// compare/sort by type
|
|
624
|
+
return type() < rhs.type();
|
|
625
|
+
}
|
|
626
|
+
|
|
534
627
|
bool Color_RGBA::operator== (const Expression& rhs) const
|
|
535
628
|
{
|
|
536
629
|
if (auto r = Cast<Color_RGBA>(&rhs)) {
|
|
@@ -616,6 +709,23 @@ namespace Sass {
|
|
|
616
709
|
// hash_(ptr->hash_)
|
|
617
710
|
{ concrete_type(COLOR); }
|
|
618
711
|
|
|
712
|
+
bool Color_HSLA::operator< (const Expression& rhs) const
|
|
713
|
+
{
|
|
714
|
+
if (auto r = Cast<Color_HSLA>(&rhs)) {
|
|
715
|
+
if (h_ < r->h()) return true;
|
|
716
|
+
if (h_ > r->h()) return false;
|
|
717
|
+
if (s_ < r->s()) return true;
|
|
718
|
+
if (s_ > r->s()) return false;
|
|
719
|
+
if (l_ < r->l()) return true;
|
|
720
|
+
if (l_ > r->l()) return false;
|
|
721
|
+
if (a_ < r->a()) return true;
|
|
722
|
+
if (a_ > r->a()) return false;
|
|
723
|
+
return false; // is equal
|
|
724
|
+
}
|
|
725
|
+
// compare/sort by type
|
|
726
|
+
return type() < rhs.type();
|
|
727
|
+
}
|
|
728
|
+
|
|
619
729
|
bool Color_HSLA::operator== (const Expression& rhs) const
|
|
620
730
|
{
|
|
621
731
|
if (auto r = Cast<Color_HSLA>(&rhs)) {
|
|
@@ -687,6 +797,15 @@ namespace Sass {
|
|
|
687
797
|
: Value(ptr), message_(ptr->message_)
|
|
688
798
|
{ concrete_type(C_ERROR); }
|
|
689
799
|
|
|
800
|
+
bool Custom_Error::operator< (const Expression& rhs) const
|
|
801
|
+
{
|
|
802
|
+
if (auto r = Cast<Custom_Error>(&rhs)) {
|
|
803
|
+
return message() < r->message();
|
|
804
|
+
}
|
|
805
|
+
// compare/sort by type
|
|
806
|
+
return type() < rhs.type();
|
|
807
|
+
}
|
|
808
|
+
|
|
690
809
|
bool Custom_Error::operator== (const Expression& rhs) const
|
|
691
810
|
{
|
|
692
811
|
if (auto r = Cast<Custom_Error>(&rhs)) {
|
|
@@ -706,6 +825,15 @@ namespace Sass {
|
|
|
706
825
|
: Value(ptr), message_(ptr->message_)
|
|
707
826
|
{ concrete_type(C_WARNING); }
|
|
708
827
|
|
|
828
|
+
bool Custom_Warning::operator< (const Expression& rhs) const
|
|
829
|
+
{
|
|
830
|
+
if (auto r = Cast<Custom_Warning>(&rhs)) {
|
|
831
|
+
return message() < r->message();
|
|
832
|
+
}
|
|
833
|
+
// compare/sort by type
|
|
834
|
+
return type() < rhs.type();
|
|
835
|
+
}
|
|
836
|
+
|
|
709
837
|
bool Custom_Warning::operator== (const Expression& rhs) const
|
|
710
838
|
{
|
|
711
839
|
if (auto r = Cast<Custom_Warning>(&rhs)) {
|
|
@@ -728,15 +856,23 @@ namespace Sass {
|
|
|
728
856
|
hash_(ptr->hash_)
|
|
729
857
|
{ concrete_type(BOOLEAN); }
|
|
730
858
|
|
|
731
|
-
bool Boolean::operator
|
|
859
|
+
bool Boolean::operator< (const Expression& rhs) const
|
|
732
860
|
{
|
|
733
861
|
if (auto r = Cast<Boolean>(&rhs)) {
|
|
734
|
-
return (value()
|
|
862
|
+
return (value() < r->value());
|
|
735
863
|
}
|
|
736
864
|
return false;
|
|
737
865
|
}
|
|
738
866
|
|
|
739
|
-
|
|
867
|
+
bool Boolean::operator== (const Expression& rhs) const
|
|
868
|
+
{
|
|
869
|
+
if (auto r = Cast<Boolean>(&rhs)) {
|
|
870
|
+
return (value() == r->value());
|
|
871
|
+
}
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
size_t Boolean::hash() const
|
|
740
876
|
{
|
|
741
877
|
if (hash_ == 0) {
|
|
742
878
|
hash_ = std::hash<bool>()(value_);
|
|
@@ -784,6 +920,23 @@ namespace Sass {
|
|
|
784
920
|
return length() && last()->is_right_interpolant();
|
|
785
921
|
}
|
|
786
922
|
|
|
923
|
+
bool String_Schema::operator< (const Expression& rhs) const
|
|
924
|
+
{
|
|
925
|
+
if (auto r = Cast<String_Schema>(&rhs)) {
|
|
926
|
+
if (length() < r->length()) return true;
|
|
927
|
+
if (length() > r->length()) return false;
|
|
928
|
+
for (size_t i = 0, L = length(); i < L; ++i) {
|
|
929
|
+
if (*get(i) < *r->get(i)) return true;
|
|
930
|
+
if (*get(i) == *r->get(i)) continue;
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
// Is equal
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
// compare/sort by type
|
|
937
|
+
return type() < rhs.type();
|
|
938
|
+
}
|
|
939
|
+
|
|
787
940
|
bool String_Schema::operator== (const Expression& rhs) const
|
|
788
941
|
{
|
|
789
942
|
if (auto r = Cast<String_Schema>(&rhs)) {
|
|
@@ -824,22 +977,21 @@ namespace Sass {
|
|
|
824
977
|
/////////////////////////////////////////////////////////////////////////
|
|
825
978
|
|
|
826
979
|
String_Constant::String_Constant(ParserState pstate, std::string val, bool css)
|
|
827
|
-
: String(pstate), quote_mark_(0),
|
|
980
|
+
: String(pstate), quote_mark_(0), value_(read_css_string(val, css)), hash_(0)
|
|
828
981
|
{ }
|
|
829
982
|
String_Constant::String_Constant(ParserState pstate, const char* beg, bool css)
|
|
830
|
-
: String(pstate), quote_mark_(0),
|
|
983
|
+
: String(pstate), quote_mark_(0), value_(read_css_string(std::string(beg), css)), hash_(0)
|
|
831
984
|
{ }
|
|
832
985
|
String_Constant::String_Constant(ParserState pstate, const char* beg, const char* end, bool css)
|
|
833
|
-
: String(pstate), quote_mark_(0),
|
|
986
|
+
: String(pstate), quote_mark_(0), value_(read_css_string(std::string(beg, end-beg), css)), hash_(0)
|
|
834
987
|
{ }
|
|
835
988
|
String_Constant::String_Constant(ParserState pstate, const Token& tok, bool css)
|
|
836
|
-
: String(pstate), quote_mark_(0),
|
|
989
|
+
: String(pstate), quote_mark_(0), value_(read_css_string(std::string(tok.begin, tok.end), css)), hash_(0)
|
|
837
990
|
{ }
|
|
838
991
|
|
|
839
992
|
String_Constant::String_Constant(const String_Constant* ptr)
|
|
840
993
|
: String(ptr),
|
|
841
994
|
quote_mark_(ptr->quote_mark_),
|
|
842
|
-
can_compress_whitespace_(ptr->can_compress_whitespace_),
|
|
843
995
|
value_(ptr->value_),
|
|
844
996
|
hash_(ptr->hash_)
|
|
845
997
|
{ }
|
|
@@ -848,11 +1000,24 @@ namespace Sass {
|
|
|
848
1000
|
return value_.empty() && quote_mark_ == 0;
|
|
849
1001
|
}
|
|
850
1002
|
|
|
1003
|
+
bool String_Constant::operator< (const Expression& rhs) const
|
|
1004
|
+
{
|
|
1005
|
+
if (auto qstr = Cast<String_Quoted>(&rhs)) {
|
|
1006
|
+
return value() < qstr->value();
|
|
1007
|
+
}
|
|
1008
|
+
else if (auto cstr = Cast<String_Constant>(&rhs)) {
|
|
1009
|
+
return value() < cstr->value();
|
|
1010
|
+
}
|
|
1011
|
+
// compare/sort by type
|
|
1012
|
+
return type() < rhs.type();
|
|
1013
|
+
}
|
|
1014
|
+
|
|
851
1015
|
bool String_Constant::operator== (const Expression& rhs) const
|
|
852
1016
|
{
|
|
853
1017
|
if (auto qstr = Cast<String_Quoted>(&rhs)) {
|
|
854
1018
|
return value() == qstr->value();
|
|
855
|
-
}
|
|
1019
|
+
}
|
|
1020
|
+
else if (auto cstr = Cast<String_Constant>(&rhs)) {
|
|
856
1021
|
return value() == cstr->value();
|
|
857
1022
|
}
|
|
858
1023
|
return false;
|
|
@@ -894,11 +1059,24 @@ namespace Sass {
|
|
|
894
1059
|
: String_Constant(ptr)
|
|
895
1060
|
{ }
|
|
896
1061
|
|
|
1062
|
+
bool String_Quoted::operator< (const Expression& rhs) const
|
|
1063
|
+
{
|
|
1064
|
+
if (auto qstr = Cast<String_Quoted>(&rhs)) {
|
|
1065
|
+
return value() < qstr->value();
|
|
1066
|
+
}
|
|
1067
|
+
else if (auto cstr = Cast<String_Constant>(&rhs)) {
|
|
1068
|
+
return value() < cstr->value();
|
|
1069
|
+
}
|
|
1070
|
+
// compare/sort by type
|
|
1071
|
+
return type() < rhs.type();
|
|
1072
|
+
}
|
|
1073
|
+
|
|
897
1074
|
bool String_Quoted::operator== (const Expression& rhs) const
|
|
898
1075
|
{
|
|
899
1076
|
if (auto qstr = Cast<String_Quoted>(&rhs)) {
|
|
900
1077
|
return value() == qstr->value();
|
|
901
|
-
}
|
|
1078
|
+
}
|
|
1079
|
+
else if (auto cstr = Cast<String_Constant>(&rhs)) {
|
|
902
1080
|
return value() == cstr->value();
|
|
903
1081
|
}
|
|
904
1082
|
return false;
|
|
@@ -919,9 +1097,18 @@ namespace Sass {
|
|
|
919
1097
|
Null::Null(const Null* ptr) : Value(ptr)
|
|
920
1098
|
{ concrete_type(NULL_VAL); }
|
|
921
1099
|
|
|
1100
|
+
bool Null::operator< (const Expression& rhs) const
|
|
1101
|
+
{
|
|
1102
|
+
if (Cast<Null>(&rhs)) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
// compare/sort by type
|
|
1106
|
+
return type() < rhs.type();
|
|
1107
|
+
}
|
|
1108
|
+
|
|
922
1109
|
bool Null::operator== (const Expression& rhs) const
|
|
923
1110
|
{
|
|
924
|
-
return Cast<Null>(&rhs) !=
|
|
1111
|
+
return Cast<Null>(&rhs) != nullptr;
|
|
925
1112
|
}
|
|
926
1113
|
|
|
927
1114
|
size_t Null::hash() const
|
|
@@ -4,35 +4,7 @@
|
|
|
4
4
|
// sass.hpp must go before all system headers to get the
|
|
5
5
|
// __EXTENSIONS__ fix on Solaris.
|
|
6
6
|
#include "sass.hpp"
|
|
7
|
-
|
|
8
|
-
#include <set>
|
|
9
|
-
#include <deque>
|
|
10
|
-
#include <vector>
|
|
11
|
-
#include <string>
|
|
12
|
-
#include <sstream>
|
|
13
|
-
#include <iostream>
|
|
14
|
-
#include <typeinfo>
|
|
15
|
-
#include <algorithm>
|
|
16
|
-
#include "sass/base.h"
|
|
17
|
-
#include "ast_fwd_decl.hpp"
|
|
18
|
-
|
|
19
|
-
#include "util.hpp"
|
|
20
|
-
#include "units.hpp"
|
|
21
|
-
#include "context.hpp"
|
|
22
|
-
#include "position.hpp"
|
|
23
|
-
#include "constants.hpp"
|
|
24
|
-
#include "operation.hpp"
|
|
25
|
-
#include "position.hpp"
|
|
26
|
-
#include "inspect.hpp"
|
|
27
|
-
#include "source_map.hpp"
|
|
28
|
-
#include "environment.hpp"
|
|
29
|
-
#include "error_handling.hpp"
|
|
30
|
-
#include "ast_def_macros.hpp"
|
|
31
|
-
#include "ast_fwd_decl.hpp"
|
|
32
|
-
#include "source_map.hpp"
|
|
33
|
-
#include "fn_utils.hpp"
|
|
34
|
-
|
|
35
|
-
#include "sass.h"
|
|
7
|
+
#include "ast.hpp"
|
|
36
8
|
|
|
37
9
|
namespace Sass {
|
|
38
10
|
|
|
@@ -52,8 +24,23 @@ namespace Sass {
|
|
|
52
24
|
class Value : public PreValue {
|
|
53
25
|
public:
|
|
54
26
|
Value(ParserState pstate, bool d = false, bool e = false, bool i = false, Type ct = NONE);
|
|
55
|
-
|
|
27
|
+
|
|
28
|
+
// Some obects are not meant to be compared
|
|
29
|
+
// ToDo: maybe fallback to pointer comparison?
|
|
30
|
+
virtual bool operator< (const Expression& rhs) const override = 0;
|
|
56
31
|
virtual bool operator== (const Expression& rhs) const override = 0;
|
|
32
|
+
|
|
33
|
+
// We can give some reasonable implementations by using
|
|
34
|
+
// inverst operators on the specialized implementations
|
|
35
|
+
virtual bool operator> (const Expression& rhs) const {
|
|
36
|
+
return rhs < *this;
|
|
37
|
+
}
|
|
38
|
+
virtual bool operator!= (const Expression& rhs) const {
|
|
39
|
+
return !(*this == rhs);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ATTACH_VIRTUAL_AST_OPERATIONS(Value);
|
|
43
|
+
|
|
57
44
|
};
|
|
58
45
|
|
|
59
46
|
///////////////////////////////////////////////////////////////////////
|
|
@@ -81,6 +68,8 @@ namespace Sass {
|
|
|
81
68
|
virtual size_t hash() const override;
|
|
82
69
|
virtual size_t size() const;
|
|
83
70
|
virtual void set_delayed(bool delayed) override;
|
|
71
|
+
|
|
72
|
+
virtual bool operator< (const Expression& rhs) const override;
|
|
84
73
|
virtual bool operator== (const Expression& rhs) const override;
|
|
85
74
|
|
|
86
75
|
ATTACH_AST_OPERATIONS(List)
|
|
@@ -90,7 +79,7 @@ namespace Sass {
|
|
|
90
79
|
///////////////////////////////////////////////////////////////////////
|
|
91
80
|
// Key value paris.
|
|
92
81
|
///////////////////////////////////////////////////////////////////////
|
|
93
|
-
class Map : public Value, public Hashed {
|
|
82
|
+
class Map : public Value, public Hashed<Expression_Obj, Expression_Obj, Map_Obj> {
|
|
94
83
|
void adjust_after_pushing(std::pair<Expression_Obj, Expression_Obj> p) override { is_expanded(false); }
|
|
95
84
|
public:
|
|
96
85
|
Map(ParserState pstate, size_t size = 0);
|
|
@@ -100,6 +89,8 @@ namespace Sass {
|
|
|
100
89
|
List_Obj to_list(ParserState& pstate);
|
|
101
90
|
|
|
102
91
|
virtual size_t hash() const override;
|
|
92
|
+
|
|
93
|
+
virtual bool operator< (const Expression& rhs) const override;
|
|
103
94
|
virtual bool operator== (const Expression& rhs) const override;
|
|
104
95
|
|
|
105
96
|
ATTACH_AST_OPERATIONS(Map)
|
|
@@ -130,6 +121,7 @@ namespace Sass {
|
|
|
130
121
|
|
|
131
122
|
virtual void set_delayed(bool delayed) override;
|
|
132
123
|
|
|
124
|
+
virtual bool operator< (const Expression& rhs) const override;
|
|
133
125
|
virtual bool operator==(const Expression& rhs) const override;
|
|
134
126
|
|
|
135
127
|
virtual size_t hash() const override;
|
|
@@ -154,6 +146,7 @@ namespace Sass {
|
|
|
154
146
|
|
|
155
147
|
std::string name();
|
|
156
148
|
|
|
149
|
+
bool operator< (const Expression& rhs) const override;
|
|
157
150
|
bool operator== (const Expression& rhs) const override;
|
|
158
151
|
|
|
159
152
|
ATTACH_AST_OPERATIONS(Function)
|
|
@@ -230,6 +223,7 @@ namespace Sass {
|
|
|
230
223
|
|
|
231
224
|
bool operator< (const Number& rhs) const;
|
|
232
225
|
bool operator== (const Number& rhs) const;
|
|
226
|
+
bool operator< (const Expression& rhs) const override;
|
|
233
227
|
bool operator== (const Expression& rhs) const override;
|
|
234
228
|
ATTACH_AST_OPERATIONS(Number)
|
|
235
229
|
ATTACH_CRTP_PERFORM_METHODS()
|
|
@@ -251,6 +245,7 @@ namespace Sass {
|
|
|
251
245
|
|
|
252
246
|
virtual size_t hash() const override = 0;
|
|
253
247
|
|
|
248
|
+
bool operator< (const Expression& rhs) const override;
|
|
254
249
|
bool operator== (const Expression& rhs) const override;
|
|
255
250
|
|
|
256
251
|
virtual Color_RGBA* copyAsRGBA() const = 0;
|
|
@@ -283,6 +278,7 @@ namespace Sass {
|
|
|
283
278
|
Color_HSLA* copyAsHSLA() const override;
|
|
284
279
|
Color_HSLA* toHSLA() override { return copyAsHSLA(); }
|
|
285
280
|
|
|
281
|
+
bool operator< (const Expression& rhs) const override;
|
|
286
282
|
bool operator== (const Expression& rhs) const override;
|
|
287
283
|
|
|
288
284
|
ATTACH_AST_OPERATIONS(Color_RGBA)
|
|
@@ -311,6 +307,7 @@ namespace Sass {
|
|
|
311
307
|
Color_HSLA* copyAsHSLA() const override;
|
|
312
308
|
Color_HSLA* toHSLA() override { return this; }
|
|
313
309
|
|
|
310
|
+
bool operator< (const Expression& rhs) const override;
|
|
314
311
|
bool operator== (const Expression& rhs) const override;
|
|
315
312
|
|
|
316
313
|
ATTACH_AST_OPERATIONS(Color_HSLA)
|
|
@@ -324,6 +321,7 @@ namespace Sass {
|
|
|
324
321
|
ADD_CONSTREF(std::string, message)
|
|
325
322
|
public:
|
|
326
323
|
Custom_Error(ParserState pstate, std::string msg);
|
|
324
|
+
bool operator< (const Expression& rhs) const override;
|
|
327
325
|
bool operator== (const Expression& rhs) const override;
|
|
328
326
|
ATTACH_AST_OPERATIONS(Custom_Error)
|
|
329
327
|
ATTACH_CRTP_PERFORM_METHODS()
|
|
@@ -336,6 +334,7 @@ namespace Sass {
|
|
|
336
334
|
ADD_CONSTREF(std::string, message)
|
|
337
335
|
public:
|
|
338
336
|
Custom_Warning(ParserState pstate, std::string msg);
|
|
337
|
+
bool operator< (const Expression& rhs) const override;
|
|
339
338
|
bool operator== (const Expression& rhs) const override;
|
|
340
339
|
ATTACH_AST_OPERATIONS(Custom_Warning)
|
|
341
340
|
ATTACH_CRTP_PERFORM_METHODS()
|
|
@@ -358,6 +357,7 @@ namespace Sass {
|
|
|
358
357
|
|
|
359
358
|
bool is_false() override { return !value_; }
|
|
360
359
|
|
|
360
|
+
bool operator< (const Expression& rhs) const override;
|
|
361
361
|
bool operator== (const Expression& rhs) const override;
|
|
362
362
|
|
|
363
363
|
ATTACH_AST_OPERATIONS(Boolean)
|
|
@@ -377,6 +377,9 @@ namespace Sass {
|
|
|
377
377
|
virtual bool operator<(const Expression& rhs) const override {
|
|
378
378
|
return this->to_string() < rhs.to_string();
|
|
379
379
|
};
|
|
380
|
+
virtual bool operator==(const Expression& rhs) const override {
|
|
381
|
+
return this->to_string() == rhs.to_string();
|
|
382
|
+
};
|
|
380
383
|
ATTACH_VIRTUAL_AST_OPERATIONS(String);
|
|
381
384
|
ATTACH_CRTP_PERFORM_METHODS()
|
|
382
385
|
};
|
|
@@ -403,6 +406,7 @@ namespace Sass {
|
|
|
403
406
|
size_t hash() const override;
|
|
404
407
|
virtual void set_delayed(bool delayed) override;
|
|
405
408
|
|
|
409
|
+
bool operator< (const Expression& rhs) const override;
|
|
406
410
|
bool operator==(const Expression& rhs) const override;
|
|
407
411
|
ATTACH_AST_OPERATIONS(String_Schema)
|
|
408
412
|
ATTACH_CRTP_PERFORM_METHODS()
|
|
@@ -413,7 +417,6 @@ namespace Sass {
|
|
|
413
417
|
////////////////////////////////////////////////////////
|
|
414
418
|
class String_Constant : public String {
|
|
415
419
|
ADD_PROPERTY(char, quote_mark)
|
|
416
|
-
ADD_PROPERTY(bool, can_compress_whitespace)
|
|
417
420
|
HASH_CONSTREF(std::string, value)
|
|
418
421
|
protected:
|
|
419
422
|
mutable size_t hash_;
|
|
@@ -427,6 +430,7 @@ namespace Sass {
|
|
|
427
430
|
bool is_invisible() const override;
|
|
428
431
|
virtual void rtrim() override;
|
|
429
432
|
size_t hash() const override;
|
|
433
|
+
bool operator< (const Expression& rhs) const override;
|
|
430
434
|
bool operator==(const Expression& rhs) const override;
|
|
431
435
|
// quotes are forced on inspection
|
|
432
436
|
virtual std::string inspect() const override;
|
|
@@ -442,6 +446,7 @@ namespace Sass {
|
|
|
442
446
|
String_Quoted(ParserState pstate, std::string val, char q = 0,
|
|
443
447
|
bool keep_utf8_escapes = false, bool skip_unquoting = false,
|
|
444
448
|
bool strict_unquoting = true, bool css = true);
|
|
449
|
+
bool operator< (const Expression& rhs) const override;
|
|
445
450
|
bool operator==(const Expression& rhs) const override;
|
|
446
451
|
// quotes are forced on inspection
|
|
447
452
|
std::string inspect() const override;
|
|
@@ -463,6 +468,7 @@ namespace Sass {
|
|
|
463
468
|
|
|
464
469
|
size_t hash() const override;
|
|
465
470
|
|
|
471
|
+
bool operator< (const Expression& rhs) const override;
|
|
466
472
|
bool operator== (const Expression& rhs) const override;
|
|
467
473
|
|
|
468
474
|
ATTACH_AST_OPERATIONS(Null)
|
|
@@ -477,8 +483,11 @@ namespace Sass {
|
|
|
477
483
|
Parent_Reference(ParserState pstate);
|
|
478
484
|
std::string type() const override { return "parent"; }
|
|
479
485
|
static std::string type_name() { return "parent"; }
|
|
486
|
+
bool operator< (const Expression& rhs) const override {
|
|
487
|
+
return false; // they are always equal
|
|
488
|
+
}
|
|
480
489
|
bool operator==(const Expression& rhs) const override {
|
|
481
|
-
return true; //
|
|
490
|
+
return true; // they are always equal
|
|
482
491
|
};
|
|
483
492
|
ATTACH_AST_OPERATIONS(Parent_Reference)
|
|
484
493
|
ATTACH_CRTP_PERFORM_METHODS()
|