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
@@ -8,20 +8,19 @@
8
8
 
9
9
  namespace Sass {
10
10
 
11
- typedef Environment<AST_Node_Obj> Env;
12
11
  struct Backtrace;
13
12
 
14
13
  class Cssize : public Operation_CRTP<Statement_Ptr, Cssize> {
15
14
 
16
15
  Context& ctx;
17
- std::vector<Block_Ptr> block_stack;
18
- std::vector<Statement_Ptr> p_stack;
19
- Backtrace* backtrace;
16
+ Backtraces& traces;
17
+ std::vector<Block_Ptr> block_stack;
18
+ std::vector<Statement_Ptr> p_stack;
20
19
 
21
20
  Statement_Ptr fallback_impl(AST_Node_Ptr n);
22
21
 
23
22
  public:
24
- Cssize(Context&, Backtrace*);
23
+ Cssize(Context&);
25
24
  ~Cssize() { }
26
25
 
27
26
  Selector_List_Ptr selector();
@@ -10,11 +10,15 @@ using namespace Sass;
10
10
 
11
11
  inline void debug_ast(AST_Node_Ptr node, std::string ind = "", Env* env = 0);
12
12
 
13
- inline void debug_sources_set(SourcesSet& set, std::string ind = "")
13
+ inline void debug_ast(const AST_Node* node, std::string ind = "", Env* env = 0) {
14
+ debug_ast(const_cast<AST_Node*>(node), ind, env);
15
+ }
16
+
17
+ inline void debug_sources_set(ComplexSelectorSet& set, std::string ind = "")
14
18
  {
15
19
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
16
20
  for(auto const &pair : set) {
17
- debug_ast(&pair, ind + "");
21
+ debug_ast(pair, ind + "");
18
22
  // debug_ast(set[pair], ind + "first: ");
19
23
  }
20
24
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
@@ -64,30 +68,30 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
64
68
  {
65
69
  if (node == 0) return;
66
70
  if (ind == "") std::cerr << "####################################################################\n";
67
- if (dynamic_cast<Bubble_Ptr>(node)) {
68
- Bubble_Ptr bubble = dynamic_cast<Bubble_Ptr>(node);
71
+ if (Cast<Bubble>(node)) {
72
+ Bubble_Ptr bubble = Cast<Bubble>(node);
69
73
  std::cerr << ind << "Bubble " << bubble;
70
74
  std::cerr << " (" << pstate_source_position(node) << ")";
71
75
  std::cerr << " " << bubble->tabs();
72
76
  std::cerr << std::endl;
73
- debug_ast(&bubble->node(), ind + " ", env);
74
- } else if (dynamic_cast<Trace_Ptr>(node)) {
75
- Trace_Ptr trace = dynamic_cast<Trace_Ptr>(node);
77
+ debug_ast(bubble->node(), ind + " ", env);
78
+ } else if (Cast<Trace>(node)) {
79
+ Trace_Ptr trace = Cast<Trace>(node);
76
80
  std::cerr << ind << "Trace " << trace;
77
81
  std::cerr << " (" << pstate_source_position(node) << ")"
78
- << " [name:" << trace->name() << "]"
82
+ << " [name:" << trace->name() << ", type: " << trace->type() << "]"
79
83
  << std::endl;
80
- debug_ast(&trace->block(), ind + " ", env);
81
- } else if (dynamic_cast<At_Root_Block_Ptr>(node)) {
82
- At_Root_Block_Ptr root_block = dynamic_cast<At_Root_Block_Ptr>(node);
84
+ debug_ast(trace->block(), ind + " ", env);
85
+ } else if (Cast<At_Root_Block>(node)) {
86
+ At_Root_Block_Ptr root_block = Cast<At_Root_Block>(node);
83
87
  std::cerr << ind << "At_Root_Block " << root_block;
84
88
  std::cerr << " (" << pstate_source_position(node) << ")";
85
89
  std::cerr << " " << root_block->tabs();
86
90
  std::cerr << std::endl;
87
- debug_ast(&root_block->expression(), ind + ":", env);
88
- debug_ast(&root_block->block(), ind + " ", env);
89
- } else if (dynamic_cast<Selector_List_Ptr>(node)) {
90
- Selector_List_Ptr selector = dynamic_cast<Selector_List_Ptr>(node);
91
+ debug_ast(root_block->expression(), ind + ":", env);
92
+ debug_ast(root_block->block(), ind + " ", env);
93
+ } else if (Cast<Selector_List>(node)) {
94
+ Selector_List_Ptr selector = Cast<Selector_List>(node);
91
95
  std::cerr << ind << "Selector_List " << selector;
92
96
  std::cerr << " (" << pstate_source_position(node) << ")";
93
97
  std::cerr << " <" << selector->hash() << ">";
@@ -99,15 +103,16 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
99
103
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
100
104
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
101
105
  std::cerr << std::endl;
106
+ debug_ast(selector->schema(), ind + "#{} ");
102
107
 
103
- for(const Complex_Selector_Obj& i : selector->elements()) { debug_ast(&i, ind + " ", env); }
108
+ for(const Complex_Selector_Obj& i : selector->elements()) { debug_ast(i, ind + " ", env); }
104
109
 
105
- // } else if (dynamic_cast<Expression_Ptr>(node)) {
106
- // Expression_Ptr expression = dynamic_cast<Expression_Ptr>(node);
110
+ // } else if (Cast<Expression>(node)) {
111
+ // Expression_Ptr expression = Cast<Expression>(node);
107
112
  // std::cerr << ind << "Expression " << expression << " " << expression->concrete_type() << std::endl;
108
113
 
109
- } else if (dynamic_cast<Parent_Selector_Ptr>(node)) {
110
- Parent_Selector_Ptr selector = dynamic_cast<Parent_Selector_Ptr>(node);
114
+ } else if (Cast<Parent_Selector>(node)) {
115
+ Parent_Selector_Ptr selector = Cast<Parent_Selector>(node);
111
116
  std::cerr << ind << "Parent_Selector " << selector;
112
117
  // if (selector->not_selector()) cerr << " [in_declaration]";
113
118
  std::cerr << " (" << pstate_source_position(node) << ")";
@@ -116,8 +121,8 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
116
121
  std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
117
122
  // debug_ast(selector->selector(), ind + "->", env);
118
123
 
119
- } else if (dynamic_cast<Complex_Selector_Ptr>(node)) {
120
- Complex_Selector_Ptr selector = dynamic_cast<Complex_Selector_Ptr>(node);
124
+ } else if (Cast<Complex_Selector>(node)) {
125
+ Complex_Selector_Ptr selector = Cast<Complex_Selector>(node);
121
126
  std::cerr << ind << "Complex_Selector " << selector
122
127
  << " (" << pstate_source_position(node) << ")"
123
128
  << " <" << selector->hash() << ">"
@@ -141,16 +146,16 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
141
146
  }
142
147
  // if (del = "/") del += selector->reference()->perform(&to_string) + "/";
143
148
  std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
144
- debug_ast(&selector->head(), ind + " " /* + "[" + del + "]" */, env);
149
+ debug_ast(selector->head(), ind + " " /* + "[" + del + "]" */, env);
145
150
  if (selector->tail()) {
146
- debug_ast(&selector->tail(), ind + "{" + del + "}", env);
151
+ debug_ast(selector->tail(), ind + "{" + del + "}", env);
147
152
  } else if(del != " ") {
148
153
  std::cerr << ind << " |" << del << "| {trailing op}" << std::endl;
149
154
  }
150
- SourcesSet set = selector->sources();
155
+ ComplexSelectorSet set = selector->sources();
151
156
  // debug_sources_set(set, ind + " @--> ");
152
- } else if (dynamic_cast<Compound_Selector_Ptr>(node)) {
153
- Compound_Selector_Ptr selector = dynamic_cast<Compound_Selector_Ptr>(node);
157
+ } else if (Cast<Compound_Selector>(node)) {
158
+ Compound_Selector_Ptr selector = Cast<Compound_Selector>(node);
154
159
  std::cerr << ind << "Compound_Selector " << selector;
155
160
  std::cerr << " (" << pstate_source_position(node) << ")";
156
161
  std::cerr << " <" << selector->hash() << ">";
@@ -162,9 +167,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
162
167
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
163
168
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
164
169
  std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
165
- for(const Simple_Selector_Obj& i : selector->elements()) { debug_ast(&i, ind + " ", env); }
166
- } else if (dynamic_cast<Wrapped_Selector_Ptr>(node)) {
167
- Wrapped_Selector_Ptr selector = dynamic_cast<Wrapped_Selector_Ptr>(node);
170
+ for(const Simple_Selector_Obj& i : selector->elements()) { debug_ast(i, ind + " ", env); }
171
+ } else if (Cast<Wrapped_Selector>(node)) {
172
+ Wrapped_Selector_Ptr selector = Cast<Wrapped_Selector>(node);
168
173
  std::cerr << ind << "Wrapped_Selector " << selector;
169
174
  std::cerr << " (" << pstate_source_position(node) << ")";
170
175
  std::cerr << " <" << selector->hash() << ">";
@@ -174,9 +179,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
174
179
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
175
180
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
176
181
  std::cerr << std::endl;
177
- debug_ast(&selector->selector(), ind + " () ", env);
178
- } else if (dynamic_cast<Pseudo_Selector_Ptr>(node)) {
179
- Pseudo_Selector_Ptr selector = dynamic_cast<Pseudo_Selector_Ptr>(node);
182
+ debug_ast(selector->selector(), ind + " () ", env);
183
+ } else if (Cast<Pseudo_Selector>(node)) {
184
+ Pseudo_Selector_Ptr selector = Cast<Pseudo_Selector>(node);
180
185
  std::cerr << ind << "Pseudo_Selector " << selector;
181
186
  std::cerr << " (" << pstate_source_position(node) << ")";
182
187
  std::cerr << " <" << selector->hash() << ">";
@@ -186,9 +191,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
186
191
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
187
192
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
188
193
  std::cerr << std::endl;
189
- debug_ast(&selector->expression(), ind + " <= ", env);
190
- } else if (dynamic_cast<Attribute_Selector_Ptr>(node)) {
191
- Attribute_Selector_Ptr selector = dynamic_cast<Attribute_Selector_Ptr>(node);
194
+ debug_ast(selector->expression(), ind + " <= ", env);
195
+ } else if (Cast<Attribute_Selector>(node)) {
196
+ Attribute_Selector_Ptr selector = Cast<Attribute_Selector>(node);
192
197
  std::cerr << ind << "Attribute_Selector " << selector;
193
198
  std::cerr << " (" << pstate_source_position(node) << ")";
194
199
  std::cerr << " <" << selector->hash() << ">";
@@ -198,9 +203,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
198
203
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
199
204
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
200
205
  std::cerr << std::endl;
201
- debug_ast(&selector->value(), ind + "[" + selector->matcher() + "] ", env);
202
- } else if (dynamic_cast<Class_Selector_Ptr>(node)) {
203
- Class_Selector_Ptr selector = dynamic_cast<Class_Selector_Ptr>(node);
206
+ debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env);
207
+ } else if (Cast<Class_Selector>(node)) {
208
+ Class_Selector_Ptr selector = Cast<Class_Selector>(node);
204
209
  std::cerr << ind << "Class_Selector " << selector;
205
210
  std::cerr << " (" << pstate_source_position(node) << ")";
206
211
  std::cerr << " <" << selector->hash() << ">";
@@ -210,8 +215,8 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
210
215
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
211
216
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
212
217
  std::cerr << std::endl;
213
- } else if (dynamic_cast<Id_Selector_Ptr>(node)) {
214
- Id_Selector_Ptr selector = dynamic_cast<Id_Selector_Ptr>(node);
218
+ } else if (Cast<Id_Selector>(node)) {
219
+ Id_Selector_Ptr selector = Cast<Id_Selector>(node);
215
220
  std::cerr << ind << "Id_Selector " << selector;
216
221
  std::cerr << " (" << pstate_source_position(node) << ")";
217
222
  std::cerr << " <" << selector->hash() << ">";
@@ -221,8 +226,8 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
221
226
  std::cerr << (selector->has_line_break() ? " [line-break]": " -");
222
227
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
223
228
  std::cerr << std::endl;
224
- } else if (dynamic_cast<Element_Selector_Ptr>(node)) {
225
- Element_Selector_Ptr selector = dynamic_cast<Element_Selector_Ptr>(node);
229
+ } else if (Cast<Element_Selector>(node)) {
230
+ Element_Selector_Ptr selector = Cast<Element_Selector>(node);
226
231
  std::cerr << ind << "Element_Selector " << selector;
227
232
  std::cerr << " (" << pstate_source_position(node) << ")";
228
233
  std::cerr << " <" << selector->hash() << ">";
@@ -233,9 +238,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
233
238
  std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
234
239
  std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">";
235
240
  std::cerr << std::endl;
236
- } else if (dynamic_cast<Placeholder_Selector_Ptr>(node)) {
241
+ } else if (Cast<Placeholder_Selector>(node)) {
237
242
 
238
- Placeholder_Selector_Ptr selector = dynamic_cast<Placeholder_Selector_Ptr>(node);
243
+ Placeholder_Selector_Ptr selector = Cast<Placeholder_Selector>(node);
239
244
  std::cerr << ind << "Placeholder_Selector [" << selector->ns_name() << "] " << selector;
240
245
  std::cerr << " (" << pstate_source_position(selector) << ")"
241
246
  << " <" << selector->hash() << ">"
@@ -245,212 +250,211 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
245
250
  << (selector->has_line_feed() ? " [line-feed]": " -")
246
251
  << std::endl;
247
252
 
248
- } else if (dynamic_cast<Simple_Selector*>(node)) {
249
- Simple_Selector* selector = dynamic_cast<Simple_Selector*>(node);
253
+ } else if (Cast<Simple_Selector>(node)) {
254
+ Simple_Selector* selector = Cast<Simple_Selector>(node);
250
255
  std::cerr << ind << "Simple_Selector " << selector;
251
256
  std::cerr << " (" << pstate_source_position(node) << ")";
252
257
  std::cerr << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << std::endl;
253
258
 
254
- } else if (dynamic_cast<Selector_Schema_Ptr>(node)) {
255
- Selector_Schema_Ptr selector = dynamic_cast<Selector_Schema_Ptr>(node);
259
+ } else if (Cast<Selector_Schema>(node)) {
260
+ Selector_Schema_Ptr selector = Cast<Selector_Schema>(node);
256
261
  std::cerr << ind << "Selector_Schema " << selector;
257
262
  std::cerr << " (" << pstate_source_position(node) << ")"
258
- << (selector->at_root() && selector->at_root() ? " [@ROOT]" : "")
259
263
  << " [@media:" << selector->media_block() << "]"
260
- << (selector->has_line_break() ? " [line-break]": " -")
261
- << (selector->has_line_feed() ? " [line-feed]": " -")
264
+ << (selector->connect_parent() ? " [connect-parent]": " -")
262
265
  << std::endl;
263
266
 
264
- debug_ast(&selector->contents(), ind + " ");
267
+ debug_ast(selector->contents(), ind + " ");
265
268
  // for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
266
269
 
267
- } else if (dynamic_cast<Selector_Ptr>(node)) {
268
- Selector_Ptr selector = dynamic_cast<Selector_Ptr>(node);
270
+ } else if (Cast<Selector>(node)) {
271
+ Selector_Ptr selector = Cast<Selector>(node);
269
272
  std::cerr << ind << "Selector " << selector;
270
273
  std::cerr << " (" << pstate_source_position(node) << ")";
271
274
  std::cerr << (selector->has_line_break() ? " [line-break]": " -")
272
275
  << (selector->has_line_feed() ? " [line-feed]": " -")
273
276
  << std::endl;
274
277
 
275
- } else if (dynamic_cast<Media_Query_Expression_Ptr>(node)) {
276
- Media_Query_Expression_Ptr block = dynamic_cast<Media_Query_Expression_Ptr>(node);
278
+ } else if (Cast<Media_Query_Expression>(node)) {
279
+ Media_Query_Expression_Ptr block = Cast<Media_Query_Expression>(node);
277
280
  std::cerr << ind << "Media_Query_Expression " << block;
278
281
  std::cerr << " (" << pstate_source_position(node) << ")";
279
282
  std::cerr << (block->is_interpolated() ? " [is_interpolated]": " -")
280
283
  << std::endl;
281
- debug_ast(&block->feature(), ind + " feature) ");
282
- debug_ast(&block->value(), ind + " value) ");
284
+ debug_ast(block->feature(), ind + " feature) ");
285
+ debug_ast(block->value(), ind + " value) ");
283
286
 
284
- } else if (dynamic_cast<Media_Query_Ptr>(node)) {
285
- Media_Query_Ptr block = dynamic_cast<Media_Query_Ptr>(node);
287
+ } else if (Cast<Media_Query>(node)) {
288
+ Media_Query_Ptr block = Cast<Media_Query>(node);
286
289
  std::cerr << ind << "Media_Query " << block;
287
290
  std::cerr << " (" << pstate_source_position(node) << ")";
288
291
  std::cerr << (block->is_negated() ? " [is_negated]": " -")
289
292
  << (block->is_restricted() ? " [is_restricted]": " -")
290
293
  << std::endl;
291
- debug_ast(&block->media_type(), ind + " ");
292
- for(const auto& i : block->elements()) { debug_ast(&i, ind + " ", env); }
294
+ debug_ast(block->media_type(), ind + " ");
295
+ for(const auto& i : block->elements()) { debug_ast(i, ind + " ", env); }
293
296
 
294
- } else if (dynamic_cast<Media_Block_Ptr>(node)) {
295
- Media_Block_Ptr block = dynamic_cast<Media_Block_Ptr>(node);
297
+ } else if (Cast<Media_Block>(node)) {
298
+ Media_Block_Ptr block = Cast<Media_Block>(node);
296
299
  std::cerr << ind << "Media_Block " << block;
297
300
  std::cerr << " (" << pstate_source_position(node) << ")";
298
301
  std::cerr << " " << block->tabs() << std::endl;
299
- debug_ast(&block->media_queries(), ind + " =@ ");
300
- if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(&i, ind + " ", env); }
301
- } else if (dynamic_cast<Supports_Block_Ptr>(node)) {
302
- Supports_Block_Ptr block = dynamic_cast<Supports_Block_Ptr>(node);
302
+ debug_ast(block->media_queries(), ind + " =@ ");
303
+ if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
304
+ } else if (Cast<Supports_Block>(node)) {
305
+ Supports_Block_Ptr block = Cast<Supports_Block>(node);
303
306
  std::cerr << ind << "Supports_Block " << block;
304
307
  std::cerr << " (" << pstate_source_position(node) << ")";
305
308
  std::cerr << " " << block->tabs() << std::endl;
306
- debug_ast(&block->condition(), ind + " =@ ");
307
- debug_ast(&block->block(), ind + " <>");
308
- } else if (dynamic_cast<Supports_Operator_Ptr>(node)) {
309
- Supports_Operator_Ptr block = dynamic_cast<Supports_Operator_Ptr>(node);
309
+ debug_ast(block->condition(), ind + " =@ ");
310
+ debug_ast(block->block(), ind + " <>");
311
+ } else if (Cast<Supports_Operator>(node)) {
312
+ Supports_Operator_Ptr block = Cast<Supports_Operator>(node);
310
313
  std::cerr << ind << "Supports_Operator " << block;
311
314
  std::cerr << " (" << pstate_source_position(node) << ")"
312
315
  << std::endl;
313
- debug_ast(&block->left(), ind + " left) ");
314
- debug_ast(&block->right(), ind + " right) ");
315
- } else if (dynamic_cast<Supports_Negation_Ptr>(node)) {
316
- Supports_Negation_Ptr block = dynamic_cast<Supports_Negation_Ptr>(node);
316
+ debug_ast(block->left(), ind + " left) ");
317
+ debug_ast(block->right(), ind + " right) ");
318
+ } else if (Cast<Supports_Negation>(node)) {
319
+ Supports_Negation_Ptr block = Cast<Supports_Negation>(node);
317
320
  std::cerr << ind << "Supports_Negation " << block;
318
321
  std::cerr << " (" << pstate_source_position(node) << ")"
319
322
  << std::endl;
320
- debug_ast(&block->condition(), ind + " condition) ");
321
- } else if (dynamic_cast<At_Root_Query_Ptr>(node)) {
322
- At_Root_Query_Ptr block = dynamic_cast<At_Root_Query_Ptr>(node);
323
+ debug_ast(block->condition(), ind + " condition) ");
324
+ } else if (Cast<At_Root_Query>(node)) {
325
+ At_Root_Query_Ptr block = Cast<At_Root_Query>(node);
323
326
  std::cerr << ind << "At_Root_Query " << block;
324
327
  std::cerr << " (" << pstate_source_position(node) << ")"
325
328
  << std::endl;
326
- debug_ast(&block->feature(), ind + " feature) ");
327
- debug_ast(&block->value(), ind + " value) ");
328
- } else if (dynamic_cast<Supports_Declaration_Ptr>(node)) {
329
- Supports_Declaration_Ptr block = dynamic_cast<Supports_Declaration_Ptr>(node);
329
+ debug_ast(block->feature(), ind + " feature) ");
330
+ debug_ast(block->value(), ind + " value) ");
331
+ } else if (Cast<Supports_Declaration>(node)) {
332
+ Supports_Declaration_Ptr block = Cast<Supports_Declaration>(node);
330
333
  std::cerr << ind << "Supports_Declaration " << block;
331
334
  std::cerr << " (" << pstate_source_position(node) << ")"
332
335
  << std::endl;
333
- debug_ast(&block->feature(), ind + " feature) ");
334
- debug_ast(&block->value(), ind + " value) ");
335
- } else if (dynamic_cast<Block_Ptr>(node)) {
336
- Block_Ptr root_block = dynamic_cast<Block_Ptr>(node);
336
+ debug_ast(block->feature(), ind + " feature) ");
337
+ debug_ast(block->value(), ind + " value) ");
338
+ } else if (Cast<Block>(node)) {
339
+ Block_Ptr root_block = Cast<Block>(node);
337
340
  std::cerr << ind << "Block " << root_block;
338
341
  std::cerr << " (" << pstate_source_position(node) << ")";
339
342
  if (root_block->is_root()) std::cerr << " [root]";
340
343
  std::cerr << " " << root_block->tabs() << std::endl;
341
- for(const Statement_Obj& i : root_block->elements()) { debug_ast(&i, ind + " ", env); }
342
- } else if (dynamic_cast<Warning_Ptr>(node)) {
343
- Warning_Ptr block = dynamic_cast<Warning_Ptr>(node);
344
+ for(const Statement_Obj& i : root_block->elements()) { debug_ast(i, ind + " ", env); }
345
+ } else if (Cast<Warning>(node)) {
346
+ Warning_Ptr block = Cast<Warning>(node);
344
347
  std::cerr << ind << "Warning " << block;
345
348
  std::cerr << " (" << pstate_source_position(node) << ")";
346
349
  std::cerr << " " << block->tabs() << std::endl;
347
- debug_ast(&block->message(), ind + " : ");
348
- } else if (dynamic_cast<Error_Ptr>(node)) {
349
- Error_Ptr block = dynamic_cast<Error_Ptr>(node);
350
+ debug_ast(block->message(), ind + " : ");
351
+ } else if (Cast<Error>(node)) {
352
+ Error_Ptr block = Cast<Error>(node);
350
353
  std::cerr << ind << "Error " << block;
351
354
  std::cerr << " (" << pstate_source_position(node) << ")";
352
355
  std::cerr << " " << block->tabs() << std::endl;
353
- } else if (dynamic_cast<Debug_Ptr>(node)) {
354
- Debug_Ptr block = dynamic_cast<Debug_Ptr>(node);
356
+ } else if (Cast<Debug>(node)) {
357
+ Debug_Ptr block = Cast<Debug>(node);
355
358
  std::cerr << ind << "Debug " << block;
356
359
  std::cerr << " (" << pstate_source_position(node) << ")";
357
360
  std::cerr << " " << block->tabs() << std::endl;
358
- debug_ast(&block->value(), ind + " ");
359
- } else if (dynamic_cast<Comment_Ptr>(node)) {
360
- Comment_Ptr block = dynamic_cast<Comment_Ptr>(node);
361
+ debug_ast(block->value(), ind + " ");
362
+ } else if (Cast<Comment>(node)) {
363
+ Comment_Ptr block = Cast<Comment>(node);
361
364
  std::cerr << ind << "Comment " << block;
362
365
  std::cerr << " (" << pstate_source_position(node) << ")";
363
366
  std::cerr << " " << block->tabs() <<
364
367
  " <" << prettyprint(block->pstate().token.ws_before()) << ">" << std::endl;
365
- debug_ast(&block->text(), ind + "// ", env);
366
- } else if (dynamic_cast<If_Ptr>(node)) {
367
- If_Ptr block = dynamic_cast<If_Ptr>(node);
368
+ debug_ast(block->text(), ind + "// ", env);
369
+ } else if (Cast<If>(node)) {
370
+ If_Ptr block = Cast<If>(node);
368
371
  std::cerr << ind << "If " << block;
369
372
  std::cerr << " (" << pstate_source_position(node) << ")";
370
373
  std::cerr << " " << block->tabs() << std::endl;
371
- debug_ast(&block->predicate(), ind + " = ");
372
- debug_ast(&block->block(), ind + " <>");
373
- debug_ast(&block->alternative(), ind + " ><");
374
- } else if (dynamic_cast<Return_Ptr>(node)) {
375
- Return_Ptr block = dynamic_cast<Return_Ptr>(node);
374
+ debug_ast(block->predicate(), ind + " = ");
375
+ debug_ast(block->block(), ind + " <>");
376
+ debug_ast(block->alternative(), ind + " ><");
377
+ } else if (Cast<Return>(node)) {
378
+ Return_Ptr block = Cast<Return>(node);
376
379
  std::cerr << ind << "Return " << block;
377
380
  std::cerr << " (" << pstate_source_position(node) << ")";
378
381
  std::cerr << " " << block->tabs() << std::endl;
379
- } else if (dynamic_cast<Extension_Ptr>(node)) {
380
- Extension_Ptr block = dynamic_cast<Extension_Ptr>(node);
382
+ } else if (Cast<Extension>(node)) {
383
+ Extension_Ptr block = Cast<Extension>(node);
381
384
  std::cerr << ind << "Extension " << block;
382
385
  std::cerr << " (" << pstate_source_position(node) << ")";
383
386
  std::cerr << " " << block->tabs() << std::endl;
384
- debug_ast(&block->selector(), ind + "-> ", env);
385
- } else if (dynamic_cast<Content_Ptr>(node)) {
386
- Content_Ptr block = dynamic_cast<Content_Ptr>(node);
387
+ debug_ast(block->selector(), ind + "-> ", env);
388
+ } else if (Cast<Content>(node)) {
389
+ Content_Ptr block = Cast<Content>(node);
387
390
  std::cerr << ind << "Content " << block;
388
391
  std::cerr << " (" << pstate_source_position(node) << ")";
389
392
  std::cerr << " [@media:" << block->media_block() << "]";
390
393
  std::cerr << " " << block->tabs() << std::endl;
391
- } else if (dynamic_cast<Import_Stub_Ptr>(node)) {
392
- Import_Stub_Ptr block = dynamic_cast<Import_Stub_Ptr>(node);
394
+ } else if (Cast<Import_Stub>(node)) {
395
+ Import_Stub_Ptr block = Cast<Import_Stub>(node);
393
396
  std::cerr << ind << "Import_Stub " << block;
394
397
  std::cerr << " (" << pstate_source_position(node) << ")";
395
398
  std::cerr << " [" << block->imp_path() << "] ";
396
399
  std::cerr << " " << block->tabs() << std::endl;
397
- } else if (dynamic_cast<Import_Ptr>(node)) {
398
- Import_Ptr block = dynamic_cast<Import_Ptr>(node);
400
+ } else if (Cast<Import>(node)) {
401
+ Import_Ptr block = Cast<Import>(node);
399
402
  std::cerr << ind << "Import " << block;
400
403
  std::cerr << " (" << pstate_source_position(node) << ")";
401
404
  std::cerr << " " << block->tabs() << std::endl;
402
405
  // std::vector<std::string> files_;
403
- for (auto imp : block->urls()) debug_ast(&imp, ind + "@: ", env);
404
- debug_ast(&block->import_queries(), ind + "@@ ");
405
- } else if (dynamic_cast<Assignment_Ptr>(node)) {
406
- Assignment_Ptr block = dynamic_cast<Assignment_Ptr>(node);
406
+ for (auto imp : block->urls()) debug_ast(imp, ind + "@: ", env);
407
+ debug_ast(block->import_queries(), ind + "@@ ");
408
+ } else if (Cast<Assignment>(node)) {
409
+ Assignment_Ptr block = Cast<Assignment>(node);
407
410
  std::cerr << ind << "Assignment " << block;
408
411
  std::cerr << " (" << pstate_source_position(node) << ")";
409
412
  std::cerr << " <<" << block->variable() << ">> " << block->tabs() << std::endl;
410
- debug_ast(&block->value(), ind + "=", env);
411
- } else if (dynamic_cast<Declaration_Ptr>(node)) {
412
- Declaration_Ptr block = dynamic_cast<Declaration_Ptr>(node);
413
+ debug_ast(block->value(), ind + "=", env);
414
+ } else if (Cast<Declaration>(node)) {
415
+ Declaration_Ptr block = Cast<Declaration>(node);
413
416
  std::cerr << ind << "Declaration " << block;
414
417
  std::cerr << " (" << pstate_source_position(node) << ")";
418
+ std::cerr << " [is_custom_property: " << block->is_custom_property() << "] ";
415
419
  std::cerr << " " << block->tabs() << std::endl;
416
- debug_ast(&block->property(), ind + " prop: ", env);
417
- debug_ast(&block->value(), ind + " value: ", env);
418
- debug_ast(&block->block(), ind + " ", env);
419
- } else if (dynamic_cast<Keyframe_Rule_Ptr>(node)) {
420
- Keyframe_Rule_Ptr has_block = dynamic_cast<Keyframe_Rule_Ptr>(node);
420
+ debug_ast(block->property(), ind + " prop: ", env);
421
+ debug_ast(block->value(), ind + " value: ", env);
422
+ debug_ast(block->block(), ind + " ", env);
423
+ } else if (Cast<Keyframe_Rule>(node)) {
424
+ Keyframe_Rule_Ptr has_block = Cast<Keyframe_Rule>(node);
421
425
  std::cerr << ind << "Keyframe_Rule " << has_block;
422
426
  std::cerr << " (" << pstate_source_position(node) << ")";
423
427
  std::cerr << " " << has_block->tabs() << std::endl;
424
- if (has_block->name()) debug_ast(&has_block->name(), ind + "@");
425
- if (has_block->block()) for(const Statement_Obj& i : has_block->block()->elements()) { debug_ast(&i, ind + " ", env); }
426
- } else if (dynamic_cast<Directive_Ptr>(node)) {
427
- Directive_Ptr block = dynamic_cast<Directive_Ptr>(node);
428
+ if (has_block->name()) debug_ast(has_block->name(), ind + "@");
429
+ if (has_block->block()) for(const Statement_Obj& i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
430
+ } else if (Cast<Directive>(node)) {
431
+ Directive_Ptr block = Cast<Directive>(node);
428
432
  std::cerr << ind << "Directive " << block;
429
433
  std::cerr << " (" << pstate_source_position(node) << ")";
430
434
  std::cerr << " [" << block->keyword() << "] " << block->tabs() << std::endl;
431
- debug_ast(&block->selector(), ind + "~", env);
432
- debug_ast(&block->value(), ind + "+", env);
433
- if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(&i, ind + " ", env); }
434
- } else if (dynamic_cast<Each_Ptr>(node)) {
435
- Each_Ptr block = dynamic_cast<Each_Ptr>(node);
435
+ debug_ast(block->selector(), ind + "~", env);
436
+ debug_ast(block->value(), ind + "+", env);
437
+ if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
438
+ } else if (Cast<Each>(node)) {
439
+ Each_Ptr block = Cast<Each>(node);
436
440
  std::cerr << ind << "Each " << block;
437
441
  std::cerr << " (" << pstate_source_position(node) << ")";
438
442
  std::cerr << " " << block->tabs() << std::endl;
439
- if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(&i, ind + " ", env); }
440
- } else if (dynamic_cast<For_Ptr>(node)) {
441
- For_Ptr block = dynamic_cast<For_Ptr>(node);
443
+ if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
444
+ } else if (Cast<For>(node)) {
445
+ For_Ptr block = Cast<For>(node);
442
446
  std::cerr << ind << "For " << block;
443
447
  std::cerr << " (" << pstate_source_position(node) << ")";
444
448
  std::cerr << " " << block->tabs() << std::endl;
445
- if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(&i, ind + " ", env); }
446
- } else if (dynamic_cast<While_Ptr>(node)) {
447
- While_Ptr block = dynamic_cast<While_Ptr>(node);
449
+ if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
450
+ } else if (Cast<While>(node)) {
451
+ While_Ptr block = Cast<While>(node);
448
452
  std::cerr << ind << "While " << block;
449
453
  std::cerr << " (" << pstate_source_position(node) << ")";
450
454
  std::cerr << " " << block->tabs() << std::endl;
451
- if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(&i, ind + " ", env); }
452
- } else if (dynamic_cast<Definition_Ptr>(node)) {
453
- Definition_Ptr block = dynamic_cast<Definition_Ptr>(node);
455
+ if (block->block()) for(const Statement_Obj& i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
456
+ } else if (Cast<Definition>(node)) {
457
+ Definition_Ptr block = Cast<Definition>(node);
454
458
  std::cerr << ind << "Definition " << block;
455
459
  std::cerr << " (" << pstate_source_position(node) << ")";
456
460
  std::cerr << " [name: " << block->name() << "] ";
@@ -459,73 +463,69 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
459
463
  // std::cerr << " [signature: " << block->signature() << "] ";
460
464
  std::cerr << " [native: " << block->native_function() << "] ";
461
465
  std::cerr << " " << block->tabs() << std::endl;
462
- debug_ast(&block->parameters(), ind + " params: ", env);
463
- if (block->block()) debug_ast(&block->block(), ind + " ", env);
464
- } else if (dynamic_cast<Mixin_Call_Ptr>(node)) {
465
- Mixin_Call_Ptr block = dynamic_cast<Mixin_Call_Ptr>(node);
466
+ debug_ast(block->parameters(), ind + " params: ", env);
467
+ if (block->block()) debug_ast(block->block(), ind + " ", env);
468
+ } else if (Cast<Mixin_Call>(node)) {
469
+ Mixin_Call_Ptr block = Cast<Mixin_Call>(node);
466
470
  std::cerr << ind << "Mixin_Call " << block << " " << block->tabs();
467
471
  std::cerr << " (" << pstate_source_position(block) << ")";
468
472
  std::cerr << " [" << block->name() << "]";
469
473
  std::cerr << " [has_content: " << block->has_content() << "] " << std::endl;
470
- debug_ast(&block->arguments(), ind + " args: ");
471
- if (block->block()) debug_ast(&block->block(), ind + " ", env);
472
- } else if (Ruleset_Ptr ruleset = dynamic_cast<Ruleset_Ptr>(node)) {
474
+ debug_ast(block->arguments(), ind + " args: ");
475
+ if (block->block()) debug_ast(block->block(), ind + " ", env);
476
+ } else if (Ruleset_Ptr ruleset = Cast<Ruleset>(node)) {
473
477
  std::cerr << ind << "Ruleset " << ruleset;
474
478
  std::cerr << " (" << pstate_source_position(node) << ")";
475
479
  std::cerr << " [indent: " << ruleset->tabs() << "]";
476
480
  std::cerr << (ruleset->is_invisible() ? " [INVISIBLE]" : "");
477
- std::cerr << (ruleset->at_root() ? " [@ROOT]" : "");
478
481
  std::cerr << (ruleset->is_root() ? " [root]" : "");
479
482
  std::cerr << std::endl;
480
- debug_ast(&ruleset->selector(), ind + ">");
481
- debug_ast(&ruleset->block(), ind + " ");
482
- } else if (dynamic_cast<Block_Ptr>(node)) {
483
- Block_Ptr block = dynamic_cast<Block_Ptr>(node);
483
+ debug_ast(ruleset->selector(), ind + ">");
484
+ debug_ast(ruleset->block(), ind + " ");
485
+ } else if (Cast<Block>(node)) {
486
+ Block_Ptr block = Cast<Block>(node);
484
487
  std::cerr << ind << "Block " << block;
485
488
  std::cerr << " (" << pstate_source_position(node) << ")";
486
489
  std::cerr << (block->is_invisible() ? " [INVISIBLE]" : "");
487
490
  std::cerr << " [indent: " << block->tabs() << "]" << std::endl;
488
- for(const Statement_Obj& i : block->elements()) { debug_ast(&i, ind + " ", env); }
489
- } else if (dynamic_cast<Textual_Ptr>(node)) {
490
- Textual_Ptr expression = dynamic_cast<Textual_Ptr>(node);
491
- std::cerr << ind << "Textual " << expression;
492
- std::cerr << " (" << pstate_source_position(node) << ")";
493
- if (expression->type() == Textual::NUMBER) std::cerr << " [NUMBER]";
494
- else if (expression->type() == Textual::PERCENTAGE) std::cerr << " [PERCENTAGE]";
495
- else if (expression->type() == Textual::DIMENSION) std::cerr << " [DIMENSION]";
496
- else if (expression->type() == Textual::HEX) std::cerr << " [HEX]";
497
- std::cerr << " [" << expression->value() << "]";
498
- std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
499
- if (expression->is_delayed()) std::cerr << " [delayed]";
500
- std::cerr << std::endl;
501
- } else if (dynamic_cast<Variable_Ptr>(node)) {
502
- Variable_Ptr expression = dynamic_cast<Variable_Ptr>(node);
491
+ for(const Statement_Obj& i : block->elements()) { debug_ast(i, ind + " ", env); }
492
+ } else if (Cast<Variable>(node)) {
493
+ Variable_Ptr expression = Cast<Variable>(node);
503
494
  std::cerr << ind << "Variable " << expression;
504
495
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
505
496
  std::cerr << " (" << pstate_source_position(node) << ")";
506
497
  std::cerr << " [" << expression->name() << "]" << std::endl;
507
498
  std::string name(expression->name());
508
- if (env && env->has(name)) debug_ast(SASS_MEMORY_CAST(Expression, (*env)[name]), ind + " -> ", env);
509
- } else if (dynamic_cast<Function_Call_Schema_Ptr>(node)) {
510
- Function_Call_Schema_Ptr expression = dynamic_cast<Function_Call_Schema_Ptr>(node);
499
+ if (env && env->has(name)) debug_ast(Cast<Expression>((*env)[name]), ind + " -> ", env);
500
+ } else if (Cast<Function_Call_Schema>(node)) {
501
+ Function_Call_Schema_Ptr expression = Cast<Function_Call_Schema>(node);
511
502
  std::cerr << ind << "Function_Call_Schema " << expression;
512
503
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
513
504
  std::cerr << " (" << pstate_source_position(node) << ")";
514
505
  std::cerr << "" << std::endl;
515
- debug_ast(&expression->name(), ind + "name: ", env);
516
- debug_ast(&expression->arguments(), ind + " args: ", env);
517
- } else if (dynamic_cast<Function_Call_Ptr>(node)) {
518
- Function_Call_Ptr expression = dynamic_cast<Function_Call_Ptr>(node);
506
+ debug_ast(expression->name(), ind + "name: ", env);
507
+ debug_ast(expression->arguments(), ind + " args: ", env);
508
+ } else if (Cast<Function_Call>(node)) {
509
+ Function_Call_Ptr expression = Cast<Function_Call>(node);
519
510
  std::cerr << ind << "Function_Call " << expression;
520
511
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
521
512
  std::cerr << " (" << pstate_source_position(node) << ")";
522
513
  std::cerr << " [" << expression->name() << "]";
523
514
  if (expression->is_delayed()) std::cerr << " [delayed]";
524
515
  if (expression->is_interpolant()) std::cerr << " [interpolant]";
516
+ if (expression->is_css()) std::cerr << " [css]";
517
+ std::cerr << std::endl;
518
+ debug_ast(expression->arguments(), ind + " args: ", env);
519
+ debug_ast(expression->func(), ind + " func: ", env);
520
+ } else if (Cast<Function>(node)) {
521
+ Function_Ptr expression = Cast<Function>(node);
522
+ std::cerr << ind << "Function " << expression;
523
+ std::cerr << " (" << pstate_source_position(node) << ")";
524
+ if (expression->is_css()) std::cerr << " [css]";
525
525
  std::cerr << std::endl;
526
- debug_ast(&expression->arguments(), ind + " args: ", env);
527
- } else if (dynamic_cast<Arguments_Ptr>(node)) {
528
- Arguments_Ptr expression = dynamic_cast<Arguments_Ptr>(node);
526
+ debug_ast(expression->definition(), ind + " definition: ", env);
527
+ } else if (Cast<Arguments>(node)) {
528
+ Arguments_Ptr expression = Cast<Arguments>(node);
529
529
  std::cerr << ind << "Arguments " << expression;
530
530
  if (expression->is_delayed()) std::cerr << " [delayed]";
531
531
  std::cerr << " (" << pstate_source_position(node) << ")";
@@ -533,41 +533,41 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
533
533
  if (expression->has_rest_argument()) std::cerr << " [has_rest_argument]";
534
534
  if (expression->has_keyword_argument()) std::cerr << " [has_keyword_argument]";
535
535
  std::cerr << std::endl;
536
- for(const Argument_Obj& i : expression->elements()) { debug_ast(&i, ind + " ", env); }
537
- } else if (dynamic_cast<Argument_Ptr>(node)) {
538
- Argument_Ptr expression = dynamic_cast<Argument_Ptr>(node);
536
+ for(const Argument_Obj& i : expression->elements()) { debug_ast(i, ind + " ", env); }
537
+ } else if (Cast<Argument>(node)) {
538
+ Argument_Ptr expression = Cast<Argument>(node);
539
539
  std::cerr << ind << "Argument " << expression;
540
540
  std::cerr << " (" << pstate_source_position(node) << ")";
541
- std::cerr << " [" << expression->value() << "]";
541
+ std::cerr << " [" << expression->value().ptr() << "]";
542
542
  std::cerr << " [name: " << expression->name() << "] ";
543
543
  std::cerr << " [rest: " << expression->is_rest_argument() << "] ";
544
544
  std::cerr << " [keyword: " << expression->is_keyword_argument() << "] " << std::endl;
545
- debug_ast(&expression->value(), ind + " value: ", env);
546
- } else if (dynamic_cast<Parameters_Ptr>(node)) {
547
- Parameters_Ptr expression = dynamic_cast<Parameters_Ptr>(node);
545
+ debug_ast(expression->value(), ind + " value: ", env);
546
+ } else if (Cast<Parameters>(node)) {
547
+ Parameters_Ptr expression = Cast<Parameters>(node);
548
548
  std::cerr << ind << "Parameters " << expression;
549
549
  std::cerr << " (" << pstate_source_position(node) << ")";
550
550
  std::cerr << " [has_optional: " << expression->has_optional_parameters() << "] ";
551
551
  std::cerr << " [has_rest: " << expression->has_rest_parameter() << "] ";
552
552
  std::cerr << std::endl;
553
- for(const Parameter_Obj& i : expression->elements()) { debug_ast(&i, ind + " ", env); }
554
- } else if (dynamic_cast<Parameter_Ptr>(node)) {
555
- Parameter_Ptr expression = dynamic_cast<Parameter_Ptr>(node);
553
+ for(const Parameter_Obj& i : expression->elements()) { debug_ast(i, ind + " ", env); }
554
+ } else if (Cast<Parameter>(node)) {
555
+ Parameter_Ptr expression = Cast<Parameter>(node);
556
556
  std::cerr << ind << "Parameter " << expression;
557
557
  std::cerr << " (" << pstate_source_position(node) << ")";
558
558
  std::cerr << " [name: " << expression->name() << "] ";
559
- std::cerr << " [default: " << expression->default_value() << "] ";
559
+ std::cerr << " [default: " << expression->default_value().ptr() << "] ";
560
560
  std::cerr << " [rest: " << expression->is_rest_parameter() << "] " << std::endl;
561
- } else if (dynamic_cast<Unary_Expression_Ptr>(node)) {
562
- Unary_Expression_Ptr expression = dynamic_cast<Unary_Expression_Ptr>(node);
561
+ } else if (Cast<Unary_Expression>(node)) {
562
+ Unary_Expression_Ptr expression = Cast<Unary_Expression>(node);
563
563
  std::cerr << ind << "Unary_Expression " << expression;
564
564
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
565
565
  std::cerr << " [delayed: " << expression->is_delayed() << "] ";
566
566
  std::cerr << " (" << pstate_source_position(node) << ")";
567
567
  std::cerr << " [" << expression->type() << "]" << std::endl;
568
- debug_ast(&expression->operand(), ind + " operand: ", env);
569
- } else if (dynamic_cast<Binary_Expression_Ptr>(node)) {
570
- Binary_Expression_Ptr expression = dynamic_cast<Binary_Expression_Ptr>(node);
568
+ debug_ast(expression->operand(), ind + " operand: ", env);
569
+ } else if (Cast<Binary_Expression>(node)) {
570
+ Binary_Expression_Ptr expression = Cast<Binary_Expression>(node);
571
571
  std::cerr << ind << "Binary_Expression " << expression;
572
572
  if (expression->is_interpolant()) std::cerr << " [is interpolant] ";
573
573
  if (expression->is_left_interpolant()) std::cerr << " [left interpolant] ";
@@ -577,67 +577,70 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
577
577
  std::cerr << " [ws_after: " << expression->op().ws_after << "] ";
578
578
  std::cerr << " (" << pstate_source_position(node) << ")";
579
579
  std::cerr << " [" << expression->type_name() << "]" << std::endl;
580
- debug_ast(&expression->left(), ind + " left: ", env);
581
- debug_ast(&expression->right(), ind + " right: ", env);
582
- } else if (dynamic_cast<Map_Ptr>(node)) {
583
- Map_Ptr expression = dynamic_cast<Map_Ptr>(node);
580
+ debug_ast(expression->left(), ind + " left: ", env);
581
+ debug_ast(expression->right(), ind + " right: ", env);
582
+ } else if (Cast<Map>(node)) {
583
+ Map_Ptr expression = Cast<Map>(node);
584
584
  std::cerr << ind << "Map " << expression;
585
585
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
586
586
  std::cerr << " (" << pstate_source_position(node) << ")";
587
587
  std::cerr << " [Hashed]" << std::endl;
588
588
  for (const auto& i : expression->elements()) {
589
- debug_ast(&i.first, ind + " key: ");
590
- debug_ast(&i.second, ind + " val: ");
589
+ debug_ast(i.first, ind + " key: ");
590
+ debug_ast(i.second, ind + " val: ");
591
591
  }
592
- } else if (dynamic_cast<List_Ptr>(node)) {
593
- List_Ptr expression = dynamic_cast<List_Ptr>(node);
592
+ } else if (Cast<List>(node)) {
593
+ List_Ptr expression = Cast<List>(node);
594
594
  std::cerr << ind << "List " << expression;
595
595
  std::cerr << " (" << pstate_source_position(node) << ")";
596
596
  std::cerr << " (" << expression->length() << ") " <<
597
- (expression->separator() == SASS_COMMA ? "Comma " : expression->separator() == SASS_HASH ? "Map" : "Space ") <<
597
+ (expression->separator() == SASS_COMMA ? "Comma " : expression->separator() == SASS_HASH ? "Map " : "Space ") <<
598
598
  " [delayed: " << expression->is_delayed() << "] " <<
599
599
  " [interpolant: " << expression->is_interpolant() << "] " <<
600
600
  " [listized: " << expression->from_selector() << "] " <<
601
601
  " [arglist: " << expression->is_arglist() << "] " <<
602
+ " [bracketed: " << expression->is_bracketed() << "] " <<
603
+ " [expanded: " << expression->is_expanded() << "] " <<
602
604
  " [hash: " << expression->hash() << "] " <<
603
605
  std::endl;
604
- for(const auto& i : expression->elements()) { debug_ast(&i, ind + " ", env); }
605
- } else if (dynamic_cast<Content_Ptr>(node)) {
606
- Content_Ptr expression = dynamic_cast<Content_Ptr>(node);
606
+ for(const auto& i : expression->elements()) { debug_ast(i, ind + " ", env); }
607
+ } else if (Cast<Content>(node)) {
608
+ Content_Ptr expression = Cast<Content>(node);
607
609
  std::cerr << ind << "Content " << expression;
608
610
  std::cerr << " (" << pstate_source_position(node) << ")";
609
611
  std::cerr << " [@media:" << expression->media_block() << "]";
610
612
  std::cerr << " [Statement]" << std::endl;
611
- } else if (dynamic_cast<Boolean_Ptr>(node)) {
612
- Boolean_Ptr expression = dynamic_cast<Boolean_Ptr>(node);
613
+ } else if (Cast<Boolean>(node)) {
614
+ Boolean_Ptr expression = Cast<Boolean>(node);
613
615
  std::cerr << ind << "Boolean " << expression;
614
616
  std::cerr << " (" << pstate_source_position(node) << ")";
615
617
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
616
618
  std::cerr << " [" << expression->value() << "]" << std::endl;
617
- } else if (dynamic_cast<Color_Ptr>(node)) {
618
- Color_Ptr expression = dynamic_cast<Color_Ptr>(node);
619
+ } else if (Cast<Color>(node)) {
620
+ Color_Ptr expression = Cast<Color>(node);
619
621
  std::cerr << ind << "Color " << expression;
620
622
  std::cerr << " (" << pstate_source_position(node) << ")";
621
623
  std::cerr << " [delayed: " << expression->is_delayed() << "] ";
622
624
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
623
625
  std::cerr << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << std::endl;
624
- } else if (dynamic_cast<Number_Ptr>(node)) {
625
- Number_Ptr expression = dynamic_cast<Number_Ptr>(node);
626
+ } else if (Cast<Number>(node)) {
627
+ Number_Ptr expression = Cast<Number>(node);
626
628
  std::cerr << ind << "Number " << expression;
627
629
  std::cerr << " (" << pstate_source_position(node) << ")";
630
+ std::cerr << " [delayed: " << expression->is_delayed() << "] ";
628
631
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
629
632
  std::cerr << " [" << expression->value() << expression->unit() << "]" <<
630
633
  " [hash: " << expression->hash() << "] " <<
631
634
  std::endl;
632
- } else if (dynamic_cast<Null_Ptr>(node)) {
633
- Null_Ptr expression = dynamic_cast<Null_Ptr>(node);
635
+ } else if (Cast<Null>(node)) {
636
+ Null_Ptr expression = Cast<Null>(node);
634
637
  std::cerr << ind << "Null " << expression;
635
638
  std::cerr << " (" << pstate_source_position(node) << ")";
636
639
  std::cerr << " [interpolant: " << expression->is_interpolant() << "] "
637
640
  // " [hash: " << expression->hash() << "] "
638
641
  << std::endl;
639
- } else if (dynamic_cast<String_Quoted_Ptr>(node)) {
640
- String_Quoted_Ptr expression = dynamic_cast<String_Quoted_Ptr>(node);
642
+ } else if (Cast<String_Quoted>(node)) {
643
+ String_Quoted_Ptr expression = Cast<String_Quoted>(node);
641
644
  std::cerr << ind << "String_Quoted " << expression;
642
645
  std::cerr << " (" << pstate_source_position(node) << ")";
643
646
  std::cerr << " [" << prettyprint(expression->value()) << "]";
@@ -645,8 +648,8 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
645
648
  if (expression->is_interpolant()) std::cerr << " [interpolant]";
646
649
  if (expression->quote_mark()) std::cerr << " [quote_mark: " << expression->quote_mark() << "]";
647
650
  std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
648
- } else if (dynamic_cast<String_Constant_Ptr>(node)) {
649
- String_Constant_Ptr expression = dynamic_cast<String_Constant_Ptr>(node);
651
+ } else if (Cast<String_Constant>(node)) {
652
+ String_Constant_Ptr expression = Cast<String_Constant>(node);
650
653
  std::cerr << ind << "String_Constant " << expression;
651
654
  if (expression->concrete_type()) {
652
655
  std::cerr << " " << expression->concrete_type();
@@ -656,28 +659,29 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
656
659
  if (expression->is_delayed()) std::cerr << " [delayed]";
657
660
  if (expression->is_interpolant()) std::cerr << " [interpolant]";
658
661
  std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
659
- } else if (dynamic_cast<String_Schema_Ptr>(node)) {
660
- String_Schema_Ptr expression = dynamic_cast<String_Schema_Ptr>(node);
662
+ } else if (Cast<String_Schema>(node)) {
663
+ String_Schema_Ptr expression = Cast<String_Schema>(node);
661
664
  std::cerr << ind << "String_Schema " << expression;
662
665
  std::cerr << " (" << pstate_source_position(expression) << ")";
663
666
  std::cerr << " " << expression->concrete_type();
664
667
  std::cerr << " (" << pstate_source_position(node) << ")";
668
+ if (expression->css()) std::cerr << " [css]";
665
669
  if (expression->is_delayed()) std::cerr << " [delayed]";
666
670
  if (expression->is_interpolant()) std::cerr << " [is interpolant]";
667
671
  if (expression->has_interpolant()) std::cerr << " [has interpolant]";
668
672
  if (expression->is_left_interpolant()) std::cerr << " [left interpolant] ";
669
673
  if (expression->is_right_interpolant()) std::cerr << " [right interpolant] ";
670
674
  std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
671
- for(const auto& i : expression->elements()) { debug_ast(&i, ind + " ", env); }
672
- } else if (dynamic_cast<String_Ptr>(node)) {
673
- String_Ptr expression = dynamic_cast<String_Ptr>(node);
675
+ for(const auto& i : expression->elements()) { debug_ast(i, ind + " ", env); }
676
+ } else if (Cast<String>(node)) {
677
+ String_Ptr expression = Cast<String>(node);
674
678
  std::cerr << ind << "String " << expression;
675
679
  std::cerr << " " << expression->concrete_type();
676
680
  std::cerr << " (" << pstate_source_position(node) << ")";
677
681
  if (expression->is_interpolant()) std::cerr << " [interpolant]";
678
682
  std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
679
- } else if (dynamic_cast<Expression_Ptr>(node)) {
680
- Expression_Ptr expression = dynamic_cast<Expression_Ptr>(node);
683
+ } else if (Cast<Expression>(node)) {
684
+ Expression_Ptr expression = Cast<Expression>(node);
681
685
  std::cerr << ind << "Expression " << expression;
682
686
  std::cerr << " (" << pstate_source_position(node) << ")";
683
687
  switch (expression->concrete_type()) {
@@ -694,16 +698,18 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
694
698
  case Expression::Concrete_Type::C_ERROR: std::cerr << " [C_ERROR]"; break;
695
699
  case Expression::Concrete_Type::FUNCTION: std::cerr << " [FUNCTION]"; break;
696
700
  case Expression::Concrete_Type::NUM_TYPES: std::cerr << " [NUM_TYPES]"; break;
701
+ case Expression::Concrete_Type::VARIABLE: std::cerr << " [VARIABLE]"; break;
702
+ case Expression::Concrete_Type::FUNCTION_VAL: std::cerr << " [FUNCTION_VAL]"; break;
697
703
  }
698
704
  std::cerr << std::endl;
699
- } else if (dynamic_cast<Has_Block_Ptr>(node)) {
700
- Has_Block_Ptr has_block = dynamic_cast<Has_Block_Ptr>(node);
705
+ } else if (Cast<Has_Block>(node)) {
706
+ Has_Block_Ptr has_block = Cast<Has_Block>(node);
701
707
  std::cerr << ind << "Has_Block " << has_block;
702
708
  std::cerr << " (" << pstate_source_position(node) << ")";
703
709
  std::cerr << " " << has_block->tabs() << std::endl;
704
- if (has_block->block()) for(const Statement_Obj& i : has_block->block()->elements()) { debug_ast(&i, ind + " ", env); }
705
- } else if (dynamic_cast<Statement_Ptr>(node)) {
706
- Statement_Ptr statement = dynamic_cast<Statement_Ptr>(node);
710
+ if (has_block->block()) for(const Statement_Obj& i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
711
+ } else if (Cast<Statement>(node)) {
712
+ Statement_Ptr statement = Cast<Statement>(node);
707
713
  std::cerr << ind << "Statement " << statement;
708
714
  std::cerr << " (" << pstate_source_position(node) << ")";
709
715
  std::cerr << " " << statement->tabs() << std::endl;
@@ -735,7 +741,7 @@ inline void debug_node(Node* node, std::string ind = "")
735
741
  std::cerr << node << " ";
736
742
  if (node->got_line_feed) std::cerr << "[LF] ";
737
743
  std::cerr << std::endl;
738
- debug_ast(&node->selector(), ind + " ");
744
+ debug_ast(node->selector(), ind + " ");
739
745
  } else if (node->isCollection()) {
740
746
  std::cerr << ind;
741
747
  std::cerr << "Collection ";
@@ -776,21 +782,18 @@ inline void debug_subset_map(Sass::Subset_Map& map, std::string ind = "")
776
782
  {
777
783
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
778
784
  for(auto const &it : map.values()) {
779
- debug_ast(&it.first, ind + "first: ");
780
- debug_ast(&it.second, ind + "second: ");
785
+ debug_ast(it.first, ind + "first: ");
786
+ debug_ast(it.second, ind + "second: ");
781
787
  }
782
788
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
783
789
  }
784
790
 
785
- typedef std::pair<Complex_Selector_Obj, Compound_Selector_Obj> ExtensionPair;
786
- typedef std::vector<ExtensionPair> SubsetMapEntries;
787
-
788
- inline void debug_subset_entries(SubsetMapEntries* entries, std::string ind = "")
791
+ inline void debug_subset_entries(SubSetMapPairs* entries, std::string ind = "")
789
792
  {
790
793
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
791
794
  for(auto const &pair : *entries) {
792
- debug_ast(&pair.first, ind + "first: ");
793
- debug_ast(&pair.second, ind + "second: ");
795
+ debug_ast(pair.first, ind + "first: ");
796
+ debug_ast(pair.second, ind + "second: ");
794
797
  }
795
798
  if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
796
799
  }