sassc 2.0.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.gitmodules +1 -1
- data/.travis.yml +9 -3
- data/CHANGELOG.md +36 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +43 -7
- data/ext/depend +4 -0
- data/ext/extconf.rb +92 -0
- data/ext/libsass/VERSION +1 -0
- data/ext/libsass/include/sass/base.h +9 -1
- data/ext/libsass/include/sass/context.h +5 -1
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +755 -2028
- data/ext/libsass/src/ast.hpp +492 -2477
- 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 +70 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +5 -3
- data/ext/libsass/src/ast_fwd_decl.hpp +107 -296
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +275 -0
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +1043 -0
- data/ext/libsass/src/ast_selectors.hpp +522 -0
- data/ext/libsass/src/ast_supports.cpp +114 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +1154 -0
- data/ext/libsass/src/ast_values.hpp +498 -0
- data/ext/libsass/src/backtrace.cpp +11 -7
- data/ext/libsass/src/backtrace.hpp +5 -5
- data/ext/libsass/src/base64vlq.cpp +5 -2
- data/ext/libsass/src/base64vlq.hpp +1 -1
- data/ext/libsass/src/bind.cpp +35 -34
- 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 +4 -6
- data/ext/libsass/src/check_nesting.cpp +83 -88
- data/ext/libsass/src/check_nesting.hpp +39 -34
- data/ext/libsass/src/color_maps.cpp +168 -164
- data/ext/libsass/src/color_maps.hpp +152 -160
- data/ext/libsass/src/constants.cpp +20 -0
- data/ext/libsass/src/constants.hpp +19 -0
- data/ext/libsass/src/context.cpp +104 -121
- data/ext/libsass/src/context.hpp +43 -55
- data/ext/libsass/src/cssize.cpp +103 -188
- data/ext/libsass/src/cssize.hpp +45 -51
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +524 -361
- data/ext/libsass/src/emitter.cpp +26 -26
- data/ext/libsass/src/emitter.hpp +20 -18
- data/ext/libsass/src/environment.cpp +41 -27
- data/ext/libsass/src/environment.hpp +33 -22
- data/ext/libsass/src/error_handling.cpp +92 -94
- data/ext/libsass/src/error_handling.hpp +73 -50
- data/ext/libsass/src/eval.cpp +380 -515
- data/ext/libsass/src/eval.hpp +64 -57
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +322 -263
- data/ext/libsass/src/expand.hpp +55 -39
- data/ext/libsass/src/extender.cpp +1188 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +134 -88
- data/ext/libsass/src/file.hpp +28 -37
- data/ext/libsass/src/fn_colors.cpp +596 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +285 -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 +244 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +227 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +205 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +268 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +158 -0
- data/ext/libsass/src/fn_utils.hpp +62 -0
- data/ext/libsass/src/inspect.cpp +253 -266
- data/ext/libsass/src/inspect.hpp +72 -74
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +25 -84
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +27 -43
- data/ext/libsass/src/listize.hpp +14 -11
- data/ext/libsass/src/mapping.hpp +1 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/memory/allocator.cpp +48 -0
- data/ext/libsass/src/memory/allocator.hpp +138 -0
- data/ext/libsass/src/memory/config.hpp +20 -0
- data/ext/libsass/src/memory/memory_pool.hpp +186 -0
- data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
- data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
- data/ext/libsass/src/operation.hpp +193 -143
- data/ext/libsass/src/operators.cpp +56 -29
- data/ext/libsass/src/operators.hpp +11 -11
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +59 -75
- data/ext/libsass/src/output.hpp +15 -22
- data/ext/libsass/src/parser.cpp +662 -818
- data/ext/libsass/src/parser.hpp +96 -100
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +12 -8
- data/ext/libsass/src/plugins.hpp +8 -8
- data/ext/libsass/src/position.cpp +10 -26
- data/ext/libsass/src/position.hpp +44 -21
- data/ext/libsass/src/prelexer.cpp +14 -8
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +59 -57
- data/ext/libsass/src/remove_placeholders.hpp +20 -18
- data/ext/libsass/src/sass.cpp +25 -18
- data/ext/libsass/src/sass.hpp +22 -14
- data/ext/libsass/src/sass2scss.cpp +49 -18
- data/ext/libsass/src/sass_context.cpp +104 -132
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +7 -4
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_values.cpp +26 -21
- data/ext/libsass/src/settings.hpp +19 -0
- data/ext/libsass/src/source.cpp +69 -0
- data/ext/libsass/src/source.hpp +95 -0
- data/ext/libsass/src/source_data.hpp +32 -0
- data/ext/libsass/src/source_map.cpp +27 -20
- data/ext/libsass/src/source_map.hpp +14 -11
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +24 -22
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +28 -22
- data/ext/libsass/src/units.hpp +9 -8
- 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 +12 -10
- data/ext/libsass/src/utf8_string.hpp +7 -6
- data/ext/libsass/src/util.cpp +97 -107
- data/ext/libsass/src/util.hpp +74 -30
- data/ext/libsass/src/util_string.cpp +125 -0
- data/ext/libsass/src/util_string.hpp +73 -0
- data/ext/libsass/src/values.cpp +33 -24
- data/ext/libsass/src/values.hpp +2 -2
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +7 -5
- data/lib/sassc/functions_handler.rb +11 -13
- data/lib/sassc/native.rb +10 -9
- data/lib/sassc/native/native_functions_api.rb +0 -5
- data/lib/sassc/script.rb +4 -6
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +32 -12
- data/test/engine_test.rb +32 -2
- data/test/functions_test.rb +38 -1
- data/test/native_test.rb +4 -4
- metadata +95 -109
- data/ext/Rakefile +0 -3
- data/ext/libsass/.editorconfig +0 -15
- data/ext/libsass/.gitattributes +0 -2
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.gitignore +0 -85
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/COPYING +0 -25
- data/ext/libsass/GNUmakefile.am +0 -88
- data/ext/libsass/INSTALL +0 -1
- data/ext/libsass/LICENSE +0 -25
- data/ext/libsass/Makefile +0 -351
- data/ext/libsass/Makefile.conf +0 -55
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/configure.ac +0 -138
- data/ext/libsass/contrib/libsass.spec +0 -66
- 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/include/sass/version.h.in +0 -12
- data/ext/libsass/m4/.gitkeep +0 -0
- data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +0 -167
- data/ext/libsass/res/resource.rc +0 -35
- 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/GNUmakefile.am +0 -54
- data/ext/libsass/src/extend.cpp +0 -2130
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/memory/SharedPtr.cpp +0 -114
- data/ext/libsass/src/memory/SharedPtr.hpp +0 -206
- data/ext/libsass/src/node.cpp +0 -319
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -149
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -55
- data/ext/libsass/src/subset_map.hpp +0 -76
- data/ext/libsass/src/support/libsass.pc.in +0 -11
- 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/ext/libsass/version.sh +0 -10
- data/ext/libsass/win/libsass.sln +0 -39
- data/ext/libsass/win/libsass.sln.DotSettings +0 -9
- data/ext/libsass/win/libsass.targets +0 -118
- data/ext/libsass/win/libsass.vcxproj +0 -188
- data/ext/libsass/win/libsass.vcxproj.filters +0 -357
- data/lib/sassc/native/lib_c.rb +0 -21
- data/lib/tasks/libsass.rb +0 -33
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
namespace Sass {
|
4
4
|
|
5
|
-
const
|
5
|
+
const sass::string traces_to_string(Backtraces traces, sass::string indent) {
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
sass::ostream ss;
|
8
|
+
sass::string cwd(File::get_cwd());
|
9
9
|
|
10
10
|
bool first = true;
|
11
11
|
size_t i_beg = traces.size() - 1;
|
12
|
-
size_t i_end =
|
12
|
+
size_t i_end = sass::string::npos;
|
13
13
|
for (size_t i = i_beg; i != i_end; i --) {
|
14
14
|
|
15
15
|
const Backtrace& trace = traces[i];
|
16
16
|
|
17
17
|
// make path relative to the current directory
|
18
|
-
|
18
|
+
sass::string rel_path(File::abs2rel(trace.pstate.getPath(), cwd, cwd));
|
19
19
|
|
20
20
|
// skip functions on error cases (unsure why ruby sass does this)
|
21
21
|
// if (trace.caller.substr(0, 6) == ", in f") continue;
|
@@ -23,7 +23,9 @@ namespace Sass {
|
|
23
23
|
if (first) {
|
24
24
|
ss << indent;
|
25
25
|
ss << "on line ";
|
26
|
-
ss << trace.pstate.
|
26
|
+
ss << trace.pstate.getLine();
|
27
|
+
ss << ":";
|
28
|
+
ss << trace.pstate.getColumn();
|
27
29
|
ss << " of " << rel_path;
|
28
30
|
// ss << trace.caller;
|
29
31
|
first = false;
|
@@ -32,7 +34,9 @@ namespace Sass {
|
|
32
34
|
ss << std::endl;
|
33
35
|
ss << indent;
|
34
36
|
ss << "from line ";
|
35
|
-
ss << trace.pstate.
|
37
|
+
ss << trace.pstate.getLine();
|
38
|
+
ss << ":";
|
39
|
+
ss << trace.pstate.getColumn();
|
36
40
|
ss << " of " << rel_path;
|
37
41
|
}
|
38
42
|
|
@@ -10,19 +10,19 @@ namespace Sass {
|
|
10
10
|
|
11
11
|
struct Backtrace {
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
SourceSpan pstate;
|
14
|
+
sass::string caller;
|
15
15
|
|
16
|
-
Backtrace(
|
16
|
+
Backtrace(SourceSpan pstate, sass::string c = "")
|
17
17
|
: pstate(pstate),
|
18
18
|
caller(c)
|
19
19
|
{ }
|
20
20
|
|
21
21
|
};
|
22
22
|
|
23
|
-
typedef
|
23
|
+
typedef sass::vector<Backtrace> Backtraces;
|
24
24
|
|
25
|
-
const
|
25
|
+
const sass::string traces_to_string(Backtraces traces, sass::string indent = "\t");
|
26
26
|
|
27
27
|
}
|
28
28
|
|
@@ -1,11 +1,14 @@
|
|
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 "base64vlq.hpp"
|
3
6
|
|
4
7
|
namespace Sass {
|
5
8
|
|
6
|
-
|
9
|
+
sass::string Base64VLQ::encode(const int number) const
|
7
10
|
{
|
8
|
-
|
11
|
+
sass::string encoded = "";
|
9
12
|
|
10
13
|
int vlq = to_vlq_signed(number);
|
11
14
|
|
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,11 +11,11 @@
|
|
10
11
|
|
11
12
|
namespace Sass {
|
12
13
|
|
13
|
-
void bind(
|
14
|
+
void bind(sass::string type, sass::string name, Parameters_Obj ps, Arguments_Obj as, Env* env, Eval* eval, Backtraces& traces)
|
14
15
|
{
|
15
|
-
|
16
|
+
sass::string callee(type + " " + name);
|
16
17
|
|
17
|
-
std::map<
|
18
|
+
std::map<sass::string, Parameter_Obj> param_map;
|
18
19
|
List_Obj varargs = SASS_MEMORY_NEW(List, as->pstate());
|
19
20
|
varargs->is_arglist(true); // enable keyword size handling
|
20
21
|
|
@@ -51,10 +52,10 @@ namespace Sass {
|
|
51
52
|
}
|
52
53
|
}
|
53
54
|
}
|
54
|
-
|
55
|
+
sass::ostream 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,13 +67,13 @@ 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(),
|
73
74
|
true);
|
74
75
|
// wrap each item from list as an argument
|
75
|
-
for (
|
76
|
+
for (ExpressionObj item : rest->elements()) {
|
76
77
|
if (Argument_Obj arg = Cast<Argument>(item)) {
|
77
78
|
arglist->append(SASS_MEMORY_COPY(arg)); // copy
|
78
79
|
} else {
|
@@ -94,12 +95,12 @@ 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()) {
|
101
102
|
if (String_Constant_Obj str = Cast<String_Constant>(key)) {
|
102
|
-
|
103
|
+
sass::string param = unquote(str->value());
|
103
104
|
arglist->append(SASS_MEMORY_NEW(Argument,
|
104
105
|
key->pstate(),
|
105
106
|
argmap->at(key),
|
@@ -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
|
|
@@ -129,7 +130,7 @@ namespace Sass {
|
|
129
130
|
// skip any list completely if empty
|
130
131
|
if (ls && ls->empty() && a->is_rest_argument()) continue;
|
131
132
|
|
132
|
-
|
133
|
+
ExpressionObj value = a->value();
|
133
134
|
if (Argument_Obj arg = Cast<Argument>(value)) {
|
134
135
|
arglist->append(arg);
|
135
136
|
}
|
@@ -140,7 +141,7 @@ namespace Sass {
|
|
140
141
|
arglist->separator(rest->separator());
|
141
142
|
|
142
143
|
for (size_t i = 0, L = rest->length(); i < L; ++i) {
|
143
|
-
|
144
|
+
ExpressionObj obj = rest->value_at_index(i);
|
144
145
|
arglist->append(SASS_MEMORY_NEW(Argument,
|
145
146
|
obj->pstate(),
|
146
147
|
obj,
|
@@ -167,7 +168,7 @@ namespace Sass {
|
|
167
168
|
}
|
168
169
|
// consumed parameter
|
169
170
|
++ip;
|
170
|
-
// no more
|
171
|
+
// no more parameters
|
171
172
|
break;
|
172
173
|
}
|
173
174
|
|
@@ -176,7 +177,7 @@ namespace Sass {
|
|
176
177
|
// normal param and rest arg
|
177
178
|
List_Obj arglist = Cast<List>(a->value());
|
178
179
|
if (!arglist) {
|
179
|
-
if (
|
180
|
+
if (ExpressionObj arg = Cast<Expression>(a->value())) {
|
180
181
|
arglist = SASS_MEMORY_NEW(List, a->pstate(), 1);
|
181
182
|
arglist->append(arg);
|
182
183
|
}
|
@@ -188,7 +189,7 @@ namespace Sass {
|
|
188
189
|
} else {
|
189
190
|
if (arglist->length() > LP - ip && !ps->has_rest_parameter()) {
|
190
191
|
size_t arg_count = (arglist->length() + LA - 1);
|
191
|
-
|
192
|
+
sass::ostream msg;
|
192
193
|
msg << callee << " takes " << LP;
|
193
194
|
msg << (LP == 1 ? " argument" : " arguments");
|
194
195
|
msg << " but " << arg_count;
|
@@ -201,9 +202,9 @@ namespace Sass {
|
|
201
202
|
}
|
202
203
|
}
|
203
204
|
// otherwise move one of the rest args into the param, converting to argument if necessary
|
204
|
-
|
205
|
+
ExpressionObj 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
|
+
sass::string param = "$" + unquote(val->value());
|
229
230
|
|
230
231
|
if (!param_map.count(param)) {
|
231
|
-
|
232
|
+
sass::ostream 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
|
}
|
@@ -242,10 +243,10 @@ namespace Sass {
|
|
242
243
|
|
243
244
|
if (a->name().empty()) {
|
244
245
|
if (env->has_local(p->name())) {
|
245
|
-
|
246
|
+
sass::ostream 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();
|
@@ -257,24 +258,24 @@ namespace Sass {
|
|
257
258
|
if (ps->has_rest_parameter()) {
|
258
259
|
varargs->append(a);
|
259
260
|
} else {
|
260
|
-
|
261
|
+
sass::ostream 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()]) {
|
266
267
|
if (param_map[a->name()]->is_rest_parameter()) {
|
267
|
-
|
268
|
+
sass::ostream 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
|
+
sass::ostream 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(
|
11
|
+
void bind(sass::string type, sass::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, SourceSpan 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: " + sass::string(sass_error_get_message(v)), pstate, traces);
|
55
|
+
} break;
|
56
|
+
case SASS_WARNING: {
|
57
|
+
error("Warning in C function: " + sass::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
@@ -46,9 +46,8 @@ 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
|
-
|
50
|
-
|
51
|
-
#endif
|
49
|
+
/* fall through */
|
50
|
+
|
52
51
|
case step_B:
|
53
52
|
if (plainchar == plaintextend)
|
54
53
|
{
|
@@ -60,9 +59,8 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
60
59
|
result |= (fragment & 0x0f0) >> 4;
|
61
60
|
*codechar++ = base64_encode_value(result);
|
62
61
|
result = (fragment & 0x00f) << 2;
|
63
|
-
|
64
|
-
|
65
|
-
#endif
|
62
|
+
/* fall through */
|
63
|
+
|
66
64
|
case step_C:
|
67
65
|
if (plainchar == plaintextend)
|
68
66
|
{
|
@@ -1,31 +1,32 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
2
|
-
#include
|
3
|
-
|
4
|
+
#include "ast.hpp"
|
4
5
|
#include "check_nesting.hpp"
|
5
6
|
|
6
7
|
namespace Sass {
|
7
8
|
|
8
9
|
CheckNesting::CheckNesting()
|
9
|
-
: parents(
|
10
|
-
traces(
|
10
|
+
: parents(sass::vector<Statement*>()),
|
11
|
+
traces(sass::vector<Backtrace>()),
|
11
12
|
parent(0), current_mixin_definition(0)
|
12
13
|
{ }
|
13
14
|
|
14
|
-
void error(
|
15
|
+
void error(AST_Node* node, Backtraces traces, sass::string msg) {
|
15
16
|
traces.push_back(Backtrace(node->pstate()));
|
16
17
|
throw Exception::InvalidSass(node->pstate(), traces, msg);
|
17
18
|
}
|
18
19
|
|
19
|
-
|
20
|
+
Statement* CheckNesting::visit_children(Statement* parent)
|
20
21
|
{
|
21
|
-
|
22
|
+
Statement* old_parent = this->parent;
|
22
23
|
|
23
|
-
if (
|
24
|
-
|
25
|
-
|
24
|
+
if (AtRootRule* root = Cast<AtRootRule>(parent)) {
|
25
|
+
sass::vector<Statement*> old_parents = this->parents;
|
26
|
+
sass::vector<Statement*> new_parents;
|
26
27
|
|
27
28
|
for (size_t i = 0, L = this->parents.size(); i < L; i++) {
|
28
|
-
|
29
|
+
Statement* p = this->parents.at(i);
|
29
30
|
if (!root->exclude_node(p)) {
|
30
31
|
new_parents.push_back(p);
|
31
32
|
}
|
@@ -33,8 +34,8 @@ namespace Sass {
|
|
33
34
|
this->parents = new_parents;
|
34
35
|
|
35
36
|
for (size_t i = this->parents.size(); i > 0; i--) {
|
36
|
-
|
37
|
-
|
37
|
+
Statement* p = 0;
|
38
|
+
Statement* gp = 0;
|
38
39
|
if (i > 0) p = this->parents.at(i - 1);
|
39
40
|
if (i > 1) gp = this->parents.at(i - 2);
|
40
41
|
|
@@ -44,8 +45,8 @@ namespace Sass {
|
|
44
45
|
}
|
45
46
|
}
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
AtRootRule* ar = Cast<AtRootRule>(parent);
|
49
|
+
Block* ret = ar->block();
|
49
50
|
|
50
51
|
if (ret != NULL) {
|
51
52
|
for (auto n : ret->elements()) {
|
@@ -65,16 +66,16 @@ namespace Sass {
|
|
65
66
|
|
66
67
|
this->parents.push_back(parent);
|
67
68
|
|
68
|
-
|
69
|
+
Block* b = Cast<Block>(parent);
|
69
70
|
|
70
|
-
if (
|
71
|
+
if (Trace* trace = Cast<Trace>(parent)) {
|
71
72
|
if (trace->type() == 'i') {
|
72
73
|
this->traces.push_back(Backtrace(trace->pstate()));
|
73
74
|
}
|
74
75
|
}
|
75
76
|
|
76
77
|
if (!b) {
|
77
|
-
if (
|
78
|
+
if (ParentStatement* bb = Cast<ParentStatement>(parent)) {
|
78
79
|
b = bb->block();
|
79
80
|
}
|
80
81
|
}
|
@@ -88,7 +89,7 @@ namespace Sass {
|
|
88
89
|
this->parent = old_parent;
|
89
90
|
this->parents.pop_back();
|
90
91
|
|
91
|
-
if (
|
92
|
+
if (Trace* trace = Cast<Trace>(parent)) {
|
92
93
|
if (trace->type() == 'i') {
|
93
94
|
this->traces.pop_back();
|
94
95
|
}
|
@@ -98,12 +99,12 @@ namespace Sass {
|
|
98
99
|
}
|
99
100
|
|
100
101
|
|
101
|
-
|
102
|
+
Statement* CheckNesting::operator()(Block* b)
|
102
103
|
{
|
103
104
|
return this->visit_children(b);
|
104
105
|
}
|
105
106
|
|
106
|
-
|
107
|
+
Statement* CheckNesting::operator()(Definition* n)
|
107
108
|
{
|
108
109
|
if (!this->should_visit(n)) return NULL;
|
109
110
|
if (!is_mixin(n)) {
|
@@ -111,7 +112,7 @@ namespace Sass {
|
|
111
112
|
return n;
|
112
113
|
}
|
113
114
|
|
114
|
-
|
115
|
+
Definition* old_mixin_definition = this->current_mixin_definition;
|
115
116
|
this->current_mixin_definition = n;
|
116
117
|
|
117
118
|
visit_children(n);
|
@@ -121,25 +122,18 @@ namespace Sass {
|
|
121
122
|
return n;
|
122
123
|
}
|
123
124
|
|
124
|
-
|
125
|
+
Statement* CheckNesting::operator()(If* i)
|
125
126
|
{
|
126
127
|
this->visit_children(i);
|
127
128
|
|
128
|
-
if (
|
129
|
+
if (Block* b = Cast<Block>(i->alternative())) {
|
129
130
|
for (auto n : b->elements()) n->perform(this);
|
130
131
|
}
|
131
132
|
|
132
133
|
return i;
|
133
134
|
}
|
134
135
|
|
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)
|
136
|
+
bool CheckNesting::should_visit(Statement* node)
|
143
137
|
{
|
144
138
|
if (!this->parent) return true;
|
145
139
|
|
@@ -149,7 +143,7 @@ namespace Sass {
|
|
149
143
|
if (is_charset(node))
|
150
144
|
{ this->invalid_charset_parent(this->parent, node); }
|
151
145
|
|
152
|
-
if (Cast<
|
146
|
+
if (Cast<ExtendRule>(node))
|
153
147
|
{ this->invalid_extend_parent(this->parent, node); }
|
154
148
|
|
155
149
|
// if (Cast<Import>(node))
|
@@ -164,7 +158,7 @@ namespace Sass {
|
|
164
158
|
if (this->is_function(this->parent))
|
165
159
|
{ this->invalid_function_child(node); }
|
166
160
|
|
167
|
-
if (
|
161
|
+
if (Declaration* d = Cast<Declaration>(node))
|
168
162
|
{
|
169
163
|
this->invalid_prop_parent(this->parent, node);
|
170
164
|
this->invalid_value_child(d->value());
|
@@ -179,14 +173,14 @@ namespace Sass {
|
|
179
173
|
return true;
|
180
174
|
}
|
181
175
|
|
182
|
-
void CheckNesting::invalid_content_parent(
|
176
|
+
void CheckNesting::invalid_content_parent(Statement* parent, AST_Node* node)
|
183
177
|
{
|
184
178
|
if (!this->current_mixin_definition) {
|
185
179
|
error(node, traces, "@content may only be used within a mixin.");
|
186
180
|
}
|
187
181
|
}
|
188
182
|
|
189
|
-
void CheckNesting::invalid_charset_parent(
|
183
|
+
void CheckNesting::invalid_charset_parent(Statement* parent, AST_Node* node)
|
190
184
|
{
|
191
185
|
if (!(
|
192
186
|
is_root_node(parent)
|
@@ -195,10 +189,10 @@ namespace Sass {
|
|
195
189
|
}
|
196
190
|
}
|
197
191
|
|
198
|
-
void CheckNesting::invalid_extend_parent(
|
192
|
+
void CheckNesting::invalid_extend_parent(Statement* parent, AST_Node* node)
|
199
193
|
{
|
200
194
|
if (!(
|
201
|
-
Cast<
|
195
|
+
Cast<StyleRule>(parent) ||
|
202
196
|
Cast<Mixin_Call>(parent) ||
|
203
197
|
is_mixin(parent)
|
204
198
|
)) {
|
@@ -206,14 +200,14 @@ namespace Sass {
|
|
206
200
|
}
|
207
201
|
}
|
208
202
|
|
209
|
-
// void CheckNesting::invalid_import_parent(
|
203
|
+
// void CheckNesting::invalid_import_parent(Statement* parent, AST_Node* node)
|
210
204
|
// {
|
211
205
|
// for (auto pp : this->parents) {
|
212
206
|
// if (
|
213
|
-
// Cast<
|
214
|
-
// Cast<
|
207
|
+
// Cast<EachRule>(pp) ||
|
208
|
+
// Cast<ForRule>(pp) ||
|
215
209
|
// Cast<If>(pp) ||
|
216
|
-
// Cast<
|
210
|
+
// Cast<WhileRule>(pp) ||
|
217
211
|
// Cast<Trace>(pp) ||
|
218
212
|
// Cast<Mixin_Call>(pp) ||
|
219
213
|
// is_mixin(pp)
|
@@ -231,14 +225,14 @@ namespace Sass {
|
|
231
225
|
// }
|
232
226
|
// }
|
233
227
|
|
234
|
-
void CheckNesting::invalid_mixin_definition_parent(
|
228
|
+
void CheckNesting::invalid_mixin_definition_parent(Statement* parent, AST_Node* node)
|
235
229
|
{
|
236
|
-
for (
|
230
|
+
for (Statement* pp : this->parents) {
|
237
231
|
if (
|
238
|
-
Cast<
|
239
|
-
Cast<
|
232
|
+
Cast<EachRule>(pp) ||
|
233
|
+
Cast<ForRule>(pp) ||
|
240
234
|
Cast<If>(pp) ||
|
241
|
-
Cast<
|
235
|
+
Cast<WhileRule>(pp) ||
|
242
236
|
Cast<Trace>(pp) ||
|
243
237
|
Cast<Mixin_Call>(pp) ||
|
244
238
|
is_mixin(pp)
|
@@ -248,14 +242,14 @@ namespace Sass {
|
|
248
242
|
}
|
249
243
|
}
|
250
244
|
|
251
|
-
void CheckNesting::invalid_function_parent(
|
245
|
+
void CheckNesting::invalid_function_parent(Statement* parent, AST_Node* node)
|
252
246
|
{
|
253
|
-
for (
|
247
|
+
for (Statement* pp : this->parents) {
|
254
248
|
if (
|
255
|
-
Cast<
|
256
|
-
Cast<
|
249
|
+
Cast<EachRule>(pp) ||
|
250
|
+
Cast<ForRule>(pp) ||
|
257
251
|
Cast<If>(pp) ||
|
258
|
-
Cast<
|
252
|
+
Cast<WhileRule>(pp) ||
|
259
253
|
Cast<Trace>(pp) ||
|
260
254
|
Cast<Mixin_Call>(pp) ||
|
261
255
|
is_mixin(pp)
|
@@ -265,34 +259,34 @@ namespace Sass {
|
|
265
259
|
}
|
266
260
|
}
|
267
261
|
|
268
|
-
void CheckNesting::invalid_function_child(
|
262
|
+
void CheckNesting::invalid_function_child(Statement* child)
|
269
263
|
{
|
270
264
|
if (!(
|
271
|
-
Cast<
|
272
|
-
Cast<
|
265
|
+
Cast<EachRule>(child) ||
|
266
|
+
Cast<ForRule>(child) ||
|
273
267
|
Cast<If>(child) ||
|
274
|
-
Cast<
|
268
|
+
Cast<WhileRule>(child) ||
|
275
269
|
Cast<Trace>(child) ||
|
276
270
|
Cast<Comment>(child) ||
|
277
|
-
Cast<
|
271
|
+
Cast<DebugRule>(child) ||
|
278
272
|
Cast<Return>(child) ||
|
279
273
|
Cast<Variable>(child) ||
|
280
274
|
// Ruby Sass doesn't distinguish variables and assignments
|
281
275
|
Cast<Assignment>(child) ||
|
282
|
-
Cast<
|
283
|
-
Cast<
|
276
|
+
Cast<WarningRule>(child) ||
|
277
|
+
Cast<ErrorRule>(child)
|
284
278
|
)) {
|
285
279
|
error(child, traces, "Functions can only contain variable declarations and control directives.");
|
286
280
|
}
|
287
281
|
}
|
288
282
|
|
289
|
-
void CheckNesting::invalid_prop_child(
|
283
|
+
void CheckNesting::invalid_prop_child(Statement* child)
|
290
284
|
{
|
291
285
|
if (!(
|
292
|
-
Cast<
|
293
|
-
Cast<
|
286
|
+
Cast<EachRule>(child) ||
|
287
|
+
Cast<ForRule>(child) ||
|
294
288
|
Cast<If>(child) ||
|
295
|
-
Cast<
|
289
|
+
Cast<WhileRule>(child) ||
|
296
290
|
Cast<Trace>(child) ||
|
297
291
|
Cast<Comment>(child) ||
|
298
292
|
Cast<Declaration>(child) ||
|
@@ -302,12 +296,12 @@ namespace Sass {
|
|
302
296
|
}
|
303
297
|
}
|
304
298
|
|
305
|
-
void CheckNesting::invalid_prop_parent(
|
299
|
+
void CheckNesting::invalid_prop_parent(Statement* parent, AST_Node* node)
|
306
300
|
{
|
307
301
|
if (!(
|
308
302
|
is_mixin(parent) ||
|
309
303
|
is_directive_node(parent) ||
|
310
|
-
Cast<
|
304
|
+
Cast<StyleRule>(parent) ||
|
311
305
|
Cast<Keyframe_Rule>(parent) ||
|
312
306
|
Cast<Declaration>(parent) ||
|
313
307
|
Cast<Mixin_Call>(parent)
|
@@ -316,13 +310,13 @@ namespace Sass {
|
|
316
310
|
}
|
317
311
|
}
|
318
312
|
|
319
|
-
void CheckNesting::invalid_value_child(
|
313
|
+
void CheckNesting::invalid_value_child(AST_Node* d)
|
320
314
|
{
|
321
|
-
if (
|
315
|
+
if (Map* m = Cast<Map>(d)) {
|
322
316
|
traces.push_back(Backtrace(m->pstate()));
|
323
317
|
throw Exception::InvalidValue(traces, *m);
|
324
318
|
}
|
325
|
-
if (
|
319
|
+
if (Number* n = Cast<Number>(d)) {
|
326
320
|
if (!n->is_valid_css_unit()) {
|
327
321
|
traces.push_back(Backtrace(n->pstate()));
|
328
322
|
throw Exception::InvalidValue(traces, *n);
|
@@ -333,14 +327,14 @@ namespace Sass {
|
|
333
327
|
|
334
328
|
}
|
335
329
|
|
336
|
-
void CheckNesting::invalid_return_parent(
|
330
|
+
void CheckNesting::invalid_return_parent(Statement* parent, AST_Node* node)
|
337
331
|
{
|
338
332
|
if (!this->is_function(parent)) {
|
339
333
|
error(node, traces, "@return may only be used within a function.");
|
340
334
|
}
|
341
335
|
}
|
342
336
|
|
343
|
-
bool CheckNesting::is_transparent_parent(
|
337
|
+
bool CheckNesting::is_transparent_parent(Statement* parent, Statement* grandparent)
|
344
338
|
{
|
345
339
|
bool parent_bubbles = parent && parent->bubbles();
|
346
340
|
|
@@ -349,50 +343,51 @@ namespace Sass {
|
|
349
343
|
!is_at_root_node(grandparent);
|
350
344
|
|
351
345
|
return Cast<Import>(parent) ||
|
352
|
-
Cast<
|
353
|
-
Cast<
|
346
|
+
Cast<EachRule>(parent) ||
|
347
|
+
Cast<ForRule>(parent) ||
|
354
348
|
Cast<If>(parent) ||
|
355
|
-
Cast<
|
349
|
+
Cast<WhileRule>(parent) ||
|
356
350
|
Cast<Trace>(parent) ||
|
357
351
|
valid_bubble_node;
|
358
352
|
}
|
359
353
|
|
360
|
-
bool CheckNesting::is_charset(
|
354
|
+
bool CheckNesting::is_charset(Statement* n)
|
361
355
|
{
|
362
|
-
|
356
|
+
AtRule* d = Cast<AtRule>(n);
|
363
357
|
return d && d->keyword() == "charset";
|
364
358
|
}
|
365
359
|
|
366
|
-
bool CheckNesting::is_mixin(
|
360
|
+
bool CheckNesting::is_mixin(Statement* n)
|
367
361
|
{
|
368
|
-
|
362
|
+
Definition* def = Cast<Definition>(n);
|
369
363
|
return def && def->type() == Definition::MIXIN;
|
370
364
|
}
|
371
365
|
|
372
|
-
bool CheckNesting::is_function(
|
366
|
+
bool CheckNesting::is_function(Statement* n)
|
373
367
|
{
|
374
|
-
|
368
|
+
Definition* def = Cast<Definition>(n);
|
375
369
|
return def && def->type() == Definition::FUNCTION;
|
376
370
|
}
|
377
371
|
|
378
|
-
bool CheckNesting::is_root_node(
|
372
|
+
bool CheckNesting::is_root_node(Statement* n)
|
379
373
|
{
|
380
|
-
if (Cast<
|
374
|
+
if (Cast<StyleRule>(n)) return false;
|
381
375
|
|
382
|
-
|
376
|
+
Block* b = Cast<Block>(n);
|
383
377
|
return b && b->is_root();
|
384
378
|
}
|
385
379
|
|
386
|
-
bool CheckNesting::is_at_root_node(
|
380
|
+
bool CheckNesting::is_at_root_node(Statement* n)
|
387
381
|
{
|
388
|
-
return Cast<
|
382
|
+
return Cast<AtRootRule>(n) != NULL;
|
389
383
|
}
|
390
384
|
|
391
|
-
bool CheckNesting::is_directive_node(
|
385
|
+
bool CheckNesting::is_directive_node(Statement* n)
|
392
386
|
{
|
393
|
-
return Cast<
|
387
|
+
return Cast<AtRule>(n) ||
|
394
388
|
Cast<Import>(n) ||
|
395
|
-
|
396
|
-
|
389
|
+
Cast<MediaRule>(n) ||
|
390
|
+
Cast<CssMediaRule>(n) ||
|
391
|
+
Cast<SupportsRule>(n);
|
397
392
|
}
|
398
393
|
}
|