sassc 2.0.1 → 2.1.0.pre1
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 +4 -4
- data/.gitignore +1 -0
- data/.gitmodules +1 -1
- data/.travis.yml +7 -3
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +23 -8
- data/ext/extconf.rb +39 -0
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/GNUmakefile.am +23 -39
- data/ext/libsass/Makefile +56 -91
- data/ext/libsass/Makefile.conf +16 -2
- data/ext/libsass/configure.ac +8 -12
- data/ext/libsass/include/sass/base.h +1 -0
- data/ext/libsass/include/sass/context.h +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -5
- data/ext/libsass/src/ast.cpp +747 -2010
- data/ext/libsass/src/ast.hpp +239 -2383
- data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +62 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
- data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
- data/ext/libsass/src/ast_sel_unify.cpp +280 -0
- data/ext/libsass/src/ast_selectors.cpp +1475 -0
- data/ext/libsass/src/ast_selectors.hpp +568 -0
- data/ext/libsass/src/ast_supports.cpp +130 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +967 -0
- data/ext/libsass/src/ast_values.hpp +489 -0
- data/ext/libsass/src/backtrace.cpp +4 -0
- data/ext/libsass/src/base64vlq.cpp +3 -0
- data/ext/libsass/src/bind.cpp +18 -17
- data/ext/libsass/src/bind.hpp +3 -1
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/cencode.c +2 -2
- data/ext/libsass/src/check_nesting.cpp +52 -56
- data/ext/libsass/src/check_nesting.hpp +35 -34
- data/ext/libsass/src/color_maps.cpp +156 -153
- data/ext/libsass/src/color_maps.hpp +152 -152
- data/ext/libsass/src/constants.cpp +15 -0
- data/ext/libsass/src/constants.hpp +13 -0
- data/ext/libsass/src/context.cpp +24 -14
- data/ext/libsass/src/context.hpp +6 -6
- data/ext/libsass/src/cssize.cpp +69 -71
- data/ext/libsass/src/cssize.hpp +50 -50
- data/ext/libsass/src/debugger.hpp +117 -110
- data/ext/libsass/src/emitter.cpp +13 -12
- data/ext/libsass/src/emitter.hpp +13 -9
- data/ext/libsass/src/environment.cpp +15 -1
- data/ext/libsass/src/environment.hpp +6 -0
- data/ext/libsass/src/error_handling.cpp +36 -59
- data/ext/libsass/src/error_handling.hpp +29 -16
- data/ext/libsass/src/eval.cpp +302 -323
- data/ext/libsass/src/eval.hpp +64 -55
- data/ext/libsass/src/expand.cpp +94 -88
- data/ext/libsass/src/expand.hpp +33 -37
- data/ext/libsass/src/extend.cpp +38 -36
- data/ext/libsass/src/extend.hpp +15 -15
- data/ext/libsass/src/file.cpp +34 -2
- data/ext/libsass/src/fn_colors.cpp +594 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +284 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +256 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +220 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +235 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +254 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +156 -0
- data/ext/libsass/src/fn_utils.hpp +56 -0
- data/ext/libsass/src/inspect.cpp +101 -152
- data/ext/libsass/src/inspect.hpp +69 -73
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +6 -3
- data/ext/libsass/src/listize.cpp +9 -11
- data/ext/libsass/src/listize.hpp +11 -7
- data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
- data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
- data/ext/libsass/src/node.cpp +13 -10
- data/ext/libsass/src/node.hpp +3 -3
- data/ext/libsass/src/operation.hpp +184 -144
- data/ext/libsass/src/operators.cpp +43 -17
- data/ext/libsass/src/operators.hpp +5 -5
- data/ext/libsass/src/output.cpp +21 -18
- data/ext/libsass/src/output.hpp +14 -21
- data/ext/libsass/src/parser.cpp +215 -183
- data/ext/libsass/src/parser.hpp +28 -24
- data/ext/libsass/src/plugins.cpp +5 -1
- data/ext/libsass/src/position.cpp +3 -0
- data/ext/libsass/src/prelexer.cpp +9 -3
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +14 -11
- data/ext/libsass/src/remove_placeholders.hpp +8 -9
- data/ext/libsass/src/sass.cpp +9 -3
- data/ext/libsass/src/sass.hpp +12 -9
- data/ext/libsass/src/sass2scss.cpp +45 -14
- data/ext/libsass/src/sass_context.cpp +18 -15
- data/ext/libsass/src/sass_functions.cpp +6 -3
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_util.cpp +3 -0
- data/ext/libsass/src/sass_values.cpp +21 -13
- data/ext/libsass/src/source_map.cpp +5 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +4 -1
- data/ext/libsass/src/to_value.cpp +23 -21
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +4 -0
- data/ext/libsass/src/units.hpp +1 -0
- data/ext/libsass/src/utf8/checked.h +12 -10
- data/ext/libsass/src/utf8/core.h +3 -0
- data/ext/libsass/src/utf8_string.cpp +3 -0
- data/ext/libsass/src/util.cpp +67 -75
- data/ext/libsass/src/util.hpp +64 -19
- data/ext/libsass/src/util_string.cpp +75 -0
- data/ext/libsass/src/util_string.hpp +19 -0
- data/ext/libsass/src/values.cpp +22 -13
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/win/libsass.targets +30 -4
- data/ext/libsass/win/libsass.vcxproj.filters +82 -4
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +2 -2
- data/lib/sassc/native.rb +8 -1
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +19 -11
- data/test/engine_test.rb +26 -1
- data/test/native_test.rb +1 -1
- metadata +66 -72
- data/ext/Rakefile +0 -3
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/docs/README.md +0 -20
- data/ext/libsass/docs/api-context-example.md +0 -45
- data/ext/libsass/docs/api-context-internal.md +0 -163
- data/ext/libsass/docs/api-context.md +0 -295
- data/ext/libsass/docs/api-doc.md +0 -215
- data/ext/libsass/docs/api-function-example.md +0 -67
- data/ext/libsass/docs/api-function-internal.md +0 -8
- data/ext/libsass/docs/api-function.md +0 -74
- data/ext/libsass/docs/api-importer-example.md +0 -112
- data/ext/libsass/docs/api-importer-internal.md +0 -20
- data/ext/libsass/docs/api-importer.md +0 -86
- data/ext/libsass/docs/api-value-example.md +0 -55
- data/ext/libsass/docs/api-value-internal.md +0 -76
- data/ext/libsass/docs/api-value.md +0 -154
- data/ext/libsass/docs/build-on-darwin.md +0 -27
- data/ext/libsass/docs/build-on-gentoo.md +0 -55
- data/ext/libsass/docs/build-on-windows.md +0 -139
- data/ext/libsass/docs/build-shared-library.md +0 -35
- data/ext/libsass/docs/build-with-autotools.md +0 -78
- data/ext/libsass/docs/build-with-makefiles.md +0 -68
- data/ext/libsass/docs/build-with-mingw.md +0 -107
- data/ext/libsass/docs/build-with-visual-studio.md +0 -90
- data/ext/libsass/docs/build.md +0 -97
- data/ext/libsass/docs/compatibility-plan.md +0 -48
- data/ext/libsass/docs/contributing.md +0 -17
- data/ext/libsass/docs/custom-functions-internal.md +0 -122
- data/ext/libsass/docs/dev-ast-memory.md +0 -223
- data/ext/libsass/docs/implementations.md +0 -56
- data/ext/libsass/docs/plugins.md +0 -47
- data/ext/libsass/docs/setup-environment.md +0 -68
- data/ext/libsass/docs/source-map-internals.md +0 -51
- data/ext/libsass/docs/trace.md +0 -26
- data/ext/libsass/docs/triage.md +0 -17
- data/ext/libsass/docs/unicode.md +0 -39
- data/ext/libsass/extconf.rb +0 -6
- data/ext/libsass/script/bootstrap +0 -13
- data/ext/libsass/script/branding +0 -10
- data/ext/libsass/script/ci-build-libsass +0 -134
- data/ext/libsass/script/ci-build-plugin +0 -62
- data/ext/libsass/script/ci-install-compiler +0 -6
- data/ext/libsass/script/ci-install-deps +0 -20
- data/ext/libsass/script/ci-report-coverage +0 -42
- data/ext/libsass/script/spec +0 -5
- data/ext/libsass/script/tap-driver +0 -652
- data/ext/libsass/script/tap-runner +0 -1
- data/ext/libsass/script/test-leaks.pl +0 -103
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/to_c.hpp +0 -39
- data/ext/libsass/test/test_node.cpp +0 -94
- data/ext/libsass/test/test_paths.cpp +0 -28
- data/ext/libsass/test/test_selector_difference.cpp +0 -25
- data/ext/libsass/test/test_specificity.cpp +0 -25
- data/ext/libsass/test/test_subset_map.cpp +0 -472
- data/ext/libsass/test/test_superselector.cpp +0 -69
- data/ext/libsass/test/test_unification.cpp +0 -31
- data/lib/tasks/libsass.rb +0 -33
@@ -24,6 +24,8 @@ namespace Sass {
|
|
24
24
|
ss << indent;
|
25
25
|
ss << "on line ";
|
26
26
|
ss << trace.pstate.line + 1;
|
27
|
+
ss << ":";
|
28
|
+
ss << trace.pstate.column + 1;
|
27
29
|
ss << " of " << rel_path;
|
28
30
|
// ss << trace.caller;
|
29
31
|
first = false;
|
@@ -33,6 +35,8 @@ namespace Sass {
|
|
33
35
|
ss << indent;
|
34
36
|
ss << "from line ";
|
35
37
|
ss << trace.pstate.line + 1;
|
38
|
+
ss << ":";
|
39
|
+
ss << trace.pstate.column + 1;
|
36
40
|
ss << " of " << rel_path;
|
37
41
|
}
|
38
42
|
|
data/ext/libsass/src/bind.cpp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "sass.hpp"
|
2
2
|
#include "bind.hpp"
|
3
3
|
#include "ast.hpp"
|
4
|
+
#include "backtrace.hpp"
|
4
5
|
#include "context.hpp"
|
5
6
|
#include "expand.hpp"
|
6
7
|
#include "eval.hpp"
|
@@ -10,7 +11,7 @@
|
|
10
11
|
|
11
12
|
namespace Sass {
|
12
13
|
|
13
|
-
void bind(std::string type, std::string name, Parameters_Obj ps, Arguments_Obj as,
|
14
|
+
void bind(std::string type, std::string name, Parameters_Obj ps, Arguments_Obj as, Env* env, Eval* eval, Backtraces& traces)
|
14
15
|
{
|
15
16
|
std::string callee(type + " " + name);
|
16
17
|
|
@@ -54,7 +55,7 @@ namespace Sass {
|
|
54
55
|
std::stringstream msg;
|
55
56
|
msg << "wrong number of arguments (" << LA << " for " << LP << ")";
|
56
57
|
msg << " for `" << name << "'";
|
57
|
-
return error(msg.str(), as->pstate(),
|
58
|
+
return error(msg.str(), as->pstate(), traces);
|
58
59
|
}
|
59
60
|
Parameter_Obj p = ps->at(ip);
|
60
61
|
|
@@ -66,7 +67,7 @@ namespace Sass {
|
|
66
67
|
// We should always get a list for rest arguments
|
67
68
|
if (List_Obj rest = Cast<List>(a->value())) {
|
68
69
|
// create a new list object for wrapped items
|
69
|
-
|
70
|
+
List* arglist = SASS_MEMORY_NEW(List,
|
70
71
|
p->pstate(),
|
71
72
|
0,
|
72
73
|
rest->separator(),
|
@@ -94,7 +95,7 @@ namespace Sass {
|
|
94
95
|
} else if (a->is_keyword_argument()) {
|
95
96
|
|
96
97
|
// expand keyword arguments into their parameters
|
97
|
-
|
98
|
+
List* arglist = SASS_MEMORY_NEW(List, p->pstate(), 0, SASS_COMMA, true);
|
98
99
|
env->local_frame()[p->name()] = arglist;
|
99
100
|
Map_Obj argmap = Cast<Map>(a->value());
|
100
101
|
for (auto key : argmap->keys()) {
|
@@ -107,8 +108,8 @@ namespace Sass {
|
|
107
108
|
false,
|
108
109
|
false));
|
109
110
|
} else {
|
110
|
-
|
111
|
-
throw Exception::InvalidVarKwdType(key->pstate(),
|
111
|
+
traces.push_back(Backtrace(key->pstate()));
|
112
|
+
throw Exception::InvalidVarKwdType(key->pstate(), traces, key->inspect(), a);
|
112
113
|
}
|
113
114
|
}
|
114
115
|
|
@@ -203,7 +204,7 @@ namespace Sass {
|
|
203
204
|
// otherwise move one of the rest args into the param, converting to argument if necessary
|
204
205
|
Expression_Obj obj = arglist->at(0);
|
205
206
|
if (!(a = Cast<Argument>(obj))) {
|
206
|
-
|
207
|
+
Expression* a_to_convert = obj;
|
207
208
|
a = SASS_MEMORY_NEW(Argument,
|
208
209
|
a_to_convert->pstate(),
|
209
210
|
a_to_convert,
|
@@ -220,17 +221,17 @@ namespace Sass {
|
|
220
221
|
Map_Obj argmap = Cast<Map>(a->value());
|
221
222
|
|
222
223
|
for (auto key : argmap->keys()) {
|
223
|
-
|
224
|
+
String_Constant* val = Cast<String_Constant>(key);
|
224
225
|
if (val == NULL) {
|
225
|
-
|
226
|
-
throw Exception::InvalidVarKwdType(key->pstate(),
|
226
|
+
traces.push_back(Backtrace(key->pstate()));
|
227
|
+
throw Exception::InvalidVarKwdType(key->pstate(), traces, key->inspect(), a);
|
227
228
|
}
|
228
229
|
std::string param = "$" + unquote(val->value());
|
229
230
|
|
230
231
|
if (!param_map.count(param)) {
|
231
232
|
std::stringstream msg;
|
232
233
|
msg << callee << " has no parameter named " << param;
|
233
|
-
error(msg.str(), a->pstate(),
|
234
|
+
error(msg.str(), a->pstate(), traces);
|
234
235
|
}
|
235
236
|
env->local_frame()[param] = argmap->at(key);
|
236
237
|
}
|
@@ -245,7 +246,7 @@ namespace Sass {
|
|
245
246
|
std::stringstream msg;
|
246
247
|
msg << "parameter " << p->name()
|
247
248
|
<< " provided more than once in call to " << callee;
|
248
|
-
error(msg.str(), a->pstate(),
|
249
|
+
error(msg.str(), a->pstate(), traces);
|
249
250
|
}
|
250
251
|
// ordinal arg -- bind it to the next param
|
251
252
|
env->local_frame()[p->name()] = a->value();
|
@@ -259,7 +260,7 @@ namespace Sass {
|
|
259
260
|
} else {
|
260
261
|
std::stringstream msg;
|
261
262
|
msg << callee << " has no parameter named " << a->name();
|
262
|
-
error(msg.str(), a->pstate(),
|
263
|
+
error(msg.str(), a->pstate(), traces);
|
263
264
|
}
|
264
265
|
}
|
265
266
|
if (param_map[a->name()]) {
|
@@ -267,14 +268,14 @@ namespace Sass {
|
|
267
268
|
std::stringstream msg;
|
268
269
|
msg << "argument " << a->name() << " of " << callee
|
269
270
|
<< "cannot be used as named argument";
|
270
|
-
error(msg.str(), a->pstate(),
|
271
|
+
error(msg.str(), a->pstate(), traces);
|
271
272
|
}
|
272
273
|
}
|
273
274
|
if (env->has_local(a->name())) {
|
274
275
|
std::stringstream msg;
|
275
276
|
msg << "parameter " << p->name()
|
276
277
|
<< "provided more than once in call to " << callee;
|
277
|
-
error(msg.str(), a->pstate(),
|
278
|
+
error(msg.str(), a->pstate(), traces);
|
278
279
|
}
|
279
280
|
env->local_frame()[a->name()] = a->value();
|
280
281
|
}
|
@@ -294,12 +295,12 @@ namespace Sass {
|
|
294
295
|
env->local_frame()[leftover->name()] = varargs;
|
295
296
|
}
|
296
297
|
else if (leftover->default_value()) {
|
297
|
-
|
298
|
+
Expression* dv = leftover->default_value()->perform(eval);
|
298
299
|
env->local_frame()[leftover->name()] = dv;
|
299
300
|
}
|
300
301
|
else {
|
301
302
|
// param is unbound and has no default value -- error
|
302
|
-
throw Exception::MissingArgument(as->pstate(),
|
303
|
+
throw Exception::MissingArgument(as->pstate(), traces, name, leftover->name(), type);
|
303
304
|
}
|
304
305
|
}
|
305
306
|
}
|
data/ext/libsass/src/bind.hpp
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
#define SASS_BIND_H
|
3
3
|
|
4
4
|
#include <string>
|
5
|
+
#include "backtrace.hpp"
|
5
6
|
#include "environment.hpp"
|
6
7
|
#include "ast_fwd_decl.hpp"
|
7
8
|
|
8
9
|
namespace Sass {
|
9
10
|
|
10
|
-
void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj,
|
11
|
+
void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces& traces);
|
12
|
+
|
11
13
|
}
|
12
14
|
|
13
15
|
#endif
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#include "ast.hpp"
|
2
|
+
#include "units.hpp"
|
3
|
+
#include "position.hpp"
|
4
|
+
#include "backtrace.hpp"
|
5
|
+
#include "sass/values.h"
|
6
|
+
#include "ast_fwd_decl.hpp"
|
7
|
+
#include "error_handling.hpp"
|
8
|
+
|
9
|
+
namespace Sass {
|
10
|
+
|
11
|
+
Value* c2ast(union Sass_Value* v, Backtraces traces, ParserState pstate)
|
12
|
+
{
|
13
|
+
using std::strlen;
|
14
|
+
using std::strcpy;
|
15
|
+
Value* e = NULL;
|
16
|
+
switch (sass_value_get_tag(v)) {
|
17
|
+
case SASS_BOOLEAN: {
|
18
|
+
e = SASS_MEMORY_NEW(Boolean, pstate, !!sass_boolean_get_value(v));
|
19
|
+
} break;
|
20
|
+
case SASS_NUMBER: {
|
21
|
+
e = SASS_MEMORY_NEW(Number, pstate, sass_number_get_value(v), sass_number_get_unit(v));
|
22
|
+
} break;
|
23
|
+
case SASS_COLOR: {
|
24
|
+
e = SASS_MEMORY_NEW(Color_RGBA, pstate, sass_color_get_r(v), sass_color_get_g(v), sass_color_get_b(v), sass_color_get_a(v));
|
25
|
+
} break;
|
26
|
+
case SASS_STRING: {
|
27
|
+
if (sass_string_is_quoted(v))
|
28
|
+
e = SASS_MEMORY_NEW(String_Quoted, pstate, sass_string_get_value(v));
|
29
|
+
else {
|
30
|
+
e = SASS_MEMORY_NEW(String_Constant, pstate, sass_string_get_value(v));
|
31
|
+
}
|
32
|
+
} break;
|
33
|
+
case SASS_LIST: {
|
34
|
+
List* l = SASS_MEMORY_NEW(List, pstate, sass_list_get_length(v), sass_list_get_separator(v));
|
35
|
+
for (size_t i = 0, L = sass_list_get_length(v); i < L; ++i) {
|
36
|
+
l->append(c2ast(sass_list_get_value(v, i), traces, pstate));
|
37
|
+
}
|
38
|
+
l->is_bracketed(sass_list_get_is_bracketed(v));
|
39
|
+
e = l;
|
40
|
+
} break;
|
41
|
+
case SASS_MAP: {
|
42
|
+
Map* m = SASS_MEMORY_NEW(Map, pstate);
|
43
|
+
for (size_t i = 0, L = sass_map_get_length(v); i < L; ++i) {
|
44
|
+
*m << std::make_pair(
|
45
|
+
c2ast(sass_map_get_key(v, i), traces, pstate),
|
46
|
+
c2ast(sass_map_get_value(v, i), traces, pstate));
|
47
|
+
}
|
48
|
+
e = m;
|
49
|
+
} break;
|
50
|
+
case SASS_NULL: {
|
51
|
+
e = SASS_MEMORY_NEW(Null, pstate);
|
52
|
+
} break;
|
53
|
+
case SASS_ERROR: {
|
54
|
+
error("Error in C function: " + std::string(sass_error_get_message(v)), pstate, traces);
|
55
|
+
} break;
|
56
|
+
case SASS_WARNING: {
|
57
|
+
error("Warning in C function: " + std::string(sass_warning_get_message(v)), pstate, traces);
|
58
|
+
} break;
|
59
|
+
default: break;
|
60
|
+
}
|
61
|
+
return e;
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
data/ext/libsass/src/cencode.c
CHANGED
@@ -47,7 +47,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
47
47
|
*codechar++ = base64_encode_value(result);
|
48
48
|
result = (fragment & 0x003) << 4;
|
49
49
|
#ifndef _MSC_VER
|
50
|
-
|
50
|
+
/* fall through */
|
51
51
|
#endif
|
52
52
|
case step_B:
|
53
53
|
if (plainchar == plaintextend)
|
@@ -61,7 +61,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
61
61
|
*codechar++ = base64_encode_value(result);
|
62
62
|
result = (fragment & 0x00f) << 2;
|
63
63
|
#ifndef _MSC_VER
|
64
|
-
|
64
|
+
/* fall through */
|
65
65
|
#endif
|
66
66
|
case step_C:
|
67
67
|
if (plainchar == plaintextend)
|
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <vector>
|
3
6
|
|
4
7
|
#include "check_nesting.hpp"
|
@@ -6,26 +9,26 @@
|
|
6
9
|
namespace Sass {
|
7
10
|
|
8
11
|
CheckNesting::CheckNesting()
|
9
|
-
: parents(std::vector<
|
12
|
+
: parents(std::vector<Statement*>()),
|
10
13
|
traces(std::vector<Backtrace>()),
|
11
14
|
parent(0), current_mixin_definition(0)
|
12
15
|
{ }
|
13
16
|
|
14
|
-
void error(
|
17
|
+
void error(AST_Node* node, Backtraces traces, std::string msg) {
|
15
18
|
traces.push_back(Backtrace(node->pstate()));
|
16
19
|
throw Exception::InvalidSass(node->pstate(), traces, msg);
|
17
20
|
}
|
18
21
|
|
19
|
-
|
22
|
+
Statement* CheckNesting::visit_children(Statement* parent)
|
20
23
|
{
|
21
|
-
|
24
|
+
Statement* old_parent = this->parent;
|
22
25
|
|
23
|
-
if (
|
24
|
-
std::vector<
|
25
|
-
std::vector<
|
26
|
+
if (At_Root_Block* root = Cast<At_Root_Block>(parent)) {
|
27
|
+
std::vector<Statement*> old_parents = this->parents;
|
28
|
+
std::vector<Statement*> new_parents;
|
26
29
|
|
27
30
|
for (size_t i = 0, L = this->parents.size(); i < L; i++) {
|
28
|
-
|
31
|
+
Statement* p = this->parents.at(i);
|
29
32
|
if (!root->exclude_node(p)) {
|
30
33
|
new_parents.push_back(p);
|
31
34
|
}
|
@@ -33,8 +36,8 @@ namespace Sass {
|
|
33
36
|
this->parents = new_parents;
|
34
37
|
|
35
38
|
for (size_t i = this->parents.size(); i > 0; i--) {
|
36
|
-
|
37
|
-
|
39
|
+
Statement* p = 0;
|
40
|
+
Statement* gp = 0;
|
38
41
|
if (i > 0) p = this->parents.at(i - 1);
|
39
42
|
if (i > 1) gp = this->parents.at(i - 2);
|
40
43
|
|
@@ -44,8 +47,8 @@ namespace Sass {
|
|
44
47
|
}
|
45
48
|
}
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
At_Root_Block* ar = Cast<At_Root_Block>(parent);
|
51
|
+
Block* ret = ar->block();
|
49
52
|
|
50
53
|
if (ret != NULL) {
|
51
54
|
for (auto n : ret->elements()) {
|
@@ -65,16 +68,16 @@ namespace Sass {
|
|
65
68
|
|
66
69
|
this->parents.push_back(parent);
|
67
70
|
|
68
|
-
|
71
|
+
Block* b = Cast<Block>(parent);
|
69
72
|
|
70
|
-
if (
|
73
|
+
if (Trace* trace = Cast<Trace>(parent)) {
|
71
74
|
if (trace->type() == 'i') {
|
72
75
|
this->traces.push_back(Backtrace(trace->pstate()));
|
73
76
|
}
|
74
77
|
}
|
75
78
|
|
76
79
|
if (!b) {
|
77
|
-
if (
|
80
|
+
if (Has_Block* bb = Cast<Has_Block>(parent)) {
|
78
81
|
b = bb->block();
|
79
82
|
}
|
80
83
|
}
|
@@ -88,7 +91,7 @@ namespace Sass {
|
|
88
91
|
this->parent = old_parent;
|
89
92
|
this->parents.pop_back();
|
90
93
|
|
91
|
-
if (
|
94
|
+
if (Trace* trace = Cast<Trace>(parent)) {
|
92
95
|
if (trace->type() == 'i') {
|
93
96
|
this->traces.pop_back();
|
94
97
|
}
|
@@ -98,12 +101,12 @@ namespace Sass {
|
|
98
101
|
}
|
99
102
|
|
100
103
|
|
101
|
-
|
104
|
+
Statement* CheckNesting::operator()(Block* b)
|
102
105
|
{
|
103
106
|
return this->visit_children(b);
|
104
107
|
}
|
105
108
|
|
106
|
-
|
109
|
+
Statement* CheckNesting::operator()(Definition* n)
|
107
110
|
{
|
108
111
|
if (!this->should_visit(n)) return NULL;
|
109
112
|
if (!is_mixin(n)) {
|
@@ -111,7 +114,7 @@ namespace Sass {
|
|
111
114
|
return n;
|
112
115
|
}
|
113
116
|
|
114
|
-
|
117
|
+
Definition* old_mixin_definition = this->current_mixin_definition;
|
115
118
|
this->current_mixin_definition = n;
|
116
119
|
|
117
120
|
visit_children(n);
|
@@ -121,25 +124,18 @@ namespace Sass {
|
|
121
124
|
return n;
|
122
125
|
}
|
123
126
|
|
124
|
-
|
127
|
+
Statement* CheckNesting::operator()(If* i)
|
125
128
|
{
|
126
129
|
this->visit_children(i);
|
127
130
|
|
128
|
-
if (
|
131
|
+
if (Block* b = Cast<Block>(i->alternative())) {
|
129
132
|
for (auto n : b->elements()) n->perform(this);
|
130
133
|
}
|
131
134
|
|
132
135
|
return i;
|
133
136
|
}
|
134
137
|
|
135
|
-
|
136
|
-
{
|
137
|
-
Block_Ptr b1 = Cast<Block>(s);
|
138
|
-
Has_Block_Ptr b2 = Cast<Has_Block>(s);
|
139
|
-
return b1 || b2 ? visit_children(s) : s;
|
140
|
-
}
|
141
|
-
|
142
|
-
bool CheckNesting::should_visit(Statement_Ptr node)
|
138
|
+
bool CheckNesting::should_visit(Statement* node)
|
143
139
|
{
|
144
140
|
if (!this->parent) return true;
|
145
141
|
|
@@ -164,7 +160,7 @@ namespace Sass {
|
|
164
160
|
if (this->is_function(this->parent))
|
165
161
|
{ this->invalid_function_child(node); }
|
166
162
|
|
167
|
-
if (
|
163
|
+
if (Declaration* d = Cast<Declaration>(node))
|
168
164
|
{
|
169
165
|
this->invalid_prop_parent(this->parent, node);
|
170
166
|
this->invalid_value_child(d->value());
|
@@ -179,14 +175,14 @@ namespace Sass {
|
|
179
175
|
return true;
|
180
176
|
}
|
181
177
|
|
182
|
-
void CheckNesting::invalid_content_parent(
|
178
|
+
void CheckNesting::invalid_content_parent(Statement* parent, AST_Node* node)
|
183
179
|
{
|
184
180
|
if (!this->current_mixin_definition) {
|
185
181
|
error(node, traces, "@content may only be used within a mixin.");
|
186
182
|
}
|
187
183
|
}
|
188
184
|
|
189
|
-
void CheckNesting::invalid_charset_parent(
|
185
|
+
void CheckNesting::invalid_charset_parent(Statement* parent, AST_Node* node)
|
190
186
|
{
|
191
187
|
if (!(
|
192
188
|
is_root_node(parent)
|
@@ -195,7 +191,7 @@ namespace Sass {
|
|
195
191
|
}
|
196
192
|
}
|
197
193
|
|
198
|
-
void CheckNesting::invalid_extend_parent(
|
194
|
+
void CheckNesting::invalid_extend_parent(Statement* parent, AST_Node* node)
|
199
195
|
{
|
200
196
|
if (!(
|
201
197
|
Cast<Ruleset>(parent) ||
|
@@ -206,7 +202,7 @@ namespace Sass {
|
|
206
202
|
}
|
207
203
|
}
|
208
204
|
|
209
|
-
// void CheckNesting::invalid_import_parent(
|
205
|
+
// void CheckNesting::invalid_import_parent(Statement* parent, AST_Node* node)
|
210
206
|
// {
|
211
207
|
// for (auto pp : this->parents) {
|
212
208
|
// if (
|
@@ -231,9 +227,9 @@ namespace Sass {
|
|
231
227
|
// }
|
232
228
|
// }
|
233
229
|
|
234
|
-
void CheckNesting::invalid_mixin_definition_parent(
|
230
|
+
void CheckNesting::invalid_mixin_definition_parent(Statement* parent, AST_Node* node)
|
235
231
|
{
|
236
|
-
for (
|
232
|
+
for (Statement* pp : this->parents) {
|
237
233
|
if (
|
238
234
|
Cast<Each>(pp) ||
|
239
235
|
Cast<For>(pp) ||
|
@@ -248,9 +244,9 @@ namespace Sass {
|
|
248
244
|
}
|
249
245
|
}
|
250
246
|
|
251
|
-
void CheckNesting::invalid_function_parent(
|
247
|
+
void CheckNesting::invalid_function_parent(Statement* parent, AST_Node* node)
|
252
248
|
{
|
253
|
-
for (
|
249
|
+
for (Statement* pp : this->parents) {
|
254
250
|
if (
|
255
251
|
Cast<Each>(pp) ||
|
256
252
|
Cast<For>(pp) ||
|
@@ -265,7 +261,7 @@ namespace Sass {
|
|
265
261
|
}
|
266
262
|
}
|
267
263
|
|
268
|
-
void CheckNesting::invalid_function_child(
|
264
|
+
void CheckNesting::invalid_function_child(Statement* child)
|
269
265
|
{
|
270
266
|
if (!(
|
271
267
|
Cast<Each>(child) ||
|
@@ -286,7 +282,7 @@ namespace Sass {
|
|
286
282
|
}
|
287
283
|
}
|
288
284
|
|
289
|
-
void CheckNesting::invalid_prop_child(
|
285
|
+
void CheckNesting::invalid_prop_child(Statement* child)
|
290
286
|
{
|
291
287
|
if (!(
|
292
288
|
Cast<Each>(child) ||
|
@@ -302,7 +298,7 @@ namespace Sass {
|
|
302
298
|
}
|
303
299
|
}
|
304
300
|
|
305
|
-
void CheckNesting::invalid_prop_parent(
|
301
|
+
void CheckNesting::invalid_prop_parent(Statement* parent, AST_Node* node)
|
306
302
|
{
|
307
303
|
if (!(
|
308
304
|
is_mixin(parent) ||
|
@@ -316,13 +312,13 @@ namespace Sass {
|
|
316
312
|
}
|
317
313
|
}
|
318
314
|
|
319
|
-
void CheckNesting::invalid_value_child(
|
315
|
+
void CheckNesting::invalid_value_child(AST_Node* d)
|
320
316
|
{
|
321
|
-
if (
|
317
|
+
if (Map* m = Cast<Map>(d)) {
|
322
318
|
traces.push_back(Backtrace(m->pstate()));
|
323
319
|
throw Exception::InvalidValue(traces, *m);
|
324
320
|
}
|
325
|
-
if (
|
321
|
+
if (Number* n = Cast<Number>(d)) {
|
326
322
|
if (!n->is_valid_css_unit()) {
|
327
323
|
traces.push_back(Backtrace(n->pstate()));
|
328
324
|
throw Exception::InvalidValue(traces, *n);
|
@@ -333,14 +329,14 @@ namespace Sass {
|
|
333
329
|
|
334
330
|
}
|
335
331
|
|
336
|
-
void CheckNesting::invalid_return_parent(
|
332
|
+
void CheckNesting::invalid_return_parent(Statement* parent, AST_Node* node)
|
337
333
|
{
|
338
334
|
if (!this->is_function(parent)) {
|
339
335
|
error(node, traces, "@return may only be used within a function.");
|
340
336
|
}
|
341
337
|
}
|
342
338
|
|
343
|
-
bool CheckNesting::is_transparent_parent(
|
339
|
+
bool CheckNesting::is_transparent_parent(Statement* parent, Statement* grandparent)
|
344
340
|
{
|
345
341
|
bool parent_bubbles = parent && parent->bubbles();
|
346
342
|
|
@@ -357,38 +353,38 @@ namespace Sass {
|
|
357
353
|
valid_bubble_node;
|
358
354
|
}
|
359
355
|
|
360
|
-
bool CheckNesting::is_charset(
|
356
|
+
bool CheckNesting::is_charset(Statement* n)
|
361
357
|
{
|
362
|
-
|
358
|
+
Directive* d = Cast<Directive>(n);
|
363
359
|
return d && d->keyword() == "charset";
|
364
360
|
}
|
365
361
|
|
366
|
-
bool CheckNesting::is_mixin(
|
362
|
+
bool CheckNesting::is_mixin(Statement* n)
|
367
363
|
{
|
368
|
-
|
364
|
+
Definition* def = Cast<Definition>(n);
|
369
365
|
return def && def->type() == Definition::MIXIN;
|
370
366
|
}
|
371
367
|
|
372
|
-
bool CheckNesting::is_function(
|
368
|
+
bool CheckNesting::is_function(Statement* n)
|
373
369
|
{
|
374
|
-
|
370
|
+
Definition* def = Cast<Definition>(n);
|
375
371
|
return def && def->type() == Definition::FUNCTION;
|
376
372
|
}
|
377
373
|
|
378
|
-
bool CheckNesting::is_root_node(
|
374
|
+
bool CheckNesting::is_root_node(Statement* n)
|
379
375
|
{
|
380
376
|
if (Cast<Ruleset>(n)) return false;
|
381
377
|
|
382
|
-
|
378
|
+
Block* b = Cast<Block>(n);
|
383
379
|
return b && b->is_root();
|
384
380
|
}
|
385
381
|
|
386
|
-
bool CheckNesting::is_at_root_node(
|
382
|
+
bool CheckNesting::is_at_root_node(Statement* n)
|
387
383
|
{
|
388
384
|
return Cast<At_Root_Block>(n) != NULL;
|
389
385
|
}
|
390
386
|
|
391
|
-
bool CheckNesting::is_directive_node(
|
387
|
+
bool CheckNesting::is_directive_node(Statement* n)
|
392
388
|
{
|
393
389
|
return Cast<Directive>(n) ||
|
394
390
|
Cast<Import>(n) ||
|