Cthulhu  0.2.10
Cthulhu compiler collection
common_extra.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #pragma once
4 
5 #include "common.h"
6 
7 #include "core/text.h"
8 #include "format/notify.h"
9 #include "notify/notify.h"
10 
11 #include <stddef.h>
12 
14 
15 typedef struct map_t map_t;
16 typedef struct scan_t scan_t;
17 
18 severity_t get_severity(const diagnostic_t *diag, bool override_fatal);
19 
20 const char *get_severity_name(severity_t severity);
22 
23 typevec_t *all_segments_in_scan(const typevec_t *segments, const node_t *node, arena_t *arena);
24 void segments_sort(typevec_t *segments);
25 
26 size_t get_line_number(file_config_t config, const node_t *node);
27 
28 bool node_has_line(const node_t *node);
29 
31 void cache_map_delete(cache_map_t *map);
32 
35 
36 text_view_t cache_get_line(text_cache_t *cache, size_t line);
37 size_t cache_count_lines(text_cache_t *cache);
38 
39 // extract a line of text, converting non-printable characters to their escape codes
40 // and highlighting the escaped characters
41 text_t cache_escape_line(text_cache_t *cache, size_t line, const colour_pallete_t *colours, size_t column_limit);
42 
46 
47 char *fmt_node_location(source_config_t config, const node_t *node);
CT_NODISCARD size_t size
Definition: scan.h:128
colour_t get_severity_colour(severity_t severity)
Definition: common_extra.c:52
text_cache_t * cache_emplace_file(cache_map_t *map, const char *path)
Definition: common_extra.c:275
bool node_has_line(const node_t *node)
Definition: common_extra.c:129
void cache_map_delete(cache_map_t *map)
Definition: common_extra.c:262
const char * get_severity_name(severity_t severity)
Definition: common_extra.c:38
void segments_sort(typevec_t *segments)
Definition: common_extra.c:90
typevec_t * all_segments_in_scan(const typevec_t *segments, const node_t *node, arena_t *arena)
Definition: common_extra.c:95
text_cache_t * cache_emplace_scan(cache_map_t *map, const scan_t *scan)
Definition: common_extra.c:295
size_t get_line_number(file_config_t config, const node_t *node)
Definition: common_extra.c:121
size_t cache_count_lines(text_cache_t *cache)
Definition: common_extra.c:327
severity_t get_severity(const diagnostic_t *diag, bool override_fatal)
Definition: common_extra.c:30
char * fmt_node_location(source_config_t config, const node_t *node)
Definition: common_extra.c:530
text_t cache_escape_line(text_cache_t *cache, size_t line, const colour_pallete_t *colours, size_t column_limit)
Definition: common_extra.c:355
text_view_t cache_get_line(text_cache_t *cache, size_t line)
Definition: common_extra.c:310
cache_map_t * cache_map_new(size_t size, arena_t *arena)
Definition: common_extra.c:251
colour_t
a colour code
Definition: colour.h:23
severity_t
the default severity of a diagnostic
Definition: diagnostic.h:18
an allocator object
Definition: arena.h:86
a colour pallete
Definition: colour.h:39
a diagnostic
Definition: diagnostic.h:27
the configuration for a file
Definition: notify.h:49
an unordered hash map
Definition: map.h:38
a position in a source file
Definition: node.h:23
a source file scanner
Definition: scan.h:24
STA_FIELD_STRING const char * path
the path to this file
Definition: scan.h:39
arena_t * arena
the allocator to use
Definition: scan.h:30
a range of text
Definition: text.h:14
a non-owning view of text
Definition: text.h:24
A vector with a fixed type size.
Definition: vector.h:24