sassc 2.1.0.pre3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +24 -0
  4. data/Rakefile +2 -4
  5. data/ext/extconf.rb +13 -5
  6. data/ext/libsass/VERSION +1 -1
  7. data/ext/libsass/include/sass/base.h +2 -1
  8. data/ext/libsass/include/sass/context.h +4 -0
  9. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  10. data/ext/libsass/src/ast.cpp +158 -168
  11. data/ext/libsass/src/ast.hpp +389 -230
  12. data/ext/libsass/src/ast_def_macros.hpp +18 -10
  13. data/ext/libsass/src/ast_fwd_decl.cpp +4 -3
  14. data/ext/libsass/src/ast_fwd_decl.hpp +98 -165
  15. data/ext/libsass/src/ast_helpers.hpp +292 -0
  16. data/ext/libsass/src/ast_sel_cmp.cpp +219 -732
  17. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  18. data/ext/libsass/src/ast_sel_unify.cpp +207 -212
  19. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  20. data/ext/libsass/src/ast_selectors.cpp +594 -1026
  21. data/ext/libsass/src/ast_selectors.hpp +339 -385
  22. data/ext/libsass/src/ast_supports.cpp +36 -52
  23. data/ext/libsass/src/ast_supports.hpp +29 -29
  24. data/ext/libsass/src/ast_values.cpp +271 -84
  25. data/ext/libsass/src/ast_values.hpp +116 -107
  26. data/ext/libsass/src/backtrace.cpp +9 -9
  27. data/ext/libsass/src/backtrace.hpp +5 -5
  28. data/ext/libsass/src/base64vlq.cpp +2 -2
  29. data/ext/libsass/src/base64vlq.hpp +1 -1
  30. data/ext/libsass/src/bind.cpp +18 -18
  31. data/ext/libsass/src/bind.hpp +1 -1
  32. data/ext/libsass/src/c2ast.cpp +3 -3
  33. data/ext/libsass/src/c2ast.hpp +1 -1
  34. data/ext/libsass/src/cencode.c +4 -6
  35. data/ext/libsass/src/check_nesting.cpp +40 -41
  36. data/ext/libsass/src/check_nesting.hpp +6 -2
  37. data/ext/libsass/src/color_maps.cpp +14 -13
  38. data/ext/libsass/src/color_maps.hpp +1 -9
  39. data/ext/libsass/src/constants.cpp +5 -0
  40. data/ext/libsass/src/constants.hpp +6 -0
  41. data/ext/libsass/src/context.cpp +92 -119
  42. data/ext/libsass/src/context.hpp +41 -53
  43. data/ext/libsass/src/cssize.cpp +66 -149
  44. data/ext/libsass/src/cssize.hpp +17 -23
  45. data/ext/libsass/src/dart_helpers.hpp +199 -0
  46. data/ext/libsass/src/debugger.hpp +451 -295
  47. data/ext/libsass/src/emitter.cpp +15 -16
  48. data/ext/libsass/src/emitter.hpp +10 -12
  49. data/ext/libsass/src/environment.cpp +27 -27
  50. data/ext/libsass/src/environment.hpp +29 -24
  51. data/ext/libsass/src/error_handling.cpp +62 -41
  52. data/ext/libsass/src/error_handling.hpp +61 -51
  53. data/ext/libsass/src/eval.cpp +167 -281
  54. data/ext/libsass/src/eval.hpp +27 -29
  55. data/ext/libsass/src/eval_selectors.cpp +75 -0
  56. data/ext/libsass/src/expand.cpp +275 -222
  57. data/ext/libsass/src/expand.hpp +36 -16
  58. data/ext/libsass/src/extender.cpp +1188 -0
  59. data/ext/libsass/src/extender.hpp +399 -0
  60. data/ext/libsass/src/extension.cpp +43 -0
  61. data/ext/libsass/src/extension.hpp +89 -0
  62. data/ext/libsass/src/file.cpp +81 -72
  63. data/ext/libsass/src/file.hpp +28 -37
  64. data/ext/libsass/src/fn_colors.cpp +20 -18
  65. data/ext/libsass/src/fn_lists.cpp +30 -29
  66. data/ext/libsass/src/fn_maps.cpp +3 -3
  67. data/ext/libsass/src/fn_miscs.cpp +34 -46
  68. data/ext/libsass/src/fn_numbers.cpp +20 -13
  69. data/ext/libsass/src/fn_selectors.cpp +98 -128
  70. data/ext/libsass/src/fn_strings.cpp +47 -33
  71. data/ext/libsass/src/fn_utils.cpp +31 -29
  72. data/ext/libsass/src/fn_utils.hpp +17 -11
  73. data/ext/libsass/src/inspect.cpp +186 -148
  74. data/ext/libsass/src/inspect.hpp +31 -29
  75. data/ext/libsass/src/lexer.cpp +20 -82
  76. data/ext/libsass/src/lexer.hpp +5 -16
  77. data/ext/libsass/src/listize.cpp +23 -37
  78. data/ext/libsass/src/listize.hpp +8 -9
  79. data/ext/libsass/src/mapping.hpp +1 -0
  80. data/ext/libsass/src/memory.hpp +12 -0
  81. data/ext/libsass/src/memory/allocator.cpp +48 -0
  82. data/ext/libsass/src/memory/allocator.hpp +138 -0
  83. data/ext/libsass/src/memory/config.hpp +20 -0
  84. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  85. data/ext/libsass/src/memory/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
  86. data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +55 -9
  87. data/ext/libsass/src/operation.hpp +71 -61
  88. data/ext/libsass/src/operators.cpp +19 -18
  89. data/ext/libsass/src/operators.hpp +11 -11
  90. data/ext/libsass/src/ordered_map.hpp +112 -0
  91. data/ext/libsass/src/output.cpp +45 -64
  92. data/ext/libsass/src/output.hpp +6 -6
  93. data/ext/libsass/src/parser.cpp +512 -700
  94. data/ext/libsass/src/parser.hpp +89 -97
  95. data/ext/libsass/src/parser_selectors.cpp +189 -0
  96. data/ext/libsass/src/permutate.hpp +164 -0
  97. data/ext/libsass/src/plugins.cpp +7 -7
  98. data/ext/libsass/src/plugins.hpp +8 -8
  99. data/ext/libsass/src/position.cpp +7 -26
  100. data/ext/libsass/src/position.hpp +44 -21
  101. data/ext/libsass/src/prelexer.cpp +6 -6
  102. data/ext/libsass/src/remove_placeholders.cpp +55 -56
  103. data/ext/libsass/src/remove_placeholders.hpp +21 -18
  104. data/ext/libsass/src/sass.cpp +16 -15
  105. data/ext/libsass/src/sass.hpp +10 -5
  106. data/ext/libsass/src/sass2scss.cpp +4 -4
  107. data/ext/libsass/src/sass_context.cpp +91 -122
  108. data/ext/libsass/src/sass_context.hpp +2 -2
  109. data/ext/libsass/src/sass_functions.cpp +1 -1
  110. data/ext/libsass/src/sass_values.cpp +8 -11
  111. data/ext/libsass/src/settings.hpp +19 -0
  112. data/ext/libsass/src/source.cpp +69 -0
  113. data/ext/libsass/src/source.hpp +95 -0
  114. data/ext/libsass/src/source_data.hpp +32 -0
  115. data/ext/libsass/src/source_map.cpp +22 -18
  116. data/ext/libsass/src/source_map.hpp +12 -9
  117. data/ext/libsass/src/stylesheet.cpp +22 -0
  118. data/ext/libsass/src/stylesheet.hpp +57 -0
  119. data/ext/libsass/src/to_value.cpp +2 -2
  120. data/ext/libsass/src/to_value.hpp +1 -1
  121. data/ext/libsass/src/units.cpp +24 -22
  122. data/ext/libsass/src/units.hpp +8 -8
  123. data/ext/libsass/src/utf8_string.cpp +9 -10
  124. data/ext/libsass/src/utf8_string.hpp +7 -6
  125. data/ext/libsass/src/util.cpp +48 -50
  126. data/ext/libsass/src/util.hpp +20 -21
  127. data/ext/libsass/src/util_string.cpp +111 -61
  128. data/ext/libsass/src/util_string.hpp +62 -8
  129. data/ext/libsass/src/values.cpp +12 -12
  130. data/lib/sassc/engine.rb +5 -3
  131. data/lib/sassc/functions_handler.rb +11 -13
  132. data/lib/sassc/native.rb +9 -7
  133. data/lib/sassc/script.rb +4 -6
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/functions_test.rb +38 -1
  136. data/test/native_test.rb +4 -4
  137. metadata +31 -18
  138. data/ext/libsass/src/extend.cpp +0 -2132
  139. data/ext/libsass/src/extend.hpp +0 -86
  140. data/ext/libsass/src/node.cpp +0 -322
  141. data/ext/libsass/src/node.hpp +0 -118
  142. data/ext/libsass/src/paths.hpp +0 -71
  143. data/ext/libsass/src/sass_util.cpp +0 -152
  144. data/ext/libsass/src/sass_util.hpp +0 -256
  145. data/ext/libsass/src/subset_map.cpp +0 -58
  146. data/ext/libsass/src/subset_map.hpp +0 -76
  147. data/lib/sassc/native/lib_c.rb +0 -21
