| 1 | module sourcemap |
| 2 | |
| 3 | struct V3 { |
| 4 | SourceMap |
| 5 | pub: |
| 6 | sections []Section @[json: sections] |
| 7 | } |
| 8 | |
| 9 | struct Offset { |
| 10 | pub mut: |
| 11 | line int @[json: line] |
| 12 | column int @[json: column] |
| 13 | } |
| 14 | |
| 15 | struct Section { |
| 16 | pub mut: |
| 17 | offset Offset @[json: offset] |
| 18 | source_map SourceMap @[json: map] |
| 19 | } |
| 20 | |
| 21 | struct Generator { |
| 22 | mut: |
| 23 | file string |
| 24 | // source_root string |
| 25 | sections []Section |
| 26 | } |
| 27 | |
| 28 | pub fn generate_empty_map() &Generator { |
| 29 | return &Generator{} |
| 30 | } |
| 31 | |
| 32 | pub fn (mut g Generator) add_map(file string, source_root string, sources_content_inline bool, line_offset int, |
| 33 | column_offset int) &SourceMap { |
| 34 | source_map := new_sourcemap(file, source_root, sources_content_inline) |
| 35 | |
| 36 | offset := Offset{ |
| 37 | line: line_offset |
| 38 | column: column_offset |
| 39 | } |
| 40 | |
| 41 | g.sections << Section{ |
| 42 | offset: offset |
| 43 | source_map: source_map |
| 44 | } |
| 45 | |
| 46 | return &source_map |
| 47 | } |
| 48 | |