# klemmbaustein/dsharp architecture

> Architecture diagram of the GitHub repository klemmbaustein/dsharp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/klemmbaustein/dsharp
- Repository: https://github.com/klemmbaustein/dsharp

## Overview

D# is an embeddable, statically typed scripting-language library. Its principal workflow is host- or file-supplied script text, parsed and compiled into bytecode, then run by the runtime; native bindings and standard-library modules extend what scripts can access. The repository also includes JIT/debugging and editor-language-service capabilities. Edges are limited to relationships explicit in the supplied excerpts or README; some implementation links, especially around JIT and library registration, remain unverified.

Main entry points: [`include/ds/parser/parser.hpp`](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parser.hpp) (Parse context), [`src/modules/system.cpp`](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.cpp) (System modules), [`include/ds/bytecode.hpp`](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/bytecode.hpp) (Bytecode stream), [`src/jit/justInTimeCompiler_x64.cpp`](https://github.com/klemmbaustein/dsharp/blob/main/src/jit/justInTimeCompiler_x64.cpp) (JIT compiler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Parsing and types"]
  node_parse_context["Parse context<br/>[parser.hpp]"]
  node_file_scanner["File scanning<br/>[parseFile.hpp]"]
  node_class_parser["Class parsing<br/>[parseClass.hpp]"]
  node_type_system["Type system<br/>[type.hpp]"]
  node_type_registry["Type registry<br/>[typeRegistry.hpp]"]
end

subgraph group_compile["Bytecode compilation"]
  node_bytecode_compiler["Bytecode compiler"]
  node_bytecode_stream["Bytecode stream<br/>[bytecode.hpp]"]
end

subgraph group_runtime["Execution"]
  node_interpreter["Interpreter<br/>[interpreter.cpp]"]
  node_runtime_core["Runtime core<br/>[baseRuntime.cpp]"]
  node_jit_compiler["JIT compiler"]
  node_jit_code["x64 JIT code"]
end

subgraph group_embed["Embedding and libraries"]
  node_native_api["Native module API<br/>[nativeModule.hpp]"]
  node_standard_library["Standard library"]
  node_system_modules["System modules<br/>[system.cpp]"]
  node_fs_module["Filesystem module<br/>[system.fs.cpp]"]
  node_io_module["I/O module<br/>[system.io.cpp]"]
  node_math_module["Math module<br/>[system.math.cpp]"]
  node_async_module["Async module<br/>[system.async.cpp]"]
end

subgraph group_tools["Debug and editor tools"]
  node_debug_states["Debug states"]
  node_jit_debug_state["JIT debug state<br/>[jitDebugState.cpp]"]
  node_language_service["Language service"]
  node_scanned_symbols["Scanned symbols<br/>[scannedSymbols.cpp]"]
end

node_script_author(("Script author"))
node_host_app(("Embedding host"))

node_script_author -->|"provides scripts"| node_parse_context
node_host_app -->|"embeds scripts"| node_parse_context
node_parse_context -->|"parses files"| node_file_scanner
node_parse_context -->|"parses classes"| node_class_parser
node_parse_context -->|"uses registry"| node_type_registry
node_parse_context -->|"compiles with"| node_bytecode_compiler
node_parse_context -->|"produces bytecode"| node_bytecode_stream
node_bytecode_stream -->|"executes in"| node_interpreter
node_host_app -->|"adds bindings"| node_native_api
node_standard_library -.->|"provides modules"| node_system_modules
node_system_modules -.->|"includes filesystem"| node_fs_module
node_system_modules -.->|"includes I/O"| node_io_module
node_system_modules -.->|"includes math"| node_math_module
node_system_modules -.->|"includes async"| node_async_module
node_bytecode_stream -.->|"may compile"| node_jit_compiler
node_jit_compiler -.->|"emits code"| node_jit_code
node_interpreter -.->|"supports debugging"| node_debug_states
node_jit_compiler -.->|"supports debugging"| node_jit_debug_state
node_host_app -->|"requests editor data"| node_language_service
node_language_service -->|"uses scanned data"| node_scanned_symbols

click node_parse_context "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parser.hpp"
click node_file_scanner "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parseFile.hpp"
click node_class_parser "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parseClass.hpp"
click node_type_system "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/types/type.hpp"
click node_type_registry "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/typeRegistry.hpp"
click node_bytecode_compiler "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/bytecode/compileBytecode.hpp"
click node_bytecode_stream "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/bytecode.hpp"
click node_interpreter "https://github.com/klemmbaustein/dsharp/blob/main/src/interpreter.cpp"
click node_runtime_core "https://github.com/klemmbaustein/dsharp/blob/main/src/baseRuntime.cpp"
click node_jit_compiler "https://github.com/klemmbaustein/dsharp/blob/main/src/jit/justInTimeCompiler_x64.cpp"
click node_jit_code "https://github.com/klemmbaustein/dsharp/blob/main/src/jit/justInTimeCode_x64.cpp"
click node_native_api "https://github.com/klemmbaustein/dsharp/blob/main/include/ds/native/nativeModule.hpp"
click node_standard_library "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/standardLibrary.cpp"
click node_system_modules "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.cpp"
click node_fs_module "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.fs.cpp"
click node_io_module "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.io.cpp"
click node_math_module "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.math.cpp"
click node_async_module "https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.async.cpp"
click node_debug_states "https://github.com/klemmbaustein/dsharp/blob/main/src/debug/interpreterDebugState.cpp"
click node_jit_debug_state "https://github.com/klemmbaustein/dsharp/blob/main/src/debug/jitDebugState.cpp"
click node_language_service "https://github.com/klemmbaustein/dsharp/blob/main/src/service/languageService.cpp"
click node_scanned_symbols "https://github.com/klemmbaustein/dsharp/blob/main/src/service/scannedSymbols.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parse_context,node_file_scanner,node_class_parser,node_type_system,node_type_registry toneBlue
class node_bytecode_compiler,node_bytecode_stream toneAmber
class node_interpreter,node_runtime_core,node_jit_compiler,node_jit_code toneMint
class node_native_api,node_standard_library,node_system_modules,node_fs_module,node_io_module,node_math_module,node_async_module toneRose
class node_debug_states,node_jit_debug_state,node_language_service,node_scanned_symbols,node_script_author,node_host_app toneIndigo
```

## Components

### Parsing and types

- [Parse context](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parser.hpp): `include/ds/parser/parser.hpp`
- [File scanning](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parseFile.hpp): `include/ds/parser/parseFile.hpp`
- [Class parsing](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/parseClass.hpp): `include/ds/parser/parseClass.hpp`
- [Type system](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/types/type.hpp): `include/ds/parser/types/type.hpp`
- [Type registry](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/typeRegistry.hpp): `include/ds/parser/typeRegistry.hpp`

### Bytecode compilation

- [Bytecode compiler](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/parser/bytecode/compileBytecode.hpp): `include/ds/parser/bytecode/compileBytecode.hpp`
- [Bytecode stream](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/bytecode.hpp): `include/ds/bytecode.hpp`

### Execution

- [Interpreter](https://github.com/klemmbaustein/dsharp/blob/main/src/interpreter.cpp): `src/interpreter.cpp`
- [Runtime core](https://github.com/klemmbaustein/dsharp/blob/main/src/baseRuntime.cpp): `src/baseRuntime.cpp`
- [JIT compiler](https://github.com/klemmbaustein/dsharp/blob/main/src/jit/justInTimeCompiler_x64.cpp): `src/jit/justInTimeCompiler_x64.cpp`
- [x64 JIT code](https://github.com/klemmbaustein/dsharp/blob/main/src/jit/justInTimeCode_x64.cpp): `src/jit/justInTimeCode_x64.cpp`

### Embedding and libraries

- [Native module API](https://github.com/klemmbaustein/dsharp/blob/main/include/ds/native/nativeModule.hpp): `include/ds/native/nativeModule.hpp`
- [Standard library](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/standardLibrary.cpp): `src/modules/standardLibrary.cpp`
- [System modules](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.cpp): `src/modules/system.cpp`
- [Filesystem module](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.fs.cpp): `src/modules/system.fs.cpp`
- [I/O module](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.io.cpp): `src/modules/system.io.cpp`
- [Math module](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.math.cpp): `src/modules/system.math.cpp`
- [Async module](https://github.com/klemmbaustein/dsharp/blob/main/src/modules/system.async.cpp): `src/modules/system.async.cpp`

### Debug and editor tools

- [Debug states](https://github.com/klemmbaustein/dsharp/blob/main/src/debug/interpreterDebugState.cpp): `src/debug/interpreterDebugState.cpp`
- [JIT debug state](https://github.com/klemmbaustein/dsharp/blob/main/src/debug/jitDebugState.cpp): `src/debug/jitDebugState.cpp`
- [Language service](https://github.com/klemmbaustein/dsharp/blob/main/src/service/languageService.cpp): `src/service/languageService.cpp`
- [Scanned symbols](https://github.com/klemmbaustein/dsharp/blob/main/src/service/scannedSymbols.cpp): `src/service/scannedSymbols.cpp`

### Other components

- **Script author**
- **Embedding host**

## Connections

- Script author → Parse context: provides scripts
- Embedding host → Parse context: embeds scripts
- Parse context → File scanning: parses files (evidence: `include/ds/parser/parser.hpp`)
- Parse context → Class parsing: parses classes (evidence: `include/ds/parser/parser.hpp`)
- Parse context → Type registry: uses registry (evidence: `include/ds/parser/parser.hpp`)
- Parse context → Bytecode compiler: compiles with (evidence: `include/ds/parser/parser.hpp`)
- Parse context → Bytecode stream: produces bytecode (evidence: `include/ds/parser/parser.hpp`)
- Bytecode stream → Interpreter: executes in (evidence: `include/ds/bytecode.hpp`)
- Embedding host → Native module API: adds bindings
- Standard library → System modules: provides modules
- System modules → Filesystem module: includes filesystem
- System modules → I/O module: includes I/O
- System modules → Math module: includes math
- System modules → Async module: includes async
- Bytecode stream → JIT compiler: may compile
- JIT compiler → x64 JIT code: emits code
- Interpreter → Debug states: supports debugging
- JIT compiler → JIT debug state: supports debugging
- Embedding host → Language service: requests editor data
- Language service → Scanned symbols: uses scanned data
