sassc 1.7.1 → 1.8.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.gitignore +10 -6
  4. data/ext/libsass/.travis.yml +4 -1
  5. data/ext/libsass/GNUmakefile.am +88 -0
  6. data/ext/libsass/Makefile +157 -76
  7. data/ext/libsass/Makefile.conf +47 -0
  8. data/ext/libsass/Readme.md +13 -14
  9. data/ext/libsass/appveyor.yml +25 -41
  10. data/ext/libsass/configure.ac +20 -7
  11. data/ext/libsass/contrib/plugin.cpp +1 -1
  12. data/ext/libsass/include/sass.h +15 -0
  13. data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
  14. data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
  15. data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
  16. data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
  17. data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
  18. data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
  19. data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
  20. data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
  21. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
  22. data/ext/libsass/script/ci-build-libsass +67 -23
  23. data/ext/libsass/src/GNUmakefile.am +54 -0
  24. data/ext/libsass/src/ast.cpp +2029 -0
  25. data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
  26. data/ext/libsass/src/ast_def_macros.hpp +47 -0
  27. data/ext/libsass/src/ast_factory.hpp +93 -0
  28. data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
  29. data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
  30. data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
  31. data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
  32. data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
  33. data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
  34. data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
  35. data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
  36. data/ext/libsass/src/c99func.c +54 -0
  37. data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
  38. data/ext/libsass/src/color_maps.cpp +643 -0
  39. data/ext/libsass/src/color_maps.hpp +333 -0
  40. data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
  41. data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
  42. data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
  43. data/ext/libsass/src/context.hpp +150 -0
  44. data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
  45. data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
  46. data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
  47. data/ext/libsass/src/debugger.hpp +683 -0
  48. data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
  49. data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
  50. data/ext/libsass/src/environment.cpp +184 -0
  51. data/ext/libsass/src/environment.hpp +92 -0
  52. data/ext/libsass/src/error_handling.cpp +46 -0
  53. data/ext/libsass/src/error_handling.hpp +34 -0
  54. data/ext/libsass/src/eval.cpp +1462 -0
  55. data/ext/libsass/src/eval.hpp +107 -0
  56. data/ext/libsass/src/expand.cpp +653 -0
  57. data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
  58. data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
  59. data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
  60. data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
  61. data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
  62. data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
  63. data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
  64. data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
  65. data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
  66. data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
  67. data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
  68. data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
  69. data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
  70. data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
  71. data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
  72. data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
  73. data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
  74. data/ext/libsass/src/memory_manager.cpp +76 -0
  75. data/ext/libsass/src/memory_manager.hpp +48 -0
  76. data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
  77. data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
  78. data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
  79. data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
  80. data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
  81. data/ext/libsass/src/parser.cpp +2529 -0
  82. data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
  83. data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
  84. data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
  85. data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
  86. data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
  87. data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
  88. data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
  89. data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
  90. data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
  91. data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
  92. data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
  93. data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
  94. data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
  95. data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
  96. data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
  97. data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
  98. data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
  99. data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
  100. data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
  101. data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
  102. data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
  103. data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
  104. data/ext/libsass/src/to_c.cpp +73 -0
  105. data/ext/libsass/src/to_c.hpp +41 -0
  106. data/ext/libsass/src/to_string.cpp +47 -0
  107. data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
  108. data/ext/libsass/src/to_value.cpp +109 -0
  109. data/ext/libsass/src/to_value.hpp +50 -0
  110. data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
  111. data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
  112. data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
  113. data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
  114. data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
  115. data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
  116. data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
  117. data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
  118. data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
  119. data/ext/libsass/src/util.hpp +59 -0
  120. data/ext/libsass/src/values.cpp +137 -0
  121. data/ext/libsass/src/values.hpp +12 -0
  122. data/ext/libsass/test/test_node.cpp +33 -33
  123. data/ext/libsass/test/test_paths.cpp +5 -6
  124. data/ext/libsass/test/test_selector_difference.cpp +4 -5
  125. data/ext/libsass/test/test_specificity.cpp +4 -5
  126. data/ext/libsass/test/test_subset_map.cpp +91 -91
  127. data/ext/libsass/test/test_superselector.cpp +11 -11
  128. data/ext/libsass/test/test_unification.cpp +4 -4
  129. data/ext/libsass/win/libsass.targets +101 -0
  130. data/ext/libsass/win/libsass.vcxproj +45 -127
  131. data/ext/libsass/win/libsass.vcxproj.filters +303 -0
  132. data/lib/sassc/import_handler.rb +1 -1
  133. data/lib/sassc/native/native_functions_api.rb +3 -3
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/custom_importer_test.rb +1 -4
  136. data/test/functions_test.rb +3 -2
  137. data/test/native_test.rb +4 -3
  138. metadata +117 -110
  139. data/ext/libsass/Makefile.am +0 -146
  140. data/ext/libsass/ast.cpp +0 -945
  141. data/ext/libsass/ast_def_macros.hpp +0 -21
  142. data/ext/libsass/ast_factory.hpp +0 -92
  143. data/ext/libsass/color_names.hpp +0 -327
  144. data/ext/libsass/context.hpp +0 -157
  145. data/ext/libsass/contextualize.cpp +0 -148
  146. data/ext/libsass/contextualize.hpp +0 -46
  147. data/ext/libsass/contextualize_eval.cpp +0 -93
  148. data/ext/libsass/contextualize_eval.hpp +0 -44
  149. data/ext/libsass/debugger.hpp +0 -558
  150. data/ext/libsass/environment.hpp +0 -163
  151. data/ext/libsass/error_handling.cpp +0 -35
  152. data/ext/libsass/error_handling.hpp +0 -32
  153. data/ext/libsass/eval.cpp +0 -1392
  154. data/ext/libsass/eval.hpp +0 -88
  155. data/ext/libsass/expand.cpp +0 -575
  156. data/ext/libsass/memory_manager.hpp +0 -57
  157. data/ext/libsass/parser.cpp +0 -2403
  158. data/ext/libsass/posix/getopt.c +0 -562
  159. data/ext/libsass/posix/getopt.h +0 -95
  160. data/ext/libsass/to_c.cpp +0 -61
  161. data/ext/libsass/to_c.hpp +0 -44
  162. data/ext/libsass/to_string.cpp +0 -34
  163. data/ext/libsass/util.hpp +0 -54
  164. data/ext/libsass/win/libsass.filters +0 -312
