2019-10-31 18:42:30 +00:00
|
|
|
/*
|
|
|
|
4coder_code_index.h - Generic code indexing system for layout, definition jumps, etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FCODER_CODE_INDEX_H)
|
|
|
|
#define FCODER_CODE_INDEX_H
|
|
|
|
|
|
|
|
struct Code_Index_Nest_List{
|
|
|
|
struct Code_Index_Nest *first;
|
|
|
|
struct Code_Index_Nest *last;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_Nest_Ptr_Array{
|
|
|
|
struct Code_Index_Nest **ptrs;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef i32 Code_Index_Nest_Kind;
|
|
|
|
enum{
|
|
|
|
CodeIndexNest_Scope,
|
|
|
|
CodeIndexNest_Paren,
|
2019-11-02 19:12:36 +00:00
|
|
|
CodeIndexNest_Preprocessor,
|
2019-11-03 21:22:10 +00:00
|
|
|
CodeIndexNest_Statement,
|
2019-10-31 18:42:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_Nest{
|
|
|
|
Code_Index_Nest *next;
|
|
|
|
|
|
|
|
Code_Index_Nest_Kind kind;
|
|
|
|
b32 is_closed;
|
|
|
|
Range_i64 open;
|
|
|
|
Range_i64 close;
|
|
|
|
|
2019-10-31 21:42:11 +00:00
|
|
|
struct Code_Index_File *file;
|
|
|
|
Code_Index_Nest *parent;
|
|
|
|
|
2019-10-31 18:42:30 +00:00
|
|
|
Code_Index_Nest_List nest_list;
|
|
|
|
Code_Index_Nest_Ptr_Array nest_array;
|
|
|
|
};
|
|
|
|
|
2019-12-13 23:36:28 +00:00
|
|
|
typedef i64 Code_Index_Note_Kind;
|
|
|
|
enum{
|
|
|
|
CodeIndexNote_Type,
|
|
|
|
CodeIndexNote_Function,
|
|
|
|
CodeIndexNote_Macro,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_Note{
|
|
|
|
Code_Index_Note *next;
|
|
|
|
Code_Index_Note_Kind note_kind;
|
|
|
|
Range_i64 pos;
|
|
|
|
String_Const_u8 text;
|
|
|
|
struct Code_Index_File *file;
|
|
|
|
Code_Index_Nest *parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_Note_List{
|
|
|
|
Code_Index_Note *first;
|
|
|
|
Code_Index_Note *last;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_Note_Ptr_Array{
|
|
|
|
Code_Index_Note **ptrs;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
2019-10-31 18:42:30 +00:00
|
|
|
struct Code_Index_File{
|
|
|
|
Code_Index_Nest_List nest_list;
|
|
|
|
Code_Index_Nest_Ptr_Array nest_array;
|
2019-12-13 23:36:28 +00:00
|
|
|
Code_Index_Note_List note_list;
|
|
|
|
Code_Index_Note_Ptr_Array note_array;
|
2019-10-31 21:42:11 +00:00
|
|
|
Buffer_ID buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index_File_Storage{
|
|
|
|
Code_Index_File_Storage *next;
|
|
|
|
Code_Index_File_Storage *prev;
|
|
|
|
Arena arena;
|
|
|
|
Code_Index_File *file;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_Index{
|
|
|
|
System_Mutex mutex;
|
|
|
|
Arena node_arena;
|
|
|
|
Table_u64_u64 buffer_to_index_file;
|
|
|
|
Code_Index_File_Storage *free_storage;
|
|
|
|
Code_Index_File_Storage *storage_first;
|
|
|
|
Code_Index_File_Storage *storage_last;
|
|
|
|
i32 storage_count;
|
2019-10-31 18:42:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
typedef void Generic_Parse_Comment_Function(Application_Links *app, Arena *arena, Code_Index_File *index,
|
|
|
|
Token *token, String_Const_u8 contents);
|
|
|
|
|
|
|
|
struct Generic_Parse_State{
|
|
|
|
Application_Links *app;
|
|
|
|
Arena *arena;
|
|
|
|
String_Const_u8 contents;
|
|
|
|
Token_Iterator_Array it;
|
|
|
|
Generic_Parse_Comment_Function *handle_comment;
|
2019-10-31 21:42:11 +00:00
|
|
|
u8 *prev_line_start;
|
|
|
|
b32 finished;
|
2019-11-02 19:12:36 +00:00
|
|
|
|
2019-11-03 21:22:10 +00:00
|
|
|
i32 scope_counter;
|
|
|
|
i32 paren_counter;
|
2019-11-02 19:12:36 +00:00
|
|
|
b32 in_preprocessor;
|
2019-11-03 21:22:10 +00:00
|
|
|
b32 in_statement;
|
2019-10-31 18:42:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|