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
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "../sass.hpp"
|
2
|
+
#include <iostream>
|
3
|
+
#include <typeinfo>
|
4
|
+
|
5
|
+
#include "shared_ptr.hpp"
|
6
|
+
#include "../ast_fwd_decl.hpp"
|
7
|
+
|
8
|
+
#ifdef DEBUG_SHARED_PTR
|
9
|
+
#include "../debugger.hpp"
|
10
|
+
#endif
|
11
|
+
|
12
|
+
namespace Sass {
|
13
|
+
|
14
|
+
#ifdef DEBUG_SHARED_PTR
|
15
|
+
void SharedObj::dumpMemLeaks() {
|
16
|
+
if (!all.empty()) {
|
17
|
+
std::cerr << "###################################\n";
|
18
|
+
std::cerr << "# REPORTING MISSING DEALLOCATIONS #\n";
|
19
|
+
std::cerr << "###################################\n";
|
20
|
+
for (SharedObj* var : all) {
|
21
|
+
if (AST_Node* ast = dynamic_cast<AST_Node*>(var)) {
|
22
|
+
debug_ast(ast);
|
23
|
+
} else {
|
24
|
+
std::cerr << "LEAKED " << var << "\n";
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
sass::vector<SharedObj*> SharedObj::all;
|
30
|
+
#endif
|
31
|
+
|
32
|
+
bool SharedObj::taint = false;
|
33
|
+
}
|
@@ -0,0 +1,332 @@
|
|
1
|
+
#ifndef SASS_MEMORY_SHARED_PTR_H
|
2
|
+
#define SASS_MEMORY_SHARED_PTR_H
|
3
|
+
|
4
|
+
#include "sass/base.h"
|
5
|
+
|
6
|
+
#include "../sass.hpp"
|
7
|
+
#include "allocator.hpp"
|
8
|
+
#include <cstddef>
|
9
|
+
#include <iostream>
|
10
|
+
#include <string>
|
11
|
+
#include <type_traits>
|
12
|
+
#include <vector>
|
13
|
+
|
14
|
+
// https://lokiastari.com/blog/2014/12/30/c-plus-plus-by-example-smart-pointer/index.html
|
15
|
+
// https://lokiastari.com/blog/2015/01/15/c-plus-plus-by-example-smart-pointer-part-ii/index.html
|
16
|
+
// https://lokiastari.com/blog/2015/01/23/c-plus-plus-by-example-smart-pointer-part-iii/index.html
|
17
|
+
|
18
|
+
namespace Sass {
|
19
|
+
|
20
|
+
// Forward declaration
|
21
|
+
class SharedPtr;
|
22
|
+
|
23
|
+
///////////////////////////////////////////////////////////////////////////////
|
24
|
+
// Use macros for the allocation task, since overloading operator `new`
|
25
|
+
// has been proven to be flaky under certain compilers (see comment below).
|
26
|
+
///////////////////////////////////////////////////////////////////////////////
|
27
|
+
|
28
|
+
#ifdef DEBUG_SHARED_PTR
|
29
|
+
|
30
|
+
#define SASS_MEMORY_NEW(Class, ...) \
|
31
|
+
((Class*)(new Class(__VA_ARGS__))->trace(__FILE__, __LINE__)) \
|
32
|
+
|
33
|
+
#define SASS_MEMORY_COPY(obj) \
|
34
|
+
((obj)->copy(__FILE__, __LINE__)) \
|
35
|
+
|
36
|
+
#define SASS_MEMORY_CLONE(obj) \
|
37
|
+
((obj)->clone(__FILE__, __LINE__)) \
|
38
|
+
|
39
|
+
#else
|
40
|
+
|
41
|
+
#define SASS_MEMORY_NEW(Class, ...) \
|
42
|
+
new Class(__VA_ARGS__) \
|
43
|
+
|
44
|
+
#define SASS_MEMORY_COPY(obj) \
|
45
|
+
((obj)->copy()) \
|
46
|
+
|
47
|
+
#define SASS_MEMORY_CLONE(obj) \
|
48
|
+
((obj)->clone()) \
|
49
|
+
|
50
|
+
#endif
|
51
|
+
|
52
|
+
// SharedObj is the base class for all objects that can be stored as a shared object
|
53
|
+
// It adds the reference counter and other values directly to the objects
|
54
|
+
// This gives a slight overhead when directly used as a stack object, but has some
|
55
|
+
// advantages for our code. It is safe to create two shared pointers from the same
|
56
|
+
// objects, as the "control block" is directly attached to it. This would lead
|
57
|
+
// to undefined behavior with std::shared_ptr. This also avoids the need to
|
58
|
+
// allocate additional control blocks and/or the need to dereference two
|
59
|
+
// pointers on each operation. This can be optimized in `std::shared_ptr`
|
60
|
+
// too by using `std::make_shared` (where the control block and the actual
|
61
|
+
// object are allocated in one continuous memory block via one single call).
|
62
|
+
class SharedObj {
|
63
|
+
public:
|
64
|
+
SharedObj() : refcount(0), detached(false) {
|
65
|
+
#ifdef DEBUG_SHARED_PTR
|
66
|
+
if (taint) all.push_back(this);
|
67
|
+
#endif
|
68
|
+
}
|
69
|
+
virtual ~SharedObj() {
|
70
|
+
#ifdef DEBUG_SHARED_PTR
|
71
|
+
for (size_t i = 0; i < all.size(); i++) {
|
72
|
+
if (all[i] == this) {
|
73
|
+
all.erase(all.begin() + i);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
#endif
|
78
|
+
}
|
79
|
+
|
80
|
+
#ifdef DEBUG_SHARED_PTR
|
81
|
+
static void dumpMemLeaks();
|
82
|
+
SharedObj* trace(sass::string file, size_t line) {
|
83
|
+
this->file = file;
|
84
|
+
this->line = line;
|
85
|
+
return this;
|
86
|
+
}
|
87
|
+
sass::string getDbgFile() { return file; }
|
88
|
+
size_t getDbgLine() { return line; }
|
89
|
+
void setDbg(bool dbg) { this->dbg = dbg; }
|
90
|
+
size_t getRefCount() const { return refcount; }
|
91
|
+
#endif
|
92
|
+
|
93
|
+
static void setTaint(bool val) { taint = val; }
|
94
|
+
|
95
|
+
#ifdef SASS_CUSTOM_ALLOCATOR
|
96
|
+
inline void* operator new(size_t nbytes) {
|
97
|
+
return allocateMem(nbytes);
|
98
|
+
}
|
99
|
+
inline void operator delete(void* ptr) {
|
100
|
+
return deallocateMem(ptr);
|
101
|
+
}
|
102
|
+
#endif
|
103
|
+
|
104
|
+
virtual sass::string to_string() const = 0;
|
105
|
+
protected:
|
106
|
+
friend class SharedPtr;
|
107
|
+
friend class Memory_Manager;
|
108
|
+
size_t refcount;
|
109
|
+
bool detached;
|
110
|
+
static bool taint;
|
111
|
+
#ifdef DEBUG_SHARED_PTR
|
112
|
+
sass::string file;
|
113
|
+
size_t line;
|
114
|
+
bool dbg = false;
|
115
|
+
static sass::vector<SharedObj*> all;
|
116
|
+
#endif
|
117
|
+
};
|
118
|
+
|
119
|
+
// SharedPtr is a intermediate (template-less) base class for SharedImpl.
|
120
|
+
// ToDo: there should be a way to include this in SharedImpl and to get
|
121
|
+
// ToDo: rid of all the static_cast that are now needed in SharedImpl.
|
122
|
+
class SharedPtr {
|
123
|
+
public:
|
124
|
+
SharedPtr() : node(nullptr) {}
|
125
|
+
SharedPtr(SharedObj* ptr) : node(ptr) {
|
126
|
+
incRefCount();
|
127
|
+
}
|
128
|
+
SharedPtr(const SharedPtr& obj) : SharedPtr(obj.node) {}
|
129
|
+
~SharedPtr() {
|
130
|
+
decRefCount();
|
131
|
+
}
|
132
|
+
|
133
|
+
SharedPtr& operator=(SharedObj* other_node) {
|
134
|
+
if (node != other_node) {
|
135
|
+
decRefCount();
|
136
|
+
node = other_node;
|
137
|
+
incRefCount();
|
138
|
+
} else if (node != nullptr) {
|
139
|
+
node->detached = false;
|
140
|
+
}
|
141
|
+
return *this;
|
142
|
+
}
|
143
|
+
|
144
|
+
SharedPtr& operator=(const SharedPtr& obj) {
|
145
|
+
return *this = obj.node;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Prevents all SharedPtrs from freeing this node until it is assigned to another SharedPtr.
|
149
|
+
SharedObj* detach() {
|
150
|
+
if (node != nullptr) node->detached = true;
|
151
|
+
#ifdef DEBUG_SHARED_PTR
|
152
|
+
if (node->dbg) {
|
153
|
+
std::cerr << "DETACHING NODE\n";
|
154
|
+
}
|
155
|
+
#endif
|
156
|
+
return node;
|
157
|
+
}
|
158
|
+
|
159
|
+
SharedObj* obj() const { return node; }
|
160
|
+
SharedObj* operator->() const { return node; }
|
161
|
+
bool isNull() const { return node == nullptr; }
|
162
|
+
operator bool() const { return node != nullptr; }
|
163
|
+
|
164
|
+
protected:
|
165
|
+
SharedObj* node;
|
166
|
+
void decRefCount() {
|
167
|
+
if (node == nullptr) return;
|
168
|
+
--node->refcount;
|
169
|
+
#ifdef DEBUG_SHARED_PTR
|
170
|
+
if (node->dbg) std::cerr << "- " << node << " X " << node->refcount << " (" << this << ") " << "\n";
|
171
|
+
#endif
|
172
|
+
if (node->refcount == 0 && !node->detached) {
|
173
|
+
#ifdef DEBUG_SHARED_PTR
|
174
|
+
if (node->dbg) std::cerr << "DELETE NODE " << node << "\n";
|
175
|
+
#endif
|
176
|
+
delete node;
|
177
|
+
}
|
178
|
+
else if (node->refcount == 0) {
|
179
|
+
#ifdef DEBUG_SHARED_PTR
|
180
|
+
if (node->dbg) std::cerr << "NODE EVAEDED DELETE " << node << "\n";
|
181
|
+
#endif
|
182
|
+
}
|
183
|
+
}
|
184
|
+
void incRefCount() {
|
185
|
+
if (node == nullptr) return;
|
186
|
+
node->detached = false;
|
187
|
+
++node->refcount;
|
188
|
+
#ifdef DEBUG_SHARED_PTR
|
189
|
+
if (node->dbg) std::cerr << "+ " << node << " X " << node->refcount << " (" << this << ") " << "\n";
|
190
|
+
#endif
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
template <class T>
|
195
|
+
class SharedImpl : private SharedPtr {
|
196
|
+
|
197
|
+
public:
|
198
|
+
SharedImpl() : SharedPtr(nullptr) {}
|
199
|
+
|
200
|
+
template <class U>
|
201
|
+
SharedImpl(U* node) :
|
202
|
+
SharedPtr(static_cast<T*>(node)) {}
|
203
|
+
|
204
|
+
template <class U>
|
205
|
+
SharedImpl(const SharedImpl<U>& impl) :
|
206
|
+
SharedImpl(impl.ptr()) {}
|
207
|
+
|
208
|
+
template <class U>
|
209
|
+
SharedImpl<T>& operator=(U *rhs) {
|
210
|
+
return static_cast<SharedImpl<T>&>(
|
211
|
+
SharedPtr::operator=(static_cast<T*>(rhs)));
|
212
|
+
}
|
213
|
+
|
214
|
+
template <class U>
|
215
|
+
SharedImpl<T>& operator=(const SharedImpl<U>& rhs) {
|
216
|
+
return static_cast<SharedImpl<T>&>(
|
217
|
+
SharedPtr::operator=(static_cast<const SharedImpl<T>&>(rhs)));
|
218
|
+
}
|
219
|
+
|
220
|
+
operator sass::string() const {
|
221
|
+
if (node) return node->to_string();
|
222
|
+
return "null";
|
223
|
+
}
|
224
|
+
|
225
|
+
using SharedPtr::isNull;
|
226
|
+
using SharedPtr::operator bool;
|
227
|
+
operator T*() const { return static_cast<T*>(this->obj()); }
|
228
|
+
operator T&() const { return *static_cast<T*>(this->obj()); }
|
229
|
+
T& operator* () const { return *static_cast<T*>(this->obj()); };
|
230
|
+
T* operator-> () const { return static_cast<T*>(this->obj()); };
|
231
|
+
T* ptr () const { return static_cast<T*>(this->obj()); };
|
232
|
+
T* detach() { return static_cast<T*>(SharedPtr::detach()); }
|
233
|
+
|
234
|
+
};
|
235
|
+
|
236
|
+
// Comparison operators, based on:
|
237
|
+
// https://en.cppreference.com/w/cpp/memory/unique_ptr/operator_cmp
|
238
|
+
|
239
|
+
template<class T1, class T2>
|
240
|
+
bool operator==(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
241
|
+
return x.ptr() == y.ptr();
|
242
|
+
}
|
243
|
+
|
244
|
+
template<class T1, class T2>
|
245
|
+
bool operator!=(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
246
|
+
return x.ptr() != y.ptr();
|
247
|
+
}
|
248
|
+
|
249
|
+
template<class T1, class T2>
|
250
|
+
bool operator<(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
251
|
+
using CT = typename std::common_type<T1*, T2*>::type;
|
252
|
+
return std::less<CT>()(x.get(), y.get());
|
253
|
+
}
|
254
|
+
|
255
|
+
template<class T1, class T2>
|
256
|
+
bool operator<=(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
257
|
+
return !(y < x);
|
258
|
+
}
|
259
|
+
|
260
|
+
template<class T1, class T2>
|
261
|
+
bool operator>(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
262
|
+
return y < x;
|
263
|
+
}
|
264
|
+
|
265
|
+
template<class T1, class T2>
|
266
|
+
bool operator>=(const SharedImpl<T1>& x, const SharedImpl<T2>& y) {
|
267
|
+
return !(x < y);
|
268
|
+
}
|
269
|
+
|
270
|
+
template <class T>
|
271
|
+
bool operator==(const SharedImpl<T>& x, std::nullptr_t) noexcept {
|
272
|
+
return x.isNull();
|
273
|
+
}
|
274
|
+
|
275
|
+
template <class T>
|
276
|
+
bool operator==(std::nullptr_t, const SharedImpl<T>& x) noexcept {
|
277
|
+
return x.isNull();
|
278
|
+
}
|
279
|
+
|
280
|
+
template <class T>
|
281
|
+
bool operator!=(const SharedImpl<T>& x, std::nullptr_t) noexcept {
|
282
|
+
return !x.isNull();
|
283
|
+
}
|
284
|
+
|
285
|
+
template <class T>
|
286
|
+
bool operator!=(std::nullptr_t, const SharedImpl<T>& x) noexcept {
|
287
|
+
return !x.isNull();
|
288
|
+
}
|
289
|
+
|
290
|
+
template <class T>
|
291
|
+
bool operator<(const SharedImpl<T>& x, std::nullptr_t) {
|
292
|
+
return std::less<T*>()(x.get(), nullptr);
|
293
|
+
}
|
294
|
+
|
295
|
+
template <class T>
|
296
|
+
bool operator<(std::nullptr_t, const SharedImpl<T>& y) {
|
297
|
+
return std::less<T*>()(nullptr, y.get());
|
298
|
+
}
|
299
|
+
|
300
|
+
template <class T>
|
301
|
+
bool operator<=(const SharedImpl<T>& x, std::nullptr_t) {
|
302
|
+
return !(nullptr < x);
|
303
|
+
}
|
304
|
+
|
305
|
+
template <class T>
|
306
|
+
bool operator<=(std::nullptr_t, const SharedImpl<T>& y) {
|
307
|
+
return !(y < nullptr);
|
308
|
+
}
|
309
|
+
|
310
|
+
template <class T>
|
311
|
+
bool operator>(const SharedImpl<T>& x, std::nullptr_t) {
|
312
|
+
return nullptr < x;
|
313
|
+
}
|
314
|
+
|
315
|
+
template <class T>
|
316
|
+
bool operator>(std::nullptr_t, const SharedImpl<T>& y) {
|
317
|
+
return y < nullptr;
|
318
|
+
}
|
319
|
+
|
320
|
+
template <class T>
|
321
|
+
bool operator>=(const SharedImpl<T>& x, std::nullptr_t) {
|
322
|
+
return !(x < nullptr);
|
323
|
+
}
|
324
|
+
|
325
|
+
template <class T>
|
326
|
+
bool operator>=(std::nullptr_t, const SharedImpl<T>& y) {
|
327
|
+
return !(nullptr < y);
|
328
|
+
}
|
329
|
+
|
330
|
+
} // namespace Sass
|
331
|
+
|
332
|
+
#endif
|
@@ -1,171 +1,221 @@
|
|
1
1
|
#ifndef SASS_OPERATION_H
|
2
2
|
#define SASS_OPERATION_H
|
3
3
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
6
|
+
#include "sass.hpp"
|
7
|
+
|
8
|
+
// base classes to implement curiously recurring template pattern (CRTP)
|
9
|
+
// https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
|
10
|
+
|
11
|
+
#include <typeinfo>
|
12
|
+
#include <stdexcept>
|
13
|
+
|
4
14
|
#include "ast_fwd_decl.hpp"
|
15
|
+
#include "ast_def_macros.hpp"
|
5
16
|
|
6
17
|
namespace Sass {
|
7
18
|
|
19
|
+
#define ATTACH_ABSTRACT_CRTP_PERFORM_METHODS()\
|
20
|
+
virtual void perform(Operation<void>* op) = 0; \
|
21
|
+
virtual Value* perform(Operation<Value*>* op) = 0; \
|
22
|
+
virtual sass::string perform(Operation<sass::string>* op) = 0; \
|
23
|
+
virtual AST_Node* perform(Operation<AST_Node*>* op) = 0; \
|
24
|
+
virtual Selector* perform(Operation<Selector*>* op) = 0; \
|
25
|
+
virtual Statement* perform(Operation<Statement*>* op) = 0; \
|
26
|
+
virtual Expression* perform(Operation<Expression*>* op) = 0; \
|
27
|
+
virtual union Sass_Value* perform(Operation<union Sass_Value*>* op) = 0; \
|
28
|
+
virtual SupportsCondition* perform(Operation<SupportsCondition*>* op) = 0; \
|
29
|
+
|
30
|
+
// you must add operators to every class
|
31
|
+
// ensures `this` of actual instance type
|
32
|
+
// we therefore call the specific operator
|
33
|
+
// they are virtual so most specific is used
|
34
|
+
#define ATTACH_CRTP_PERFORM_METHODS()\
|
35
|
+
virtual void perform(Operation<void>* op) override { return (*op)(this); } \
|
36
|
+
virtual Value* perform(Operation<Value*>* op) override { return (*op)(this); } \
|
37
|
+
virtual sass::string perform(Operation<sass::string>* op) override { return (*op)(this); } \
|
38
|
+
virtual AST_Node* perform(Operation<AST_Node*>* op) override { return (*op)(this); } \
|
39
|
+
virtual Selector* perform(Operation<Selector*>* op) override { return (*op)(this); } \
|
40
|
+
virtual Statement* perform(Operation<Statement*>* op) override { return (*op)(this); } \
|
41
|
+
virtual Expression* perform(Operation<Expression*>* op) override { return (*op)(this); } \
|
42
|
+
virtual union Sass_Value* perform(Operation<union Sass_Value*>* op) override { return (*op)(this); } \
|
43
|
+
virtual SupportsCondition* perform(Operation<SupportsCondition*>* op) override { return (*op)(this); } \
|
44
|
+
|
8
45
|
template<typename T>
|
9
46
|
class Operation {
|
10
47
|
public:
|
11
|
-
virtual T operator()(
|
12
|
-
virtual ~Operation() { }
|
48
|
+
virtual T operator()(AST_Node* x) = 0;
|
13
49
|
// statements
|
14
|
-
virtual T operator()(
|
15
|
-
virtual T operator()(
|
16
|
-
virtual T operator()(
|
17
|
-
virtual T operator()(
|
18
|
-
virtual T operator()(
|
19
|
-
virtual T operator()(
|
20
|
-
virtual T operator()(
|
21
|
-
virtual T operator()(
|
22
|
-
virtual T operator()(
|
23
|
-
virtual T operator()(
|
24
|
-
virtual T operator()(
|
25
|
-
virtual T operator()(
|
26
|
-
virtual T operator()(
|
27
|
-
virtual T operator()(
|
28
|
-
virtual T operator()(
|
29
|
-
virtual T operator()(
|
30
|
-
virtual T operator()(
|
31
|
-
virtual T operator()(
|
32
|
-
virtual T operator()(
|
33
|
-
virtual T operator()(
|
34
|
-
virtual T operator()(
|
35
|
-
virtual T operator()(
|
36
|
-
virtual T operator()(
|
37
|
-
virtual T operator()(
|
38
|
-
virtual T operator()(
|
39
|
-
virtual T operator()(
|
50
|
+
virtual T operator()(Block* x) = 0;
|
51
|
+
virtual T operator()(StyleRule* x) = 0;
|
52
|
+
virtual T operator()(Bubble* x) = 0;
|
53
|
+
virtual T operator()(Trace* x) = 0;
|
54
|
+
virtual T operator()(SupportsRule* x) = 0;
|
55
|
+
virtual T operator()(MediaRule* x) = 0;
|
56
|
+
virtual T operator()(CssMediaRule* x) = 0;
|
57
|
+
virtual T operator()(CssMediaQuery* x) = 0;
|
58
|
+
virtual T operator()(AtRootRule* x) = 0;
|
59
|
+
virtual T operator()(AtRule* x) = 0;
|
60
|
+
virtual T operator()(Keyframe_Rule* x) = 0;
|
61
|
+
virtual T operator()(Declaration* x) = 0;
|
62
|
+
virtual T operator()(Assignment* x) = 0;
|
63
|
+
virtual T operator()(Import* x) = 0;
|
64
|
+
virtual T operator()(Import_Stub* x) = 0;
|
65
|
+
virtual T operator()(WarningRule* x) = 0;
|
66
|
+
virtual T operator()(ErrorRule* x) = 0;
|
67
|
+
virtual T operator()(DebugRule* x) = 0;
|
68
|
+
virtual T operator()(Comment* x) = 0;
|
69
|
+
virtual T operator()(If* x) = 0;
|
70
|
+
virtual T operator()(ForRule* x) = 0;
|
71
|
+
virtual T operator()(EachRule* x) = 0;
|
72
|
+
virtual T operator()(WhileRule* x) = 0;
|
73
|
+
virtual T operator()(Return* x) = 0;
|
74
|
+
virtual T operator()(Content* x) = 0;
|
75
|
+
virtual T operator()(ExtendRule* x) = 0;
|
76
|
+
virtual T operator()(Definition* x) = 0;
|
77
|
+
virtual T operator()(Mixin_Call* x) = 0;
|
40
78
|
// expressions
|
41
|
-
virtual T operator()(
|
42
|
-
virtual T operator()(
|
43
|
-
virtual T operator()(
|
44
|
-
virtual T operator()(
|
45
|
-
virtual T operator()(
|
46
|
-
virtual T operator()(
|
47
|
-
virtual T operator()(
|
48
|
-
virtual T operator()(
|
49
|
-
virtual T operator()(
|
50
|
-
virtual T operator()(
|
51
|
-
virtual T operator()(
|
52
|
-
virtual T operator()(
|
53
|
-
virtual T operator()(
|
54
|
-
virtual T operator()(
|
55
|
-
virtual T operator()(
|
56
|
-
virtual T operator()(
|
57
|
-
virtual T operator()(
|
58
|
-
virtual T operator()(
|
59
|
-
virtual T operator()(
|
60
|
-
virtual T operator()(
|
61
|
-
virtual T operator()(
|
62
|
-
virtual T operator()(
|
63
|
-
virtual T operator()(
|
64
|
-
virtual T operator()(
|
65
|
-
virtual T operator()(
|
66
|
-
virtual T operator()(
|
79
|
+
virtual T operator()(Null* x) = 0;
|
80
|
+
virtual T operator()(List* x) = 0;
|
81
|
+
virtual T operator()(Map* x) = 0;
|
82
|
+
virtual T operator()(Function* x) = 0;
|
83
|
+
virtual T operator()(Binary_Expression* x) = 0;
|
84
|
+
virtual T operator()(Unary_Expression* x) = 0;
|
85
|
+
virtual T operator()(Function_Call* x) = 0;
|
86
|
+
virtual T operator()(Custom_Warning* x) = 0;
|
87
|
+
virtual T operator()(Custom_Error* x) = 0;
|
88
|
+
virtual T operator()(Variable* x) = 0;
|
89
|
+
virtual T operator()(Number* x) = 0;
|
90
|
+
virtual T operator()(Color* x) = 0;
|
91
|
+
virtual T operator()(Color_RGBA* x) = 0;
|
92
|
+
virtual T operator()(Color_HSLA* x) = 0;
|
93
|
+
virtual T operator()(Boolean* x) = 0;
|
94
|
+
virtual T operator()(String_Schema* x) = 0;
|
95
|
+
virtual T operator()(String_Quoted* x) = 0;
|
96
|
+
virtual T operator()(String_Constant* x) = 0;
|
97
|
+
virtual T operator()(SupportsCondition* x) = 0;
|
98
|
+
virtual T operator()(SupportsOperation* x) = 0;
|
99
|
+
virtual T operator()(SupportsNegation* x) = 0;
|
100
|
+
virtual T operator()(SupportsDeclaration* x) = 0;
|
101
|
+
virtual T operator()(Supports_Interpolation* x) = 0;
|
102
|
+
virtual T operator()(Media_Query* x) = 0;
|
103
|
+
virtual T operator()(Media_Query_Expression* x) = 0;
|
104
|
+
virtual T operator()(At_Root_Query* x) = 0;
|
105
|
+
virtual T operator()(Parent_Reference* x) = 0;
|
67
106
|
// parameters and arguments
|
68
|
-
virtual T operator()(
|
69
|
-
virtual T operator()(
|
70
|
-
virtual T operator()(
|
71
|
-
virtual T operator()(
|
107
|
+
virtual T operator()(Parameter* x) = 0;
|
108
|
+
virtual T operator()(Parameters* x) = 0;
|
109
|
+
virtual T operator()(Argument* x) = 0;
|
110
|
+
virtual T operator()(Arguments* x) = 0;
|
72
111
|
// selectors
|
73
|
-
virtual T operator()(
|
74
|
-
virtual T operator()(
|
75
|
-
virtual T operator()(
|
76
|
-
virtual T operator()(
|
77
|
-
virtual T operator()(
|
78
|
-
virtual T operator()(
|
79
|
-
virtual T operator()(
|
80
|
-
virtual T operator()(
|
81
|
-
virtual T operator()(
|
82
|
-
virtual T operator()(
|
83
|
-
virtual T operator()(
|
112
|
+
virtual T operator()(Selector_Schema* x) = 0;
|
113
|
+
virtual T operator()(PlaceholderSelector* x) = 0;
|
114
|
+
virtual T operator()(TypeSelector* x) = 0;
|
115
|
+
virtual T operator()(ClassSelector* x) = 0;
|
116
|
+
virtual T operator()(IDSelector* x) = 0;
|
117
|
+
virtual T operator()(AttributeSelector* x) = 0;
|
118
|
+
virtual T operator()(PseudoSelector* x) = 0;
|
119
|
+
virtual T operator()(SelectorComponent* x) = 0;
|
120
|
+
virtual T operator()(SelectorCombinator* x) = 0;
|
121
|
+
virtual T operator()(CompoundSelector* x) = 0;
|
122
|
+
virtual T operator()(ComplexSelector* x) = 0;
|
123
|
+
virtual T operator()(SelectorList* x) = 0;
|
84
124
|
|
85
|
-
template <typename U>
|
86
|
-
T fallback(U x) { return T(); }
|
87
125
|
};
|
88
126
|
|
127
|
+
// example: Operation_CRTP<Expression*, Eval>
|
128
|
+
// T is the base return type of all visitors
|
129
|
+
// D is the class derived visitor class
|
130
|
+
// normally you want to implement all operators
|
89
131
|
template <typename T, typename D>
|
90
132
|
class Operation_CRTP : public Operation<T> {
|
91
133
|
public:
|
92
|
-
|
93
|
-
public:
|
94
|
-
T operator()(AST_Node_Ptr x) { return static_cast<D*>(this)->fallback(x); }
|
134
|
+
T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
|
95
135
|
// statements
|
96
|
-
T operator()(
|
97
|
-
T operator()(
|
98
|
-
T operator()(
|
99
|
-
T operator()(
|
100
|
-
T operator()(
|
101
|
-
T operator()(
|
102
|
-
T operator()(
|
103
|
-
T operator()(
|
104
|
-
T operator()(
|
105
|
-
T operator()(
|
106
|
-
T operator()(
|
107
|
-
T operator()(
|
108
|
-
T operator()(
|
109
|
-
T operator()(
|
110
|
-
T operator()(
|
111
|
-
T operator()(
|
112
|
-
T operator()(
|
113
|
-
T operator()(
|
114
|
-
T operator()(
|
115
|
-
T operator()(
|
116
|
-
T operator()(
|
117
|
-
T operator()(
|
118
|
-
T operator()(
|
119
|
-
T operator()(
|
120
|
-
T operator()(
|
121
|
-
T operator()(
|
136
|
+
T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
|
137
|
+
T operator()(StyleRule* x) { return static_cast<D*>(this)->fallback(x); }
|
138
|
+
T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
|
139
|
+
T operator()(Trace* x) { return static_cast<D*>(this)->fallback(x); }
|
140
|
+
T operator()(SupportsRule* x) { return static_cast<D*>(this)->fallback(x); }
|
141
|
+
T operator()(MediaRule* x) { return static_cast<D*>(this)->fallback(x); }
|
142
|
+
T operator()(CssMediaRule* x) { return static_cast<D*>(this)->fallback(x); }
|
143
|
+
T operator()(CssMediaQuery* x) { return static_cast<D*>(this)->fallback(x); }
|
144
|
+
T operator()(AtRootRule* x) { return static_cast<D*>(this)->fallback(x); }
|
145
|
+
T operator()(AtRule* x) { return static_cast<D*>(this)->fallback(x); }
|
146
|
+
T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
|
147
|
+
T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
|
148
|
+
T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
|
149
|
+
T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
|
150
|
+
T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
|
151
|
+
T operator()(WarningRule* x) { return static_cast<D*>(this)->fallback(x); }
|
152
|
+
T operator()(ErrorRule* x) { return static_cast<D*>(this)->fallback(x); }
|
153
|
+
T operator()(DebugRule* x) { return static_cast<D*>(this)->fallback(x); }
|
154
|
+
T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
|
155
|
+
T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
|
156
|
+
T operator()(ForRule* x) { return static_cast<D*>(this)->fallback(x); }
|
157
|
+
T operator()(EachRule* x) { return static_cast<D*>(this)->fallback(x); }
|
158
|
+
T operator()(WhileRule* x) { return static_cast<D*>(this)->fallback(x); }
|
159
|
+
T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
|
160
|
+
T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
|
161
|
+
T operator()(ExtendRule* x) { return static_cast<D*>(this)->fallback(x); }
|
162
|
+
T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
|
163
|
+
T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
|
122
164
|
// expressions
|
123
|
-
T operator()(
|
124
|
-
T operator()(
|
125
|
-
T operator()(
|
126
|
-
T operator()(
|
127
|
-
T operator()(
|
128
|
-
T operator()(
|
129
|
-
T operator()(
|
130
|
-
T operator()(
|
131
|
-
T operator()(
|
132
|
-
T operator()(
|
133
|
-
T operator()(
|
134
|
-
T operator()(
|
135
|
-
T operator()(
|
136
|
-
T operator()(
|
137
|
-
T operator()(
|
138
|
-
T operator()(
|
139
|
-
T operator()(
|
140
|
-
T operator()(
|
141
|
-
T operator()(
|
142
|
-
T operator()(
|
143
|
-
T operator()(
|
144
|
-
T operator()(
|
145
|
-
T operator()(
|
146
|
-
T operator()(
|
147
|
-
T operator()(
|
148
|
-
T operator()(
|
165
|
+
T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
|
166
|
+
T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
|
167
|
+
T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
|
168
|
+
T operator()(Function* x) { return static_cast<D*>(this)->fallback(x); }
|
169
|
+
T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
|
170
|
+
T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
|
171
|
+
T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
|
172
|
+
T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
|
173
|
+
T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
|
174
|
+
T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
|
175
|
+
T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
|
176
|
+
T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
|
177
|
+
T operator()(Color_RGBA* x) { return static_cast<D*>(this)->fallback(x); }
|
178
|
+
T operator()(Color_HSLA* x) { return static_cast<D*>(this)->fallback(x); }
|
179
|
+
T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
|
180
|
+
T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
|
181
|
+
T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
|
182
|
+
T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
|
183
|
+
T operator()(SupportsCondition* x) { return static_cast<D*>(this)->fallback(x); }
|
184
|
+
T operator()(SupportsOperation* x) { return static_cast<D*>(this)->fallback(x); }
|
185
|
+
T operator()(SupportsNegation* x) { return static_cast<D*>(this)->fallback(x); }
|
186
|
+
T operator()(SupportsDeclaration* x) { return static_cast<D*>(this)->fallback(x); }
|
187
|
+
T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
|
188
|
+
T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
|
189
|
+
T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
|
190
|
+
T operator()(At_Root_Query* x) { return static_cast<D*>(this)->fallback(x); }
|
191
|
+
T operator()(Parent_Reference* x) { return static_cast<D*>(this)->fallback(x); }
|
149
192
|
// parameters and arguments
|
150
|
-
T operator()(
|
151
|
-
T operator()(
|
152
|
-
T operator()(
|
153
|
-
T operator()(
|
193
|
+
T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
|
194
|
+
T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
|
195
|
+
T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
|
196
|
+
T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
|
154
197
|
// selectors
|
155
|
-
T operator()(
|
156
|
-
T operator()(
|
157
|
-
T operator()(
|
158
|
-
T operator()(
|
159
|
-
T operator()(
|
160
|
-
T operator()(
|
161
|
-
T operator()(
|
162
|
-
T operator()(
|
163
|
-
T operator()(
|
164
|
-
T operator()(
|
165
|
-
T operator()(
|
198
|
+
T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
|
199
|
+
T operator()(PlaceholderSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
200
|
+
T operator()(TypeSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
201
|
+
T operator()(ClassSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
202
|
+
T operator()(IDSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
203
|
+
T operator()(AttributeSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
204
|
+
T operator()(PseudoSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
205
|
+
T operator()(SelectorComponent* x) { return static_cast<D*>(this)->fallback(x); }
|
206
|
+
T operator()(SelectorCombinator* x) { return static_cast<D*>(this)->fallback(x); }
|
207
|
+
T operator()(CompoundSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
208
|
+
T operator()(ComplexSelector* x) { return static_cast<D*>(this)->fallback(x); }
|
209
|
+
T operator()(SelectorList* x) { return static_cast<D*>(this)->fallback(x); }
|
210
|
+
|
211
|
+
// fallback with specific type U
|
212
|
+
// will be called if not overloaded
|
213
|
+
template <typename U> inline T fallback(U x)
|
214
|
+
{
|
215
|
+
throw std::runtime_error(
|
216
|
+
std::string(typeid(*this).name()) + ": CRTP not implemented for " + typeid(x).name());
|
217
|
+
}
|
166
218
|
|
167
|
-
template <typename U>
|
168
|
-
T fallback(U x) { return T(); }
|
169
219
|
};
|
170
220
|
|
171
221
|
}
|