3.6 KiB
3.6 KiB
CodeInspector Development Guidelines & Project Invariants
1. Build System & Architecture (RAD Debugger Style)
- Zero CMake: Do not add CMake or CMake-generated project files.
- Unity Build: All source modules in
src/must be included into a unified translation unit (src/main.cpp). Keep compilation times sub-second to 2 seconds. - Build Script (
build.bat):- Auto-detects Visual Studio installations using
vswhere.exeand callsvcvars64.batifcl.exeis not in%PATH%. - Caches precompiled vendor objects (
vendor_imgui.obj,rlImGui.obj) inbuild/to maximize iteration speed. - Supports
debug,release,run, andcleanmodes.
- Auto-detects Visual Studio installations using
2. MSVC Output Routing Invariant (Zero Root Pollution)
Whenever compiling with MSVC (cl.exe) in build.bat:
- Always route all outputs strictly into the
build/directory:- Object files:
/Fo:"build\"or/Fo:"build\<name>.obj" - Compiler PDBs:
/Fd:"build\" - Binaries:
/Fe:"build\<name>.exe" - Linker PDBs:
/link /PDB:"build\<name>.pdb"
- Object files:
- Never let
cl.exedropvc*.pdb,*.obj,*.lib, or*.expinto the project root. - Keep
imgui.iniand compiler intermediates ignored in.gitignore.
3. General-Purpose Clang AST Execution Engine (Inspect ANY Code)
- No DLL Compilation / No Subprocess Execution: Never invoke external compilers (
cl.exe) at runtime to load code as DLLs. - No Ad-Hoc Token Regexes: Never use pattern matching or token scanning to guess function behavior.
- Recursive AST Evaluation:
- All code inspection, evaluation, and call tracing are driven directly by the
libclangAST tree (CXCursor). - The AST interpreter (
Runner) must support standard C constructs:- Control flow:
IfStmt,CompoundStmt,WhileStmt,ForStmt,ReturnStmt. - Expressions:
ConditionalOperator(ternary? :),BinaryOperator(comparison, arithmetic, bitwise, assignment),UnaryOperator(-,!,~,++,--). - Values:
IntegerLiteral,CharacterLiteral,FloatingLiteral,DeclRefExpr,VarDecl.
- Control flow:
- Every function invocation (
CallExpr) records aTraceFramecapturing timestamps, arguments, return values, depth, and child calls for the flamegraph and call tree. - Recursion and loop guard limits (e.g. max depth 60, max calls 50,000) must protect against infinite execution.
- All code inspection, evaluation, and call tracing are driven directly by the
4. Working Directory & Path Safety
- On startup, the application must immediately call
ensure_project_root()to detect if it was launched frombuild/or an external shortcut, resettingstd::filesystem::current_pathto the repository root. - Always load existing files from disk on launch. Never overwrite the user's buffer with hardcoded sample strings.
- Always ensure parent directories exist (
std::filesystem::create_directories) before saving or creating files.
5. Live Synchronization Architecture
SourceManagermaintains a monotonicrevision_counter incremented upon every AST reparse, load, edit, or save.- UI panels observe
revision_and re-evaluate parameters and flamegraphs automatically live as the user types.
6. UI Ergonomics & Clipboard Export
- Log and console panels must always support easy copying:
- Provide a "Copy All Logs" button using
ImGui::SetClipboardText. - Provide right-click context menus (
Copy Line,Copy Message Only). - Provide a "Raw Text (Selectable)" tab with mouse selection and native
Ctrl+C.
- Provide a "Copy All Logs" button using
- AST Debug Export:
- Provide a one-click "Copy AST & Debug Dump to Clipboard" button in the inspector, in the AST Explorer view, and via global shortcut
Ctrl+D(export_ast_dump) to facilitate instant debugging in pair-programming workflows.
- Provide a one-click "Copy AST & Debug Dump to Clipboard" button in the inspector, in the AST Explorer view, and via global shortcut