Skip to content

Commit 5d8e6da

Browse files
committed
begin working on watch window stylization for file system evaluations
1 parent c77f2de commit 5d8e6da

File tree

10 files changed

+83
-82
lines changed

10 files changed

+83
-82
lines changed

src/eval/eval.mdesk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ E_ExprKindTable:
134134
{ Array Null 0 "array" "" "" "" }
135135
{ Func Null 0 "function" "" "" "" }
136136

137-
{ Line Binary 1 ":" "" ":" "" }
138-
139137
{ Define Binary 13 "=" "" "=" "" }
140138

141139
{ Tag Null 0 "=>" "=>" "," "" }

src/eval/eval_ir.c

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,25 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(file)
243243
String8 member_name = rhs->string;
244244
if(str8_match(member_name, str8_lit("size"), 0))
245245
{
246-
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.size);
246+
E_Space space = e_space_make(E_SpaceKind_FileSystem);
247+
space.u64_0 = e_id_from_string(accel->file_path);
248+
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.size));
247249
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
248250
result.irtree_and_type.mode = E_Mode_Value;
249251
}
250252
else if(str8_match(member_name, str8_lit("last_modified_time"), 0))
251253
{
252-
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.modified);
254+
E_Space space = e_space_make(E_SpaceKind_FileSystem);
255+
space.u64_0 = e_id_from_string(accel->file_path);
256+
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.modified));
253257
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
254258
result.irtree_and_type.mode = E_Mode_Value;
255259
}
256260
else if(str8_match(member_name, str8_lit("creation_time"), 0))
257261
{
258-
result.irtree_and_type.root = e_irtree_const_u(arena, accel->props.created);
262+
E_Space space = e_space_make(E_SpaceKind_FileSystem);
263+
space.u64_0 = e_id_from_string(accel->file_path);
264+
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, accel->props.created));
259265
result.irtree_and_type.type_key = e_type_key_basic(E_TypeKind_U64);
260266
result.irtree_and_type.mode = E_Mode_Value;
261267
}
@@ -2223,32 +2229,24 @@ E_IRGEN_FUNCTION_DEF(default)
22232229
//- rjf: leaf file paths
22242230
case E_ExprKind_LeafFilePath:
22252231
{
2226-
FileProperties props = os_properties_from_file_path(expr->string);
2232+
Temp scratch = scratch_begin(&arena, 1);
2233+
String8 file_path = path_normalized_from_string(scratch.arena, expr->string);
2234+
FileProperties props = os_properties_from_file_path(file_path);
22272235
if(props.flags & FilePropertyFlag_IsFolder)
22282236
{
22292237
E_Space space = e_space_make(E_SpaceKind_FileSystem);
2230-
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(expr->string)));
2238+
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(file_path)));
22312239
result.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("folder"));
22322240
result.mode = E_Mode_Value;
22332241
}
22342242
else
22352243
{
22362244
E_Space space = e_space_make(E_SpaceKind_FileSystem);
2237-
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(expr->string)));
2245+
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(file_path)));
22382246
result.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("file"));
22392247
result.mode = E_Mode_Value;
2240-
#if 0
2241-
U128 key = fs_key_from_path_range(expr->string, r1u64(0, max_U64));
2242-
E_Space space = {E_SpaceKind_HashStoreKey, .u128 = key};
2243-
U64 size = props.size;
2244-
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
2245-
base_offset->space = space;
2246-
result.root = base_offset;
2247-
result.root->string = push_str8_copy(arena, expr->string);
2248-
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
2249-
result.mode = E_Mode_Offset;
2250-
#endif
22512248
}
2249+
scratch_end(scratch);
22522250
}break;
22532251

22542252
//- rjf: types
@@ -2268,54 +2266,6 @@ E_IRGEN_FUNCTION_DEF(default)
22682266
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, expr->location, "Type expression not expected.");
22692267
}break;
22702268

