diff --git a/src/dbg_info/dbg_info.c b/src/dbg_info/dbg_info.c index 6a17d6f2..8e90de47 100644 --- a/src/dbg_info/dbg_info.c +++ b/src/dbg_info/dbg_info.c @@ -1519,12 +1519,12 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g Temp scratch = scratch_begin(0, 0); //- rjf: unpack key - U64 index = 0; + U64 index = 0; String8 name = {0}; DI_Key preferred_key = {0}; { U64 key_read_off = 0; - key_read_off += str8_deserial_read_struct(key, key_read_off, &index); + key_read_off += str8_deserial_read_struct(key, key_read_off, &index); key_read_off += str8_deserial_read_struct(key, key_read_off, &preferred_key); key_read_off += str8_deserial_read_struct(key, key_read_off, &name.size); name.str = push_array_no_zero(scratch.arena, U8, name.size); @@ -1657,12 +1657,14 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g RDI_NameMapNode *map_node = rdi_name_map_lookup(rdi, &parsed_name_map, leaf_part_of_name.str, leaf_part_of_name.size); U32 matches_count = 0; U32 *matches = rdi_matches_from_map_node(rdi, map_node, &matches_count); - - // rjf: do we have a container? -> filter matches according to container string also + + // rjf: do we have a container? -> filter matches according to container string also + U32 *filtered_matches = matches; + U32 filtered_matches_count = matches_count; if(container_part_of_name.size != 0) - { - U32 *filtered_matches = push_array(scratch.arena, U32, matches_count); - U32 filtered_matches_count = 0; + { + filtered_matches = push_array(scratch.arena, U32, matches_count); + filtered_matches_count = 0; for EachIndex(match_idx, matches_count) { Temp scratch = scratch_begin(0, 0); @@ -1699,17 +1701,23 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g } scratch_end(scratch); } - matches = filtered_matches; - matches_count = filtered_matches_count; - } - + } + + // rjf: do we have a specific unit queried? -> filter matches according to containing unit +#if 0 + if(target_unit_index != 0) + { + + } +#endif + // rjf: given matches, pick selected & return as result - if(matches_count != 0) + if(filtered_matches_count != 0) { - U64 selected_match_idx = (matches_count-1) - Min(index, matches_count-1); + U64 selected_match_idx = (filtered_matches_count-1) - Min(index, filtered_matches_count-1); lane_matches[lane_idx()].key = dbgi_key; lane_matches[lane_idx()].section_kind = name_map_section_kinds[name_map_kind_idx]; - lane_matches[lane_idx()].idx = matches[selected_match_idx]; + lane_matches[lane_idx()].idx = filtered_matches[selected_match_idx]; } } } @@ -1753,14 +1761,14 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g } internal DI_Match -di_match_from_string(String8 string, U64 index, DI_Key preferred_dbgi_key, U64 endt_us) +di_match_from_string(String8 string, U64 match_index, DI_Key preferred_dbgi_key, U64 endt_us) { DI_Match result = {0}; Access *access = access_open(); Temp scratch = scratch_begin(0, 0); { String8List key_parts = {0}; - str8_list_push(scratch.arena, &key_parts, str8_struct(&index)); + str8_list_push(scratch.arena, &key_parts, str8_struct(&match_index)); str8_list_push(scratch.arena, &key_parts, str8_struct(&preferred_dbgi_key)); str8_list_push(scratch.arena, &key_parts, str8_struct(&string.size)); str8_list_push(scratch.arena, &key_parts, string); diff --git a/src/dbg_info/dbg_info.h b/src/dbg_info/dbg_info.h index f2ff52f5..5355e6c0 100644 --- a/src/dbg_info/dbg_info.h +++ b/src/dbg_info/dbg_info.h @@ -360,6 +360,6 @@ internal DI_SearchItemArray di_search_item_array_from_target_query(Access *acces //~ rjf: Match Artifact Cache Hooks / Lookups internal AC_Artifact di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out); -internal DI_Match di_match_from_string(String8 string, U64 index, DI_Key preferred_dbgi_key, U64 endt_us); +internal DI_Match di_match_from_string(String8 string, U64 match_index, DI_Key preferred_dbgi_key, U64 endt_us); #endif // DBG_INFO_H diff --git a/src/eval/eval.mdesk b/src/eval/eval.mdesk index ae0e0459..3bf48031 100644 --- a/src/eval/eval.mdesk +++ b/src/eval/eval.mdesk @@ -10,6 +10,7 @@ E_TokenKindTable: {StringLiteral} {CharLiteral} {Symbol} + {Comment} } @table(name basic_string basic_byte_size) diff --git a/src/eval/eval_parse.c b/src/eval/eval_parse.c index 00374472..bb44589f 100644 --- a/src/eval/eval_parse.c +++ b/src/eval/eval_parse.c @@ -74,6 +74,7 @@ e_token_array_from_text(Arena *arena, String8 text) B32 active_token_kind_started_with_tick = 0; B32 escaped = 0; B32 exp = 0; + B32 comment_is_explicit_ender = 0; for(U64 idx = 0, advance = 0; idx <= text.size; idx += advance) { U8 byte = (idx+0 < text.size) ? text.str[idx+0] : 0; @@ -114,11 +115,23 @@ e_token_array_from_text(Arena *arena, String8 text) byte == ']' || byte == '{' || byte == '}' || byte == ':' || byte == ';' || byte == ',' || byte == '.' || byte == '<' || byte == '>' || byte == '/' || byte == '?' || byte == '|' || - byte == '#') + byte == '#' || byte == '@') { active_token_kind = E_TokenKind_Symbol; active_token_start_idx = idx; } + else if(byte == '/' && byte_next == '/') + { + active_token_kind = E_TokenKind_Comment; + active_token_start_idx = idx; + comment_is_explicit_ender = 0; + } + else if(byte == '/' && byte_next == '*') + { + active_token_kind = E_TokenKind_Comment; + active_token_start_idx = idx; + comment_is_explicit_ender = 1; + } }break; //- rjf: active tokens -> seek enders @@ -226,12 +239,24 @@ e_token_array_from_text(Arena *arena, String8 text) byte != ']' && byte != '{' && byte != '}' && byte != ':' && byte != ';' && byte != ',' && byte != '.' && byte != '<' && byte != '>' && byte != '/' && byte != '?' && byte != '|' && - byte != '#') + byte != '#' && byte != '@') { advance = 0; token_formed = 1; } }break; + case E_TokenKind_Comment: + { + if(byte == 0) + { + token_formed = 1; + } + else if(comment_is_explicit_ender && byte == '*' && byte_next == '/') + { + token_formed = 1; + advance = 2; + } + }break; } //- rjf: token formed -> push new formed token(s) @@ -650,97 +675,6 @@ e_type_key_from_expr(E_Expr *expr) return result; } -internal E_Parse -e_push_type_parse_from_text_tokens(Arena *arena, String8 text, E_TokenArray tokens) -{ - E_Parse parse = {tokens, 0, &e_expr_nil, &e_expr_nil}; - E_Token *token_it = tokens.v; - - //- rjf: parse unsigned marker - B32 unsigned_marker = 0; - { - E_Token token = e_token_at_it(token_it, &tokens); - if(token.kind == E_TokenKind_Identifier) - { - String8 token_string = str8_substr(text, token.range); - if(str8_match(token_string, str8_lit("unsigned"), 0)) - { - token_it += 1; - unsigned_marker = 1; - } - } - } - - //- rjf: parse base type - { - E_Token token = e_token_at_it(token_it, &tokens); - if(token.kind == E_TokenKind_Identifier) - { - String8 token_string = str8_substr(text, token.range); - if(token_string.size >= 2 && - token_string.str[0] == '`' && - token_string.str[token_string.size-1] == '`') - { - token_string = str8_substr(token_string, r1u64(1, token_string.size-1)); - } - E_TypeKey type_key = e_leaf_type_key_from_name(token_string); - if(!e_type_key_match(e_type_key_zero(), type_key)) - { - token_it += 1; - - // rjf: apply unsigned marker to base type - if(unsigned_marker) switch(e_type_kind_from_key(type_key)) - { - default:{}break; - case E_TypeKind_Char8: {type_key = e_type_key_basic(E_TypeKind_UChar8);}break; - case E_TypeKind_Char16:{type_key = e_type_key_basic(E_TypeKind_UChar16);}break; - case E_TypeKind_Char32:{type_key = e_type_key_basic(E_TypeKind_UChar32);}break; - case E_TypeKind_S8: {type_key = e_type_key_basic(E_TypeKind_U8);}break; - case E_TypeKind_S16: {type_key = e_type_key_basic(E_TypeKind_U16);}break; - case E_TypeKind_S32: {type_key = e_type_key_basic(E_TypeKind_U32);}break; - case E_TypeKind_S64: {type_key = e_type_key_basic(E_TypeKind_U64);}break; - case E_TypeKind_S128:{type_key = e_type_key_basic(E_TypeKind_U128);}break; - case E_TypeKind_S256:{type_key = e_type_key_basic(E_TypeKind_U256);}break; - case E_TypeKind_S512:{type_key = e_type_key_basic(E_TypeKind_U512);}break; - } - - // rjf: construct leaf type - parse.expr = e_push_expr(arena, E_ExprKind_TypeIdent, token.range); - parse.expr->type_key = type_key; - } - } - } - - //- rjf: parse extensions - if(parse.expr != &e_expr_nil) - { - for(;;) - { - E_Token token = e_token_at_it(token_it, &tokens); - if(token.kind != E_TokenKind_Symbol) - { - break; - } - String8 token_string = str8_substr(text, token.range); - if(str8_match(token_string, str8_lit("*"), 0)) - { - token_it += 1; - E_Expr *ptee = parse.expr; - parse.expr = e_push_expr(arena, E_ExprKind_Ptr, token.range); - e_expr_push_child(parse.expr, ptee); - } - else - { - break; - } - } - } - - //- rjf: fill parse & end - parse.last_token = token_it; - return parse; -} - internal E_Parse e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray tokens, S64 max_precedence, U64 max_chain_count) { @@ -847,14 +781,14 @@ e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray t } // rjf: try 'unsigned' marker - if(str8_match(token_string, str8_lit("unsigned"), 0)) + if(token.kind == E_TokenKind_Identifier && str8_match(token_string, str8_lit("unsigned"), 0)) { prefix_unary_kind = E_ExprKind_Unsigned; prefix_unary_precedence = 2; } // rjf: try explicit cast - if(str8_match(token_string, str8_lit("cast"), 0)) + if(token.kind == E_TokenKind_Identifier && str8_match(token_string, str8_lit("cast"), 0)) { // rjf: consume cast & open paren E_Token open_paren_maybe = e_token_at_it(it+1, &tokens); @@ -923,14 +857,28 @@ e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray t { E_Token token = e_token_at_it(it, &tokens); String8 token_string = str8_substr(text, token.range); - if(token.kind == E_TokenKind_Identifier) + if(token.kind == E_TokenKind_Identifier || token.kind == E_TokenKind_StringLiteral) { - E_Token next_token = e_token_at_it(it+1, &tokens); - String8 next_token_string = str8_substr(text, next_token.range); - if(next_token.range.min == token.range.max && next_token.kind == E_TokenKind_Symbol && str8_match(next_token_string, str8_lit(":"), 0)) + // rjf: look for extensions - for qualifiers of the form `foo.dll!bar` + U64 token_ext_count = 0; + E_Token dot_maybe_token = e_token_at_it(it+1, &tokens); + String8 dot_maybe_token_string = str8_substr(text, dot_maybe_token.range); + E_Token ext_maybe_token = e_token_at_it(it+2, &tokens); + String8 ext_maybe_token_string = str8_substr(text, ext_maybe_token.range); + if(dot_maybe_token.kind == E_TokenKind_Symbol && + ext_maybe_token.kind == E_TokenKind_Identifier && + str8_match(dot_maybe_token_string, str8_lit("."), 0)) { - it += 2; - resolution_qualifier = token_string; + token_ext_count = 2; + } + + // rjf: look for : or ! + E_Token next_token = e_token_at_it(it+1+token_ext_count, &tokens); + String8 next_token_string = str8_substr(text, next_token.range); + if(next_token.kind == E_TokenKind_Symbol && (str8_match(next_token_string, str8_lit(":"), 0) || str8_match(next_token_string, str8_lit("!"), 0))) + { + it += 2 + token_ext_count; + resolution_qualifier = str8_substr(text, union_1u64(token.range, r1u64(token.range.min, next_token.range.min))); } } } diff --git a/src/eval/eval_parse.h b/src/eval/eval_parse.h index 1f14b160..f9f8f22f 100644 --- a/src/eval/eval_parse.h +++ b/src/eval/eval_parse.h @@ -37,7 +37,6 @@ internal String8 e_string_from_expr(Arena *arena, E_Expr *expr, String8 parent_e internal E_TypeKey e_leaf_builtin_type_key_from_name(String8 name); internal E_TypeKey e_leaf_type_key_from_name(String8 name); internal E_TypeKey e_type_key_from_expr(E_Expr *expr); -internal E_Parse e_push_type_parse_from_text_tokens(Arena *arena, String8 text, E_TokenArray tokens); internal E_Parse e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray tokens, S64 max_precedence, U64 max_chain_count); internal E_Parse e_push_parse_from_string(Arena *arena, String8 text); diff --git a/src/eval/generated/eval.meta.c b/src/eval/generated/eval.meta.c index 5459b3a4..caab4db9 100644 --- a/src/eval/generated/eval.meta.c +++ b/src/eval/generated/eval.meta.c @@ -4,7 +4,7 @@ //- GENERATED CODE C_LINKAGE_BEGIN -String8 e_token_kind_strings[6] = +String8 e_token_kind_strings[7] = { str8_lit_comp("Null"), str8_lit_comp("Identifier"), @@ -12,6 +12,7 @@ str8_lit_comp("Numeric"), str8_lit_comp("StringLiteral"), str8_lit_comp("CharLiteral"), str8_lit_comp("Symbol"), +str8_lit_comp("Comment"), }; String8 e_type_kind_basic_string_table[61] = diff --git a/src/eval/generated/eval.meta.h b/src/eval/generated/eval.meta.h index 26785c11..65847eb1 100644 --- a/src/eval/generated/eval.meta.h +++ b/src/eval/generated/eval.meta.h @@ -14,6 +14,7 @@ E_TokenKind_Numeric, E_TokenKind_StringLiteral, E_TokenKind_CharLiteral, E_TokenKind_Symbol, +E_TokenKind_Comment, E_TokenKind_COUNT, } E_TokenKind; @@ -168,7 +169,7 @@ E_InterpretationCode_COUNT, } E_InterpretationCode; C_LINKAGE_BEGIN -extern String8 e_token_kind_strings[6]; +extern String8 e_token_kind_strings[7]; extern String8 e_type_kind_basic_string_table[61]; extern U8 e_type_kind_basic_byte_size_table[61]; extern String8 e_expr_kind_strings[50]; diff --git a/src/mule/mule_c.c b/src/mule/mule_c.c index e67e42fd..50a0f206 100644 --- a/src/mule/mule_c.c +++ b/src/mule/mule_c.c @@ -98,6 +98,9 @@ struct BitfieldType64 uint64_t is_free : 1; }; +static int mut_xarray[4] = {100, 101, 102, 103}; +static float mut_farray[4] = {100.5f, 101.5f, 102.5f, 103.5f}; + void c_type_with_bitfield_usage(void) { @@ -113,5 +116,11 @@ c_type_with_bitfield_usage(void) BitfieldType64 b64 = {0}; b64.size = 524288; b64.is_free = 1; - int abc = 0; + int abc = mut_xarray[0]; + mut_xarray[0] += 1; + abc += mut_xarray[0]; + abc += mut_xarray[1]; + abc += mut_xarray[2]; + float f = mut_farray[0] + mut_farray[1] + mut_farray[2] + mut_farray[3]; + int w = 0; }