sassc 1.11.4 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -2
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/README.md +4 -1
  5. data/ext/libsass/.editorconfig +1 -1
  6. data/ext/libsass/.github/CONTRIBUTING.md +7 -7
  7. data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
  8. data/ext/libsass/.gitignore +3 -0
  9. data/ext/libsass/.travis.yml +37 -18
  10. data/ext/libsass/GNUmakefile.am +23 -37
  11. data/ext/libsass/Makefile +10 -6
  12. data/ext/libsass/Makefile.conf +3 -0
  13. data/ext/libsass/Readme.md +68 -63
  14. data/ext/libsass/appveyor.yml +7 -3
  15. data/ext/libsass/configure.ac +10 -14
  16. data/ext/libsass/docs/api-context-internal.md +29 -21
  17. data/ext/libsass/docs/api-context.md +26 -6
  18. data/ext/libsass/docs/api-doc.md +49 -16
  19. data/ext/libsass/docs/api-function-example.md +1 -1
  20. data/ext/libsass/docs/api-function.md +31 -7
  21. data/ext/libsass/docs/api-importer.md +19 -19
  22. data/ext/libsass/docs/api-value.md +4 -2
  23. data/ext/libsass/docs/build-on-windows.md +4 -4
  24. data/ext/libsass/docs/build-with-mingw.md +3 -3
  25. data/ext/libsass/docs/build.md +9 -9
  26. data/ext/libsass/docs/custom-functions-internal.md +10 -8
  27. data/ext/libsass/docs/implementations.md +20 -8
  28. data/ext/libsass/docs/unicode.md +16 -10
  29. data/ext/libsass/include/sass/base.h +0 -3
  30. data/ext/libsass/include/sass/context.h +20 -2
  31. data/ext/libsass/include/sass/functions.h +31 -0
  32. data/ext/libsass/include/sass/values.h +3 -1
  33. data/ext/libsass/include/sass/version.h +1 -1
  34. data/ext/libsass/include/sass/version.h.in +1 -1
  35. data/ext/libsass/include/sass2scss.h +1 -1
  36. data/ext/libsass/res/resource.rc +6 -6
  37. data/ext/libsass/script/ci-build-libsass +10 -5
  38. data/ext/libsass/script/ci-build-plugin +62 -0
  39. data/ext/libsass/script/ci-install-compiler +1 -1
  40. data/ext/libsass/script/ci-install-deps +4 -7
  41. data/ext/libsass/script/ci-report-coverage +13 -3
  42. data/ext/libsass/script/tap-driver +1 -1
  43. data/ext/libsass/script/tap-runner +1 -1
  44. data/ext/libsass/src/GNUmakefile.am +1 -1
  45. data/ext/libsass/src/ast.cpp +537 -762
  46. data/ext/libsass/src/ast.hpp +377 -419
  47. data/ext/libsass/src/ast_def_macros.hpp +26 -1
  48. data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
  49. data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
  50. data/ext/libsass/src/b64/encode.h +3 -1
  51. data/ext/libsass/src/backtrace.cpp +46 -0
  52. data/ext/libsass/src/backtrace.hpp +7 -54
  53. data/ext/libsass/src/bind.cpp +72 -50
  54. data/ext/libsass/src/bind.hpp +0 -1
  55. data/ext/libsass/src/cencode.c +6 -0
  56. data/ext/libsass/src/check_nesting.cpp +157 -135
  57. data/ext/libsass/src/check_nesting.hpp +11 -10
  58. data/ext/libsass/src/color_maps.cpp +10 -6
  59. data/ext/libsass/src/color_maps.hpp +6 -8
  60. data/ext/libsass/src/constants.cpp +4 -3
  61. data/ext/libsass/src/constants.hpp +4 -3
  62. data/ext/libsass/src/context.cpp +110 -47
  63. data/ext/libsass/src/context.hpp +11 -1
  64. data/ext/libsass/src/cssize.cpp +105 -94
  65. data/ext/libsass/src/cssize.hpp +4 -5
  66. data/ext/libsass/src/debugger.hpp +247 -244
  67. data/ext/libsass/src/emitter.cpp +30 -6
  68. data/ext/libsass/src/emitter.hpp +7 -0
  69. data/ext/libsass/src/environment.cpp +67 -16
  70. data/ext/libsass/src/environment.hpp +28 -7
  71. data/ext/libsass/src/error_handling.cpp +92 -64
  72. data/ext/libsass/src/error_handling.hpp +64 -43
  73. data/ext/libsass/src/eval.cpp +494 -544
  74. data/ext/libsass/src/eval.hpp +17 -23
  75. data/ext/libsass/src/expand.cpp +182 -154
  76. data/ext/libsass/src/expand.hpp +4 -5
  77. data/ext/libsass/src/extend.cpp +299 -291
  78. data/ext/libsass/src/extend.hpp +46 -11
  79. data/ext/libsass/src/file.cpp +103 -36
  80. data/ext/libsass/src/file.hpp +21 -4
  81. data/ext/libsass/src/functions.cpp +561 -312
  82. data/ext/libsass/src/functions.hpp +8 -5
  83. data/ext/libsass/src/inspect.cpp +108 -53
  84. data/ext/libsass/src/inspect.hpp +5 -2
  85. data/ext/libsass/src/lexer.cpp +15 -7
  86. data/ext/libsass/src/lexer.hpp +13 -4
  87. data/ext/libsass/src/listize.cpp +3 -2
  88. data/ext/libsass/src/listize.hpp +0 -1
  89. data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
  90. data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
  91. data/ext/libsass/src/node.cpp +34 -38
  92. data/ext/libsass/src/node.hpp +6 -8
  93. data/ext/libsass/src/operation.hpp +2 -2
  94. data/ext/libsass/src/operators.cpp +240 -0
  95. data/ext/libsass/src/operators.hpp +30 -0
  96. data/ext/libsass/src/output.cpp +22 -20
  97. data/ext/libsass/src/parser.cpp +719 -358
  98. data/ext/libsass/src/parser.hpp +57 -22
  99. data/ext/libsass/src/plugins.cpp +28 -10
  100. data/ext/libsass/src/position.cpp +21 -3
  101. data/ext/libsass/src/position.hpp +2 -1
  102. data/ext/libsass/src/prelexer.cpp +104 -19
  103. data/ext/libsass/src/prelexer.hpp +10 -3
  104. data/ext/libsass/src/remove_placeholders.cpp +9 -10
  105. data/ext/libsass/src/remove_placeholders.hpp +1 -5
  106. data/ext/libsass/src/sass.cpp +62 -4
  107. data/ext/libsass/src/sass.hpp +5 -2
  108. data/ext/libsass/src/sass_context.cpp +96 -58
  109. data/ext/libsass/src/sass_context.hpp +7 -5
  110. data/ext/libsass/src/sass_functions.cpp +63 -1
  111. data/ext/libsass/src/sass_functions.hpp +19 -1
  112. data/ext/libsass/src/sass_util.cpp +3 -3
  113. data/ext/libsass/src/sass_util.hpp +4 -4
  114. data/ext/libsass/src/sass_values.cpp +42 -39
  115. data/ext/libsass/src/sass_values.hpp +2 -1
  116. data/ext/libsass/src/source_map.cpp +16 -18
  117. data/ext/libsass/src/subset_map.cpp +6 -8
  118. data/ext/libsass/src/subset_map.hpp +6 -6
  119. data/ext/libsass/src/to_c.cpp +2 -2
  120. data/ext/libsass/src/to_value.cpp +8 -3
  121. data/ext/libsass/src/to_value.hpp +1 -0
  122. data/ext/libsass/src/units.cpp +349 -45
  123. data/ext/libsass/src/units.hpp +39 -22
  124. data/ext/libsass/src/utf8/checked.h +7 -0
  125. data/ext/libsass/src/utf8/unchecked.h +7 -0
  126. data/ext/libsass/src/utf8_string.cpp +1 -1
  127. data/ext/libsass/src/util.cpp +139 -45
  128. data/ext/libsass/src/util.hpp +4 -7
  129. data/ext/libsass/src/values.cpp +15 -23
  130. data/ext/libsass/win/libsass.sln +13 -2
  131. data/ext/libsass/win/libsass.sln.DotSettings +9 -0
  132. data/ext/libsass/win/libsass.targets +3 -0
  133. data/ext/libsass/win/libsass.vcxproj.filters +9 -0
  134. data/lib/sassc/version.rb +1 -1
  135. data/sassc.gemspec +1 -1
  136. data/test/native_test.rb +1 -1
  137. metadata +11 -4