@@ -13,13 +13,13 @@ namespace Sass {
13
13
 
14
14
  namespace Exception {
15
15
 
16
- Base::Base(ParserState pstate, std::string msg, Backtraces traces)
17
- : std::runtime_error(msg), msg(msg),
16
+ Base::Base(SourceSpan pstate, sass::string msg, Backtraces traces)
17
+ : std::runtime_error(msg.c_str()), msg(msg),
18
18
  prefix("Error"), pstate(pstate), traces(traces)
19
19
  { }
20
20
 
21
- InvalidSass::InvalidSass(ParserState pstate, Backtraces traces, std::string msg, char* owned_src)
22
- : Base(pstate, msg, traces), owned_src(owned_src)
21
+ InvalidSass::InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg)
22
+ : Base(pstate, msg, traces)
23
23
  { }
24
24
 
25
25
 
@@ -31,14 +31,14 @@ namespace Sass {
31
31
  "\"" + parent->to_string(Sass_Inspect_Options()) + "\"";
32
32
  }
33
33
 
34
- InvalidVarKwdType::InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument* arg)
34
+ InvalidVarKwdType::InvalidVarKwdType(SourceSpan pstate, Backtraces traces, sass::string name, const Argument* arg)
35
35
  : Base(pstate, def_msg, traces), name(name), arg(arg)
36
36
  {
37
37
  msg = "Variable keyword argument map must have string keys.\n" +
38
38
  name + " is not a string in " + arg->to_string() + ".";
39
39
  }
40
40
 
41
- InvalidArgumentType::InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value* value)
41
+ InvalidArgumentType::InvalidArgumentType(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string type, const Value* value)
42
42
  : Base(pstate, def_msg, traces), fn(fn), arg(arg), type(type), value(value)
43
43
  {
44
44
  msg = arg + ": \"";
@@ -46,17 +46,17 @@ namespace Sass {
46
46
  msg += "\" is not a " + type + " for `" + fn + "'";
47
47
  }
48
48
 
49
- MissingArgument::MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype)
49
+ MissingArgument::MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string fntype)
50
50
  : Base(pstate, def_msg, traces), fn(fn), arg(arg), fntype(fntype)
51
51
  {
52
52
  msg = fntype + " " + fn + " is missing argument " + arg + ".";
53
53
  }
54
54
 
55
- InvalidSyntax::InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg)
55
+ InvalidSyntax::InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg)
56
56
  : Base(pstate, msg, traces)
57
57
  { }
58
58
 
59
- NestingLimitError::NestingLimitError(ParserState pstate, Backtraces traces, std::string msg)
59
+ NestingLimitError::NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg)
60
60
  : Base(pstate, msg, traces)
61
61
  { }
62
62
 
@@ -66,7 +66,7 @@ namespace Sass {
66
66
  msg = "Duplicate key " + dup.get_duplicate_key()->inspect() + " in map (" + org.inspect() + ").";
67
67
  }
68
68
 
69
- TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const std::string type)
69
+ TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const sass::string type)
70
70
  : Base(var.pstate(), def_msg, traces), var(var), type(type)
