sassc 1.11.4 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/CODE_OF_CONDUCT.md +10 -0
- data/README.md +4 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.github/CONTRIBUTING.md +7 -7
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
- data/ext/libsass/.gitignore +3 -0
- data/ext/libsass/.travis.yml +37 -18
- data/ext/libsass/GNUmakefile.am +23 -37
- data/ext/libsass/Makefile +10 -6
- data/ext/libsass/Makefile.conf +3 -0
- data/ext/libsass/Readme.md +68 -63
- data/ext/libsass/appveyor.yml +7 -3
- data/ext/libsass/configure.ac +10 -14
- data/ext/libsass/docs/api-context-internal.md +29 -21
- data/ext/libsass/docs/api-context.md +26 -6
- data/ext/libsass/docs/api-doc.md +49 -16
- data/ext/libsass/docs/api-function-example.md +1 -1
- data/ext/libsass/docs/api-function.md +31 -7
- data/ext/libsass/docs/api-importer.md +19 -19
- data/ext/libsass/docs/api-value.md +4 -2
- data/ext/libsass/docs/build-on-windows.md +4 -4
- data/ext/libsass/docs/build-with-mingw.md +3 -3
- data/ext/libsass/docs/build.md +9 -9
- data/ext/libsass/docs/custom-functions-internal.md +10 -8
- data/ext/libsass/docs/implementations.md +20 -8
- data/ext/libsass/docs/unicode.md +16 -10
- data/ext/libsass/include/sass/base.h +0 -3
- data/ext/libsass/include/sass/context.h +20 -2
- data/ext/libsass/include/sass/functions.h +31 -0
- data/ext/libsass/include/sass/values.h +3 -1
- data/ext/libsass/include/sass/version.h +1 -1
- data/ext/libsass/include/sass/version.h.in +1 -1
- data/ext/libsass/include/sass2scss.h +1 -1
- data/ext/libsass/res/resource.rc +6 -6
- data/ext/libsass/script/ci-build-libsass +10 -5
- data/ext/libsass/script/ci-build-plugin +62 -0
- data/ext/libsass/script/ci-install-compiler +1 -1
- data/ext/libsass/script/ci-install-deps +4 -7
- data/ext/libsass/script/ci-report-coverage +13 -3
- data/ext/libsass/script/tap-driver +1 -1
- data/ext/libsass/script/tap-runner +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -1
- data/ext/libsass/src/ast.cpp +537 -762
- data/ext/libsass/src/ast.hpp +377 -419
- data/ext/libsass/src/ast_def_macros.hpp +26 -1
- data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
- data/ext/libsass/src/b64/encode.h +3 -1
- data/ext/libsass/src/backtrace.cpp +46 -0
- data/ext/libsass/src/backtrace.hpp +7 -54
- data/ext/libsass/src/bind.cpp +72 -50
- data/ext/libsass/src/bind.hpp +0 -1
- data/ext/libsass/src/cencode.c +6 -0
- data/ext/libsass/src/check_nesting.cpp +157 -135
- data/ext/libsass/src/check_nesting.hpp +11 -10
- data/ext/libsass/src/color_maps.cpp +10 -6
- data/ext/libsass/src/color_maps.hpp +6 -8
- data/ext/libsass/src/constants.cpp +4 -3
- data/ext/libsass/src/constants.hpp +4 -3
- data/ext/libsass/src/context.cpp +110 -47
- data/ext/libsass/src/context.hpp +11 -1
- data/ext/libsass/src/cssize.cpp +105 -94
- data/ext/libsass/src/cssize.hpp +4 -5
- data/ext/libsass/src/debugger.hpp +247 -244
- data/ext/libsass/src/emitter.cpp +30 -6
- data/ext/libsass/src/emitter.hpp +7 -0
- data/ext/libsass/src/environment.cpp +67 -16
- data/ext/libsass/src/environment.hpp +28 -7
- data/ext/libsass/src/error_handling.cpp +92 -64
- data/ext/libsass/src/error_handling.hpp +64 -43
- data/ext/libsass/src/eval.cpp +494 -544
- data/ext/libsass/src/eval.hpp +17 -23
- data/ext/libsass/src/expand.cpp +182 -154
- data/ext/libsass/src/expand.hpp +4 -5
- data/ext/libsass/src/extend.cpp +299 -291
- data/ext/libsass/src/extend.hpp +46 -11
- data/ext/libsass/src/file.cpp +103 -36
- data/ext/libsass/src/file.hpp +21 -4
- data/ext/libsass/src/functions.cpp +561 -312
- data/ext/libsass/src/functions.hpp +8 -5
- data/ext/libsass/src/inspect.cpp +108 -53
- data/ext/libsass/src/inspect.hpp +5 -2
- data/ext/libsass/src/lexer.cpp +15 -7
- data/ext/libsass/src/lexer.hpp +13 -4
- data/ext/libsass/src/listize.cpp +3 -2
- data/ext/libsass/src/listize.hpp +0 -1
- data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
- data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
- data/ext/libsass/src/node.cpp +34 -38
- data/ext/libsass/src/node.hpp +6 -8
- data/ext/libsass/src/operation.hpp +2 -2
- data/ext/libsass/src/operators.cpp +240 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/output.cpp +22 -20
- data/ext/libsass/src/parser.cpp +719 -358
- data/ext/libsass/src/parser.hpp +57 -22
- data/ext/libsass/src/plugins.cpp +28 -10
- data/ext/libsass/src/position.cpp +21 -3
- data/ext/libsass/src/position.hpp +2 -1
- data/ext/libsass/src/prelexer.cpp +104 -19
- data/ext/libsass/src/prelexer.hpp +10 -3
- data/ext/libsass/src/remove_placeholders.cpp +9 -10
- data/ext/libsass/src/remove_placeholders.hpp +1 -5
- data/ext/libsass/src/sass.cpp +62 -4
- data/ext/libsass/src/sass.hpp +5 -2
- data/ext/libsass/src/sass_context.cpp +96 -58
- data/ext/libsass/src/sass_context.hpp +7 -5
- data/ext/libsass/src/sass_functions.cpp +63 -1
- data/ext/libsass/src/sass_functions.hpp +19 -1
- data/ext/libsass/src/sass_util.cpp +3 -3
- data/ext/libsass/src/sass_util.hpp +4 -4
- data/ext/libsass/src/sass_values.cpp +42 -39
- data/ext/libsass/src/sass_values.hpp +2 -1
- data/ext/libsass/src/source_map.cpp +16 -18
- data/ext/libsass/src/subset_map.cpp +6 -8
- data/ext/libsass/src/subset_map.hpp +6 -6
- data/ext/libsass/src/to_c.cpp +2 -2
- data/ext/libsass/src/to_value.cpp +8 -3
- data/ext/libsass/src/to_value.hpp +1 -0
- data/ext/libsass/src/units.cpp +349 -45
- data/ext/libsass/src/units.hpp +39 -22
- data/ext/libsass/src/utf8/checked.h +7 -0
- data/ext/libsass/src/utf8/unchecked.h +7 -0
- data/ext/libsass/src/utf8_string.cpp +1 -1
- data/ext/libsass/src/util.cpp +139 -45
- data/ext/libsass/src/util.hpp +4 -7
- data/ext/libsass/src/values.cpp +15 -23
- data/ext/libsass/win/libsass.sln +13 -2
- data/ext/libsass/win/libsass.sln.DotSettings +9 -0
- data/ext/libsass/win/libsass.targets +3 -0
- data/ext/libsass/win/libsass.vcxproj.filters +9 -0
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -1
- data/test/native_test.rb +1 -1
- metadata +11 -4
data/ext/libsass/src/bind.hpp
CHANGED
data/ext/libsass/src/cencode.c
CHANGED
|
@@ -46,6 +46,9 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
|
46
46
|
result = (fragment & 0x0fc) >> 2;
|
|
47
47
|
*codechar++ = base64_encode_value(result);
|
|
48
48
|
result = (fragment & 0x003) << 4;
|
|
49
|
+
#ifndef _MSC_VER
|
|
50
|
+
__attribute__ ((fallthrough));
|
|
51
|
+
#endif
|
|
49
52
|
case step_B:
|
|
50
53
|
if (plainchar == plaintextend)
|
|
51
54
|
{
|
|
@@ -57,6 +60,9 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
|
57
60
|
result |= (fragment & 0x0f0) >> 4;
|
|
58
61
|
*codechar++ = base64_encode_value(result);
|
|
59
62
|
result = (fragment & 0x00f) << 2;
|
|
63
|
+
#ifndef _MSC_VER
|
|
64
|
+
__attribute__ ((fallthrough));
|
|
65
|
+
#endif
|
|
60
66
|
case step_C:
|
|
61
67
|
if (plainchar == plaintextend)
|
|
62
68
|
{
|
|
@@ -7,15 +7,20 @@ namespace Sass {
|
|
|
7
7
|
|
|
8
8
|
CheckNesting::CheckNesting()
|
|
9
9
|
: parents(std::vector<Statement_Ptr>()),
|
|
10
|
-
|
|
11
|
-
current_mixin_definition(0)
|
|
10
|
+
traces(std::vector<Backtrace>()),
|
|
11
|
+
parent(0), current_mixin_definition(0)
|
|
12
12
|
{ }
|
|
13
13
|
|
|
14
|
+
void error(AST_Node_Ptr node, Backtraces traces, std::string msg) {
|
|
15
|
+
traces.push_back(Backtrace(node->pstate()));
|
|
16
|
+
throw Exception::InvalidSass(node->pstate(), traces, msg);
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
Statement_Ptr CheckNesting::visit_children(Statement_Ptr parent)
|
|
15
20
|
{
|
|
16
21
|
Statement_Ptr old_parent = this->parent;
|
|
17
22
|
|
|
18
|
-
if (At_Root_Block_Ptr root =
|
|
23
|
+
if (At_Root_Block_Ptr root = Cast<At_Root_Block>(parent)) {
|
|
19
24
|
std::vector<Statement_Ptr> old_parents = this->parents;
|
|
20
25
|
std::vector<Statement_Ptr> new_parents;
|
|
21
26
|
|
|
@@ -39,8 +44,14 @@ namespace Sass {
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
At_Root_Block_Ptr ar =
|
|
43
|
-
|
|
47
|
+
At_Root_Block_Ptr ar = Cast<At_Root_Block>(parent);
|
|
48
|
+
Block_Ptr ret = ar->block();
|
|
49
|
+
|
|
50
|
+
if (ret != NULL) {
|
|
51
|
+
for (auto n : ret->elements()) {
|
|
52
|
+
n->perform(this);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
|
|
45
56
|
this->parent = old_parent;
|
|
46
57
|
this->parents = old_parents;
|
|
@@ -54,11 +65,17 @@ namespace Sass {
|
|
|
54
65
|
|
|
55
66
|
this->parents.push_back(parent);
|
|
56
67
|
|
|
57
|
-
Block_Ptr b =
|
|
68
|
+
Block_Ptr b = Cast<Block>(parent);
|
|
69
|
+
|
|
70
|
+
if (Trace_Ptr trace = Cast<Trace>(parent)) {
|
|
71
|
+
if (trace->type() == 'i') {
|
|
72
|
+
this->traces.push_back(Backtrace(trace->pstate()));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
58
75
|
|
|
59
76
|
if (!b) {
|
|
60
|
-
if (Has_Block_Ptr bb =
|
|
61
|
-
b =
|
|
77
|
+
if (Has_Block_Ptr bb = Cast<Has_Block>(parent)) {
|
|
78
|
+
b = bb->block();
|
|
62
79
|
}
|
|
63
80
|
}
|
|
64
81
|
|
|
@@ -67,9 +84,16 @@ namespace Sass {
|
|
|
67
84
|
n->perform(this);
|
|
68
85
|
}
|
|
69
86
|
}
|
|
87
|
+
|
|
70
88
|
this->parent = old_parent;
|
|
71
89
|
this->parents.pop_back();
|
|
72
90
|
|
|
91
|
+
if (Trace_Ptr trace = Cast<Trace>(parent)) {
|
|
92
|
+
if (trace->type() == 'i') {
|
|
93
|
+
this->traces.pop_back();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
73
97
|
return b;
|
|
74
98
|
}
|
|
75
99
|
|
|
@@ -97,10 +121,21 @@ namespace Sass {
|
|
|
97
121
|
return n;
|
|
98
122
|
}
|
|
99
123
|
|
|
124
|
+
Statement_Ptr CheckNesting::operator()(If_Ptr i)
|
|
125
|
+
{
|
|
126
|
+
this->visit_children(i);
|
|
127
|
+
|
|
128
|
+
if (Block_Ptr b = Cast<Block>(i->alternative())) {
|
|
129
|
+
for (auto n : b->elements()) n->perform(this);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return i;
|
|
133
|
+
}
|
|
134
|
+
|
|
100
135
|
Statement_Ptr CheckNesting::fallback_impl(Statement_Ptr s)
|
|
101
136
|
{
|
|
102
|
-
Block_Ptr b1 =
|
|
103
|
-
Has_Block_Ptr b2 =
|
|
137
|
+
Block_Ptr b1 = Cast<Block>(s);
|
|
138
|
+
Has_Block_Ptr b2 = Cast<Has_Block>(s);
|
|
104
139
|
return b1 || b2 ? visit_children(s) : s;
|
|
105
140
|
}
|
|
106
141
|
|
|
@@ -108,91 +143,82 @@ namespace Sass {
|
|
|
108
143
|
{
|
|
109
144
|
if (!this->parent) return true;
|
|
110
145
|
|
|
111
|
-
if (
|
|
112
|
-
{ this->invalid_content_parent(this->parent); }
|
|
146
|
+
if (Cast<Content>(node))
|
|
147
|
+
{ this->invalid_content_parent(this->parent, node); }
|
|
113
148
|
|
|
114
149
|
if (is_charset(node))
|
|
115
|
-
{ this->invalid_charset_parent(this->parent); }
|
|
150
|
+
{ this->invalid_charset_parent(this->parent, node); }
|
|
116
151
|
|
|
117
|
-
if (
|
|
118
|
-
{ this->invalid_extend_parent(this->parent); }
|
|
152
|
+
if (Cast<Extension>(node))
|
|
153
|
+
{ this->invalid_extend_parent(this->parent, node); }
|
|
119
154
|
|
|
120
|
-
// if (
|
|
155
|
+
// if (Cast<Import>(node))
|
|
121
156
|
// { this->invalid_import_parent(this->parent); }
|
|
122
157
|
|
|
123
158
|
if (this->is_mixin(node))
|
|
124
|
-
{ this->invalid_mixin_definition_parent(this->parent); }
|
|
159
|
+
{ this->invalid_mixin_definition_parent(this->parent, node); }
|
|
125
160
|
|
|
126
161
|
if (this->is_function(node))
|
|
127
|
-
{ this->invalid_function_parent(this->parent); }
|
|
162
|
+
{ this->invalid_function_parent(this->parent, node); }
|
|
128
163
|
|
|
129
164
|
if (this->is_function(this->parent))
|
|
130
165
|
{ this->invalid_function_child(node); }
|
|
131
166
|
|
|
132
|
-
if (
|
|
133
|
-
{
|
|
167
|
+
if (Declaration_Ptr d = Cast<Declaration>(node))
|
|
168
|
+
{
|
|
169
|
+
this->invalid_prop_parent(this->parent, node);
|
|
170
|
+
this->invalid_value_child(d->value());
|
|
171
|
+
}
|
|
134
172
|
|
|
135
|
-
if (
|
|
173
|
+
if (Cast<Declaration>(this->parent))
|
|
136
174
|
{ this->invalid_prop_child(node); }
|
|
137
175
|
|
|
138
|
-
if (
|
|
139
|
-
{ this->invalid_return_parent(this->parent); }
|
|
176
|
+
if (Cast<Return>(node))
|
|
177
|
+
{ this->invalid_return_parent(this->parent, node); }
|
|
140
178
|
|
|
141
179
|
return true;
|
|
142
180
|
}
|
|
143
181
|
|
|
144
|
-
void CheckNesting::invalid_content_parent(Statement_Ptr parent)
|
|
182
|
+
void CheckNesting::invalid_content_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
145
183
|
{
|
|
146
184
|
if (!this->current_mixin_definition) {
|
|
147
|
-
|
|
148
|
-
parent->pstate(),
|
|
149
|
-
"@content may only be used within a mixin."
|
|
150
|
-
);
|
|
185
|
+
error(node, traces, "@content may only be used within a mixin.");
|
|
151
186
|
}
|
|
152
187
|
}
|
|
153
188
|
|
|
154
|
-
void CheckNesting::invalid_charset_parent(Statement_Ptr parent)
|
|
189
|
+
void CheckNesting::invalid_charset_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
155
190
|
{
|
|
156
191
|
if (!(
|
|
157
192
|
is_root_node(parent)
|
|
158
193
|
)) {
|
|
159
|
-
|
|
160
|
-
parent->pstate(),
|
|
161
|
-
"@charset may only be used at the root of a document."
|
|
162
|
-
);
|
|
194
|
+
error(node, traces, "@charset may only be used at the root of a document.");
|
|
163
195
|
}
|
|
164
196
|
}
|
|
165
197
|
|
|
166
|
-
void CheckNesting::invalid_extend_parent(Statement_Ptr parent)
|
|
198
|
+
void CheckNesting::invalid_extend_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
167
199
|
{
|
|
168
200
|
if (!(
|
|
169
|
-
|
|
170
|
-
|
|
201
|
+
Cast<Ruleset>(parent) ||
|
|
202
|
+
Cast<Mixin_Call>(parent) ||
|
|
171
203
|
is_mixin(parent)
|
|
172
204
|
)) {
|
|
173
|
-
|
|
174
|
-
parent->pstate(),
|
|
175
|
-
"Extend directives may only be used within rules."
|
|
176
|
-
);
|
|
205
|
+
error(node, traces, "Extend directives may only be used within rules.");
|
|
177
206
|
}
|
|
178
207
|
}
|
|
179
208
|
|
|
180
|
-
// void CheckNesting::invalid_import_parent(Statement_Ptr parent)
|
|
209
|
+
// void CheckNesting::invalid_import_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
181
210
|
// {
|
|
182
211
|
// for (auto pp : this->parents) {
|
|
183
212
|
// if (
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
//
|
|
213
|
+
// Cast<Each>(pp) ||
|
|
214
|
+
// Cast<For>(pp) ||
|
|
215
|
+
// Cast<If>(pp) ||
|
|
216
|
+
// Cast<While>(pp) ||
|
|
217
|
+
// Cast<Trace>(pp) ||
|
|
218
|
+
// Cast<Mixin_Call>(pp) ||
|
|
190
219
|
// is_mixin(pp)
|
|
191
220
|
// ) {
|
|
192
|
-
//
|
|
193
|
-
// parent->pstate(),
|
|
194
|
-
// "Import directives may not be defined within control directives or other mixins."
|
|
195
|
-
// );
|
|
221
|
+
// error(node, traces, "Import directives may not be defined within control directives or other mixins.");
|
|
196
222
|
// }
|
|
197
223
|
// }
|
|
198
224
|
|
|
@@ -201,49 +227,40 @@ namespace Sass {
|
|
|
201
227
|
// }
|
|
202
228
|
|
|
203
229
|
// if (false/*n.css_import?*/) {
|
|
204
|
-
//
|
|
205
|
-
// parent->pstate(),
|
|
206
|
-
// "CSS import directives may only be used at the root of a document."
|
|
207
|
-
// );
|
|
230
|
+
// error(node, traces, "CSS import directives may only be used at the root of a document.");
|
|
208
231
|
// }
|
|
209
232
|
// }
|
|
210
233
|
|
|
211
|
-
void CheckNesting::invalid_mixin_definition_parent(Statement_Ptr parent)
|
|
234
|
+
void CheckNesting::invalid_mixin_definition_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
212
235
|
{
|
|
213
236
|
for (Statement_Ptr pp : this->parents) {
|
|
214
237
|
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
Cast<Each>(pp) ||
|
|
239
|
+
Cast<For>(pp) ||
|
|
240
|
+
Cast<If>(pp) ||
|
|
241
|
+
Cast<While>(pp) ||
|
|
242
|
+
Cast<Trace>(pp) ||
|
|
243
|
+
Cast<Mixin_Call>(pp) ||
|
|
221
244
|
is_mixin(pp)
|
|
222
245
|
) {
|
|
223
|
-
|
|
224
|
-
parent->pstate(),
|
|
225
|
-
"Mixins may not be defined within control directives or other mixins."
|
|
226
|
-
);
|
|
246
|
+
error(node, traces, "Mixins may not be defined within control directives or other mixins.");
|
|
227
247
|
}
|
|
228
248
|
}
|
|
229
249
|
}
|
|
230
250
|
|
|
231
|
-
void CheckNesting::invalid_function_parent(Statement_Ptr parent)
|
|
251
|
+
void CheckNesting::invalid_function_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
232
252
|
{
|
|
233
253
|
for (Statement_Ptr pp : this->parents) {
|
|
234
254
|
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
Cast<Each>(pp) ||
|
|
256
|
+
Cast<For>(pp) ||
|
|
257
|
+
Cast<If>(pp) ||
|
|
258
|
+
Cast<While>(pp) ||
|
|
259
|
+
Cast<Trace>(pp) ||
|
|
260
|
+
Cast<Mixin_Call>(pp) ||
|
|
241
261
|
is_mixin(pp)
|
|
242
262
|
) {
|
|
243
|
-
|
|
244
|
-
parent->pstate(),
|
|
245
|
-
"Functions may not be defined within control directives or other mixins."
|
|
246
|
-
);
|
|
263
|
+
error(node, traces, "Functions may not be defined within control directives or other mixins.");
|
|
247
264
|
}
|
|
248
265
|
}
|
|
249
266
|
}
|
|
@@ -251,70 +268,75 @@ namespace Sass {
|
|
|
251
268
|
void CheckNesting::invalid_function_child(Statement_Ptr child)
|
|
252
269
|
{
|
|
253
270
|
if (!(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
271
|
+
Cast<Each>(child) ||
|
|
272
|
+
Cast<For>(child) ||
|
|
273
|
+
Cast<If>(child) ||
|
|
274
|
+
Cast<While>(child) ||
|
|
275
|
+
Cast<Trace>(child) ||
|
|
276
|
+
Cast<Comment>(child) ||
|
|
277
|
+
Cast<Debug>(child) ||
|
|
278
|
+
Cast<Return>(child) ||
|
|
279
|
+
Cast<Variable>(child) ||
|
|
263
280
|
// Ruby Sass doesn't distinguish variables and assignments
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
281
|
+
Cast<Assignment>(child) ||
|
|
282
|
+
Cast<Warning>(child) ||
|
|
283
|
+
Cast<Error>(child)
|
|
267
284
|
)) {
|
|
268
|
-
|
|
269
|
-
child->pstate(),
|
|
270
|
-
"Functions can only contain variable declarations and control directives."
|
|
271
|
-
);
|
|
285
|
+
error(child, traces, "Functions can only contain variable declarations and control directives.");
|
|
272
286
|
}
|
|
273
287
|
}
|
|
274
288
|
|
|
275
289
|
void CheckNesting::invalid_prop_child(Statement_Ptr child)
|
|
276
290
|
{
|
|
277
291
|
if (!(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
292
|
+
Cast<Each>(child) ||
|
|
293
|
+
Cast<For>(child) ||
|
|
294
|
+
Cast<If>(child) ||
|
|
295
|
+
Cast<While>(child) ||
|
|
296
|
+
Cast<Trace>(child) ||
|
|
297
|
+
Cast<Comment>(child) ||
|
|
298
|
+
Cast<Declaration>(child) ||
|
|
299
|
+
Cast<Mixin_Call>(child)
|
|
286
300
|
)) {
|
|
287
|
-
|
|
288
|
-
child->pstate(),
|
|
289
|
-
"Illegal nesting: Only properties may be nested beneath properties."
|
|
290
|
-
);
|
|
301
|
+
error(child, traces, "Illegal nesting: Only properties may be nested beneath properties.");
|
|
291
302
|
}
|
|
292
303
|
}
|
|
293
304
|
|
|
294
|
-
void CheckNesting::invalid_prop_parent(Statement_Ptr parent)
|
|
305
|
+
void CheckNesting::invalid_prop_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
295
306
|
{
|
|
296
307
|
if (!(
|
|
297
308
|
is_mixin(parent) ||
|
|
298
309
|
is_directive_node(parent) ||
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
310
|
+
Cast<Ruleset>(parent) ||
|
|
311
|
+
Cast<Keyframe_Rule>(parent) ||
|
|
312
|
+
Cast<Declaration>(parent) ||
|
|
313
|
+
Cast<Mixin_Call>(parent)
|
|
303
314
|
)) {
|
|
304
|
-
|
|
305
|
-
parent->pstate(),
|
|
306
|
-
"Properties are only allowed within rules, directives, mixin includes, or other properties."
|
|
307
|
-
);
|
|
315
|
+
error(node, traces, "Properties are only allowed within rules, directives, mixin includes, or other properties.");
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
|
|
311
|
-
void CheckNesting::
|
|
319
|
+
void CheckNesting::invalid_value_child(AST_Node_Ptr d)
|
|
320
|
+
{
|
|
321
|
+
if (Map_Ptr m = Cast<Map>(d)) {
|
|
322
|
+
traces.push_back(Backtrace(m->pstate()));
|
|
323
|
+
throw Exception::InvalidValue(traces, *m);
|
|
324
|
+
}
|
|
325
|
+
if (Number_Ptr n = Cast<Number>(d)) {
|
|
326
|
+
if (!n->is_valid_css_unit()) {
|
|
327
|
+
traces.push_back(Backtrace(n->pstate()));
|
|
328
|
+
throw Exception::InvalidValue(traces, *n);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// error(dbg + " isn't a valid CSS value.", m->pstate(),);
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
void CheckNesting::invalid_return_parent(Statement_Ptr parent, AST_Node_Ptr node)
|
|
312
337
|
{
|
|
313
338
|
if (!this->is_function(parent)) {
|
|
314
|
-
|
|
315
|
-
parent->pstate(),
|
|
316
|
-
"@return may only be used within a function."
|
|
317
|
-
);
|
|
339
|
+
error(node, traces, "@return may only be used within a function.");
|
|
318
340
|
}
|
|
319
341
|
}
|
|
320
342
|
|
|
@@ -326,51 +348,51 @@ namespace Sass {
|
|
|
326
348
|
!is_root_node(grandparent) &&
|
|
327
349
|
!is_at_root_node(grandparent);
|
|
328
350
|
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
351
|
+
return Cast<Import>(parent) ||
|
|
352
|
+
Cast<Each>(parent) ||
|
|
353
|
+
Cast<For>(parent) ||
|
|
354
|
+
Cast<If>(parent) ||
|
|
355
|
+
Cast<While>(parent) ||
|
|
356
|
+
Cast<Trace>(parent) ||
|
|
335
357
|
valid_bubble_node;
|
|
336
358
|
}
|
|
337
359
|
|
|
338
360
|
bool CheckNesting::is_charset(Statement_Ptr n)
|
|
339
361
|
{
|
|
340
|
-
Directive_Ptr d =
|
|
362
|
+
Directive_Ptr d = Cast<Directive>(n);
|
|
341
363
|
return d && d->keyword() == "charset";
|
|
342
364
|
}
|
|
343
365
|
|
|
344
366
|
bool CheckNesting::is_mixin(Statement_Ptr n)
|
|
345
367
|
{
|
|
346
|
-
Definition_Ptr def =
|
|
368
|
+
Definition_Ptr def = Cast<Definition>(n);
|
|
347
369
|
return def && def->type() == Definition::MIXIN;
|
|
348
370
|
}
|
|
349
371
|
|
|
350
372
|
bool CheckNesting::is_function(Statement_Ptr n)
|
|
351
373
|
{
|
|
352
|
-
Definition_Ptr def =
|
|
374
|
+
Definition_Ptr def = Cast<Definition>(n);
|
|
353
375
|
return def && def->type() == Definition::FUNCTION;
|
|
354
376
|
}
|
|
355
377
|
|
|
356
378
|
bool CheckNesting::is_root_node(Statement_Ptr n)
|
|
357
379
|
{
|
|
358
|
-
if (
|
|
380
|
+
if (Cast<Ruleset>(n)) return false;
|
|
359
381
|
|
|
360
|
-
Block_Ptr b =
|
|
382
|
+
Block_Ptr b = Cast<Block>(n);
|
|
361
383
|
return b && b->is_root();
|
|
362
384
|
}
|
|
363
385
|
|
|
364
386
|
bool CheckNesting::is_at_root_node(Statement_Ptr n)
|
|
365
387
|
{
|
|
366
|
-
return
|
|
388
|
+
return Cast<At_Root_Block>(n) != NULL;
|
|
367
389
|
}
|
|
368
390
|
|
|
369
391
|
bool CheckNesting::is_directive_node(Statement_Ptr n)
|
|
370
392
|
{
|
|
371
|
-
return
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
393
|
+
return Cast<Directive>(n) ||
|
|
394
|
+
Cast<Import>(n) ||
|
|
395
|
+
Cast<Media_Block>(n) ||
|
|
396
|
+
Cast<Supports_Block>(n);
|
|
375
397
|
}
|
|
376
398
|
}
|