2271-
//- rjf: textual line slicing
2272-
case E_ExprKind_Line:
2273-
{
2274-
E_Expr *lhs = expr->first;
2275-
E_Expr *rhs = expr->last;
2276-
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(arena, lhs);
2277-
U64 line_num = rhs->value.u64;
2278-
B32 space_is_good = 1;
2279-
E_Space space = {0};
2280-
if(lhs_irtree.root->op != E_IRExtKind_SetSpace)
2281-
{
2282-
space_is_good = 0;
2283-
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, lhs->location, "Cannot take a line from a non-file.");
2284-
}
2285-
else
2286-
{
2287-
MemoryCopy(&space, &lhs_irtree.root->value, sizeof(space));
2288-
}
2289-
B32 line_num_is_good = 1;
2290-
if(rhs->kind != E_ExprKind_LeafU64)
2291-
{
2292-
line_num_is_good = 0;
2293-
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line number must be specified as a constant number.");
2294-
}
2295-
if(space_is_good && line_num_is_good)
2296-
{
2297-
TXT_Scope *txt_scope = txt_scope_open();
2298-
U128 key = space.u128;
2299-
U128 hash = {0};
2300-
TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, key, TXT_LangKind_Null, &hash);
2301-
if(1 <= line_num && line_num <= text_info.lines_count)
2302-
{
2303-
Rng1U64 line_range = text_info.lines_ranges[line_num-1];
2304-
U64 line_size = dim_1u64(line_range);
2305-
E_IRNode *line_offset = e_irtree_const_u(arena, line_range.min);
2306-
result.root = line_offset;
2307-
result.root->space = space;
2308-
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), line_size);
2309-
result.mode = E_Mode_Offset;
2310-
}
2311-
else
2312-
{
2313-
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line %I64u is out of bounds.", line_num);
2314-
}
2315-
txt_scope_close(txt_scope);
2316-
}
2317-
}break;
2318-
23192269
//- rjf: definitions
23202270
case E_ExprKind_Define:
23212271
{

src/eval/generated/eval.meta.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
1414
str8_lit_comp("Symbol"),
1515
};
1616

17-
String8 e_expr_kind_strings[51] =
17+
String8 e_expr_kind_strings[50] =
1818
{
1919
str8_lit_comp("Nil"),
2020
str8_lit_comp("Ref"),
@@ -64,7 +64,6 @@ str8_lit_comp("TypeIdent"),
6464
str8_lit_comp("Ptr"),
6565
str8_lit_comp("Array"),
6666
str8_lit_comp("Func"),
67-
str8_lit_comp("Line"),
6867
str8_lit_comp("Define"),
6968
str8_lit_comp("Tag"),
7069
};
@@ -84,7 +83,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."),
8483
str8_lit_comp("Malformed bytecode."),
8584
};
8685