@@ -0,0 +1,76 @@
1
+ #include "ast.hpp"
2
+ #include "memory_manager.hpp"
3
+
4
+ namespace Sass {
5
+
6
+ Memory_Manager::Memory_Manager(size_t size)
7
+ : nodes(std::vector<Memory_Object*>())
8
+ {
9
+ size_t init = size;
10
+ if (init < 8) init = 8;
11
+ // reserve some space
12
+ nodes.reserve(init);
13
+ }
14
+
15
+ Memory_Manager::~Memory_Manager()
16
+ {
17
+ // release memory for all controlled nodes
18
+ // avoid calling erase for every single node
19
+ for (size_t i = 0, S = nodes.size(); i < S; ++i) {
20
+ deallocate(nodes[i]);
21
+ }
22
+ // just in case
23
+ nodes.clear();
24
+ }
25
+
26
+ Memory_Object* Memory_Manager::add(Memory_Object* np)
27
+ {
28
+ // object has been initialized
29
+ // it can be "deleted" from now on
30
+ np->refcount = 1;
31
+ return np;
32
+ }
33
+
34
+ bool Memory_Manager::has(Memory_Object* np)
35
+ {
36
+ // check if the pointer is controlled under our pool
37
+ return find(nodes.begin(), nodes.end(), np) != nodes.end();
38
+ }
39
+
40
+ Memory_Object* Memory_Manager::allocate(size_t size)
41
+ {
42
+ // allocate requested memory
43
+ void* heap = malloc(size);
44
+ // init internal refcount status to zero
45
+ (static_cast<Memory_Object*>(heap))->refcount = 0;
46
+ // add the memory under our management
47
+ nodes.push_back(static_cast<Memory_Object*>(heap));
48
+ // cast object to its initial type
49
+ return static_cast<Memory_Object*>(heap);
50
+ }
51
+
52
+ void Memory_Manager::deallocate(Memory_Object* np)
53
+ {
54
+ // only call destructor if initialized
55
+ if (np->refcount) np->~Memory_Object();
56
+ // always free the memory
57
+ free(np);
58
+ }
59
+
60
+ void Memory_Manager::remove(Memory_Object* np)
61
+ {
62
+ // remove node from pool (no longer active)
63
+ nodes.erase(find(nodes.begin(), nodes.end(), np));
64
+ // you are now in control of the memory
65
+ }
66
+
67
+ void Memory_Manager::destroy(Memory_Object* np)
68
+ {
69
+ // remove from pool
70
+ remove(np);
71
+ // release memory
72
+ deallocate(np);
73
+ }
74
+
75
+ }
76
+
@@ -0,0 +1,48 @@
1
+ #ifndef SASS_MEMORY_MANAGER_H
2
+ #define SASS_MEMORY_MANAGER_H
3
+
4
+ #include <vector>
5
+
6
+ namespace Sass {
7
+
8
+ class Memory_Object {
9
+ friend class Memory_Manager;
10
+ long refcount;
11
+ public:
12
+ Memory_Object() { refcount = 0; };
13
+ virtual ~Memory_Object() {};
14
+ };
15
+
16
+ /////////////////////////////////////////////////////////////////////////////
17
+ // A class for tracking allocations of AST_Node objects. The intended usage
18
+ // is something like: Some_Node* n = new (mem_mgr) Some_Node(...);
19
+ // Then, at the end of the program, the memory manager will delete all of the
20
+ // allocated nodes that have been passed to it.
21
+ // In the future, this class may implement a custom allocator.
22
+ /////////////////////////////////////////////////////////////////////////////
23
+ class Memory_Manager {
24
+ std::vector<Memory_Object*> nodes;
25
+
26
+ public:
27
+ Memory_Manager(size_t size = 0);
28
+ ~Memory_Manager();
29
+
30
+ bool has(Memory_Object* np);
31
+ Memory_Object* allocate(size_t size);
32
+ void deallocate(Memory_Object* np);
33
+ void remove(Memory_Object* np);
34
+ void destroy(Memory_Object* np);
35
+ Memory_Object* add(Memory_Object* np);
36
+
37
+ };
38
+ }
39
+
40
+ ///////////////////////////////////////////////////////////////////////////////
41
+ // Use macros for the allocation task, since overloading operator `new`
42
+ // has been proven to be flaky under certain compilers (see comment below).
43
+ ///////////////////////////////////////////////////////////////////////////////
44
+
45
+ #define SASS_MEMORY_NEW(mgr, Class, ...) \
46
+ (static_cast<Class*>(mgr.add(new (mgr.allocate(sizeof(Class))) Class(__VA_ARGS__)))) \
47
+
48
+ #endif
@@ -1,3 +1,5 @@
1
+ #include <vector>
2
+
1
3
  #include "node.hpp"