71
71
  {
72
72
  msg = var.to_string() + " is not an " + type + ".";
@@ -91,7 +91,7 @@ namespace Sass {
91
91
 
92
92
  IncompatibleUnits::IncompatibleUnits(const UnitType lhs, const UnitType rhs)
93
93
  {
94
- msg = std::string("Incompatible units: '") + unit_to_string(rhs) + "' and '" + unit_to_string(lhs) + "'.";
94
+ msg = sass::string("Incompatible units: '") + unit_to_string(rhs) + "' and '" + unit_to_string(lhs) + "'.";
95
95
  }
96
96
 
97
97
  AlphaChannelsNotEqual::AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
@@ -125,58 +125,79 @@ namespace Sass {
125
125
  msg = def_op_null_msg + ": \"" + lhs->inspect() + " " + sass_op_to_name(op) + " " + rhs->inspect() + "\".";
126
126
  }
127
127
 
128
- SassValueError::SassValueError(Backtraces traces, ParserState pstate, OperationError& err)
128
+ SassValueError::SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err)
129
129
  : Base(pstate, err.what(), traces)
130
130
  {
131
131
  msg = err.what();
132
132
  prefix = err.errtype();
133
133
  }
134
134
 
135
+ TopLevelParent::TopLevelParent(Backtraces traces, SourceSpan pstate)
136
+ : Base(pstate, "Top-level selectors may not contain the parent selector \"&\".", traces)
137
+ {
138
+
139
+ }
140
+
141
+ UnsatisfiedExtend::UnsatisfiedExtend(Backtraces traces, Extension extension)
142
+ : Base(extension.target->pstate(), "The target selector was not found.\n"
143
+ "Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
144
+ {
145
+
146
+ }
147
+
148
+ ExtendAcrossMedia::ExtendAcrossMedia(Backtraces traces, Extension extension)
149
+ : Base(extension.target->pstate(), "You may not @extend selectors across media queries.\n"
150
+ "Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
151
+ {
152
+
153
+ }
154
+
155
+
135
156
  }
136
157
 
137
158
 
138
- void warn(std::string msg, ParserState pstate)
159
+ void warn(sass::string msg, SourceSpan pstate)
139
160
  {
140
161
  std::cerr << "Warning: " << msg << std::endl;
141
162
  }
142
163
 
143
- void warning(std::string msg, ParserState pstate)
164
+ void warning(sass::string msg, SourceSpan pstate)
144
165
  {
145
- std::string cwd(Sass::File::get_cwd());
146
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
147
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
148
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
166
+ sass::string cwd(Sass::File::get_cwd());
167
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
168
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
169
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
149
170
 
150
- std::cerr << "WARNING on line " << pstate.line+1 << ", column " << pstate.column+1 << " of " << output_path << ":" << std::endl;
171
+ std::cerr << "WARNING on line " << pstate.getLine() << ", column " << pstate.getColumn() << " of " << output_path << ":" << std::endl;
151
172
  std::cerr << msg << std::endl << std::endl;
152
173
  }
153
174
 
154
- void warn(std::string msg, ParserState pstate, Backtrace* bt)
175
+ void warn(sass::string msg, SourceSpan pstate, Backtrace* bt)
155
176
  {
156
177
  warn(msg, pstate);
157
178
  }
158
179
 
159
- void deprecated_function(std::string msg, ParserState pstate)
180
+ void deprecated_function(sass::string msg, SourceSpan pstate)
160
181
  {
161
- std::string cwd(Sass::File::get_cwd());
162
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
163
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
164
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
182
+ sass::string cwd(Sass::File::get_cwd());
183
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
184
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
185
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
165
186
 
166
187
  std::cerr << "DEPRECATION WARNING: " << msg << std::endl;
167
188
  std::cerr << "will be an error in future versions of Sass." << std::endl;
168
- std::cerr << " on line " << pstate.line+1 << " of " << output_path << std::endl;
189
+ std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
169
190
  }
170
191
 
171
- void deprecated(std::string msg, std::string msg2, bool with_column, ParserState pstate)
192
+ void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate)
172
193
  {
173
- std::string cwd(Sass::File::get_cwd());
174
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
175
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
176
- std::string output_path(Sass::File::path_for_console(rel_path, pstate.path, pstate.path));
194
+ sass::string cwd(Sass::File::get_cwd());
195
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
196
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
197
+ sass::string output_path(Sass::File::path_for_console(rel_path, pstate.getPath(), pstate.getPath()));
177
198
 
178
- std::cerr << "DEPRECATION WARNING on line " << pstate.line + 1;
179
- if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
199
+ std::cerr << "DEPRECATION WARNING on line " << pstate.getLine();
200
+ // if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
180
201
  if (output_path.length()) std::cerr << " of " << output_path;
181
202
  std::cerr << ":" << std::endl;
182
203
  std::cerr << msg << std::endl;
@@ -184,26 +205,26 @@ namespace Sass {
184
205
  std::cerr << std::endl;
185
206
  }
186
207
 
187
- void deprecated_bind(std::string msg, ParserState pstate)
208
+ void deprecated_bind(sass::string msg, SourceSpan pstate)
188
209
  {
189
- std::string cwd(Sass::File::get_cwd());
190
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
191
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
192
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
210
+ sass::string cwd(Sass::File::get_cwd());
211
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
212
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
213
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
193
214
 
194
215
  std::cerr << "WARNING: " << msg << std::endl;
195
- std::cerr << " on line " << pstate.line+1 << " of " << output_path << std::endl;
216
+ std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
196
217
  std::cerr << "This will be an error in future versions of Sass." << std::endl;
197
218
  }
198
219
 
199
220
  // should be replaced with error with backtraces
200
- void coreError(std::string msg, ParserState pstate)
221
+ void coreError(sass::string msg, SourceSpan pstate)
201
222
  {
202
223
  Backtraces traces;
203
224
  throw Exception::InvalidSyntax(pstate, traces, msg);
204
225
  }
205
226
 
206
- void error(std::string msg, ParserState pstate, Backtraces& traces)
227
+ void error(sass::string msg, SourceSpan pstate, Backtraces& traces)
207
228
  {
208
229
  traces.push_back(Backtrace(pstate));
209
230
  throw Exception::InvalidSyntax(pstate, traces, msg);
@@ -1,6 +1,10 @@
1
1
  #ifndef SASS_ERROR_HANDLING_H
2
2
  #define SASS_ERROR_HANDLING_H
3
3
 
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
6
+ #include "sass.hpp"
7
+
4
8
  #include <string>
5
9
  #include <sstream>
6
10
  #include <stdexcept>
@@ -16,20 +20,20 @@ namespace Sass {
16
20
 
17
21
  namespace Exception {
18
22
 
19
- const std::string def_msg = "Invalid sass detected";
20
- const std::string def_op_msg = "Undefined operation";
21
- const std::string def_op_null_msg = "Invalid null operation";
22
- const std::string def_nesting_limit = "Code too deeply neested";
23
+ const sass::string def_msg = "Invalid sass detected";
24
+ const sass::string def_op_msg = "Undefined operation";
25
+ const sass::string def_op_null_msg = "Invalid null operation";
26
+ const sass::string def_nesting_limit = "Code too deeply nested";
23
27
 
24
28
  class Base : public std::runtime_error {
25
29
  protected:
26
- std::string msg;
27
- std::string prefix;
30
+ sass::string msg;
31
+ sass::string prefix;
28
32
  public:
29
- ParserState pstate;
33
+ SourceSpan pstate;
30
34
  Backtraces traces;
31
35
  public:
32
- Base(ParserState pstate, std::string msg, Backtraces traces);
36
+ Base(SourceSpan pstate, sass::string msg, Backtraces traces);
33
37
  virtual const char* errtype() const { return prefix.c_str(); }
34
38
  virtual const char* what() const throw() { return msg.c_str(); }
35
39
  virtual ~Base() throw() {};
@@ -37,20 +41,8 @@ namespace Sass {
37
41
 
38
42
  class InvalidSass : public Base {
39
43
  public:
40
- InvalidSass(InvalidSass& other) : Base(other), owned_src(other.owned_src) {
41
- // Assumes that `this` will outlive `other`.
42
- other.owned_src = nullptr;
43
- }
44
-
45
- // Required because the copy constructor's argument is not const.
46
- // Can't use `std::move` here because we build on Visual Studio 2013.
47
- InvalidSass(InvalidSass &&other) : Base(other), owned_src(other.owned_src) {
48
- other.owned_src = nullptr;
49
- }
50
-
51
- InvalidSass(ParserState pstate, Backtraces traces, std::string msg, char* owned_src = nullptr);
52
- virtual ~InvalidSass() throw() { sass_free_memory(owned_src); };
53
- char *owned_src;
44
+ InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg);
45
+ virtual ~InvalidSass() throw() {};
54
46
  };
55
47
 
56
48
  class InvalidParent : public Base {
@@ -64,43 +56,43 @@ namespace Sass {
64
56
 
65
57
  class MissingArgument : public Base {
66
58
  protected:
67
- std::string fn;
68
- std::string arg;
69
- std::string fntype;
59
+ sass::string fn;
60
+ sass::string arg;
61
+ sass::string fntype;
70
62
  public:
71
- MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype);
63
+ MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string fntype);
72
64
  virtual ~MissingArgument() throw() {};
73
65
  };
74
66
 
75
67
  class InvalidArgumentType : public Base {
76
68
  protected:
77
- std::string fn;
78
- std::string arg;
79
- std::string type;
69
+ sass::string fn;
70
+ sass::string arg;
71
+ sass::string type;
80
72
  const Value* value;
81
73
  public:
82
- InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value* value = 0);
74
+ InvalidArgumentType(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string type, const Value* value = 0);
83
75
  virtual ~InvalidArgumentType() throw() {};
84
76
  };
85
77
 
86
78
  class InvalidVarKwdType : public Base {
87
79
  protected:
88
- std::string name;
80
+ sass::string name;
89
81
  const Argument* arg;
90
82
  public:
91
- InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument* arg = 0);
83
+ InvalidVarKwdType(SourceSpan pstate, Backtraces traces, sass::string name, const Argument* arg = 0);
92
84
  virtual ~InvalidVarKwdType() throw() {};
93
85
  };
94
86
 
95
87
  class InvalidSyntax : public Base {
96
88
  public:
97
- InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg);
89
+ InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg);
98
90
  virtual ~InvalidSyntax() throw() {};
99
91
  };
100
92
 
101
93
  class NestingLimitError : public Base {
102
94
  public:
103
- NestingLimitError(ParserState pstate, Backtraces traces, std::string msg = def_nesting_limit);
95
+ NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg = def_nesting_limit);
104
96
  virtual ~NestingLimitError() throw() {};
105
97
  };
106
98
 
@@ -117,9 +109,9 @@ namespace Sass {
117
109
  class TypeMismatch : public Base {
118
110
  protected:
119
111
  const Expression& var;
120
- const std::string type;
112
+ const sass::string type;
121
113
  public:
122
- TypeMismatch(Backtraces traces, const Expression& var, const std::string type);
114
+ TypeMismatch(Backtraces traces, const Expression& var, const sass::string type);
123
115
  virtual const char* errtype() const { return "Error"; }
124
116
  virtual ~TypeMismatch() throw() {};
125
117
  };
@@ -145,10 +137,10 @@ namespace Sass {
145
137
  /* common virtual base class (has no pstate or trace) */
146
138
  class OperationError : public std::runtime_error {
147
139
  protected:
148
- std::string msg;
140
+ sass::string msg;
149
141
  public:
150
- OperationError(std::string msg = def_op_msg)
151
- : std::runtime_error(msg), msg(msg)
142
+ OperationError(sass::string msg = def_op_msg)
143
+ : std::runtime_error(msg.c_str()), msg(msg)
152
144
  {};
153
145
  public:
154
146
  virtual const char* errtype() const { return "Error"; }
@@ -205,24 +197,42 @@ namespace Sass {
205
197
  };
206
198
 
207
199
  class SassValueError : public Base {
208
- public:
209
- SassValueError(Backtraces traces, ParserState pstate, OperationError& err);
210
- virtual ~SassValueError() throw() {};
200
+ public:
201
+ SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err);
202
+ virtual ~SassValueError() throw() {};
203
+ };
204
+
205
+ class TopLevelParent : public Base {
206
+ public:
207
+ TopLevelParent(Backtraces traces, SourceSpan pstate);
208
+ virtual ~TopLevelParent() throw() {};
209
+ };
210
+
211
+ class UnsatisfiedExtend : public Base {
212
+ public:
213
+ UnsatisfiedExtend(Backtraces traces, Extension extension);
214
+ virtual ~UnsatisfiedExtend() throw() {};
215
+ };
216
+
217
+ class ExtendAcrossMedia : public Base {
218
+ public:
219
+ ExtendAcrossMedia(Backtraces traces, Extension extension);
220
+ virtual ~ExtendAcrossMedia() throw() {};
211
221
  };
212
222
 
213
223
  }
214
224
 
215
- void warn(std::string msg, ParserState pstate);
216
- void warn(std::string msg, ParserState pstate, Backtrace* bt);
217
- void warning(std::string msg, ParserState pstate);
225
+ void warn(sass::string msg, SourceSpan pstate);
226
+ void warn(sass::string msg, SourceSpan pstate, Backtrace* bt);
227
+ void warning(sass::string msg, SourceSpan pstate);
218
228
 
219
- void deprecated_function(std::string msg, ParserState pstate);
220
- void deprecated(std::string msg, std::string msg2, bool with_column, ParserState pstate);
221
- void deprecated_bind(std::string msg, ParserState pstate);
222
- // void deprecated(std::string msg, ParserState pstate, Backtrace* bt);
229
+ void deprecated_function(sass::string msg, SourceSpan pstate);
230
+ void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate);
231
+ void deprecated_bind(sass::string msg, SourceSpan pstate);
232
+ // void deprecated(sass::string msg, SourceSpan pstate, Backtrace* bt);
223
233
 
224
- void coreError(std::string msg, ParserState pstate);
225
- void error(std::string msg, ParserState pstate, Backtraces& traces);
234
+ void coreError(sass::string msg, SourceSpan pstate);
235
+ void error(sass::string msg, SourceSpan pstate, Backtraces& traces);
226
236
 
227
237
  }
228
238
 
@@ -30,6 +30,7 @@
30
30
  #include "expand.hpp"
31
31
  #include "color_maps.hpp"
32
32
  #include "sass_functions.hpp"
33
+ #include "error_handling.hpp"
33
34
  #include "util_string.hpp"
34
35
 