87-
E_OpInfo e_expr_kind_op_info_table[51] =
86+
E_OpInfo e_expr_kind_op_info_table[50] =
8887
{
8988
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
9089
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
@@ -134,7 +133,6 @@ E_OpInfo e_expr_kind_op_info_table[51] =
134133
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
135134
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
136135
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
137-
{ E_OpKind_Binary, 1, str8_lit_comp(""), str8_lit_comp(":"), str8_lit_comp("") },
138136
{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") },
139137
{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") },
140138
};

src/eval/generated/eval.meta.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ E_ExprKind_TypeIdent,
139139
E_ExprKind_Ptr,
140140
E_ExprKind_Array,
141141
E_ExprKind_Func,
142-
E_ExprKind_Line,
143142
E_ExprKind_Define,
144143
E_ExprKind_Tag,
145144
E_ExprKind_COUNT,
@@ -163,9 +162,9 @@ E_InterpretationCode_COUNT,
163162

164163
C_LINKAGE_BEGIN
165164
extern String8 e_token_kind_strings[6];
166-
extern String8 e_expr_kind_strings[51];
165+
extern String8 e_expr_kind_strings[50];
167166
extern String8 e_interpretation_code_display_strings[11];
168-
extern E_OpInfo e_expr_kind_op_info_table[51];
167+
extern E_OpInfo e_expr_kind_op_info_table[50];
169168
extern U8 e_kind_basic_byte_size_table[56];
170169
extern String8 e_kind_basic_string_table[56];
171170

src/file_stream/file_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ASYNC_WORK_DEF(fs_stream_work)
288288
ProfBegin("load \"%.*s\"", str8_varg(path));
289289
FileProperties pre_props = os_properties_from_file_path(path);
290290
U64 range_size = dim_1u64(range);
291-
U64 read_size = Min(pre_props.size, range_size);
291+
U64 read_size = Min(pre_props.size - range.min, range_size);
292292
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite, path);
293293
B32 file_handle_is_valid = !os_handle_match(os_handle_zero(), file);
294294
U64 data_arena_size = read_size+ARENA_HEADER_SIZE;

src/raddbg/generated/raddbg.meta.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//- GENERATED CODE
55

66
C_LINKAGE_BEGIN
7-
RD_VocabInfo rd_vocab_info_table[285] =
7+
RD_VocabInfo rd_vocab_info_table[288] =
88
{
99
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
1010
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
@@ -79,6 +79,9 @@ RD_VocabInfo rd_vocab_info_table[285] =
7979
{str8_lit_comp("environment"), str8_lit_comp("environments"), str8_lit_comp("Environment"), str8_lit_comp("Environments"), RD_IconKind_Null},
8080
{str8_lit_comp("frozen"), str8_lit_comp(""), str8_lit_comp("Frozen"), str8_lit_comp(""), RD_IconKind_Null},
8181
{str8_lit_comp("id"), str8_lit_comp("ids"), str8_lit_comp("ID"), str8_lit_comp("IDs"), RD_IconKind_Null},
82+
{str8_lit_comp("last_modified_time"), str8_lit_comp("last_modified_times"), str8_lit_comp("Last Modified Time"), str8_lit_comp("Last Modified Times"), RD_IconKind_Null},
83+
{str8_lit_comp("creation_time"), str8_lit_comp("creation_times"), str8_lit_comp("Creation Time"), str8_lit_comp("Creation Times"), RD_IconKind_Null},
84+
{str8_lit_comp("data"), str8_lit_comp("datas"), str8_lit_comp("Data"), str8_lit_comp("Datas"), RD_IconKind_Null},
8285
{str8_lit_comp("launch_and_run"), str8_lit_comp(""), str8_lit_comp("Launch and Run"), str8_lit_comp(""), RD_IconKind_Play},
8386
{str8_lit_comp("launch_and_init"), str8_lit_comp(""), str8_lit_comp("Launch and Initialize"), str8_lit_comp(""), RD_IconKind_PlayStepForward},
8487
{str8_lit_comp("kill"), str8_lit_comp(""), str8_lit_comp("Kill"), str8_lit_comp(""), RD_IconKind_X},

src/raddbg/generated/raddbg.meta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ RD_Query query;
555555
.os_event = rd_regs()->os_event,\
556556

557557
C_LINKAGE_BEGIN
558-
extern RD_VocabInfo rd_vocab_info_table[285];
558+
extern RD_VocabInfo rd_vocab_info_table[288];
559559
extern RD_NameSchemaInfo rd_name_schema_info_table[10];
560560
extern Rng1U64 rd_reg_slot_range_table[38];
561561
extern String8 rd_binding_version_remap_old_name_table[8];

src/raddbg/raddbg.mdesk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ RD_VocabTable:
9191
{environment _ "Environment" _ Null }
9292
{frozen "" "Frozen" "" Null }
9393
{id _ "ID" _ Null }
94+
{last_modified_time _ "Last Modified Time" _ Null }
95+
{creation_time _ "Creation Time" _ Null }
96+
{data _ "Data" _ Null }
9497
}
9598

9699
@struct RD_VocabInfo:

src/raddbg/raddbg_core.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,19 +3032,31 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
30323032
//- rjf: file reads
30333033
case E_SpaceKind_File:
30343034
{
3035+
// rjf: unpack space/path
30353036
U64 file_path_string_id = space.u64_0;
30363037
String8 file_path = e_string_from_id(file_path_string_id);
3037-
U128 key = fs_key_from_path_range(file_path, range);
3038+
3039+
// rjf: find containing chunk range
3040+
U64 chunk_size = KB(4);
3041+
Rng1U64 containing_range = range;
3042+
containing_range.min -= containing_range.min%chunk_size;
3043+
containing_range.max += chunk_size-1;
3044+
containing_range.max -= containing_range.max%chunk_size;
3045+
3046+
// rjf: map to hash
3047+
U128 key = fs_key_from_path_range(file_path, containing_range);
30383048
U128 hash = hs_hash_from_key(key, 0);
3049+
3050+
// rjf: look up from hash store
30393051
HS_Scope *scope = hs_scope_open();
30403052
{
30413053
String8 data = hs_data_from_hash(scope, hash);
3042-
Rng1U64 legal_range = r1u64(0, data.size);
3054+
Rng1U64 legal_range = r1u64(containing_range.min, containing_range.min + data.size);
30433055
Rng1U64 read_range = intersect_1u64(range, legal_range);
30443056
if(read_range.min < read_range.max)
30453057
{
30463058
result = 1;
3047-
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
3059+
MemoryCopy(out, data.str + read_range.min - containing_range.min, dim_1u64(read_range));
30483060
}
30493061
}
30503062
hs_scope_close(scope);
@@ -8636,7 +8648,7 @@ rd_window_frame(void)
86368648
{
86378649
// rjf: brighten
86388650
{
8639-
R_Rect2DInst *inst = dr_rect(box->rect, v4f32(0, 0, 0, 0), 0, 0, 1.f);
8651+
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, 1.f), v4f32(0, 0, 0, 0), 0, 0, 1.f);
86408652
Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_Hover);
86418653
color.w *= t*0.2f;
86428654
inst->colors[Corner_00] = color;

src/raddbg/raddbg_views.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,42 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
11011101
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_ActivateWithSingleClick, .pct = 1.f, .fstrs = rd_title_fstrs_from_code_name(arena, cmd_kind_info->string, ui_top_palette()->text_weak, ui_top_font_size()));
11021102
}
11031103

