1 | #ifndef SASS_SOURCE_MAP_H |
---|---|
2 | #define SASS_SOURCE_MAP_H |
3 | |
4 | #include <string> |
5 | #include <vector> |
6 | |
7 | #include "ast_fwd_decl.hpp" |
8 | #include "base64vlq.hpp" |
9 | #include "position.hpp" |
10 | #include "mapping.hpp" |
11 | |
12 | #include "backtrace.hpp" |
13 | #include "memory.hpp" |
14 | |
15 | #define VECTOR_PUSH(vec, ins) vec.insert(vec.end(), ins.begin(), ins.end()) |
16 | #define VECTOR_UNSHIFT(vec, ins) vec.insert(vec.begin(), ins.begin(), ins.end()) |
17 | |
18 | namespace Sass { |
19 | |
20 | class Context; |
21 | class OutputBuffer; |
22 | |
23 | class SourceMap { |
24 | |
25 | public: |
26 | sass::vector<size_t> source_index; |
27 | SourceMap(); |
28 | SourceMap(const sass::string& file); |
29 | |
30 | void append(const Offset& offset); |
31 | void prepend(const Offset& offset); |
32 | void append(const OutputBuffer& out); |
33 | void prepend(const OutputBuffer& out); |
34 | void add_open_mapping(const AST_Node* node); |
35 | void add_close_mapping(const AST_Node* node); |
36 | |
37 | sass::string render_srcmap(Context &ctx); |
38 | SourceSpan remap(const SourceSpan& pstate); |
39 | |
40 | private: |
41 | |
42 | sass::string serialize_mappings(); |
43 | |
44 | sass::vector<Mapping> mappings; |
45 | Position current_position; |
46 | public: |
47 | sass::string file; |
48 | private: |
49 | Base64VLQ base64vlq; |
50 | }; |
51 | |
52 | class OutputBuffer { |
53 | public: |
54 | OutputBuffer(void) |
55 | : buffer(), |
56 | smap() |
57 | { } |
58 | public: |
59 | sass::string buffer; |
60 | SourceMap smap; |
61 | }; |
62 | |
63 | } |
64 | |
65 | #endif |
66 |