sassc 1.11.1 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +3 -2
- data/ext/libsass/Makefile.conf +2 -1
- data/ext/libsass/appveyor.yml +10 -5
- data/ext/libsass/docs/dev-ast-memory.md +223 -0
- data/ext/libsass/include/sass/base.h +2 -0
- data/ext/libsass/script/bootstrap +7 -4
- data/ext/libsass/script/ci-build-libsass +3 -3
- data/ext/libsass/script/ci-install-compiler +2 -0
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/script/test-leaks.pl +103 -0
- data/ext/libsass/src/ast.cpp +621 -495
- data/ext/libsass/src/ast.hpp +801 -367
- data/ext/libsass/src/ast_def_macros.hpp +5 -5
- data/ext/libsass/src/ast_fwd_decl.hpp +312 -14
- data/ext/libsass/src/bind.cpp +54 -51
- data/ext/libsass/src/bind.hpp +3 -7
- data/ext/libsass/src/check_nesting.cpp +117 -120
- data/ext/libsass/src/check_nesting.hpp +38 -34
- data/ext/libsass/src/color_maps.cpp +3 -3
- data/ext/libsass/src/color_maps.hpp +3 -3
- data/ext/libsass/src/context.cpp +33 -34
- data/ext/libsass/src/context.hpp +12 -14
- data/ext/libsass/src/cssize.cpp +200 -228
- data/ext/libsass/src/cssize.hpp +49 -49
- data/ext/libsass/src/debugger.hpp +260 -241
- data/ext/libsass/src/emitter.cpp +6 -6
- data/ext/libsass/src/emitter.hpp +7 -7
- data/ext/libsass/src/environment.cpp +2 -2
- data/ext/libsass/src/environment.hpp +0 -2
- data/ext/libsass/src/error_handling.cpp +5 -5
- data/ext/libsass/src/error_handling.hpp +12 -12
- data/ext/libsass/src/eval.cpp +412 -401
- data/ext/libsass/src/eval.hpp +61 -62
- data/ext/libsass/src/expand.cpp +223 -204
- data/ext/libsass/src/expand.hpp +42 -42
- data/ext/libsass/src/extend.cpp +198 -201
- data/ext/libsass/src/extend.hpp +12 -14
- data/ext/libsass/src/file.hpp +4 -5
- data/ext/libsass/src/functions.cpp +413 -418
- data/ext/libsass/src/functions.hpp +7 -10
- data/ext/libsass/src/inspect.cpp +115 -109
- data/ext/libsass/src/inspect.hpp +69 -69
- data/ext/libsass/src/listize.cpp +31 -33
- data/ext/libsass/src/listize.hpp +8 -10
- data/ext/libsass/src/memory/SharedPtr.cpp +116 -0
- data/ext/libsass/src/memory/SharedPtr.hpp +202 -0
- data/ext/libsass/src/node.cpp +45 -43
- data/ext/libsass/src/node.hpp +15 -15
- data/ext/libsass/src/operation.hpp +136 -136
- data/ext/libsass/src/output.cpp +48 -49
- data/ext/libsass/src/output.hpp +14 -14
- data/ext/libsass/src/parser.cpp +530 -554
- data/ext/libsass/src/parser.hpp +91 -96
- data/ext/libsass/src/prelexer.cpp +13 -10
- data/ext/libsass/src/remove_placeholders.cpp +25 -21
- data/ext/libsass/src/remove_placeholders.hpp +7 -7
- data/ext/libsass/src/sass2scss.cpp +2 -1
- data/ext/libsass/src/sass_context.cpp +125 -107
- data/ext/libsass/src/sass_context.hpp +1 -1
- data/ext/libsass/src/sass_util.hpp +5 -5
- data/ext/libsass/src/sass_values.cpp +27 -27
- data/ext/libsass/src/source_map.cpp +2 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +57 -0
- data/ext/libsass/src/subset_map.hpp +8 -76
- data/ext/libsass/src/to_c.cpp +13 -13
- data/ext/libsass/src/to_c.hpp +14 -14
- data/ext/libsass/src/to_value.cpp +20 -20
- data/ext/libsass/src/to_value.hpp +20 -21
- data/ext/libsass/src/util.cpp +55 -88
- data/ext/libsass/src/util.hpp +9 -13
- data/ext/libsass/src/values.cpp +27 -26
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/test/test_subset_map.cpp +69 -69
- data/ext/libsass/win/libsass.targets +3 -2
- data/ext/libsass/win/libsass.vcxproj.filters +9 -6
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +0 -1
- data/test/native_test.rb +1 -1
- metadata +7 -5
- data/ext/libsass/src/ast_factory.hpp +0 -92
- data/ext/libsass/src/memory_manager.cpp +0 -77
- data/ext/libsass/src/memory_manager.hpp +0 -48
@@ -12,6 +12,7 @@
|
|
12
12
|
<ItemGroup Label="LibSass Headers">
|
13
13
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast.hpp" />
|
14
14
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast_def_macros.hpp" />
|
15
|
+
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\memory\SharedPtr.hpp" />
|
15
16
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast_factory.hpp" />
|
16
17
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast_fwd_decl.hpp" />
|
17
18
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\backtrace.hpp" />
|
@@ -38,7 +39,6 @@
|
|
38
39
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\lexer.hpp" />
|
39
40
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\listize.hpp" />
|
40
41
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\mapping.hpp" />
|
41
|
-
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\memory_manager.hpp" />
|
42
42
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\node.hpp" />
|
43
43
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\operation.hpp" />
|
44
44
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\output.hpp" />
|
@@ -68,6 +68,7 @@
|
|
68
68
|
</ItemGroup>
|
69
69
|
<ItemGroup Label="LibSass Sources">
|
70
70
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\ast.cpp" />
|
71
|
+
<ClCompile Include="$(LIBSASS_SRC_DIR)\memory\SharedPtr.cpp" />
|
71
72
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\base64vlq.cpp" />
|
72
73
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\bind.cpp" />
|
73
74
|
<ClCompile Condition="$(VisualStudioVersion) < 14.0" Include="$(LIBSASS_SRC_DIR)\c99func.c" />
|
@@ -89,7 +90,6 @@
|
|
89
90
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\json.cpp" />
|
90
91
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\lexer.cpp" />
|
91
92
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\listize.cpp" />
|
92
|
-
<ClCompile Include="$(LIBSASS_SRC_DIR)\memory_manager.cpp" />
|
93
93
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\node.cpp" />
|
94
94
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\output.cpp" />
|
95
95
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\parser.cpp" />
|
@@ -104,6 +104,7 @@
|
|
104
104
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\sass_values.cpp" />
|
105
105
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\sass2scss.cpp" />
|
106
106
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\source_map.cpp" />
|
107
|
+
<ClCompile Include="$(LIBSASS_SRC_DIR)\subset_map.cpp" />
|
107
108
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\to_c.cpp" />
|
108
109
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\to_value.cpp" />
|
109
110
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\units.cpp" />
|
@@ -48,6 +48,9 @@
|
|
48
48
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast.hpp">
|
49
49
|
<Filter>Headers</Filter>
|
50
50
|
</ClInclude>
|
51
|
+
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\memory\SharedPtr.hpp">
|
52
|
+
<Filter>Headers</Filter>
|
53
|
+
</ClInclude>
|
51
54
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\ast_def_macros.hpp">
|
52
55
|
<Filter>Headers</Filter>
|
53
56
|
</ClInclude>
|
@@ -126,9 +129,6 @@
|
|
126
129
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\mapping.hpp">
|
127
130
|
<Filter>Headers</Filter>
|
128
131
|
</ClInclude>
|
129
|
-
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\memory_manager.hpp">
|
130
|
-
<Filter>Headers</Filter>
|
131
|
-
</ClInclude>
|
132
132
|
<ClInclude Include="$(LIBSASS_HEADERS_DIR)\node.hpp">
|
133
133
|
<Filter>Headers</Filter>
|
134
134
|
</ClInclude>
|
@@ -215,6 +215,9 @@
|
|
215
215
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\ast.cpp">
|
216
216
|
<Filter>Sources</Filter>
|
217
217
|
</ClCompile>
|
218
|
+
<ClCompile Include="$(LIBSASS_SRC_DIR)\memory\SharedPtr.cpp">
|
219
|
+
<Filter>Sources</Filter>
|
220
|
+
</ClCompile>
|
218
221
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\base64vlq.cpp">
|
219
222
|
<Filter>Sources</Filter>
|
220
223
|
</ClCompile>
|
@@ -278,9 +281,6 @@
|
|
278
281
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\listize.cpp">
|
279
282
|
<Filter>Sources</Filter>
|
280
283
|
</ClCompile>
|
281
|
-
<ClCompile Include="$(LIBSASS_SRC_DIR)\memory_manager.cpp">
|
282
|
-
<Filter>Sources</Filter>
|
283
|
-
</ClCompile>
|
284
284
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\node.cpp">
|
285
285
|
<Filter>Sources</Filter>
|
286
286
|
</ClCompile>
|
@@ -323,6 +323,9 @@
|
|
323
323
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\source_map.cpp">
|
324
324
|
<Filter>Sources</Filter>
|
325
325
|
</ClCompile>
|
326
|
+
<ClCompile Include="$(LIBSASS_SRC_DIR)\subset_map.cpp">
|
327
|
+
<Filter>Sources</Filter>
|
328
|
+
</ClCompile>
|
326
329
|
<ClCompile Include="$(LIBSASS_SRC_DIR)\to_c.cpp">
|
327
330
|
<Filter>Sources</Filter>
|
328
331
|
</ClCompile>
|
data/lib/sassc/version.rb
CHANGED
data/sassc.gemspec
CHANGED
data/test/native_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sassc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Boland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- ext/libsass/docs/compatibility-plan.md
|
183
183
|
- ext/libsass/docs/contributing.md
|
184
184
|
- ext/libsass/docs/custom-functions-internal.md
|
185
|
+
- ext/libsass/docs/dev-ast-memory.md
|
185
186
|
- ext/libsass/docs/implementations.md
|
186
187
|
- ext/libsass/docs/plugins.md
|
187
188
|
- ext/libsass/docs/setup-environment.md
|
@@ -210,11 +211,11 @@ files:
|
|
210
211
|
- ext/libsass/script/spec
|
211
212
|
- ext/libsass/script/tap-driver
|
212
213
|
- ext/libsass/script/tap-runner
|
214
|
+
- ext/libsass/script/test-leaks.pl
|
213
215
|
- ext/libsass/src/GNUmakefile.am
|
214
216
|
- ext/libsass/src/ast.cpp
|
215
217
|
- ext/libsass/src/ast.hpp
|
216
218
|
- ext/libsass/src/ast_def_macros.hpp
|
217
|
-
- ext/libsass/src/ast_factory.hpp
|
218
219
|
- ext/libsass/src/ast_fwd_decl.hpp
|
219
220
|
- ext/libsass/src/b64/cencode.h
|
220
221
|
- ext/libsass/src/b64/encode.h
|
@@ -263,8 +264,8 @@ files:
|
|
263
264
|
- ext/libsass/src/listize.cpp
|
264
265
|
- ext/libsass/src/listize.hpp
|
265
266
|
- ext/libsass/src/mapping.hpp
|
266
|
-
- ext/libsass/src/
|
267
|
-
- ext/libsass/src/
|
267
|
+
- ext/libsass/src/memory/SharedPtr.cpp
|
268
|
+
- ext/libsass/src/memory/SharedPtr.hpp
|
268
269
|
- ext/libsass/src/node.cpp
|
269
270
|
- ext/libsass/src/node.hpp
|
270
271
|
- ext/libsass/src/operation.hpp
|
@@ -294,6 +295,7 @@ files:
|
|
294
295
|
- ext/libsass/src/sass_values.hpp
|
295
296
|
- ext/libsass/src/source_map.cpp
|
296
297
|
- ext/libsass/src/source_map.hpp
|
298
|
+
- ext/libsass/src/subset_map.cpp
|
297
299
|
- ext/libsass/src/subset_map.hpp
|
298
300
|
- ext/libsass/src/support/libsass.pc.in
|
299
301
|
- ext/libsass/src/to_c.cpp
|
@@ -1,92 +0,0 @@
|
|
1
|
-
#ifndef SASS_AST_FACTORY_H
|
2
|
-
#define SASS_AST_FACTORY_H
|
3
|
-
|
4
|
-
#include <vector>
|
5
|
-
|
6
|
-
#include "ast.hpp"
|
7
|
-
|
8
|
-
namespace Sass {
|
9
|
-
|
10
|
-
class AST_Factory {
|
11
|
-
std::vector<AST_Node*> nodes;
|
12
|
-
public:
|
13
|
-
// statements
|
14
|
-
Block* new_Block(std::string p, size_t l, size_t s = 0, bool r = false);
|
15
|
-
Ruleset* new_Ruleset(std::string p, size_t l, Selector* s, Block* b);
|
16
|
-
Supports_Query* new_Supports_Query(std::string p, size_t l, Supports_Query* f, Block* b);
|
17
|
-
Media_Query* new_Media_Query(std::string p, size_t l, List* q, Block* b);
|
18
|
-
At_Root_Block* new_At_Root_Block(std::string p, size_t l, Selector* sel, Block* b);
|
19
|
-
Directive* new_At_Rule(std::string p, size_t l, std::string kwd, Selector* sel, Block* b);
|
20
|
-
Keyframe_Rule* new_Keyframe_Rule(std::string p, size_t l, Block* b);
|
21
|
-
Declaration* new_Declaration(std::string p, size_t l, String* prop, List* vals, Block* b);
|
22
|
-
Assignment* new_Assignment(std::string p, size_t l, std::string var, Expression* val, bool guarded = false);
|
23
|
-
Import<Function_Call*>* new_CSS_Import(std::string p, size_t l, Function_Call* loc);
|
24
|
-
Import<String*>* new_SASS_Import(std::string p, size_t l, String* loc);
|
25
|
-
Custom_Warning* new_Custom_Warning(std::string msg, size_t l, std::string msg);
|
26
|
-
Custom_Error* new_Custom_Error(std::string p, size_t l, std::string msg);
|
27
|
-
Warning* new_Warning(std::string p, size_t l, Expression* msg);
|
28
|
-
Error* new_Error(std::string p, size_t l, Expression* msg);
|
29
|
-
Debug* new_Debug(std::string p, size_t l, Expression* val);
|
30
|
-
Comment* new_Comment(std::string p, size_t l, String* txt);
|
31
|
-
If* new_If(std::string p, size_t l, Expression* pred, Block* con, Block* alt = 0);
|
32
|
-
For* new_For(std::string p, size_t l, std::string var, Expression* lo, Expression* hi, Block* b, bool inc);
|
33
|
-
Each* new_Each(std::string p, size_t l, std::vector<std::string> vars, Expression* lst, Block* b);
|
34
|
-
While* new_While(std::string p, size_t l, Expression* pred, Block* b);
|
35
|
-
Extension* new_Extension(std::string p, size_t l, Selector* s);
|
36
|
-
Definition<MIXIN>* new_Mixin_Definition(std::string p, size_t l, std::string n, Parameters* params, Block* b);
|
37
|
-
Definition<FUNCTION>* new_Function_Definition(std::string p, size_t l, std::string n, Parameters* params, Block* b);
|
38
|
-
Mixin_Call* new_Mixin_Call(std::string p, size_t l, std::string n, Arguments* args, Block* b = 0);
|
39
|
-
// expressions
|
40
|
-
List* new_List(std::string p, size_t l, size_t size = 0, enum Sass_Separator sep = List::space, bool argl = false);
|
41
|
-
Map* new_Map(std::string p, size_t l, size_t size = 0);
|
42
|
-
Binary_Expression<AND>* new_And(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
43
|
-
Binary_Expression<OR>* new_Or(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
44
|
-
Binary_Expression<EQ>* new_Eq(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
45
|
-
Binary_Expression<NEQ>* new_Neq(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
46
|
-
Binary_Expression<GT>* new_Gt(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
47
|
-
Binary_Expression<GTE>* new_Gte(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
48
|
-
Binary_Expression<LT>* new_Lt(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
49
|
-
Binary_Expression<LTE>* new_Lte(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
50
|
-
Binary_Expression<ADD>* new_Add(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
51
|
-
Binary_Expression<SUB>* new_Sub(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
52
|
-
Binary_Expression<MUL>* new_Mul(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
53
|
-
Binary_Expression<DIV>* new_Div(std::string p, size_t l, Expression* lhs, Expression* rhs);
|
54
|
-
Negation* new_Negation(std::string p, size_t l, Expression* o);
|
55
|
-
Function_Call* new_Function_Call(std::string p, size_t l, String* n, Arguments* args);
|
56
|
-
Variable* new_Variable(std::string p, size_t l, std::string n);
|
57
|
-
Textual<NUMBER>* new_Textual_Number(std::string p, size_t l, std::string val);
|
58
|
-
Textual<PERCENTAGE>* new_Textual_Percentage(std::string p, size_t l, std::string val);
|
59
|
-
Textual<DIMENSION>* new_Textual_Dimension(std::string p, size_t l, std::string val);
|
60
|
-
Textual<HEX>* new_Textual_Hex(std::string p, size_t l, std::string val);
|
61
|
-
Number* new_Number(std::string p, size_t l, double val);
|
62
|
-
Percentage* new_Percentage(std::string p, size_t l, double val);
|
63
|
-
Dimension* new_Dimension(std::string p, size_t l, double val, std::string unit);
|
64
|
-
Color* new_Color(std::string p, size_t l, double r, double g, double b, double a = 1, std::string disp = "");
|
65
|
-
Boolean* new_Boolean(std::string p, size_t l, bool val);
|
66
|
-
String_Schema* new_String_Schema(std::string p, size_t l, size_t size = 0);
|
67
|
-
String_Constant* new_String_Constant(std::string p, size_t l, std::string val);
|
68
|
-
String_Constant* new_String_Constant(std::string p, size_t l, const char* beg);
|
69
|
-
String_Constant* new_String_Constant(std::string p, size_t l, const char* beg, const char* end);
|
70
|
-
Supports_Condition* new_Supports_Condition(std::string p, size_t l, String* f, Expression* v);
|
71
|
-
Media_Expression* new_Media_Expression(std::string p, size_t l, String* f, Expression* v);
|
72
|
-
Parent_Selector* new_Parent_Selector(std::string p, size_t l, Selector* s);
|
73
|
-
// parameters and arguments
|
74
|
-
Parameter* new_Parameter(std::string p, size_t l, std::string n, Expression* def = 0, bool rest = false);
|
75
|
-
Parameters* new_Parameters(std::string p, size_t l);
|
76
|
-
Argument* new_Argument(std::string p, size_t l, Expression* val, std::string n = "", bool rest = false);
|
77
|
-
Arguments* new_Arguments(std::string p, size_t l);
|
78
|
-
// selectors
|
79
|
-
Selector_Schema* new_Selector_Schema(std::string p, size_t l, String* c);
|
80
|
-
Attribute_Selector* new_Attribute_Selector(std::string p, size_t l, std::string n, std::string m, String* v);
|
81
|
-
Simple_Selector* new_Simple_Selector(std::string p, size_t l, std::string c);
|
82
|
-
Reference_Selector* new_Reference_Selector(std::string p, size_t l);
|
83
|
-
Placeholder_Selector* new_Placeholder_Selector(std::string p, size_t l, std::string n);
|
84
|
-
Pseudo_Selector* new_Pseudo_Selector(std::string p, size_t l, std::string n, Expression* expr = 0);
|
85
|
-
Wrapped_Selector* new_Wrapped_Selector(std::string p, size_t l, std::string n, Simple_Base* sel);
|
86
|
-
SimpleSequence_Selector* new_SimpleSequence_Selector(std::string p, size_t l, size_t s = 0);
|
87
|
-
Sequence_Selector* new_Sequence_Selector(std::string p, size_t l, Sequence_Selector::Combinator c, Sequence_Selector* ctx, SimpleSequence_Selector* sel);
|
88
|
-
CommaSequence_Selector* new_CommaSequence_Selector(std::string p, size_t l, size_t s = 0);
|
89
|
-
};
|
90
|
-
}
|
91
|
-
|
92
|
-
#endif
|
@@ -1,77 +0,0 @@
|
|
1
|
-
#include "sass.hpp"
|
2
|
-
#include "ast.hpp"
|
3
|
-
#include "memory_manager.hpp"
|
4
|
-
|
5
|
-
namespace Sass {
|
6
|
-
|
7
|
-
Memory_Manager::Memory_Manager(size_t size)
|
8
|
-
: nodes(std::vector<Memory_Object*>())
|
9
|
-
{
|
10
|
-
size_t init = size;
|
11
|
-
if (init < 8) init = 8;
|
12
|
-
// reserve some space
|
13
|
-
nodes.reserve(init);
|
14
|
-
}
|
15
|
-
|
16
|
-
Memory_Manager::~Memory_Manager()
|
17
|
-
{
|
18
|
-
// release memory for all controlled nodes
|
19
|
-
// avoid calling erase for every single node
|
20
|
-
for (size_t i = 0, S = nodes.size(); i < S; ++i) {
|
21
|
-
deallocate(nodes[i]);
|
22
|
-
}
|
23
|
-
// just in case
|
24
|
-
nodes.clear();
|
25
|
-
}
|
26
|
-
|
27
|
-
Memory_Object* Memory_Manager::add(Memory_Object* np)
|
28
|
-
{
|
29
|
-
// object has been initialized
|
30
|
-
// it can be "deleted" from now on
|
31
|
-
np->refcount = 1;
|
32
|
-
return np;
|
33
|
-
}
|
34
|
-
|
35
|
-
bool Memory_Manager::has(Memory_Object* np)
|
36
|
-
{
|
37
|
-
// check if the pointer is controlled under our pool
|
38
|
-
return find(nodes.begin(), nodes.end(), np) != nodes.end();
|
39
|
-
}
|
40
|
-
|
41
|
-
Memory_Object* Memory_Manager::allocate(size_t size)
|
42
|
-
{
|
43
|
-
// allocate requested memory
|
44
|
-
void* heap = malloc(size);
|
45
|
-
// init internal refcount status to zero
|
46
|
-
(static_cast<Memory_Object*>(heap))->refcount = 0;
|
47
|
-
// add the memory under our management
|
48
|
-
nodes.push_back(static_cast<Memory_Object*>(heap));
|
49
|
-
// cast object to its initial type
|
50
|
-
return static_cast<Memory_Object*>(heap);
|
51
|
-
}
|
52
|
-
|
53
|
-
void Memory_Manager::deallocate(Memory_Object* np)
|
54
|
-
{
|
55
|
-
// only call destructor if initialized
|
56
|
-
if (np->refcount) np->~Memory_Object();
|
57
|
-
// always free the memory
|
58
|
-
free(np);
|
59
|
-
}
|
60
|
-
|
61
|
-
void Memory_Manager::remove(Memory_Object* np)
|
62
|
-
{
|
63
|
-
// remove node from pool (no longer active)
|
64
|
-
nodes.erase(find(nodes.begin(), nodes.end(), np));
|
65
|
-
// you are now in control of the memory
|
66
|
-
}
|
67
|
-
|
68
|
-
void Memory_Manager::destroy(Memory_Object* np)
|
69
|
-
{
|
70
|
-
// remove from pool
|
71
|
-
remove(np);
|
72
|
-
// release memory
|
73
|
-
deallocate(np);
|
74
|
-
}
|
75
|
-
|
76
|
-
}
|
77
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#ifndef SASS_MEMORY_MANAGER_H
|
2
|
-
#define SASS_MEMORY_MANAGER_H
|
3
|
-
|
4
|
-
#include <vector>
|
5
|
-
|
6
|
-
namespace Sass {
|
7
|
-
|
8
|
-
class Memory_Object {
|
9
|
-
friend class Memory_Manager;
|
10
|
-
long refcount;
|
11
|
-
public:
|
12
|
-
Memory_Object() { refcount = 0; };
|
13
|
-
virtual ~Memory_Object() {};
|
14
|
-
};
|
15
|
-
|
16
|
-
/////////////////////////////////////////////////////////////////////////////
|
17
|
-
// A class for tracking allocations of AST_Node objects. The intended usage
|
18
|
-
// is something like: Some_Node* n = new (mem_mgr) Some_Node(...);
|
19
|
-
// Then, at the end of the program, the memory manager will delete all of the
|
20
|
-
// allocated nodes that have been passed to it.
|
21
|
-
// In the future, this class may implement a custom allocator.
|
22
|
-
/////////////////////////////////////////////////////////////////////////////
|
23
|
-
class Memory_Manager {
|
24
|
-
std::vector<Memory_Object*> nodes;
|
25
|
-
|
26
|
-
public:
|
27
|
-
Memory_Manager(size_t size = 0);
|
28
|
-
~Memory_Manager();
|
29
|
-
|
30
|
-
bool has(Memory_Object* np);
|
31
|
-
Memory_Object* allocate(size_t size);
|
32
|
-
void deallocate(Memory_Object* np);
|
33
|
-
void remove(Memory_Object* np);
|
34
|
-
void destroy(Memory_Object* np);
|
35
|
-
Memory_Object* add(Memory_Object* np);
|
36
|
-
|
37
|
-
};
|
38
|
-
}
|
39
|
-
|
40
|
-
///////////////////////////////////////////////////////////////////////////////
|
41
|
-
// Use macros for the allocation task, since overloading operator `new`
|
42
|
-
// has been proven to be flaky under certain compilers (see comment below).
|
43
|
-
///////////////////////////////////////////////////////////////////////////////
|
44
|
-
|
45
|
-
#define SASS_MEMORY_NEW(mgr, Class, ...) \
|
46
|
-
(static_cast<Class*>(mgr.add(new (mgr.allocate(sizeof(Class))) Class(__VA_ARGS__)))) \
|
47
|
-
|
48
|
-
#endif
|