You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DCE: Tasks 5 & 6 - References and CrossFileItems patterns
Applies the map → list → merge pattern to references and cross-file items.
## Task 5: References
New module: References.ml/.mli
- builder (mutable) for AST processing
- t (immutable) for solver
- Tracks both value refs and type refs
- PosSet for position sets
Changes:
- Thread ~refs:References.builder through AST processing
- addValueReference, addTypeReference use References API
- Solver uses References.find_value_refs, References.find_type_refs
- Deleted global ValueReferences.table and TypeReferences.table
## Task 6: CrossFileItems (renamed from DelayedItems)
New module: CrossFileItems.ml/.mli
- builder (mutable) for AST processing
- t (immutable) for processing after merge
- Three item types: exception_refs, optional_arg_calls, function_refs
Changes:
- Thread ~cross_file:CrossFileItems.builder through AST processing
- DeadException.markAsUsed adds to cross_file builder
- DeadOptionalArgs.addReferences, addFunctionReference add to cross_file
- Deleted global delayedItems refs from DeadException and DeadOptionalArgs
## Data flow
process_cmt_file (per-file)
→ file_data { annotations; decls; refs; cross_file }
Merge phase:
FileAnnotations.merge_all → annotations (immutable)
Declarations.merge_all → decls (immutable)
CrossFileItems.merge_all → cross_file (immutable)
References builders merged into refs_builder
Process cross-file items:
process_exception_refs → writes to refs_builder
process_optional_args → reads decls
Freeze:
refs_builder → refs (immutable)
Solver:
reportDead ~annotations ~decls ~refs
## Global state deleted
- DeadCommon.ValueReferences.table
- DeadCommon.TypeReferences.table
- DeadException.delayedItems
- DeadOptionalArgs.delayedItems
- DeadOptionalArgs.functionReferences
## Naming
Renamed DelayedItems → CrossFileItems because it better describes
the semantic meaning: items that reference across file boundaries.
**Additional problem**: `positionsAnnotated` mixes **input** (source annotations from AST) with **output** (positions the solver determines are dead). The solver mutates this during analysis, violating purity.
@@ -346,29 +346,39 @@ val is_annotated_* : t -> ... -> bool
346
346
**Pattern**: Same as Task 3/4.
347
347
348
348
**Changes**:
349
-
-[ ] Create `References` module with `builder` and `t` types
350
-
-[ ]`process_cmt_file` returns `References.builder` for both value and type refs
351
-
-[ ]`References.merge_all : builder list -> t`
352
-
-[ ] Delete global `ValueReferences.table` and `TypeReferences.table`
349
+
-[x] Create `References` module with `builder` and `t` types
350
+
-[x] Thread `~refs:References.builder` through `addValueReference`, `addTypeReference`
351
+
-[x]`process_cmt_file` returns `References.builder` in `file_data`
352
+
-[x] Merge refs into builder, process delayed items, then freeze
353
+
-[x] Solver uses `References.t` via `find_value_refs` and `find_type_refs`
354
+
-[x] Delete global `ValueReferences.table` and `TypeReferences.table`
355
+
356
+
**Status**: Complete ✅
353
357
354
358
**Test**: Process files in different orders - results should be identical.
355
359
356
360
**Estimated effort**: Medium (similar to Task 4)
357
361
358
-
### Task 6: Delayed items use map → list → merge pattern (P3)
362
+
### Task 6: Cross-file items use map → list → merge pattern (P3)
359
363
360
-
**Value**: No global queues. Delayed items are per-file immutable data.
364
+
**Value**: No global queues. Cross-file items are per-file immutable data.
361
365
362
366
**Pattern**: Same as Task 3/4/5.
363
367
364
368
**Changes**:
365
-
-[ ] Create `DelayedItems` module with `builder` and `t` types
0 commit comments