2
4
  #include "to_string.hpp"
3
5
  #include "context.hpp"
@@ -19,18 +21,20 @@ namespace Sass {
19
21
  pStripped->tail(NULL);
20
22
  pStripped->combinator(Complex_Selector::ANCESTOR_OF);
21
23
 
22
- return Node(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
24
+ Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
25
+ if (pSelector) n.got_line_feed = pSelector->has_line_feed();
26
+ return n;
23
27
  }
24
28
 
25
29
 
26
30
  Node Node::createCollection() {
27
- NodeDequePtr pEmptyCollection = make_shared<NodeDeque>();
31
+ NodeDequePtr pEmptyCollection = std::make_shared<NodeDeque>();
28
32
  return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pEmptyCollection);
29
33
  }
30
34
 
31
35
 
32
36
  Node Node::createCollection(const NodeDeque& values) {
33
- NodeDequePtr pShallowCopiedCollection = make_shared<NodeDeque>(values);
37
+ NodeDequePtr pShallowCopiedCollection = std::make_shared<NodeDeque>(values);
34
38
  return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pShallowCopiedCollection);
35
39
  }
36
40
 
@@ -43,11 +47,11 @@ namespace Sass {
43
47
 
44
48
  Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection)
45
49
  : got_line_feed(false), mType(type), mCombinator(combinator), mpSelector(pSelector), mpCollection(pCollection)