35
36
  namespace Sass {
@@ -52,7 +53,7 @@ namespace Sass {
52
53
  return exp.environment();
53
54
  }
54
55
 
55
- const std::string Eval::cwd()
56
+ const sass::string Eval::cwd()
56
57
  {
57
58
  return ctx.cwd();
58
59
  }
@@ -72,28 +73,11 @@ namespace Sass {
72
73
  return exp.env_stack;
73
74
  }
74
75
 
75
- Selector_List_Obj Eval::selector()
76
- {
77
- return exp.selector();
78
- }
79
-
80
- std::vector<Sass_Callee>& Eval::callee_stack()
76
+ sass::vector<Sass_Callee>& Eval::callee_stack()
81
77
  {
82
78
  return ctx.callee_stack;
83
79
  }
84
80
 
85
-
86
- SelectorStack& Eval::selector_stack()
87
- {
88
- return exp.selector_stack;
89
- }
90
-
91
- bool& Eval::old_at_root_without_rule()
92
- {
93
- return exp.old_at_root_without_rule;
94
- }
95
-
96
-
97
81
  Expression* Eval::operator()(Block* b)
98
82
  {
99
83
  Expression* val = 0;
@@ -107,8 +91,14 @@ namespace Sass {
107
91
  Expression* Eval::operator()(Assignment* a)
108
92
  {
109
93
  Env* env = environment();
110
- std::string var(a->variable());
94
+ sass::string var(a->variable());
111
95
  if (a->is_global()) {
96
+ if (!env->has_global(var)) {
97
+ deprecated(
98
+ "!global assignments won't be able to declare new variables in future versions.",
99
+ "Consider adding `" + var + ": null` at the top level.",
100
+ true, a->pstate());
101
+ }
112
102
  if (a->is_default()) {
113
103
  if (env->has_global(var)) {
114
104
  Expression* e = Cast<Expression>(env->get_global(var));
@@ -167,10 +157,10 @@ namespace Sass {
167
157
 
168
158
  Expression* Eval::operator()(If* i)
169
159
  {
170
- Expression_Obj rv;
160
+ ExpressionObj rv;
171
161
  Env env(environment());
172
162
  env_stack().push_back(&env);
173
- Expression_Obj cond = i->predicate()->perform(this);
163
+ ExpressionObj cond = i->predicate()->perform(this);
174
164
  if (!cond->is_false()) {
175
165
  rv = i->block()->perform(this);
176
166
  }
@@ -184,15 +174,15 @@ namespace Sass {
184
174
 
185
175
  // For does not create a new env scope
186
176
  // But iteration vars are reset afterwards
187
- Expression* Eval::operator()(For* f)
177
+ Expression* Eval::operator()(ForRule* f)
188
178
  {
189
- std::string variable(f->variable());
190
- Expression_Obj low = f->lower_bound()->perform(this);
179
+ sass::string variable(f->variable());
180
+ ExpressionObj low = f->lower_bound()->perform(this);
191
181
  if (low->concrete_type() != Expression::NUMBER) {
192
182
  traces.push_back(Backtrace(low->pstate()));
193
183
  throw Exception::TypeMismatch(traces, *low, "integer");
194
184
  }
195
- Expression_Obj high = f->upper_bound()->perform(this);
185
+ ExpressionObj high = f->upper_bound()->perform(this);
196
186
  if (high->concrete_type() != Expression::NUMBER) {
197
187
  traces.push_back(Backtrace(high->pstate()));
198
188
  throw Exception::TypeMismatch(traces, *high, "integer");
@@ -201,7 +191,7 @@ namespace Sass {
201
191
  Number_Obj sass_end = Cast<Number>(high);
202
192
  // check if units are valid for sequence
203
193
  if (sass_start->unit() != sass_end->unit()) {
204
- std::stringstream msg; msg << "Incompatible units: '"
194
+ sass::ostream msg; msg << "Incompatible units: '"
205
195
  << sass_end->unit() << "' and '"
206
196
  << sass_start->unit() << "'.";
207
197
  error(msg.str(), low->pstate(), traces);
@@ -240,10 +230,10 @@ namespace Sass {
240
230
 
241
231
  // Eval does not create a new env scope
242
232
  // But iteration vars are reset afterwards
243
- Expression* Eval::operator()(Each* e)
233
+ Expression* Eval::operator()(EachRule* e)
244
234
  {
245
- std::vector<std::string> variables(e->variables());
246
- Expression_Obj expr = e->list()->perform(this);
235
+ sass::vector<sass::string> variables(e->variables());
236
+ ExpressionObj expr = e->list()->perform(this);
247
237
  Env env(environment(), true);
248
238
  env_stack().push_back(&env);
249
239
  List_Obj list;
@@ -251,9 +241,8 @@ namespace Sass {
251
241
  if (expr->concrete_type() == Expression::MAP) {
252
242
  map = Cast<Map>(expr);
253
243
  }
254
- else if (Selector_List* ls = Cast<Selector_List>(expr)) {
255
- Listize listize;
256
- Expression_Obj rv = ls->perform(&listize);
244
+ else if (SelectorList * ls = Cast<SelectorList>(expr)) {
245
+ ExpressionObj rv = Listize::perform(ls);
257
246
  list = Cast<List>(rv);
258
247
  }
259
248
  else if (expr->concrete_type() != Expression::LIST) {
@@ -265,11 +254,11 @@ namespace Sass {
265
254
  }
266
255
 
267
256
  Block_Obj body = e->block();
268
- Expression_Obj val;
257
+ ExpressionObj val;
269
258
 
270
259
  if (map) {
271
- for (Expression_Obj key : map->keys()) {
272
- Expression_Obj value = map->at(key);
260
+ for (ExpressionObj key : map->keys()) {
261
+ ExpressionObj value = map->at(key);
273
262
 
274
263
  if (variables.size() == 1) {
275
264
  List* variable = SASS_MEMORY_NEW(List, map->pstate(), 2, SASS_SPACE);
@@ -286,7 +275,7 @@ namespace Sass {
286
275
  }
287
276
  }
288
277
  else {
289
- if (list->length() == 1 && Cast<Selector_List>(list)) {
278
+ if (list->length() == 1 && Cast<SelectorList>(list)) {
290
279
  list = Cast<List>(list);
291
280
  }
292
281
  for (size_t i = 0, L = list->length(); i < L; ++i) {
@@ -299,12 +288,10 @@ namespace Sass {
299
288
  Expression* var = scalars;
300
289
  env.set_local(variables[0], var);
301
290
  } else {
302
- // XXX: this is never hit via spec tests
291
+ // https://github.com/sass/libsass/issues/3078
303
292
  for (size_t j = 0, K = variables.size(); j < K; ++j) {
304
- Expression* res = j >= scalars->length()
305
- ? SASS_MEMORY_NEW(Null, expr->pstate())
306
- : scalars->at(j);
307
- env.set_local(variables[j], res);
293
+ env.set_local(variables[j], j >= scalars->length()
294
+ ? SASS_MEMORY_NEW(Null, expr->pstate()) : scalars->at(j));
308
295
  }
309
296
  }
310
297
  } else {
@@ -325,15 +312,15 @@ namespace Sass {
325
312
  return val.detach();
326
313
  }
327
314
 
328
- Expression* Eval::operator()(While* w)
315
+ Expression* Eval::operator()(WhileRule* w)
329
316
  {
330
- Expression_Obj pred = w->predicate();
317
+ ExpressionObj pred = w->predicate();
331
318
  Block_Obj body = w->block();
332
319
  Env env(environment(), true);
333
320
  env_stack().push_back(&env);
334
- Expression_Obj cond = pred->perform(this);
321
+ ExpressionObj cond = pred->perform(this);
335
322
  while (!cond->is_false()) {
336
- Expression_Obj val = body->perform(this);
323
+ ExpressionObj val = body->perform(this);
337
324
  if (val) {
338
325
  env_stack().pop_back();
339
326
  return val.detach();
@@ -349,11 +336,11 @@ namespace Sass {
349
336
  return r->value()->perform(this);
350
337
  }
351
338
 
352
- Expression* Eval::operator()(Warning* w)
339
+ Expression* Eval::operator()(WarningRule* w)
353
340
  {
354
341
  Sass_Output_Style outstyle = options().output_style;
355
342
  options().output_style = NESTED;
356
- Expression_Obj message = w->message()->perform(this);
343
+ ExpressionObj message = w->message()->perform(this);
357
344
  Env* env = environment();
358
345
 
359
346
  // try to use generic function
@@ -362,9 +349,9 @@ namespace Sass {
362
349
  // add call stack entry
363
350
  callee_stack().push_back({
364
351
  "@warn",
365
- w->pstate().path,
366
- w->pstate().line + 1,
367
- w->pstate().column + 1,
352
+ w->pstate().getPath(),
353
+ w->pstate().getLine(),
354
+ w->pstate().getColumn(),
368
355
  SASS_CALLEE_FUNCTION,
369
356
  { env }
370
357
  });
@@ -387,7 +374,7 @@ namespace Sass {
387
374
 
388
375
  }
389
376
 
390
- std::string result(unquote(message->to_sass()));
377
+ sass::string result(unquote(message->to_sass()));
391
378
  std::cerr << "WARNING: " << result << std::endl;
392
379
  traces.push_back(Backtrace(w->pstate()));
393
380
  std::cerr << traces_to_string(traces, " ");
@@ -397,11 +384,11 @@ namespace Sass {
397
384
  return 0;
398
385
  }
399
386
 
400
- Expression* Eval::operator()(Error* e)
387
+ Expression* Eval::operator()(ErrorRule* e)
401
388
  {
402
389
  Sass_Output_Style outstyle = options().output_style;
403
390
  options().output_style = NESTED;
404
- Expression_Obj message = e->message()->perform(this);
391
+ ExpressionObj message = e->message()->perform(this);
405
392
  Env* env = environment();
406
393
 
407
394
  // try to use generic function
@@ -410,9 +397,9 @@ namespace Sass {
410
397
  // add call stack entry
411
398
  callee_stack().push_back({
412
399
  "@error",
413
- e->pstate().path,
414
- e->pstate().line + 1,
415
- e->pstate().column + 1,
400
+ e->pstate().getPath(),
401
+ e->pstate().getLine(),
402
+ e->pstate().getColumn(),
416
403
  SASS_CALLEE_FUNCTION,
417
404
  { env }
418
405
  });
@@ -435,17 +422,17 @@ namespace Sass {
435
422
 
436
423
  }
437
424
 
438
- std::string result(unquote(message->to_sass()));
425
+ sass::string result(unquote(message->to_sass()));
439
426
  options().output_style = outstyle;
440
427
  error(result, e->pstate(), traces);
441
428
  return 0;
442
429
  }
443
430
 
444
- Expression* Eval::operator()(Debug* d)
431
+ Expression* Eval::operator()(DebugRule* d)
445
432
  {
446
433
  Sass_Output_Style outstyle = options().output_style;
447
434
  options().output_style = NESTED;
448
- Expression_Obj message = d->value()->perform(this);
435
+ ExpressionObj message = d->value()->perform(this);
449
436
  Env* env = environment();
450
437
 
451
438
  // try to use generic function
@@ -454,9 +441,9 @@ namespace Sass {
454
441
  // add call stack entry
455
442
  callee_stack().push_back({
456
443
  "@debug",
457
- d->pstate().path,
458
- d->pstate().line + 1,
459
- d->pstate().column + 1,
444
+ d->pstate().getPath(),
445
+ d->pstate().getLine(),
446
+ d->pstate().getColumn(),
460
447
  SASS_CALLEE_FUNCTION,
461
448
  { env }
462
449
  });
@@ -479,17 +466,18 @@ namespace Sass {
479
466
 
480
467
  }
481
468
 
482
- std::string result(unquote(message->to_sass()));
483
- std::string abs_path(Sass::File::rel2abs(d->pstate().path, cwd(), cwd()));
484
- std::string rel_path(Sass::File::abs2rel(d->pstate().path, cwd(), cwd()));
485
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, d->pstate().path));
469
+ sass::string result(unquote(message->to_sass()));
470
+ sass::string abs_path(Sass::File::rel2abs(d->pstate().getPath(), cwd(), cwd()));
471
+ sass::string rel_path(Sass::File::abs2rel(d->pstate().getPath(), cwd(), cwd()));
472
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, d->pstate().getPath()));
486
473
  options().output_style = outstyle;
487
474
 
488
- std::cerr << output_path << ":" << d->pstate().line+1 << " DEBUG: " << result;
475
+ std::cerr << output_path << ":" << d->pstate().getLine() << " DEBUG: " << result;
489
476
  std::cerr << std::endl;
490
477
  return 0;
491
478
  }
492
479
 
480
+
493
481
  Expression* Eval::operator()(List* l)
494
482
  {
495
483
  // special case for unevaluated map
@@ -499,8 +487,8 @@ namespace Sass {
499
487
  l->length() / 2);
500
488
  for (size_t i = 0, L = l->length(); i < L; i += 2)
501
489
  {
502
- Expression_Obj key = (*l)[i+0]->perform(this);
503
- Expression_Obj val = (*l)[i+1]->perform(this);
490
+ ExpressionObj key = (*l)[i+0]->perform(this);
491
+ ExpressionObj val = (*l)[i+1]->perform(this);
504
492
  // make sure the color key never displays its real name
505
493
  key->is_delayed(true); // verified
506
494
  *lm << std::make_pair(key, val);
@@ -566,8 +554,8 @@ namespace Sass {
566
554
  Expression* Eval::operator()(Binary_Expression* b_in)
567
555
  {
568
556
 
569
- Expression_Obj lhs = b_in->left();
570
- Expression_Obj rhs = b_in->right();
557
+ ExpressionObj lhs = b_in->left();
558
+ ExpressionObj rhs = b_in->right();
571
559
  enum Sass_OP op_type = b_in->optype();
572
560
 
573
561
  if (op_type == Sass_OP::AND) {
@@ -591,7 +579,7 @@ namespace Sass {
591
579
  rhs = operator()(r_v);
592
580
  }
593
581
 
594
- Binary_Expression_Obj b = b_in;
582
+ Binary_ExpressionObj b = b_in;
595
583
 
596
584
  // Evaluate sub-expressions early on
597
585
  while (Binary_Expression* l_b = Cast<Binary_Expression>(lhs)) {
@@ -703,13 +691,13 @@ namespace Sass {
703
691
  if (String_Schema* s_l = Cast<String_Schema>(b->left())) {
704
692
  if (!s_l->has_interpolant() && (!s_l->is_right_interpolant())) {
705
693
  ret_schema = SASS_MEMORY_NEW(String_Schema, b->pstate());
706
- Binary_Expression_Obj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
694
+ Binary_ExpressionObj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
707
695
  b->op(), s_l->last(), b->right());
708
696
  bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // unverified
709
697
  for (size_t i = 0; i < s_l->length() - 1; ++i) {
710
- ret_schema->append(Cast<PreValue>(s_l->at(i)->perform(this)));
698
+ ret_schema->append(s_l->at(i)->perform(this));
711
699
  }
712
- ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
700
+ ret_schema->append(bin_ex->perform(this));
713
701
  return ret_schema->perform(this);
714
702
  }
715
703
  }
@@ -717,12 +705,12 @@ namespace Sass {
717
705
 
718
706
  if (!s_r->has_interpolant() && (!s_r->is_left_interpolant() || op_type == Sass_OP::DIV)) {
719
707
  ret_schema = SASS_MEMORY_NEW(String_Schema, b->pstate());
720
- Binary_Expression_Obj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
708
+ Binary_ExpressionObj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
721
709
  b->op(), b->left(), s_r->first());
722
710
  bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // verified
723
- ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
711
+ ret_schema->append(bin_ex->perform(this));
724
712
  for (size_t i = 1; i < s_r->length(); ++i) {
725
- ret_schema->append(Cast<PreValue>(s_r->at(i)->perform(this)));
713
+ ret_schema->append(s_r->at(i)->perform(this));
726
714
  }
727
715
  return ret_schema->perform(this);
728
716
  }
@@ -759,8 +747,8 @@ namespace Sass {
759
747
  // Is one of the operands an interpolant?
760
748
  String_Schema_Obj s1 = Cast<String_Schema>(b->left());
761
749
  String_Schema_Obj s2 = Cast<String_Schema>(b->right());
762
- Binary_Expression_Obj b1 = Cast<Binary_Expression>(b->left());
763
- Binary_Expression_Obj b2 = Cast<Binary_Expression>(b->right());
750
+ Binary_ExpressionObj b1 = Cast<Binary_Expression>(b->left());
751
+ Binary_ExpressionObj b2 = Cast<Binary_Expression>(b->right());
764
752
 
765
753
  bool schema_op = false;
766
754
 
@@ -775,7 +763,7 @@ namespace Sass {
775
763
  op_type == Sass_OP::EQ) {
776
764
  // If possible upgrade LHS to a number (for number to string compare)
777
765
  if (String_Constant* str = Cast<String_Constant>(lhs)) {
778
- std::string value(str->value());
766
+ sass::string value(str->value());
779
767
  const char* start = value.c_str();
780
768
  if (Prelexer::sequence < Prelexer::dimension, Prelexer::end_of_file >(start) != 0) {
781
769
  lhs = Parser::lexed_dimension(b->pstate(), str->value());
@@ -783,7 +771,7 @@ namespace Sass {
783
771
  }
784
772
  // If possible upgrade RHS to a number (for string to number compare)
785
773
  if (String_Constant* str = Cast<String_Constant>(rhs)) {
786
- std::string value(str->value());
774
+ sass::string value(str->value());
787
775
  const char* start = value.c_str();
788
776
  if (Prelexer::sequence < Prelexer::dimension, Prelexer::number >(start) != 0) {
789
777
  rhs = Parser::lexed_dimension(b->pstate(), str->value());
@@ -792,11 +780,11 @@ namespace Sass {
792
780
  }
793
781
 
794
782
  To_Value to_value(ctx);
795
- Value_Obj v_l = Cast<Value>(lhs->perform(&to_value));
796
- Value_Obj v_r = Cast<Value>(rhs->perform(&to_value));
783
+ ValueObj v_l = Cast<Value>(lhs->perform(&to_value));
784
+ ValueObj v_r = Cast<Value>(rhs->perform(&to_value));
797
785
 
798
786
  if (force_delay) {
799
- std::string str("");
787
+ sass::string str("");
800
788
  str += v_l->to_string(options());
801
789
  if (b->op().ws_before) str += " ";
802
790
  str += b->separator();
@@ -831,9 +819,9 @@ namespace Sass {
831
819
 
832
820
  // ToDo: throw error in op functions
833
821
  // ToDo: then catch and re-throw them
834
- Expression_Obj rv;
822
+ ExpressionObj rv;
835
823
  try {
836
- ParserState pstate(b->pstate());
824
+ SourceSpan pstate(b->pstate());
837
825
  if (l_type == Expression::NUMBER && r_type == Expression::NUMBER) {
838
826
  Number* l_n = Cast<Number>(lhs);
839
827
  Number* r_n = Cast<Number>(rhs);
@@ -858,8 +846,8 @@ namespace Sass {
858
846
  else {
859
847
  To_Value to_value(ctx);
860
848
  // this will leak if perform does not return a value!
861
- Value_Obj v_l = Cast<Value>(lhs->perform(&to_value));
862
- Value_Obj v_r = Cast<Value>(rhs->perform(&to_value));
849
+ ValueObj v_l = Cast<Value>(lhs->perform(&to_value));
850
+ ValueObj v_r = Cast<Value>(rhs->perform(&to_value));
863
851
  bool interpolant = b->is_right_interpolant() ||
864
852
  b->is_left_interpolant() ||
865
853
  b->is_interpolant();
@@ -912,7 +900,7 @@ namespace Sass {
912
900
 
913
901
  Expression* Eval::operator()(Unary_Expression* u)
914
902
  {
915
- Expression_Obj operand = u->operand()->perform(this);
903
+ ExpressionObj operand = u->operand()->perform(this);
916
904
  if (u->optype() == Unary_Expression::NOT) {
917
905
  Boolean* result = SASS_MEMORY_NEW(Boolean, u->pstate(), (bool)*operand);
918
906
  result->value(!result->value());
@@ -926,14 +914,14 @@ namespace Sass {
926
914
  return cpy.detach(); // return the copy
927
915
  }
928
916
  else if (u->optype() == Unary_Expression::SLASH) {
929
- std::string str = '/' + nr->to_string(options());
917
+ sass::string str = '/' + nr->to_string(options());
930
918
  return SASS_MEMORY_NEW(String_Constant, u->pstate(), str);
931
919
  }
932
920
  // nothing for positive
933
921
  return nr.detach();
934
922
  }
935
923
  else {
936
- // Special cases: +/- variables which evaluate to null ouput just +/-,
924
+ // Special cases: +/- variables which evaluate to null output just +/-,
937
925
  // but +/- null itself outputs the string
938
926
  if (operand->concrete_type() == Expression::NULL_VAL && Cast<Variable>(u->operand())) {
939
927
  u->operand(SASS_MEMORY_NEW(String_Quoted, u->pstate(), ""));
@@ -942,12 +930,19 @@ namespace Sass {
942
930
  else if (Color* color = Cast<Color>(operand)) {
943
931
  // Use the color name if this was eval with one
944
932
  if (color->disp().length() > 0) {
945
- operand = SASS_MEMORY_NEW(String_Constant, operand->pstate(), color->disp());
946
- u->operand(operand);
933
+ Unary_ExpressionObj cpy = SASS_MEMORY_COPY(u);
934
+ cpy->operand(SASS_MEMORY_NEW(String_Constant, operand->pstate(), color->disp()));
935
+ return SASS_MEMORY_NEW(String_Quoted,
936
+ cpy->pstate(),
937
+ cpy->inspect());
947
938
  }
948
939
  }
949
940
  else {
950
- u->operand(operand);
941
+ Unary_ExpressionObj cpy = SASS_MEMORY_COPY(u);
942
+ cpy->operand(operand);
943
+ return SASS_MEMORY_NEW(String_Quoted,
944
+ cpy->pstate(),
945
+ cpy->inspect());
951
946
  }
952
947
 
953
948
  return SASS_MEMORY_NEW(String_Quoted,
@@ -962,21 +957,21 @@ namespace Sass {
962
957
  {
963
958
  if (traces.size() > Constants::MaxCallStack) {
964
959
  // XXX: this is never hit via spec tests
965
- std::ostringstream stm;
960
+ sass::ostream stm;
966
961
  stm << "Stack depth exceeded max of " << Constants::MaxCallStack;
967
962
  error(stm.str(), c->pstate(), traces);
968
963
  }
969
964
 
970
965
  if (Cast<String_Schema>(c->sname())) {
971
- Expression_Obj evaluated_name = c->sname()->perform(this);
972
- Expression_Obj evaluated_args = c->arguments()->perform(this);
973
- std::string str(evaluated_name->to_string());
966
+ ExpressionObj evaluated_name = c->sname()->perform(this);
967
+ ExpressionObj evaluated_args = c->arguments()->perform(this);
968
+ sass::string str(evaluated_name->to_string());
974
969
  str += evaluated_args->to_string();
975
970
  return SASS_MEMORY_NEW(String_Constant, c->pstate(), str);
976
971
  }
977
972
 
978
- std::string name(Util::normalize_underscores(c->name()));
979
- std::string full_name(name + "[f]");
973
+ sass::string name(Util::normalize_underscores(c->name()));
974
+ sass::string full_name(name + "[f]");
980
975
 
981
976
  // we make a clone here, need to implement that further
982
977
  Arguments_Obj args = c->arguments();
@@ -995,7 +990,7 @@ namespace Sass {
995
990
  c->name(),
996
991
  args);
997
992
  if (args->has_named_arguments()) {
998
- error("Function " + c->name() + " doesn't support keyword arguments", c->pstate(), traces);
993
+ error("Plain CSS function " + c->name() + " doesn't support keyword arguments", c->pstate(), traces);
999
994
  }
1000
995
  String_Quoted* str = SASS_MEMORY_NEW(String_Quoted,
1001
996
  c->pstate(),
@@ -1020,7 +1015,7 @@ namespace Sass {
1020
1015
  if (c->func()) def = c->func()->definition();
1021
1016
 
1022
1017
  if (def->is_overload_stub()) {
1023
- std::stringstream ss;
1018
+ sass::ostream ss;
1024
1019
  size_t L = args->length();
1025
1020
  // account for rest arguments
1026
1021
  if (args->has_rest_argument() && args->length() > 0) {
@@ -1031,12 +1026,12 @@ namespace Sass {
1031
1026
  }
1032
1027
  ss << full_name << L;
1033
1028
  full_name = ss.str();
1034
- std::string resolved_name(full_name);
1035
- if (!env->has(resolved_name)) error("overloaded function `" + std::string(c->name()) + "` given wrong number of arguments", c->pstate(), traces);
1029
+ sass::string resolved_name(full_name);
1030
+ if (!env->has(resolved_name)) error("overloaded function `" + sass::string(c->name()) + "` given wrong number of arguments", c->pstate(), traces);
1036
1031
  def = Cast<Definition>((*env)[resolved_name]);
1037
1032
  }
1038
1033
 
1039
- Expression_Obj result = c;
1034
+ ExpressionObj result = c;
1040
1035
  Block_Obj body = def->block();
1041
1036
  Native_Function func = def->native_function();
1042
1037
  Sass_Function_Entry c_function = def->c_function();
@@ -1048,14 +1043,14 @@ namespace Sass {
1048
1043
  env_stack().push_back(&fn_env);
1049
1044
 
1050
1045
  if (func || body) {
1051
- bind(std::string("Function"), c->name(), params, args, &fn_env, this, traces);
1052
- std::string msg(", in function `" + c->name() + "`");
1046
+ bind(sass::string("Function"), c->name(), params, args, &fn_env, this, traces);
1047
+ sass::string msg(", in function `" + c->name() + "`");
1053
1048
  traces.push_back(Backtrace(c->pstate(), msg));
1054
1049
  callee_stack().push_back({
1055
1050
  c->name().c_str(),
1056
- c->pstate().path,
1057
- c->pstate().line + 1,
1058
- c->pstate().column + 1,
1051
+ c->pstate().getPath(),
1052
+ c->pstate().getLine(),
1053
+ c->pstate().getColumn(),
1059
1054
  SASS_CALLEE_FUNCTION,
1060
1055
  { env }
1061
1056
  });
@@ -1065,10 +1060,10 @@ namespace Sass {
1065
1060
  result = body->perform(this);
1066
1061
  }
1067
1062
  else if (func) {
1068
- result = func(fn_env, *env, ctx, def->signature(), c->pstate(), traces, exp.selector_stack);
1063
+ result = func(fn_env, *env, ctx, def->signature(), c->pstate(), traces, exp.getSelectorStack(), exp.originalStack);
1069
1064
  }
1070
1065
  if (!result) {
1071
- error(std::string("Function ") + c->name() + " finished without @return", c->pstate(), traces);
1066
+ error(sass::string("Function ") + c->name() + " finished without @return", c->pstate(), traces);
1072
1067
  }
1073
1068
  callee_stack().pop_back();
1074
1069
  traces.pop_back();
@@ -1087,15 +1082,15 @@ namespace Sass {
1087
1082
  }
1088
1083
 
1089
1084
  // populates env with default values for params
1090
- std::string ff(c->name());
1091
- bind(std::string("Function"), c->name(), params, args, &fn_env, this, traces);
1092
- std::string msg(", in function `" + c->name() + "`");
1085
+ sass::string ff(c->name());
1086
+ bind(sass::string("Function"), c->name(), params, args, &fn_env, this, traces);
1087
+ sass::string msg(", in function `" + c->name() + "`");
1093
1088
  traces.push_back(Backtrace(c->pstate(), msg));
1094
1089
  callee_stack().push_back({
1095
1090
  c->name().c_str(),
1096
- c->pstate().path,
1097
- c->pstate().line + 1,
1098
- c->pstate().column + 1,
1091
+ c->pstate().getPath(),
1092
+ c->pstate().getLine(),
1093
+ c->pstate().getColumn(),
1099
1094
  SASS_CALLEE_C_FUNCTION,
1100
1095
  { env }
1101
1096
  });
@@ -1104,19 +1099,19 @@ namespace Sass {
1104
1099
  union Sass_Value* c_args = sass_make_list(params->length(), SASS_COMMA, false);
1105
1100
  for(size_t i = 0; i < params->length(); i++) {
1106
1101
  Parameter_Obj param = params->at(i);
1107
- std::string key = param->name();
1102
+ sass::string key = param->name();
1108
1103
  AST_Node_Obj node = fn_env.get_local(key);
1109
- Expression_Obj arg = Cast<Expression>(node);
1104
+ ExpressionObj arg = Cast<Expression>(node);
1110
1105
  sass_list_set_value(c_args, i, arg->perform(&ast2c));
1111
1106
  }
1112
1107
  union Sass_Value* c_val = c_func(c_args, c_function, compiler());
1113
1108
  if (sass_value_get_tag(c_val) == SASS_ERROR) {
1114
- std::string message("error in C function " + c->name() + ": " + sass_error_get_message(c_val));
1109
+ sass::string message("error in C function " + c->name() + ": " + sass_error_get_message(c_val));
1115
1110
  sass_delete_value(c_val);
1116
1111
  sass_delete_value(c_args);
1117
1112
  error(message, c->pstate(), traces);
1118
1113
  } else if (sass_value_get_tag(c_val) == SASS_WARNING) {
1119
- std::string message("warning in C function " + c->name() + ": " + sass_warning_get_message(c_val));
1114
+ sass::string message("warning in C function " + c->name() + ": " + sass_warning_get_message(c_val));
1120
1115
  sass_delete_value(c_val);
1121
1116
  sass_delete_value(c_args);
1122
1117
  error(message, c->pstate(), traces);
@@ -1132,7 +1127,7 @@ namespace Sass {
1132
1127
 
1133
1128
  // link back to function definition
1134
1129
  // only do this for custom functions
1135
- if (result->pstate().file == std::string::npos)
1130
+ if (result->pstate().getSrcId() == sass::string::npos)
1136
1131
  result->pstate(c->pstate());
1137
1132
 
1138
1133
  result = result->perform(this);
@@ -1143,9 +1138,9 @@ namespace Sass {
1143
1138
 
1144
1139
  Expression* Eval::operator()(Variable* v)
1145
1140
  {
1146
- Expression_Obj value;
1141
+ ExpressionObj value;
1147
1142
  Env* env = environment();
1148
- const std::string& name(v->name());
1143
+ const sass::string& name(v->name());
1149
1144
  EnvResult rv(env->find(name));
1150
1145
  if (rv.found) value = static_cast<Expression*>(rv.it->second.ptr());
1151
1146
  else error("Undefined variable: \"" + v->name() + "\".", v->pstate(), traces);
@@ -1179,7 +1174,7 @@ namespace Sass {
1179
1174
  return b;
1180
1175
  }
1181
1176
 
1182
- void Eval::interpolation(Context& ctx, std::string& res, Expression_Obj ex, bool into_quotes, bool was_itpl) {
1177
+ void Eval::interpolation(Context& ctx, sass::string& res, ExpressionObj ex, bool into_quotes, bool was_itpl) {
1183
1178
 
1184
1179
  bool needs_closing_brace = false;
1185
1180
 
@@ -1214,11 +1209,6 @@ namespace Sass {
1214
1209
 
1215
1210
  if (Cast<Null>(ex)) { return; }
1216
1211
 
1217
- // parent selector needs another go
1218
- if (Cast<Parent_Selector>(ex)) {
1219
- // XXX: this is never hit via spec tests
1220
- ex = ex->perform(this);
1221
- }
1222
1212
  // parent selector needs another go
1223
1213
  if (Cast<Parent_Reference>(ex)) {
1224
1214
  // XXX: this is never hit via spec tests
@@ -1229,9 +1219,9 @@ namespace Sass {
1229
1219
  List_Obj ll = SASS_MEMORY_NEW(List, l->pstate(), 0, l->separator());
1230
1220
  // this fixes an issue with bourbon sample, not really sure why
1231
1221
  // if (l->size() && Cast<Null>((*l)[0])) { res += ""; }
1232
- for(Expression_Obj item : *l) {
1222
+ for(ExpressionObj item : *l) {
1233
1223
  item->is_interpolant(l->is_interpolant());
1234
- std::string rl(""); interpolation(ctx, rl, item, into_quotes, l->is_interpolant());
1224
+ sass::string rl(""); interpolation(ctx, rl, item, into_quotes, l->is_interpolant());
1235
1225
  bool is_null = Cast<Null>(item) != 0; // rl != ""
1236
1226
  if (!is_null) ll->append(SASS_MEMORY_NEW(String_Quoted, item->pstate(), rl));
1237
1227
  }
@@ -1239,7 +1229,7 @@ namespace Sass {
1239
1229
  // here. Normally single list items are already unwrapped.
1240
1230
  if (l->size() > 1) {
1241
1231
  // string_to_output would fail "#{'_\a' '_\a'}";
1242
- std::string str(ll->to_string(options()));
1232
+ sass::string str(ll->to_string(options()));
1243
1233
  str = read_hex_escapes(str); // read escapes
1244
1234
  newline_to_space(str); // replace directly
1245
1235
  res += str; // append to result string
@@ -1254,14 +1244,13 @@ namespace Sass {
1254
1244
  // Selector_List
1255
1245
  // String_Quoted
1256
1246
  // String_Constant
1257
- // Parent_Selector
1258
1247
  // Binary_Expression
1259
1248
  else {
1260
1249
  // ex = ex->perform(this);
1261
1250
  if (into_quotes && ex->is_interpolant()) {
1262
1251
  res += evacuate_escapes(ex ? ex->to_string(options()) : "");
1263
1252
  } else {
1264
- std::string str(ex ? ex->to_string(options()) : "");
1253
+ sass::string str(ex ? ex->to_string(options()) : "");
1265
1254
  if (into_quotes) str = read_hex_escapes(str);
1266
1255
  res += str; // append to result string
1267
1256
  }
@@ -1289,12 +1278,12 @@ namespace Sass {
1289
1278
  }
1290
1279
  bool was_quoted = false;
1291
1280
  bool was_interpolant = false;
1292
- std::string res("");
1281
+ sass::string res("");
1293
1282
  for (size_t i = 0; i < L; ++i) {
1294
1283
  bool is_quoted = Cast<String_Quoted>((*s)[i]) != NULL;
1295
1284
  if (was_quoted && !(*s)[i]->is_interpolant() && !was_interpolant) { res += " "; }
1296
1285
  else if (i > 0 && is_quoted && !(*s)[i]->is_interpolant() && !was_interpolant) { res += " "; }
1297
- Expression_Obj ex = (*s)[i]->perform(this);
1286
+ ExpressionObj ex = (*s)[i]->perform(this);
1298
1287
  interpolation(ctx, res, ex, into_quotes, ex->is_interpolant());
1299
1288
  was_quoted = Cast<String_Quoted>((*s)[i]) != NULL;
1300
1289
  was_interpolant = (*s)[i]->is_interpolant();
@@ -1302,7 +1291,8 @@ namespace Sass {
1302
1291
  }
1303
1292
  if (!s->is_interpolant()) {
1304
1293
  if (s->length() > 1 && res == "") return SASS_MEMORY_NEW(Null, s->pstate());
1305
- return SASS_MEMORY_NEW(String_Constant, s->pstate(), res, s->css());
1294
+ String_Constant_Obj str = SASS_MEMORY_NEW(String_Constant, s->pstate(), res, s->css());
1295
+ return str.detach();
1306
1296
  }
1307
1297
  // string schema seems to have a special unquoting behavior (also handles "nested" quotes)
1308
1298
  String_Quoted_Obj str = SASS_MEMORY_NEW(String_Quoted, s->pstate(), res, 0, false, false, false, s->css());
@@ -1329,32 +1319,32 @@ namespace Sass {
1329
1319
  return str;
1330
1320
  }
1331
1321
 
1332
- Expression* Eval::operator()(Supports_Operator* c)
1322
+ Expression* Eval::operator()(SupportsOperation* c)
1333
1323
  {
1334
1324
  Expression* left = c->left()->perform(this);
1335
1325
  Expression* right = c->right()->perform(this);
1336
- Supports_Operator* cc = SASS_MEMORY_NEW(Supports_Operator,
1326
+ SupportsOperation* cc = SASS_MEMORY_NEW(SupportsOperation,
1337
1327
  c->pstate(),
1338
- Cast<Supports_Condition>(left),
1339
- Cast<Supports_Condition>(right),
1328
+ Cast<SupportsCondition>(left),
1329
+ Cast<SupportsCondition>(right),
1340
1330
  c->operand());
1341
1331
  return cc;
1342
1332
  }
1343
1333
 
1344
- Expression* Eval::operator()(Supports_Negation* c)
1334
+ Expression* Eval::operator()(SupportsNegation* c)
1345
1335
  {
1346
1336
  Expression* condition = c->condition()->perform(this);
1347
- Supports_Negation* cc = SASS_MEMORY_NEW(Supports_Negation,
1337
+ SupportsNegation* cc = SASS_MEMORY_NEW(SupportsNegation,
1348
1338
  c->pstate(),
1349
- Cast<Supports_Condition>(condition));
1339
+ Cast<SupportsCondition>(condition));
1350
1340
  return cc;
1351
1341
  }
1352
1342
 
1353
- Expression* Eval::operator()(Supports_Declaration* c)
1343
+ Expression* Eval::operator()(SupportsDeclaration* c)
1354
1344
  {
1355
1345
  Expression* feature = c->feature()->perform(this);
1356
1346
  Expression* value = c->value()->perform(this);
1357
- Supports_Declaration* cc = SASS_MEMORY_NEW(Supports_Declaration,
1347
+ SupportsDeclaration* cc = SASS_MEMORY_NEW(SupportsDeclaration,
1358
1348
  c->pstate(),
1359
1349
  feature,
1360
1350
  value);
@@ -1372,9 +1362,9 @@ namespace Sass {
1372
1362
 
1373
1363
  Expression* Eval::operator()(At_Root_Query* e)
1374
1364
  {
1375
- Expression_Obj feature = e->feature();
1365
+ ExpressionObj feature = e->feature();
1376
1366
  feature = (feature ? feature->perform(this) : 0);
1377
- Expression_Obj value = e->value();
1367
+ ExpressionObj value = e->value();
1378
1368
  value = (value ? value->perform(this) : 0);
1379
1369
  Expression* ee = SASS_MEMORY_NEW(At_Root_Query,
1380
1370
  e->pstate(),
@@ -1401,14 +1391,14 @@ namespace Sass {
1401
1391
 
1402
1392
  Expression* Eval::operator()(Media_Query_Expression* e)
1403
1393
  {
1404
- Expression_Obj feature = e->feature();
1394
+ ExpressionObj feature = e->feature();
1405
1395
  feature = (feature ? feature->perform(this) : 0);
1406
1396
  if (feature && Cast<String_Quoted>(feature)) {
1407
1397
  feature = SASS_MEMORY_NEW(String_Quoted,
1408
1398
  feature->pstate(),
1409
1399
  Cast<String_Quoted>(feature)->value());
1410
1400
  }
1411
- Expression_Obj value = e->value();
1401
+ ExpressionObj value = e->value();
1412
1402
  value = (value ? value->perform(this) : 0);
1413
1403
  if (value && Cast<String_Quoted>(value)) {
1414
1404
  // XXX: this is never hit via spec tests
@@ -1430,7 +1420,7 @@ namespace Sass {
1430
1420
 
1431
1421
  Expression* Eval::operator()(Argument* a)
1432
1422
  {
1433
- Expression_Obj val = a->value()->perform(this);
1423
+ ExpressionObj val = a->value()->perform(this);
1434
1424
  bool is_rest_argument = a->is_rest_argument();
1435
1425
  bool is_keyword_argument = a->is_keyword_argument();
1436
1426
 
@@ -1462,7 +1452,7 @@ namespace Sass {
1462
1452
  Arguments_Obj aa = SASS_MEMORY_NEW(Arguments, a->pstate());
1463
1453
  if (a->length() == 0) return aa.detach();
1464
1454
  for (size_t i = 0, L = a->length(); i < L; ++i) {
1465
- Expression_Obj rv = (*a)[i]->perform(this);
1455
+ ExpressionObj rv = (*a)[i]->perform(this);
1466
1456
  Argument* arg = Cast<Argument>(rv);
1467
1457
  if (!(arg->is_rest_argument() || arg->is_keyword_argument())) {
1468
1458
  aa->append(arg);
@@ -1470,8 +1460,8 @@ namespace Sass {
1470
1460
  }
1471
1461
 
1472
1462
  if (a->has_rest_argument()) {
1473
- Expression_Obj rest = a->get_rest_argument()->perform(this);
1474
- Expression_Obj splat = Cast<Argument>(rest)->value()->perform(this);
1463
+ ExpressionObj rest = a->get_rest_argument()->perform(this);
1464
+ ExpressionObj splat = Cast<Argument>(rest)->value()->perform(this);
1475
1465
 
1476
1466
  Sass_Separator separator = SASS_COMMA;
1477
1467
  List* ls = Cast<List>(splat);
@@ -1498,9 +1488,9 @@ namespace Sass {
1498
1488
  }
1499
1489
 
1500
1490
  if (a->has_keyword_argument()) {
1501
- Expression_Obj rv = a->get_keyword_argument()->perform(this);
1491
+ ExpressionObj rv = a->get_keyword_argument()->perform(this);
1502
1492
  Argument* rvarg = Cast<Argument>(rv);
1503
- Expression_Obj kwarg = rvarg->value()->perform(this);
1493
+ ExpressionObj kwarg = rvarg->value()->perform(this);
1504
1494
 
1505
1495
  aa->append(SASS_MEMORY_NEW(Argument, kwarg->pstate(), kwarg, "", false, true));
1506
1496
  }
@@ -1512,146 +1502,42 @@ namespace Sass {
1512
1502
  return 0;
1513
1503
  }
1514
1504
 
1515
- Selector_List* Eval::operator()(Selector_List* s)
1516
- {
1517
- SelectorStack rv;
1518
- Selector_List_Obj sl = SASS_MEMORY_NEW(Selector_List, s->pstate());
1519
- sl->is_optional(s->is_optional());
1520
- sl->media_block(s->media_block());
1521
- sl->is_optional(s->is_optional());
1522
- for (size_t i = 0, iL = s->length(); i < iL; ++i) {
1523
- rv.push_back(operator()((*s)[i]));
1524
- }
1525
-
1526
- // we should actually permutate parent first
1527
- // but here we have permutated the selector first
1528
- size_t round = 0;
1529
- while (round != std::string::npos) {
1530
- bool abort = true;
1531
- for (size_t i = 0, iL = rv.size(); i < iL; ++i) {
1532
- if (rv[i]->length() > round) {
1533
- sl->append((*rv[i])[round]);
1534
- abort = false;
1535
- }
1536
- }
1537
- if (abort) {
1538
- round = std::string::npos;
1539
- } else {
1540
- ++ round;
1541
- }
1542
-
1543
- }
1544
- return sl.detach();
1545
- }
1546
-
1547
-
1548
- Selector_List* Eval::operator()(Complex_Selector* s)
1549
- {
1550
- bool implicit_parent = !exp.old_at_root_without_rule;
1551
- if (is_in_selector_schema) exp.selector_stack.push_back({});
1552
- Selector_List_Obj resolved = s->resolve_parent_refs(exp.selector_stack, traces, implicit_parent);
1553
- if (is_in_selector_schema) exp.selector_stack.pop_back();
1554
- for (size_t i = 0; i < resolved->length(); i++) {
1555
- Complex_Selector* is = resolved->at(i)->mutable_first();
1556
- while (is) {
1557
- if (is->head()) {
1558
- is->head(operator()(is->head()));
1559
- }
1560
- is = is->tail();
1561
- }
1562
- }
1563
- return resolved.detach();
1564
- }
1565
-
1566
- Compound_Selector* Eval::operator()(Compound_Selector* s)
1567
- {
1568
- for (size_t i = 0; i < s->length(); i++) {
1569
- Simple_Selector* ss = s->at(i);
1570
- // skip parents here (called via resolve_parent_refs)
1571
- if (ss == NULL || Cast<Parent_Selector>(ss)) continue;
1572
- s->at(i) = Cast<Simple_Selector>(ss->perform(this));
1573
- }
1574
- return s;
1575
- }
1576
-
1577
- Selector_List* Eval::operator()(Selector_Schema* s)
1505
+ SelectorList* Eval::operator()(Selector_Schema* s)
1578
1506
  {
1579
1507
  LOCAL_FLAG(is_in_selector_schema, true);
1580
1508
  // the parser will look for a brace to end the selector
1581
- Expression_Obj sel = s->contents()->perform(this);
1582
- std::string result_str(sel->to_string(options()));
1509
+ ExpressionObj sel = s->contents()->perform(this);
1510
+ sass::string result_str(sel->to_string(options()));
1583
1511
  result_str = unquote(Util::rtrim(result_str));
1584
- char* temp_cstr = sass_copy_c_string(result_str.c_str());
1585
- ctx.strings.push_back(temp_cstr); // attach to context
1586
- Parser p = Parser::from_c_str(temp_cstr, ctx, traces, s->pstate());
1587
- p.last_media_block = s->media_block();
1588
- // a selector schema may or may not connect to parent?
1589
- bool chroot = s->connect_parent() == false;
1590
- Selector_List_Obj sl = p.parse_selector_list(chroot);
1591
- flag_is_in_selector_schema.reset();
1592
- return operator()(sl);
1593
- }
1512
+ ItplFile* source = SASS_MEMORY_NEW(ItplFile,
1513
+ result_str.c_str(), s->pstate());
1514
+ Parser p(source, ctx, traces);
1594
1515
 
1595
- Expression* Eval::operator()(Parent_Selector* p)
1596
- {
1597
- if (Selector_List_Obj pr = selector()) {
1598
- exp.selector_stack.pop_back();
1599
- Selector_List_Obj rv = operator()(pr);
1600
- exp.selector_stack.push_back(rv);
1601
- return rv.detach();
1602
- } else {
1603
- return SASS_MEMORY_NEW(Null, p->pstate());
1604
- }
1516
+ // If a schema contains a reference to parent it is already
1517
+ // connected to it, so don't connect implicitly anymore
1518
+ SelectorListObj parsed = p.parseSelectorList(true);
1519
+ flag_is_in_selector_schema.reset();
1520
+ return parsed.detach();
1605
1521
  }
1606
1522
 
1607
1523
  Expression* Eval::operator()(Parent_Reference* p)
1608
1524
  {
1609
- if (Selector_List_Obj pr = selector()) {
1610
- exp.selector_stack.pop_back();
1611
- Selector_List_Obj rv = operator()(pr);
1612
- exp.selector_stack.push_back(rv);
1613
- return rv.detach();
1525
+ if (SelectorListObj pr = exp.original()) {
1526
+ return operator()(pr);
1614
1527
  } else {
1615
1528
  return SASS_MEMORY_NEW(Null, p->pstate());
1616
1529
  }
1617
1530
  }
1618
1531
 
1619
- Simple_Selector* Eval::operator()(Simple_Selector* s)
1532
+ SimpleSelector* Eval::operator()(SimpleSelector* s)
1620
1533
  {
1621
1534
  return s;
1622
1535
  }
1623
1536
 
1624
- // hotfix to avoid invalid nested `:not` selectors
1625
- // probably the wrong place, but this should ultimately
1626
- // be fixed by implement superselector correctly for `:not`
1627
- // first use of "find" (ATM only implemented for selectors)
1628
- bool hasNotSelector(AST_Node_Obj obj) {
1629
- if (Wrapped_Selector* w = Cast<Wrapped_Selector>(obj)) {
1630
- return w->name() == ":not";
1631
- }
1632
- return false;
1633
- }
1634
-
1635
- Wrapped_Selector* Eval::operator()(Wrapped_Selector* s)
1537
+ PseudoSelector* Eval::operator()(PseudoSelector* pseudo)
1636
1538
  {
1637
-
1638
- if (s->name() == ":not") {
1639
- if (exp.selector_stack.back()) {
1640
- if (s->selector()->find(hasNotSelector)) {
1641
- s->selector()->clear();
1642
- s->name(" ");
1643
- } else {
1644
- for (size_t i = 0; i < s->selector()->length(); ++i) {
1645
- Complex_Selector* cs = s->selector()->at(i);
1646
- if (cs->tail()) {
1647
- s->selector()->clear();
1648
- s->name(" ");
1649
- }
1650
- }
1651
- }
1652
- }
1653
- }
1654
- return s;
1539
+ // ToDo: should we eval selector?
1540
+ return pseudo;
1655
1541
  };
1656
1542
 
1657
1543
  }