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
@@ -14,7 +14,9 @@ namespace Sass {
14
14
  scheduled_space(0),
15
15
  scheduled_linefeed(0),
16
16
  scheduled_delimiter(false),
17
+ scheduled_crutch(0),
17
18
  scheduled_mapping(0),
19
+ in_custom_property(false),
18
20
  in_comment(false),
19
21
  in_wrapped(false),
20
22
  in_media_block(false),
@@ -101,10 +103,30 @@ namespace Sass {
101
103
  // prepend some text or token to the buffer
102
104
  void Emitter::prepend_string(const std::string& text)
103
105
  {
104
- wbuf.smap.prepend(Offset(text));
106
+ // do not adjust mappings for utf8 bom
107
+ // seems they are not counted in any UA
108
+ if (text.compare("\xEF\xBB\xBF") != 0) {
109
+ wbuf.smap.prepend(Offset(text));
110
+ }
105
111
  wbuf.buffer = text + wbuf.buffer;
106
112
  }
107
113
 
114
+ char Emitter::last_char()
115
+ {
116
+ return wbuf.buffer.back();
117
+ }
118
+
119
+ // append a single char to the buffer
120
+ void Emitter::append_char(const char chr)
121
+ {
122
+ // write space/lf
123
+ flush_schedules();
124
+ // add to buffer
125
+ wbuf.buffer += chr;
126
+ // account for data in source-maps
127
+ wbuf.smap.append(Offset(chr));
128
+ }
129
+
108
130
  // append some text or token to the buffer
109
131
  void Emitter::append_string(const std::string& text)
110
132
  {
@@ -145,9 +167,9 @@ namespace Sass {
145
167
  add_open_mapping(node);
146
168
  // hotfix for browser issues
147
169
  // this is pretty ugly indeed
148
- if (scheduled_mapping) {
149
- add_open_mapping(scheduled_mapping);
150
- scheduled_mapping = 0;
170
+ if (scheduled_crutch) {
171
+ add_open_mapping(scheduled_crutch);
172
+ scheduled_crutch = 0;
151
173
  }
152
174
  append_string(text);
153
175
  add_close_mapping(node);
@@ -193,7 +215,7 @@ namespace Sass {
193
215
  {
194
216
  scheduled_space = 0;
195
217
  append_string(":");
196
- append_optional_space();
218
+ if (!in_custom_property) append_optional_space();
197
219
  }
198
220
 
199
221
  void Emitter::append_mandatory_space()
@@ -206,7 +228,9 @@ namespace Sass {
206
228
  if ((output_style() != COMPRESSED) && buffer().size()) {
207
229
  unsigned char lst = buffer().at(buffer().length() - 1);
208
230
  if (!isspace(lst) || scheduled_delimiter) {
209
- append_mandatory_space();
231
+ if (last_char() != '(') {
232
+ append_mandatory_space();
233
+ }
210
234
  }
211
235
  }
212
236
  }
@@ -37,9 +37,12 @@ namespace Sass {
37
37
  size_t scheduled_space;
38
38
  size_t scheduled_linefeed;
39
39
  bool scheduled_delimiter;
40
+ AST_Node_Ptr scheduled_crutch;
40
41
  AST_Node_Ptr scheduled_mapping;
41
42
 
42
43
  public:
44
+ // output strings different in custom css properties
45
+ bool in_custom_property;
43
46
  // output strings different in comments
44
47
  bool in_comment;
45
48
  // selector list does not get linefeeds
@@ -66,11 +69,15 @@ namespace Sass {
66
69
  void prepend_output(const OutputBuffer& out);
67
70
  // append some text or token to the buffer
68
71
  void append_string(const std::string& text);
72
+ // append a single character to buffer
73
+ void append_char(const char chr);
69
74
  // append some white-space only text
70
75
  void append_wspace(const std::string& text);
71
76
  // append some text or token to the buffer
72
77
  // this adds source-mappings for node start and end
73
78
  void append_token(const std::string& text, const AST_Node_Ptr node);
79
+ // query last appended character
80
+ char last_char();
74
81
 
75
82
  public: // syntax sugar
76
83
  void append_indentation();
@@ -6,17 +6,17 @@ namespace Sass {
6
6
 
7
7
  template <typename T>
8
8
  Environment<T>::Environment(bool is_shadow)
9
- : local_frame_(std::map<std::string, T>()),
9
+ : local_frame_(environment_map<std::string, T>()),
10
10
  parent_(0), is_shadow_(false)
11
11
  { }
12
12
  template <typename T>
13
13
  Environment<T>::Environment(Environment<T>* env, bool is_shadow)
14
- : local_frame_(std::map<std::string, T>()),
14
+ : local_frame_(environment_map<std::string, T>()),
15
15
  parent_(env), is_shadow_(is_shadow)
16
16
  { }
17
17
  template <typename T>
18
18
  Environment<T>::Environment(Environment<T>& env, bool is_shadow)
19
- : local_frame_(std::map<std::string, T>()),
19
+ : local_frame_(environment_map<std::string, T>()),
20
20
  parent_(&env), is_shadow_(is_shadow)
21
21
  { }
22
22
 
@@ -45,7 +45,7 @@ namespace Sass {
45
45
  }
46
46
 
47
47
  template <typename T>
48
- std::map<std::string, T>& Environment<T>::local_frame() {
48
+ environment_map<std::string, T>& Environment<T>::local_frame() {
49
49
  return local_frame_;
50
50
  }
51
51
 
@@ -53,12 +53,25 @@ namespace Sass {
53
53
  bool Environment<T>::has_local(const std::string& key) const
54
54
  { return local_frame_.find(key) != local_frame_.end(); }
55
55
 
56
+ template <typename T> EnvResult
57
+ Environment<T>::find_local(const std::string& key)
58
+ {
59
+ auto end = local_frame_.end();
60
+ auto it = local_frame_.find(key);
61
+ return EnvResult(it, it != end);
62
+ }
63
+
56
64
  template <typename T>
57
65
  T& Environment<T>::get_local(const std::string& key)
58
66
  { return local_frame_[key]; }
59
67
 
60
68
  template <typename T>
61
- void Environment<T>::set_local(const std::string& key, T val)
69
+ void Environment<T>::set_local(const std::string& key, const T& val)
70
+ {
71
+ local_frame_[key] = val;
72
+ }
73
+ template <typename T>
74
+ void Environment<T>::set_local(const std::string& key, T&& val)
62
75
  {
63
76
  local_frame_[key] = val;
64
77
  }
@@ -86,7 +99,12 @@ namespace Sass {
86
99
  { return (*global_env())[key]; }
87
100
 
88
101
  template <typename T>
89
- void Environment<T>::set_global(const std::string& key, T val)
102
+ void Environment<T>::set_global(const std::string& key, const T& val)
103
+ {
104
+ global_env()->local_frame_[key] = val;
105
+ }
106
+ template <typename T>
107
+ void Environment<T>::set_global(const std::string& key, T&& val)
90
108
  {
91
109
  global_env()->local_frame_[key] = val;
92
110
  }
@@ -126,12 +144,31 @@ namespace Sass {
126
144
  // either update already existing lexical value
127
145
  // or if flag is set, we create one if no lexical found
128
146
  template <typename T>
129
- void Environment<T>::set_lexical(const std::string& key, T val)
147
+ void Environment<T>::set_lexical(const std::string& key, const T& val)
130
148
  {
131
- auto cur = this; bool shadow = false;
132
- while (cur->is_lexical() || shadow) {
133
- if (cur->has_local(key)) {
134
- cur->set_local(key, val);
149
+ Environment<T>* cur = this;
150
+ bool shadow = false;
151
+ while ((cur && cur->is_lexical()) || shadow) {
152
+ EnvResult rv(cur->find_local(key));
153
+ if (rv.found) {
154
+ rv.it->second = val;
155
+ return;
156
+ }
157
+ shadow = cur->is_shadow();
158
+ cur = cur->parent_;
159
+ }
160
+ set_local(key, val);
161
+ }
162
+ // this one moves the value
163
+ template <typename T>
164
+ void Environment<T>::set_lexical(const std::string& key, T&& val)
165
+ {
166
+ Environment<T>* cur = this;
167
+ bool shadow = false;
168
+ while ((cur && cur->is_lexical()) || shadow) {
169
+ EnvResult rv(cur->find_local(key));
170
+ if (rv.found) {
171
+ rv.it->second = val;
135
172
  return;
136
173
  }
137
174
  shadow = cur->is_shadow();
@@ -155,6 +192,20 @@ namespace Sass {
155
192
  return false;
156
193
  }
157
194
 
195
+ // look on the full stack for key
196
+ // include all scopes available
197
+ template <typename T> EnvResult
198
+ Environment<T>::find(const std::string& key)
199
+ {
200
+ auto cur = this;
201
+ while (true) {
202
+ EnvResult rv(cur->find_local(key));
203
+ if (rv.found) return rv;
204
+ cur = cur->parent_;
205
+ if (!cur) return rv;
206
+ }
207
+ };
208
+
158
209
  // use array access for getter and setter functions
159
210
  template <typename T>
160
211
  T& Environment<T>::operator[](const std::string& key)
@@ -168,7 +219,7 @@ namespace Sass {
168
219
  }
169
220
  return get_local(key);
170
221
  }
171
-
222
+ /*
172
223
  #ifdef DEBUG
173
224
  template <typename T>
174
225
  size_t Environment<T>::print(std::string prefix)
@@ -176,10 +227,10 @@ namespace Sass {
176
227
  size_t indent = 0;
177
228
  if (parent_) indent = parent_->print(prefix) + 1;
178
229
  std::cerr << prefix << std::string(indent, ' ') << "== " << this << std::endl;
179
- for (typename std::map<std::string, T>::iterator i = local_frame_.begin(); i != local_frame_.end(); ++i) {
230
+ for (typename environment_map<std::string, T>::iterator i = local_frame_.begin(); i != local_frame_.end(); ++i) {
180
231
  if (!ends_with(i->first, "[f]") && !ends_with(i->first, "[f]4") && !ends_with(i->first, "[f]2")) {
181
- std::cerr << prefix << std::string(indent, ' ') << i->first << " " << i->second;
182
- if (Value_Ptr val = SASS_MEMORY_CAST_PTR(Value, i->second))
232
+ std::cerr << prefix << std::string(indent, ' ') << i->first << " " << i->second;
233
+ if (Value_Ptr val = Cast<Value>(i->second))
183
234
  { std::cerr << " : " << val->to_string(); }
184
235
  std::cerr << std::endl;
185
236
  }
@@ -187,7 +238,7 @@ namespace Sass {
187
238
  return indent ;
188
239
  }
189
240
  #endif
190
-
241
+ */
191
242
  // compile implementation for AST_Node
192
243
  template class Environment<AST_Node_Obj>;
193
244
 
@@ -2,17 +2,26 @@
2
2
  #define SASS_ENVIRONMENT_H
3
3
 
4
4
  #include <string>
5
- #include <map>
6
-
7
5
  #include "ast_fwd_decl.hpp"
8
6
  #include "ast_def_macros.hpp"
9
7
 
10
8
  namespace Sass {
11
9
 
10
+ typedef environment_map<std::string, AST_Node_Obj>::iterator EnvIter;
11
+
12
+ class EnvResult {
13
+ public:
14
+ EnvIter it;
15
+ bool found;
16
+ public:
17
+ EnvResult(EnvIter it, bool found)
18
+ : it(it), found(found) {}
19
+ };
20
+
12
21
  template <typename T>
13
22
  class Environment {
14
23
  // TODO: test with map
15
- std::map<std::string, T> local_frame_;
24
+ environment_map<std::string, T> local_frame_;
16
25
  ADD_PROPERTY(Environment*, parent)
17
26
  ADD_PROPERTY(bool, is_shadow)
18
27
 
@@ -37,14 +46,17 @@ namespace Sass {
37
46
 
38
47
  // scope operates on the current frame
39
48
 
40
- std::map<std::string, T>& local_frame();
49
+ environment_map<std::string, T>& local_frame();
41
50
 
42
51
  bool has_local(const std::string& key) const;
43
52
 
53
+ EnvResult find_local(const std::string& key);
54
+
44
55
  T& get_local(const std::string& key);
45
56
 
46
57
  // set variable on the current frame
47
- void set_local(const std::string& key, T val);
58
+ void set_local(const std::string& key, const T& val);
59
+ void set_local(const std::string& key, T&& val);
48
60
 
49
61
  void del_local(const std::string& key);
50
62
 
@@ -60,7 +72,8 @@ namespace Sass {
60
72
  T& get_global(const std::string& key);
61
73
 
62
74
  // set a variable on the global frame
63
- void set_global(const std::string& key, T val);
75
+ void set_global(const std::string& key, const T& val);
76
+ void set_global(const std::string& key, T&& val);
64
77
 
65
78
  void del_global(const std::string& key);
66
79
 
@@ -72,12 +85,17 @@ namespace Sass {
72
85
  // see if we have a lexical we could update
73
86
  // either update already existing lexical value
74
87
  // or we create a new one on the current frame
75
- void set_lexical(const std::string& key, T val);
88
+ void set_lexical(const std::string& key, T&& val);
89
+ void set_lexical(const std::string& key, const T& val);
76
90
 
77
91
  // look on the full stack for key
78
92
  // include all scopes available
79
93
  bool has(const std::string& key) const;
80
94
 
95
+ // look on the full stack for key
96
+ // include all scopes available
97
+ EnvResult find(const std::string& key);
98
+
81
99
  // use array access for getter and setter functions
82
100
  T& operator[](const std::string& key);
83
101
 
@@ -87,6 +105,9 @@ namespace Sass {
87
105
 
88
106
  };
89
107
 
108
+ // define typedef for our use case
109
+ typedef Environment<AST_Node_Obj> Env;
110
+
90
111
  }
91
112
 
92
113
  #endif
@@ -10,19 +10,18 @@ namespace Sass {
10
10
 
11
11
  namespace Exception {
12
12
 
13
- Base::Base(ParserState pstate, std::string msg, std::vector<Sass_Import_Entry>* import_stack)
13
+ Base::Base(ParserState pstate, std::string msg, Backtraces traces)
14
14
  : std::runtime_error(msg), msg(msg),
15
- prefix("Error"), pstate(pstate),
16
- import_stack(import_stack)
15
+ prefix("Error"), pstate(pstate), traces(traces)
17
16
  { }
18
17
 
19
- InvalidSass::InvalidSass(ParserState pstate, std::string msg)
20
- : Base(pstate, msg)
18
+ InvalidSass::InvalidSass(ParserState pstate, Backtraces traces, std::string msg)
19
+ : Base(pstate, msg, traces)
21
20
  { }
22
21
 
23
22
 
24
- InvalidParent::InvalidParent(Selector_Ptr parent, Selector_Ptr selector)
25
- : Base(selector->pstate()), parent(parent), selector(selector)
23
+ InvalidParent::InvalidParent(Selector_Ptr parent, Backtraces traces, Selector_Ptr selector)
24
+ : Base(selector->pstate(), def_msg, traces), parent(parent), selector(selector)
26
25
  {
27
26
  msg = "Invalid parent selector for \"";
28
27
  msg += selector->to_string(Sass_Inspect_Options());
@@ -31,8 +30,15 @@ namespace Sass {
31
30
  msg += "\"";
32
31
  }
33
32
 
34
- InvalidArgumentType::InvalidArgumentType(ParserState pstate, std::string fn, std::string arg, std::string type, const Value_Ptr value)
35
- : Base(pstate), fn(fn), arg(arg), type(type), value(value)
33
+ InvalidVarKwdType::InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument_Ptr arg)
34
+ : Base(pstate, def_msg, traces), name(name), arg(arg)
35
+ {
36
+ msg = "Variable keyword argument map must have string keys.\n";
37
+ msg += name + " is not a string in " + arg->to_string() + ".";
38
+ }
39
+
40
+ InvalidArgumentType::InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value_Ptr value)
41
+ : Base(pstate, def_msg, traces), fn(fn), arg(arg), type(type), value(value)
36
42
  {
37
43
  msg = arg + ": \"";
38
44
  if (value) msg += value->to_string(Sass_Inspect_Options());
@@ -40,46 +46,24 @@ namespace Sass {
40
46
  msg += " for `" + fn + "'";
41
47
  }
42
48
 
43
- MissingArgument::MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype)
44
- : Base(pstate), fn(fn), arg(arg), fntype(fntype)
49
+ MissingArgument::MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype)
50
+ : Base(pstate, def_msg, traces), fn(fn), arg(arg), fntype(fntype)
45
51
  {
46
52
  msg = fntype + " " + fn;
47
53
  msg += " is missing argument ";
48
54
  msg += arg + ".";
49
55
  }
50
56
 
51
- InvalidSyntax::InvalidSyntax(ParserState pstate, std::string msg, std::vector<Sass_Import_Entry>* import_stack)
52
- : Base(pstate, msg, import_stack)
57
+ InvalidSyntax::InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg)
58
+ : Base(pstate, msg, traces)
53
59
  { }
54
60
 
55
- UndefinedOperation::UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op)
56
- : lhs(lhs), rhs(rhs), op(op)
57
- {
58
- msg = def_op_msg + ": \"";
59
- msg += lhs->to_string({ NESTED, 5 });
60
- msg += " " + op + " ";
61
- msg += rhs->to_string({ TO_SASS, 5 });
62
- msg += "\".";
63
- }
64
-
65
- InvalidNullOperation::InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op)
66
- : UndefinedOperation(lhs, rhs, op)
67
- {
68
- msg = def_op_null_msg + ": \"";
69
- msg += lhs->inspect();
70
- msg += " " + op + " ";
71
- msg += rhs->inspect();
72
- msg += "\".";
73
- }
74
-
75
- ZeroDivisionError::ZeroDivisionError(const Expression& lhs, const Expression& rhs)
76
- : lhs(lhs), rhs(rhs)
77
- {
78
- msg = "divided by 0";
79
- }
61
+ NestingLimitError::NestingLimitError(ParserState pstate, Backtraces traces, std::string msg)
62
+ : Base(pstate, msg, traces)
63
+ { }
80
64
 
81
- DuplicateKeyError::DuplicateKeyError(const Map& dup, const Expression& org)
82
- : Base(org.pstate()), dup(dup), org(org)
65
+ DuplicateKeyError::DuplicateKeyError(Backtraces traces, const Map& dup, const Expression& org)
66
+ : Base(org.pstate(), def_msg, traces), dup(dup), org(org)
83
67
  {
84
68
  msg = "Duplicate key ";
85
69
  msg += dup.get_duplicate_key()->inspect();
@@ -88,8 +72,8 @@ namespace Sass {
88
72
  msg += ").";
89
73
  }
90
74
 
91
- TypeMismatch::TypeMismatch(const Expression& var, const std::string type)
92
- : Base(var.pstate()), var(var), type(type)
75
+ TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const std::string type)
76
+ : Base(var.pstate(), def_msg, traces), var(var), type(type)
93
77
  {
94
78
  msg = var.to_string();
95
79
  msg += " is not an ";
@@ -97,21 +81,20 @@ namespace Sass {
97
81
  msg += ".";
98
82
  }
99
83
 
100
- InvalidValue::InvalidValue(const Expression& val)
101
- : Base(val.pstate()), val(val)
84
+ InvalidValue::InvalidValue(Backtraces traces, const Expression& val)
85
+ : Base(val.pstate(), def_msg, traces), val(val)
102
86
  {
103
87
  msg = val.to_string();
104
88
  msg += " isn't a valid CSS value.";
105
89
  }
106
90
 
107
- StackError::StackError(const AST_Node& node)
108
- : Base(node.pstate()), node(node)
91
+ StackError::StackError(Backtraces traces, const AST_Node& node)
92
+ : Base(node.pstate(), def_msg, traces), node(node)
109
93
  {
110
94
  msg = "stack level too deep";
111
95
  }
112
96
 
113
- IncompatibleUnits::IncompatibleUnits(const Number& lhs, const Number& rhs)
114
- : lhs(lhs), rhs(rhs)
97
+ IncompatibleUnits::IncompatibleUnits(const Units& lhs, const Units& rhs)
115
98
  {
116
99
  msg = "Incompatible units: '";
117
100
  msg += rhs.unit();
@@ -120,19 +103,53 @@ namespace Sass {
120
103
  msg += "'.";
121
104
  }
122
105
 
123
- AlphaChannelsNotEqual::AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op)
124
- : lhs(lhs), rhs(rhs), op(op)
106
+ IncompatibleUnits::IncompatibleUnits(const UnitType lhs, const UnitType rhs)
107
+ {
108
+ msg = "Incompatible units: '";
109
+ msg += unit_to_string(rhs);
110
+ msg += "' and '";
111
+ msg += unit_to_string(lhs);
112
+ msg += "'.";
113
+ }
114
+
115
+ AlphaChannelsNotEqual::AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
116
+ : OperationError(), lhs(lhs), rhs(rhs), op(op)
125
117
  {
126
118
  msg = "Alpha channels must be equal: ";
127
119
  msg += lhs->to_string({ NESTED, 5 });
128
- msg += " " + op + " ";
120
+ msg += " " + sass_op_to_name(op) + " ";
129
121
  msg += rhs->to_string({ NESTED, 5 });
130
122
  msg += ".";
131
123
  }
132
124
 
125
+ ZeroDivisionError::ZeroDivisionError(const Expression& lhs, const Expression& rhs)
126
+ : OperationError(), lhs(lhs), rhs(rhs)
127
+ {
128
+ msg = "divided by 0";
129
+ }
130
+
131
+ UndefinedOperation::UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
132
+ : OperationError(), lhs(lhs), rhs(rhs), op(op)
133
+ {
134
+ msg = def_op_msg + ": \"";
135
+ msg += lhs->to_string({ NESTED, 5 });
136
+ msg += " " + sass_op_to_name(op) + " ";
137
+ msg += rhs->to_string({ TO_SASS, 5 });
138
+ msg += "\".";
139
+ }
140
+
141
+ InvalidNullOperation::InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
142
+ : UndefinedOperation(lhs, rhs, op)
143
+ {
144
+ msg = def_op_null_msg + ": \"";
145
+ msg += lhs->inspect();
146
+ msg += " " + sass_op_to_name(op) + " ";
147
+ msg += rhs->inspect();
148
+ msg += "\".";
149
+ }
133
150
 
134
- SassValueError::SassValueError(ParserState pstate, OperationError& err)
135
- : Base(pstate, err.what())
151
+ SassValueError::SassValueError(Backtraces traces, ParserState pstate, OperationError& err)
152
+ : Base(pstate, err.what(), traces)
136
153
  {
137
154
  msg = err.what();
138
155
  prefix = err.errtype();
@@ -143,13 +160,22 @@ namespace Sass {
143
160
 
144
161
  void warn(std::string msg, ParserState pstate)
145
162
  {
146
- std::cerr << "Warning: " << msg<< std::endl;
163
+ std::cerr << "Warning: " << msg << std::endl;
164
+ }
165
+
166
+ void warning(std::string msg, ParserState pstate)
167
+ {
168
+ std::string cwd(Sass::File::get_cwd());
169
+ std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
170
+ std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
171
+ std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
172
+
173
+ std::cerr << "WARNING on line " << pstate.line+1 << ", column " << pstate.column+1 << " of " << output_path << ":" << std::endl;
174
+ std::cerr << msg << std::endl << std::endl;
147
175
  }
148
176
 
149
177
  void warn(std::string msg, ParserState pstate, Backtrace* bt)
150
178
  {
151
- Backtrace top(bt, pstate, "");
152
- msg += top.to_string();
153
179
  warn(msg, pstate);
154
180
  }
155
181
 
@@ -165,7 +191,7 @@ namespace Sass {
165
191
  std::cerr << " on line " << pstate.line+1 << " of " << output_path << std::endl;
166
192
  }
167
193
 
168
- void deprecated(std::string msg, std::string msg2, ParserState pstate)
194
+ void deprecated(std::string msg, std::string msg2, bool with_column, ParserState pstate)
169
195
  {
170
196
  std::string cwd(Sass::File::get_cwd());
171
197
  std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
@@ -173,9 +199,10 @@ namespace Sass {
173
199
  std::string output_path(Sass::File::path_for_console(rel_path, pstate.path, pstate.path));
174
200
 
175
201
  std::cerr << "DEPRECATION WARNING on line " << pstate.line + 1;
202
+ if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
176
203
  if (output_path.length()) std::cerr << " of " << output_path;
177
204
  std::cerr << ":" << std::endl;
178
- std::cerr << msg << " and will be an error in future versions of Sass." << std::endl;
205
+ std::cerr << msg << std::endl;
179
206
  if (msg2.length()) std::cerr << msg2 << std::endl;
180
207
  std::cerr << std::endl;
181
208
  }
@@ -192,16 +219,17 @@ namespace Sass {
192
219
  std::cerr << "This will be an error in future versions of Sass." << std::endl;
193
220
  }
194
221
 
195
- void error(std::string msg, ParserState pstate)
222
+ // should be replaced with error with backtraces
223
+ void coreError(std::string msg, ParserState pstate)
196
224
  {
197
- throw Exception::InvalidSyntax(pstate, msg);
225
+ Backtraces traces;
226
+ throw Exception::InvalidSyntax(pstate, traces, msg);
198
227
  }
199
228
 
200
- void error(std::string msg, ParserState pstate, Backtrace* bt)
229
+ void error(std::string msg, ParserState pstate, Backtraces& traces)
201
230
  {
202
- Backtrace top(bt, pstate, "");
203
- msg += "\n" + top.to_string();
204
- error(msg, pstate);
231
+ traces.push_back(Backtrace(pstate));
232
+ throw Exception::InvalidSyntax(pstate, traces, msg);
205
233
  }
206
234
 
207
235
  }