1104+
// rjf: singular button for folders & files
1105+
else if(info.eval.space.kind == E_SpaceKind_FileSystem)
1106+
{
1107+
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), ui_top_palette()->text, ui_top_font_size()};
1108+
E_Type *type = e_type_from_key__cached(info.eval.type_key);
1109+
String8 file_path = e_string_from_id(info.eval.value.u64);
1110+
String8 file_name = str8_skip_last_slash(file_path);
1111+
if(str8_match(type->name, str8_lit("folder"), 0))
1112+
{
1113+
DR_FStrList fstrs = {0};
1114+
dr_fstrs_push_new(arena, &fstrs, &params, file_name);
1115+
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr,
1116+
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode,
1117+
.pct = 1.f,
1118+
.fstrs = fstrs);
1119+
}
1120+
else
1121+
{
1122+
info.cell_style_key = str8_lit("expr_and_eval");
1123+
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
1124+
RD_Cfg *style = rd_cfg_child_from_string(view, info.cell_style_key);
1125+
RD_Cfg *w_cfg = style->first;
1126+
F32 next_pct = 0;
1127+
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
1128+
DR_FStrList fstrs = {0};
1129+
dr_fstrs_push_new(arena, &fstrs, &params, file_name);
1130+
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr,
1131+
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode,
1132+
.default_pct = 0.35f,
1133+
.pct = take_pct(),
1134+
.fstrs = fstrs);
1135+
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .default_pct = 0.65f, .pct = take_pct());
1136+
#undef take_pct
1137+
}
1138+
}
1139+
11041140
// rjf: singular cell for view ui
11051141
else if(info.view_ui_rule != &rd_nil_view_ui_rule)
11061142
{
@@ -1243,7 +1279,9 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
12431279
B32 is_non_code = 0;
12441280
String8 string = push_str8f(arena, ".%S", member_name);
12451281
if(row_eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
1246-
row_eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity)
1282+
row_eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
1283+
row_eval.space.kind == E_SpaceKind_File ||
1284+
row_eval.space.kind == E_SpaceKind_FileSystem)
12471285
{
12481286
String8 fancy_name = rd_display_from_code_name(member_name);
12491287
if(fancy_name.size != 0)

0 commit comments

Comments
 (0)