Hot++

Development notes

Notes for people who work on Hot++ itself: the milestones, the source layout, the tests, the translator and the hotc command line.

Status

Each row is a milestone. “Not testable here” means that the work needs a part that the development machine does not have.

Milestone Status Note
M0 Spikes Partial R0 and P1 are done with the test host tests/engine. The spikes for risk 2 and 3 need the real engine: not testable here.
M1 Runtime spine Done R1 to R6 pass, also under ASan and TSan.
M2 Translator v0 Done F1 passes, also for a native base that derives from a class template instance, a template over a template and a partial specialization (design risk 8). class Foo : Tmpl<int> works.
M3 Diagnostics and debugging Partial F2 passes. F3 passes with gdb. lldb sessions run in the tests. Visual Studio with natvis is not testable here.
M4 Engine integration Not testable here The test host tests/engine and the samples in samples/ are the only hosts. A real engine is needed.
M5 Contract enforcement Done The rows of design 5.3 have tests in tests/integration/reload/ and tests/unit/translator/translate/.
M6 Language v1 Done Inheritance, virtuals, is/as, lambdas, enums, structs, module variables, interpolation, constructors. async methods and await (C++20).
M7 AOT compilation Done hotc --aot. Generation 1 only.
M8 Unloading Done Core module. Generation 1 unloads. 1000 reloads with HOT_STRESS=1.
M9 Optional ORC backend Partial The JIT backend works on Linux. The debug-symbol resolver for Windows is not testable here.
M10 Source map and tolerant parse Done TranslateResult::source_map, hotc::analyze.
M11 VS Code extension Done Grammar snapshot test and package. A real VS Code session is not testable here.
M12 Language server stage 1 Done hot-ls, a server that uses a stock clangd as a child process (no fork).
M13 Language server stage 2 Done One test for each feature.
M14 Language server stage 3 Done Background index, hot/toScript, rename across the workspace, hotc --compile-commands.

Not done, and not testable here: Windows and macOS, a real engine, a real Visual Studio session, the optional ORC debug-symbol resolver.

Source layout

Tests

cmake --build --preset linux-clang-files-dbg && ctest --preset linux-clang-files-dbg

All tests are GoogleTest cases. CMake registers them with hot_gtest (a wrapper of gtest_discover_tests).

CI

.github/workflows/ci.yml runs on each push and pull request to master. The job linux builds with the preset linux-clang-files (Clang 23 from apt.llvm.org) and runs all tests. The job windows-msvc builds with the preset vs-files and MSVC on windows-2022 and runs the tests. The Windows smoke test runs on windows-latest, with a newer Visual Studio. Each job then makes a portable SDK (HOT_PORTABLE=ON, no tests). The smoke jobs unpack each SDK on a clean runner and run tests/sdk_smoke/run.cmake. The Windows smoke test uses MSVC and the Visual Studio generator. A push to master moves the tag latest and replaces the assets of the release latest. See Download the SDK.

Windows notes:

Translator notes

Native interface bases

A script class can have more than one native base: class Boss : Actor, IDamageable, ITagged. The first base is the primary base. The other bases are interface bases (design 4.4). See tests/scripts/boss_v1.hot, boss_v2.hot, boss_rebase.hot and tests/engine/Damageable.h.

Translator session

libclang needs about 400 ms to parse the engine headers. hotc::TranslatorSession (include/hot/hotc_lib.h) keeps the result: the virtual methods, the destructor and the constructors of each native base class. hotc::translate(options, session) uses it. hotc::translate(options) makes a temporary session, so it parses each time.

hotc command line

The tool hotc compiles scripts ahead of time. This is not a backend. Any build can load the result. Call hot::module_from_library(path) and give the Module to the Loader. This call needs no backend object. The sample samples/precompiled-library is a complete project.

hotc player_v1.hot --gen 1 -I include -I tests/engine --out-dir out/
hotc player_v2.hot --gen 2 -I include -I tests/engine --out-dir out/

The tool hotc has two modes. The default mode builds a .so. The mode --emit-cpp only translates (see “Translator”).

Command line of the build mode:

hotc <script>... --gen N (--out-dir DIR | -o x.so) [-I dir]... [--resource-dir dir]
     [--cxx command] [--cxxflag flag]... [--slots file] [--no-strict-borrowed] [--null-warnings]

Command line of the translate mode. Without -o, the tool prints the C++ to the standard output:

hotc --emit-cpp <script> --gen N [-o out.cpp] [-I dir]... [--prelude file]...
     [--slots file] [--resource-dir dir] [--no-strict-borrowed] [--null-warnings]

The exit code is 0 for success, 1 for an error and 2 for a wrong command line. The tool prints the compiler errors at the script line. It does not need CMake.

Command line of the AOT mode. The tool translates generation 1 of each script. It does not compile:

hotc --aot <script>... --out-dir DIR [-I dir]... [--prelude file]... [--no-strict-borrowed]
     [--format=std|fmt] [--resource-dir dir]