@@ -1,6 +1,5 @@
1
1
  #include "sass.hpp"
2
2
  #include <cctype>
3
- #include <cstddef>
4
3
  #include <iostream>
5
4
  #include <iomanip>
6
5
  #include "lexer.hpp"
@@ -50,6 +49,12 @@ namespace Sass {
50
49
  return unsigned(chr - '0') <= '9' - '0';
51
50
  }
52
51
 
52
+ bool is_number(const char& chr)
53
+ {
54
+ // adapted the technique from is_alpha
55
+ return is_digit(chr) || chr == '-' || chr == '+';
56
+ }
57
+
53
58
  bool is_xdigit(const char& chr)
54
59
  {
55
60
  // adapted the technique from is_alpha
@@ -80,10 +85,11 @@ namespace Sass {
80
85
  // but with specific ranges (copied from Ruby Sass)
81
86
  bool is_nonascii(const char& chr)
82
87
  {
88
+ unsigned int cmp = unsigned(chr);
83
89
  return (
84
- (unsigned(chr) >= 128 && unsigned(chr) <= 15572911) ||
85
- (unsigned(chr) >= 15630464 && unsigned(chr) <= 15712189) ||
86
- (unsigned(chr) >= 4036001920)
90
+ (cmp >= 128 && cmp <= 15572911) ||
91
+ (cmp >= 15630464 && cmp <= 15712189) ||
92
+ (cmp >= 4036001920)
87
93
  );
88
94
  }
89
95
 
@@ -91,15 +97,17 @@ namespace Sass {
91
97
  // valid in a uri (copied from Ruby Sass)
92
98
  bool is_uri_character(const char& chr)
93
99
  {
94
- return (unsigned(chr) > 41 && unsigned(chr) < 127) ||
95
- unsigned(chr) == ':' || unsigned(chr) == '/';
100
+ unsigned int cmp = unsigned(chr);
101
+ return (cmp > 41 && cmp < 127) ||
102
+ cmp == ':' || cmp == '/';
96
103
  }
97
104
 
98
105
  // check if char is within a reduced ascii range
99
106
  // valid for escaping (copied from Ruby Sass)
100
107
  bool is_escapable_character(const char& chr)
101
108
  {
102
- return unsigned(chr) > 31 && unsigned(chr) < 127;
109
+ unsigned int cmp = unsigned(chr);
110
+ return cmp > 31 && cmp < 127;
103
111
  }
104
112
 
105
113
  // Match word character (look ahead)
@@ -29,6 +29,7 @@ namespace Sass {
29
29
  bool is_alpha(const char& src);
30
30
  bool is_punct(const char& src);
31
31
  bool is_digit(const char& src);
32
+ bool is_number(const char& src);
32
33
  bool is_alnum(const char& src);
33
34
  bool is_xdigit(const char& src);
34
35
  bool is_unicode(const char& src);
@@ -96,9 +97,9 @@ namespace Sass {
96
97
  // Regex equivalent: /(?:literal)/
97
98
  template <const char* str>
98
99
  const char* exactly(const char* src) {
99
- if (str == 0) return 0;
100
+ if (str == NULL) return 0;
100
101
  const char* pre = str;
101
- if (src == 0) return 0;
102
+ if (src == NULL) return 0;
102
103
  // there is a small chance that the search string
103
104
  // is longer than the rest of the string to look at
104
105
  while (*pre && *src == *pre) {
@@ -109,14 +110,22 @@ namespace Sass {
109
110
  }
110
111
 
111
112
 
113
+ // Match a single character literal.
114
+ // Regex equivalent: /(?:x)/i
115
+ // only define lower case alpha chars
116
+ template <char chr>
117
+ const char* insensitive(const char* src) {
118
+ return *src == chr || *src+32 == chr ? src + 1 : 0;
119
+ }
120
+
112
121
  // Match the full string literal.
113
122
  // Regex equivalent: /(?:literal)/i
114
123
  // only define lower case alpha chars
115
124
  template <const char* str>
116
125
  const char* insensitive(const char* src) {
117
- if (str == 0) return 0;
126
+ if (str == NULL) return 0;
118
127
  const char* pre = str;
119
- if (src == 0) return 0;
128
+ if (src == NULL) return 0;
120
129
  // there is a small chance that the search string
121
130
  // is longer than the rest of the string to look at
122
131
  while (*pre && (*src == *pre || *src+32 == *pre)) {
@@ -64,13 +64,14 @@ namespace Sass {
64
64
  break;
65
65
  case Complex_Selector::ANCESTOR_OF:
66
66
  break;
67
+ default: break;
67
68
  }
68
69
 
69
70
  Complex_Selector_Obj tail = sel->tail();
70
71
  if (tail)
71
72
  {
72
73
  Expression_Obj tt = tail->perform(this);
73
- if (List_Ptr ls = SASS_MEMORY_CAST(List, tt))
74
+ if (List_Ptr ls = Cast<List>(tt))
74
75
  { l->concat(ls); }
75
76
  }
76
77
  if (l->length() == 0) return 0;
@@ -79,7 +80,7 @@ namespace Sass {
79
80
 
80
81
  Expression_Ptr Listize::fallback_impl(AST_Node_Ptr n)
81
82
  {
82
- return dynamic_cast<Expression_Ptr>(n);
83
+ return Cast<Expression>(n);
83
84
  }
84
85
 
85
86
  }
@@ -11,7 +11,6 @@
11
11
 
12
12
  namespace Sass {
13
13
 
14
- typedef Environment<AST_Node_Obj> Env;
15
14
  struct Backtrace;
16
15
 
17
16
  class Listize : public Operation_CRTP<Expression_Ptr, Listize> {
@@ -17,8 +17,8 @@ namespace Sass {
17
17
  std::cerr << "###################################\n";
18
18
  std::cerr << "# REPORTING MISSING DEALLOCATIONS #\n";
19
19
  std::cerr << "###################################\n";
20
- for (auto var : all) {
21
- if (AST_Node_Ptr ast = SASS_MEMORY_CAST_PTR(AST_Node, var)) {
20
+ for (SharedObj* var : all) {
21
+ if (AST_Node_Ptr ast = dynamic_cast<AST_Node*>(var)) {
22
22
  debug_ast(ast);
23
23
  } else {
24
24
  std::cerr << "LEAKED " << var << "\n";
@@ -37,22 +37,20 @@ namespace Sass {
37
37
  , dbg(false)
38
38
  #endif
39
39
  {
40
- refcounter = 0;
41
- #ifdef DEBUG_SHARED_PTR
42
- if (taint) all.push_back(this);
43
- #endif
44
- };
45
-
46
- SharedObj::~SharedObj() {
47
- #ifdef DEBUG_SHARED_PTR
48
- if (dbg) std::cerr << "Destruct " << this << "\n";
49
- if(!all.empty()) { // check needed for MSVC (no clue why?)
50
- all.erase(std::remove(all.begin(), all.end(), this), all.end());
51
- }
52
- #endif
53
- };
54
-
40
+ refcounter = 0;
41
+ #ifdef DEBUG_SHARED_PTR
42
+ if (taint) all.push_back(this);
43
+ #endif
44
+ };
55
45
 
46
+ SharedObj::~SharedObj() {
47
+ #ifdef DEBUG_SHARED_PTR
48
+ if (dbg) std::cerr << "Destruct " << this << "\n";
49
+ if(!all.empty()) { // check needed for MSVC (no clue why?)
50
+ all.erase(std::remove(all.begin(), all.end(), this), all.end());
51
+ }
52
+ #endif
53
+ };
56
54
 
57
55
  void SharedPtr::decRefCount() {
58
56
  if (node) {
@@ -62,7 +60,7 @@ namespace Sass {
62
60
  #endif
63
61
  if (node->refcounter == 0) {
64
62
  #ifdef DEBUG_SHARED_PTR
65
- AST_Node_Ptr ptr = SASS_MEMORY_CAST_PTR(AST_Node, node);
63
+ // AST_Node_Ptr ast = dynamic_cast<AST_Node*>(node);
66
64
  if (node->dbg) std::cerr << "DELETE NODE " << node << "\n";
67
65
  #endif
68
66
  if (!node->detached) {
@@ -17,7 +17,7 @@ namespace Sass {
17
17
  #ifdef DEBUG_SHARED_PTR
18
18
 
19
19
  #define SASS_MEMORY_NEW(Class, ...) \
20
- static_cast<Class##_Ptr>((new Class(__VA_ARGS__))->trace(__FILE__, __LINE__)) \
20
+ ((Class*)(new Class(__VA_ARGS__))->trace(__FILE__, __LINE__)) \
21
21
 
22
22
  #define SASS_MEMORY_COPY(obj) \
23
23
  ((obj)->copy(__FILE__, __LINE__)) \
@@ -38,12 +38,6 @@ namespace Sass {
38
38
 
39
39
  #endif
40
40
 
41
- #define SASS_MEMORY_CAST(Class, obj) \
42
- (dynamic_cast<Class##_Ptr>(&obj)) \
43
-
44
- #define SASS_MEMORY_CAST_PTR(Class, ptr) \
45
- (dynamic_cast<Class##_Ptr>(ptr)) \
46
-
47
41
  class SharedObj {
48
42
  protected:
49
43
  friend class SharedPtr;
@@ -92,9 +86,9 @@ namespace Sass {
92
86
 
93
87
 
94
88
  class SharedPtr {
95
- private:
89
+ protected:
96
90
  SharedObj* node;
97
- private:
91
+ protected:
98
92
  void decRefCount();
99
93
  void incRefCount();
100
94
  public:
@@ -103,24 +97,21 @@ namespace Sass {
103
97
  : node(NULL) {};
104
98
  // the create constructor
105
99
  SharedPtr(SharedObj* ptr);
106
- // copy assignment operator
107
- SharedPtr& operator=(const SharedPtr& rhs);
108
- // move assignment operator
109
- /* SharedPtr& operator=(SharedPtr&& rhs); */
110
100
  // the copy constructor
111
101
  SharedPtr(const SharedPtr& obj);
112
102
  // the move constructor
113
- /* SharedPtr(SharedPtr&& obj); */
114
- // destructor
115
- ~SharedPtr();
103
+ SharedPtr(SharedPtr&& obj);
104
+ // copy assignment operator
105
+ SharedPtr& operator=(const SharedPtr& obj);
106
+ // move assignment operator
107
+ SharedPtr& operator=(SharedPtr&& obj);
108
+ // pure virtual destructor
109
+ virtual ~SharedPtr() = 0;
116
110
  public:
117
- SharedObj* obj () {
118
- return node;
119
- };
120
111
  SharedObj* obj () const {
121
112
  return node;
122
113
  };
123
- SharedObj* operator-> () {
114
+ SharedObj* operator-> () const {
124
115
  return node;
125
116
  };
126
117
  bool isNull () {
@@ -129,68 +120,81 @@ namespace Sass {
129
120
  bool isNull () const {
130
121
  return node == NULL;
131
122
  };
132
- SharedObj* detach() {
133
- node->detached = true;
134
- return node;
135
- };
136
123
  SharedObj* detach() const {
137
124
  if (node) {
138
125
  node->detached = true;
139
126
  }
140
127
  return node;
141
128
  };
142
- operator bool() {
143
- return node != NULL;
144
- };
145
129
  operator bool() const {
146
130
  return node != NULL;
147
131
  };
148
132
 
149
133
  };
150
134
 
151
- template < typename T >
135
+ template < class T >
152
136
  class SharedImpl : private SharedPtr {
153
137
  public:
154
138
  SharedImpl()
155
139
  : SharedPtr(NULL) {};
156
140
  SharedImpl(T* node)
157
141
  : SharedPtr(node) {};
142
+ template < class U >
143
+ SharedImpl(SharedImpl<U> obj)
144
+ : SharedPtr(static_cast<T*>(obj.ptr())) {}
158
145
  SharedImpl(T&& node)
159
146
  : SharedPtr(node) {};
160
147
  SharedImpl(const T& node)
161
148
  : SharedPtr(node) {};
149
+ // the copy constructor
150
+ SharedImpl(const SharedImpl<T>& impl)
151
+ : SharedPtr(impl.node) {};
152
+ // the move constructor
153
+ SharedImpl(SharedImpl<T>&& impl)
154
+ : SharedPtr(impl.node) {};
155
+ // copy assignment operator
156
+ SharedImpl<T>& operator=(const SharedImpl<T>& rhs) {
157
+ if (node) decRefCount();
158
+ node = rhs.node;
159
+ incRefCount();
160
+ return *this;
161
+ }
162
+ // move assignment operator
163
+ SharedImpl<T>& operator=(SharedImpl<T>&& rhs) {
164
+ // don't move our self
165
+ if (this != &rhs) {
166
+ if (node) decRefCount();
167
+ node = std::move(rhs.node);
168
+ rhs.node = NULL;
169
+ }
170
+ return *this;
171
+ }
162
172
  ~SharedImpl() {};
163
173
  public:
164
- T* operator& () {
165
- return static_cast<T*>(this->obj());
166
- };
167
- T* operator& () const {
174
+ operator T*() const {
168
175
  return static_cast<T*>(this->obj());
169
- };
170
- T& operator* () {
176
+ }
177
+ operator T&() const {
171
178
  return *static_cast<T*>(this->obj());
172
- };
179
+ }
173
180
  T& operator* () const {
174
181
  return *static_cast<T*>(this->obj());
175
182
  };
176
- T* operator-> () {
177
- return static_cast<T*>(this->obj());
178
- };
179
183
  T* operator-> () const {
180
184
  return static_cast<T*>(this->obj());
181
185
  };
182
- T* ptr () {
186
+ T* ptr () const {
183
187
  return static_cast<T*>(this->obj());
184
188
  };
185
- T* detach() {
189
+ T* detach() const {
186
190
  if (this->obj() == NULL) return NULL;
187
191
  return static_cast<T*>(SharedPtr::detach());
188
192
  }
189
- bool isNull() {
193
+ bool isNull() const {
190
194
  return this->obj() == NULL;
191
195
  }
192
- operator bool() {
193
- return this->obj() != NULL;
196
+ bool operator<(const T& rhs) const {
197
+ return *this->ptr() < rhs;
194
198
  };
195
199
  operator bool() const {
196
200
  return this->obj() != NULL;
@@ -14,15 +14,15 @@ namespace Sass {
14
14
  }
15
15
 
16
16
 
17
- Node Node::createSelector(Complex_Selector_Ptr pSelector, Context& ctx) {
17
+ Node Node::createSelector(const Complex_Selector& pSelector) {
18
18
  NodeDequePtr null;
19
19
 
20
- Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(pSelector);
20
+ Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(&pSelector);
21
21
  pStripped->tail(NULL);
22
22
  pStripped->combinator(Complex_Selector::ANCESTOR_OF);
23
23
 
24
24
  Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
25
- if (pSelector) n.got_line_feed = pSelector->has_line_feed();
25
+ n.got_line_feed = pSelector.has_line_feed();
26
26
  return n;
27
27
  }
28
28
 
@@ -50,12 +50,12 @@ namespace Sass {
50
50
  { if (pSelector) got_line_feed = pSelector->has_line_feed(); }
51
51
 
52
52
 
53
- Node Node::klone(Context& ctx) const {
53
+ Node Node::klone() const {
54
54
  NodeDequePtr pNewCollection = std::make_shared<NodeDeque>();
55
55
  if (mpCollection) {
56
56
  for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
57
57
  Node& toClone = *iter;
58
- pNewCollection->push_back(toClone.klone(ctx));
58
+ pNewCollection->push_back(toClone.klone());
59
59
  }
60
60
  }
61
61
 
@@ -65,13 +65,13 @@ namespace Sass {
65
65
  }
66
66
 
67
67
 
68
- bool Node::contains(const Node& potentialChild, bool simpleSelectorOrderDependent) const {
69
- bool found = false;
68
+ bool Node::contains(const Node& potentialChild) const {
69
+ bool found = false;
70
70
 
71
71
  for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
72
72
  Node& toTest = *iter;
73
73
 
74
- if (nodesEqual(toTest, potentialChild, simpleSelectorOrderDependent)) {
74
+ if (toTest == potentialChild) {
75
75
  found = true;
76
76
  break;
77
77
  }
@@ -82,37 +82,32 @@ namespace Sass {
82
82
 
83
83
 
84
84
  bool Node::operator==(const Node& rhs) const {
85
- return nodesEqual(*this, rhs, true /*simpleSelectorOrderDependent*/);
86
- }
87
-
88
-
89
- bool nodesEqual(const Node& lhs, const Node& rhs, bool simpleSelectorOrderDependent) {
90
- if (lhs.type() != rhs.type()) {
85
+ if (this->type() != rhs.type()) {
91
86
  return false;
92
87
  }
93
88
 
94
- if (lhs.isCombinator()) {
89
+ if (this->isCombinator()) {
95
90
 
96
- return lhs.combinator() == rhs.combinator();
91
+ return this->combinator() == rhs.combinator();
97
92
 
98
- } else if (lhs.isNil()) {
93
+ } else if (this->isNil()) {
99
94
 
100
95
  return true; // no state to check
101
96
 
102
- } else if (lhs.isSelector()){
97
+ } else if (this->isSelector()){
103
98
 
104
- return selectors_equal(*&lhs.selector(), *&rhs.selector(), simpleSelectorOrderDependent);
99
+ return *this->selector() == *rhs.selector();
105
100
 
106
- } else if (lhs.isCollection()) {
101
+ } else if (this->isCollection()) {
107
102
 
108
- if (lhs.collection()->size() != rhs.collection()->size()) {
103
+ if (this->collection()->size() != rhs.collection()->size()) {
109
104
  return false;
110
105
  }
111
106
 
112
- for (NodeDeque::iterator lhsIter = lhs.collection()->begin(), lhsIterEnd = lhs.collection()->end(),
107
+ for (NodeDeque::iterator lhsIter = this->collection()->begin(), lhsIterEnd = this->collection()->end(),
113
108
  rhsIter = rhs.collection()->begin(); lhsIter != lhsIterEnd; lhsIter++, rhsIter++) {
114
109
 
115
- if (!nodesEqual(*lhsIter, *rhsIter, simpleSelectorOrderDependent)) {
110
+ if (*lhsIter != *rhsIter) {
116
111
  return false;
117
112
  }
118
113
 
@@ -128,10 +123,10 @@ namespace Sass {
128
123
 
129
124
 
130
125
  void Node::plus(Node& rhs) {
131
- if (!this->isCollection() || !rhs.isCollection()) {
132
- throw "Both the current node and rhs must be collections.";
126
+ if (!this->isCollection() || !rhs.isCollection()) {
127
+ throw "Both the current node and rhs must be collections.";
133
128
  }
134
- this->collection()->insert(this->collection()->end(), rhs.collection()->begin(), rhs.collection()->end());
129
+ this->collection()->insert(this->collection()->end(), rhs.collection()->begin(), rhs.collection()->end());
135
130
  }
136
131
 
137
132
  #ifdef DEBUG
@@ -177,7 +172,7 @@ namespace Sass {
177
172
  #endif
178
173
 
179
174
 
180
- Node complexSelectorToNode(Complex_Selector_Ptr pToConvert, Context& ctx) {
175
+ Node complexSelectorToNode(Complex_Selector_Ptr pToConvert) {
181
176
  if (pToConvert == NULL) {
182
177
  return Node::createNil();
183
178
  }
@@ -189,20 +184,22 @@ namespace Sass {
189
184
  if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
190
185
  Complex_Selector_Obj tail = pToConvert->tail();
191
186
  if (tail) tail->has_line_feed(pToConvert->has_line_feed());
192
- pToConvert = &tail;
187
+ pToConvert = tail;
193
188
  }
194
189
 
195
190
  while (pToConvert) {
196
191
 
197
192
  bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();
198
193
 
199
- if (pToConvert->head() || empty_parent_ref) {
200
- }
201
-
202
194
  // the first Complex_Selector may contain a dummy head pointer, skip it.
203
195
  if (pToConvert->head() && !empty_parent_ref) {
204
- node.collection()->push_back(Node::createSelector(pToConvert, ctx));
196
+ node.collection()->push_back(Node::createSelector(*pToConvert));
205
197
  if (has_lf) node.collection()->back().got_line_feed = has_lf;
198
+ if (pToConvert->head() || empty_parent_ref) {
199
+ if (pToConvert->tail()) {
200
+ pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
201
+ }
202
+ }
206
203
  has_lf = false;
207
204
  }
208
205
 
@@ -216,14 +213,14 @@ namespace Sass {
216
213
  // pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
217
214
  }
218
215
 
219
- pToConvert = &pToConvert->tail();
216
+ pToConvert = pToConvert->tail();
220
217
  }
221
218
 
222
219
  return node;
223
220
  }
224
221
 
225
222
 
226
- Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert, Context& ctx) {
223
+ Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert) {
227
224
  if (toConvert.isNil()) {
228
225
  return NULL;
229
226
  }
@@ -237,7 +234,6 @@ namespace Sass {
237
234
  NodeDeque& childNodes = *toConvert.collection();
238
235
 
239
236
  std::string noPath("");
240
- Position noPosition(-1, -1, -1);
241
237
  Complex_Selector_Obj pFirst = SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
242
238
 
243
239
  Complex_Selector_Obj pCurrent = pFirst;
@@ -254,7 +250,7 @@ namespace Sass {
254
250
  // collections, and can result in an infinite loop during the call to parentSuperselector()
255
251
  pCurrent->tail(SASS_MEMORY_COPY(child.selector()));
256
252
  // if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
257
- pCurrent = &pCurrent->tail();
253
+ pCurrent = pCurrent->tail();
258
254
  } else if (child.isCombinator()) {
259
255
  pCurrent->combinator(child.combinator());
260
256
  if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
@@ -265,7 +261,7 @@ namespace Sass {
265
261
  if (nextNode.isCombinator()) {
266
262
  pCurrent->tail(SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
267
263
  if (nextNode.got_line_feed) pCurrent->tail()->has_line_feed(nextNode.got_line_feed);
268
- pCurrent = &pCurrent->tail();
264
+ pCurrent = pCurrent->tail();
269
265
  }
270
266
  }
271
267
  } else {
@@ -285,7 +281,7 @@ namespace Sass {
285
281
 
286
282
  // A very naive trim function, which removes duplicates in a node
287
283
  // This is only used in Complex_Selector::unify_with for now, may need modifications to fit other needs
288
- Node Node::naiveTrim(Node& seqses, Context& ctx) {
284
+ Node Node::naiveTrim(Node& seqses) {
289
285
 
290
286
  std::vector<Node*> res;
291
287
  std::vector<Complex_Selector_Obj> known;