46
- { /* if (pSelector) got_line_feed = pSelector->has_line_feed(); */ }
50
+ { if (pSelector) got_line_feed = pSelector->has_line_feed(); }
47
51
 
48
52
 
49
53
  Node Node::clone(Context& ctx) const {
50
- NodeDequePtr pNewCollection = make_shared<NodeDeque>();
54
+ NodeDequePtr pNewCollection = std::make_shared<NodeDeque>();
51
55
  if (mpCollection) {
52
56
  for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
53
57
  Node& toClone = *iter;
@@ -55,7 +59,9 @@ namespace Sass {
55
59
  }
56
60
  }
57
61
 
58
- return Node(mType, mCombinator, mpSelector ? mpSelector->clone(ctx) : NULL, pNewCollection);
62
+ Node n(mType, mCombinator, mpSelector ? mpSelector->clone(ctx) : NULL, pNewCollection);
63
+ n.got_line_feed = got_line_feed;
64
+ return n;
59
65
  }
60
66
 
61
67
 
@@ -129,7 +135,7 @@ namespace Sass {
129
135
  }
130
136
 
131
137
  #ifdef DEBUG
132
- ostream& operator<<(ostream& os, const Node& node) {
138
+ std::ostream& operator<<(std::ostream& os, const Node& node) {
133
139
 
134
140
  if (node.isCombinator()) {
135
141
 
@@ -138,6 +144,7 @@ namespace Sass {
138
144
  case Complex_Selector::PARENT_OF: os << "\">\""; break;
139
145
  case Complex_Selector::PRECEDES: os << "\"~\""; break;
140
146
  case Complex_Selector::ADJACENT_TO: os << "\"+\""; break;
147
+ case Complex_Selector::REFERENCE: os << "\"/\""; break;
141
148
  }
142
149
 
143
150
  } else if (node.isNil()) {
@@ -151,14 +158,14 @@ namespace Sass {
151
158
 
152
159
  } else if (node.isCollection()) {
153
160
 
154
- os << "[";
161
+ os << "[";
155
162
 
156
163
  for (NodeDeque::iterator iter = node.collection()->begin(), iterBegin = node.collection()->begin(), iterEnd = node.collection()->end(); iter != iterEnd; iter++) {
157
164
  if (iter != iterBegin) {
158
165
  os << ", ";
159
166
  }
160
167
 
161
- os << (*iter);
168
+ os << (*iter);
162
169
  }
163
170
 
164
171
  os << "]";
@@ -175,18 +182,39 @@ namespace Sass {
175
182
  if (pToConvert == NULL) {
176
183
  return Node::createNil();
177
184
  }
178
-
179
185
  Node node = Node::createCollection();
186
+ node.got_line_feed = pToConvert->has_line_feed();
187
+ bool has_lf = pToConvert->has_line_feed();
188
+
189
+ // unwrap the selector from parent ref
190
+ if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
191
+ Complex_Selector* tail = pToConvert->tail();
192
+ if (tail) tail->has_line_feed(pToConvert->has_line_feed());
193
+ pToConvert = tail;
194
+ }
180
195
 
181
196
  while (pToConvert) {
182
197
 
198
+ bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();
199
+
200
+ if (pToConvert->head() == NULL || empty_parent_ref) {
201
+ }
202
+
183
203
  // the first Complex_Selector may contain a dummy head pointer, skip it.
184
- if (pToConvert->head() != NULL && !pToConvert->head()->is_empty_reference()) {
204
+ if (pToConvert->head() != NULL && !empty_parent_ref) {
185
205
  node.collection()->push_back(Node::createSelector(pToConvert, ctx));
206
+ if (has_lf) node.collection()->back().got_line_feed = has_lf;
207
+ has_lf = false;
186
208
  }
187
209
 
188
210
  if (pToConvert->combinator() != Complex_Selector::ANCESTOR_OF) {
189
211
  node.collection()->push_back(Node::createCombinator(pToConvert->combinator()));
212
+ if (has_lf) node.collection()->back().got_line_feed = has_lf;
213
+ has_lf = false;
214
+ }
215
+
216
+ if (pToConvert && empty_parent_ref && pToConvert->tail()) {
217
+ // pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
190
218
  }
191
219
 
192
220
  pToConvert = pToConvert->tail();
@@ -209,26 +237,33 @@ namespace Sass {
209
237
 
210
238
  NodeDeque& childNodes = *toConvert.collection();
211
239
 
212
- string noPath("");
240
+ std::string noPath("");
213
241
  Position noPosition(-1, -1, -1);
214
- Complex_Selector* pFirst = new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
242
+ Complex_Selector* pFirst = SASS_MEMORY_NEW(ctx.mem, Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
243
+
215
244
  Complex_Selector* pCurrent = pFirst;
216
245
 
246
+ if (toConvert.isSelector()) pFirst->has_line_feed(toConvert.got_line_feed);
247
+ if (toConvert.isCombinator()) pFirst->has_line_feed(toConvert.got_line_feed);
248
+
217
249
  for (NodeDeque::iterator childIter = childNodes.begin(), childIterEnd = childNodes.end(); childIter != childIterEnd; childIter++) {
218
250
 
219
251
  Node& child = *childIter;
220
252
 
221
253
  if (child.isSelector()) {
222
254
  pCurrent->tail(child.selector()->clone(ctx)); // JMA - need to clone the selector, because they can end up getting shared across Node collections, and can result in an infinite loop during the call to parentSuperselector()
255
+ // if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
223
256
  pCurrent = pCurrent->tail();
224
257
  } else if (child.isCombinator()) {
225
258
  pCurrent->combinator(child.combinator());
259
+ if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
226
260
 
227
261
  // if the next node is also a combinator, create another Complex_Selector to hold it so it doesn't replace the current combinator
228
262
  if (childIter+1 != childIterEnd) {
229
263
  Node& nextNode = *(childIter+1);
230
264
  if (nextNode.isCombinator()) {
231
- pCurrent->tail(new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
265
+ pCurrent->tail(SASS_MEMORY_NEW(ctx.mem, Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
266
+ if (nextNode.got_line_feed) pCurrent->tail()->has_line_feed(nextNode.got_line_feed);
232
267
  pCurrent = pCurrent->tail();
233
268
  }
234
269
  }
@@ -238,14 +273,50 @@ namespace Sass {
238
273
  }
239
274
 
240
275
  // Put the dummy Compound_Selector in the first position, for consistency with the rest of libsass
241
- Compound_Selector* fakeHead = new (ctx.mem) Compound_Selector(ParserState("[NODE]"), 1);
242
- Selector_Reference* selectorRef = new (ctx.mem) Selector_Reference(ParserState("[NODE]"), NULL);
276
+ Compound_Selector* fakeHead = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, ParserState("[NODE]"), 1);
277
+ Parent_Selector* selectorRef = SASS_MEMORY_NEW(ctx.mem, Parent_Selector, ParserState("[NODE]"));
243
278
  fakeHead->elements().push_back(selectorRef);
279
+ if (toConvert.got_line_feed) pFirst->has_line_feed(toConvert.got_line_feed);
280
+ // pFirst->has_line_feed(pFirst->has_line_feed() || pFirst->tail()->has_line_feed() || toConvert.got_line_feed);
244
281
  pFirst->head(fakeHead);
245
- pFirst->has_line_feed(pFirst->has_line_feed() || pFirst->tail()->has_line_feed() || toConvert.got_line_feed);
246
-
247
282
  return pFirst;
248
283
  }
249
284
 
285
+ // A very naive trim function, which removes duplicates in a node
286
+ // This is only used in Complex_Selector::unify_with for now, may need modifications to fit other needs
287
+ Node Node::naiveTrim(Node& seqses, Context& ctx) {
288
+
289
+ std::vector<Node*> res;
290
+ std::vector<Complex_Selector*> known;
291
+
292
+ NodeDeque::reverse_iterator seqsesIter = seqses.collection()->rbegin(),
293
+ seqsesIterEnd = seqses.collection()->rend();
294
+
295
+ for (; seqsesIter != seqsesIterEnd; ++seqsesIter)
296
+ {
297
+ Node& seqs1 = *seqsesIter;
298
+ if( seqs1.isSelector() ) {
299
+ Complex_Selector* sel = seqs1.selector();
300
+ std::vector<Complex_Selector*>::iterator it;
301
+ bool found = false;
302
+ for (it = known.begin(); it != known.end(); ++it) {
303
+ if (**it == *sel) { found = true; break; }
304
+ }
305
+ if( !found ) {
306
+ known.push_back(seqs1.selector());
307
+ res.push_back(&seqs1);
308
+ }
309
+ } else {
310
+ res.push_back(&seqs1);
311
+ }
312
+ }
313
+
314
+ Node result = Node::createCollection();
250
315
 
316
+ for (size_t i = res.size() - 1; i != std::string::npos; --i) {
317
+ result.collection()->push_back(*res[i]);
318
+ }
319
+
320
+ return result;
321
+ }
251
322
  }
@@ -2,7 +2,6 @@
2
2
  #define SASS_NODE_H
3
3
 
4
4
  #include <deque>
5
- #include <iostream>
6
5
  #include <memory>
7
6
 
8
7
  #include "ast.hpp"
@@ -11,7 +10,6 @@
11
10
  namespace Sass {
12
11
 
13
12
 
14
- using namespace std;
15
13
 
16
14
 
17
15
  class Context;
@@ -33,8 +31,8 @@ namespace Sass {
33
31
  */
34
32
 
35
33
  class Node;
36
- typedef deque<Node> NodeDeque;
37
- typedef shared_ptr<NodeDeque> NodeDequePtr;
34
+ typedef std::deque<Node> NodeDeque;
35
+ typedef std::shared_ptr<NodeDeque> NodeDequePtr;
38
36
 
39
37
  class Node {
40
38
  public:
@@ -45,7 +43,7 @@ namespace Sass {
45
43
  NIL
46
44
  };
47
45
 
48
- TYPE type() const { return mType; }
46
+ TYPE type() const { return mType; }
49
47
  bool isCombinator() const { return mType == COMBINATOR; }
50
48
  bool isSelector() const { return mType == SELECTOR; }
51
49
  bool isCollection() const { return mType == COLLECTION; }
@@ -69,6 +67,7 @@ namespace Sass {
69
67
  static Node createCollection(const NodeDeque& values);
70
68
 
71
69
  static Node createNil();
70
+ static Node naiveTrim(Node& seqses, Context& ctx);
72
71
 
73
72
  Node clone(Context& ctx) const;
74
73
 
@@ -109,7 +108,7 @@ namespace Sass {
109
108
  };
110
109
 
111
110
  #ifdef DEBUG
112
- ostream& operator<<(ostream& os, const Node& node);
111
+ std::ostream& operator<<(std::ostream& os, const Node& node);
113
112
  #endif
114
113
  Node complexSelectorToNode(Complex_Selector* pToConvert, Context& ctx);
115
114
  Complex_Selector* nodeToComplexSelector(const Node& toConvert, Context& ctx);
@@ -1,13 +1,9 @@
1
1
  #ifndef SASS_OPERATION_H
2
2
  #define SASS_OPERATION_H
3
3
 
4
- #include <iostream>
5
- #include <typeinfo>
6
-
7
4
  #include "ast_fwd_decl.hpp"
8
5
 
9
6
  namespace Sass {
10
- using namespace std;
11
7
 
12
8
  template<typename T>
13
9
  class Operation {
@@ -19,7 +15,7 @@ namespace Sass {
19
15
  virtual T operator()(Ruleset* x) = 0;
20
16
  virtual T operator()(Propset* x) = 0;
21
17
  virtual T operator()(Bubble* x) = 0;
22
- virtual T operator()(Feature_Block* x) = 0;
18
+ virtual T operator()(Supports_Block* x) = 0;
23
19
  virtual T operator()(Media_Block* x) = 0;
24
20
  virtual T operator()(At_Root_Block* x) = 0;
25
21
  virtual T operator()(At_Rule* x) = 0;
@@ -48,15 +44,21 @@ namespace Sass {
48
44
  virtual T operator()(Unary_Expression* x) = 0;
49
45
  virtual T operator()(Function_Call* x) = 0;
50
46
  virtual T operator()(Function_Call_Schema* x) = 0;
47
+ virtual T operator()(Custom_Warning* x) = 0;
48
+ virtual T operator()(Custom_Error* x) = 0;
51
49
  virtual T operator()(Variable* x) = 0;
52
50
  virtual T operator()(Textual* x) = 0;
53
51
  virtual T operator()(Number* x) = 0;
54
52
  virtual T operator()(Color* x) = 0;
55
53
  virtual T operator()(Boolean* x) = 0;
56
54
  virtual T operator()(String_Schema* x) = 0;
55
+ virtual T operator()(String_Quoted* x) = 0;
57
56
  virtual T operator()(String_Constant* x) = 0;
58
- virtual T operator()(Feature_Query* x) = 0;
59
- virtual T operator()(Feature_Query_Condition* x)= 0;
57
+ virtual T operator()(Supports_Condition* x) = 0;
58
+ virtual T operator()(Supports_Operator* x) = 0;
59
+ virtual T operator()(Supports_Negation* x) = 0;
60
+ virtual T operator()(Supports_Declaration* x) = 0;
61
+ virtual T operator()(Supports_Interpolation* x) = 0;
60
62
  virtual T operator()(Media_Query* x) = 0;
61
63
  virtual T operator()(Media_Query_Expression* x) = 0;
62
64
  virtual T operator()(At_Root_Expression* x) = 0;
@@ -69,7 +71,6 @@ namespace Sass {
69
71
  virtual T operator()(Arguments* x) = 0;
70
72
  // selectors
71
73
  virtual T operator()(Selector_Schema* x) = 0;
72
- virtual T operator()(Selector_Reference* x) = 0;
73
74
  virtual T operator()(Selector_Placeholder* x) = 0;
74
75
  virtual T operator()(Type_Selector* x) = 0;
75
76
  virtual T operator()(Selector_Qualifier* x) = 0;
@@ -94,7 +95,7 @@ namespace Sass {
94
95
  virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
95
96
  virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
96
97
  virtual T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
97
- virtual T operator()(Feature_Block* x) { return static_cast<D*>(this)->fallback(x); }
98
+ virtual T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
98
99
  virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
99
100
  virtual T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
100
101
  virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
@@ -123,6 +124,8 @@ namespace Sass {
123
124
  virtual T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
124
125
  virtual T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
125
126
  virtual T operator()(Function_Call_Schema* x) { return static_cast<D*>(this)->fallback(x); }
127
+ virtual T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
128
+ virtual T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
126
129
  virtual T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
127
130
  virtual T operator()(Textual* x) { return static_cast<D*>(this)->fallback(x); }
128
131
  virtual T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
@@ -130,8 +133,12 @@ namespace Sass {
130
133
  virtual T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
131
134
  virtual T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
132
135
  virtual T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
133
- virtual T operator()(Feature_Query* x) { return static_cast<D*>(this)->fallback(x); }
134
- virtual T operator()(Feature_Query_Condition* x){ return static_cast<D*>(this)->fallback(x); }
136
+ virtual T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
137
+ virtual T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
138
+ virtual T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
139
+ virtual T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
140
+ virtual T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
141
+ virtual T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
135
142
  virtual T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
136
143
  virtual T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
137
144
  virtual T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
@@ -144,7 +151,6 @@ namespace Sass {
144
151
  virtual T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
145
152
  // selectors
146
153
  virtual T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
147
- virtual T operator()(Selector_Reference* x) { return static_cast<D*>(this)->fallback(x); }
148
154
  virtual T operator()(Selector_Placeholder* x) { return static_cast<D*>(this)->fallback(x); }
149
155
  virtual T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
150
156
  virtual T operator()(Selector_Qualifier* x) { return static_cast<D*>(this)->fallback(x); }