This document tracks the phased development plan for HolyComp — a faithful, portable HolyC implementation in Rust with an interpreter and LLVM compiler backend.
- Workspace layout:
holyc_frontend,holyc_interpreter,holyc_compiler,holyc_stdlib - Full manual lexer (all tokens, operators, literals, comments, preprocessor directives)
- Recursive-descent + Pratt expression parser
- Complete AST (
Expr,Stmt,TopLevel,Module) - Type system (
HolyTypewithsize_of, signed/float predicates) -
RuntimeError+Valueinholyc_stdlib(canonical, shared) - Tree-walk interpreter: all control flow, arithmetic, function calls
- REPL with rustyline (multi-line buffering,
:help/:resetcommands) -
Print/printf, math builtins (Sin,Cos,Sqrt,Pow,Abs) -
printf-style formatter (%d %u %x %X %f %g %c %s %%) - ABI classification layer (ready for inkwell wiring)
- LLVM codegen scaffold (
CodegenCtx,emit_ir) - CI: lint + 3-OS test matrix + MSRV + nightly + security audit
-
.gitignore,.gitattributes(LF normalisation, Linguist overrides) - Compatibility test suite:
hello.HC,arithmetic.HC,loops.HC,switch.HC,fibonacci.HC
Goal: *ptr, &var, arr[i], MAlloc / Free fully working in the interpreter.
- Add a flat heap (
Vec<u8>+ bump allocator) toInterpreter - Implement
MAlloc(size)→ real heap address;Free(ptr)→ mark free - Implement
*ptrdereference and&varaddress-of invm.rs - Implement
arr[i]subscript for heap-allocated arrays - String literals → heap-allocated null-terminated bytes;
%sreads from heap -
MemSet(ptr, val, len)andMemCpy(dst, src, len)real implementations - Add
--heap-sizeCLI flag (default: 64 MiB) - Add
pointer.HCcompat test
Goal: class Foo { I64 x; }; Foo f; f.x = 1; works end-to-end.
- Struct layout engine: field offsets, padding,
sizeof(ClassName) -
TypeEnvmap:String → StructLayoutthreaded through interpreter and parser -
.fieldand->fieldaccess invm.rsvia heap offsets - Nested structs and struct arrays
-
typedefresolves throughTypeEnv - Add
structs.HCcompat test
Goal: holyc-compile --jit foo.HC executes at native speed.
- Add
inkwelldependency (llvm17or current stable) - Wire
CodegenCtx::compilefor arithmetic functions (no pointers yet) - Implement
compile_exprforIntLit,FloatLit,BinOp,Call - Implement
compile_stmtforVarDecl,Return,If,While,For - Map HolyC types → LLVM types (
I64 → i64,F64 → double,U0 → void) - Use ABI layer (
abi.rs) to set calling conventions on generated functions - JIT execution via
inkwell::execution_engine::ExecutionEngine - Parity tests: every
tests/compat/*.HCmust produce identical output via both interpreter and JIT
Goal: holyc-compile foo.HC -o foo produces a native executable.
- Emit LLVM object files via
TargetMachine::write_to_file - Link with system linker (cc / lld shim)
-
--emit-llvmflag: write.llIR to disk -
--emit-asmflag: write.sassembly - Cross-compilation:
--target x86_64-unknown-linux-gnuetc. - Add
justfilewithbuild,run,compilerecipes
Goal: asm { … } blocks pass through to LLVM inline asm.
- Lex and preserve raw asm text through the AST (currently a stub)
- Map
asm { … }→llvm::InlineAsmvia inkwell - AT&T syntax only for initial support (mirrors TempleOS x86 asm)
- Constraint string inference from surrounding variable types
- Add
asm_test.HCcompat test
-
StrCpy,StrCmp,StrCat,StrStr,StrToI64 -
FileOpen,FileClose,FileRead,FileWrite,FileSeek(host OS shims) -
Time/DateStr(host clock) -
Rand/SRand -
MemCmp -
SPrint(buf, fmt, …)— formatted string to buffer - Document every builtin in
docs/stdlib.md
-
--checkmode: parse + type-check, no execution - Structured diagnostics with source spans (line/column, caret underline)
-
holyc fmt— auto-formatter - VS Code / Neovim tree-sitter grammar for HolyC
- Language Server Protocol (LSP) stub (hover types, go-to-def)
- Code coverage via
cargo-tarpaulin
- Research TempleOS ring-0 calling convention differences
- Graphics stub: map
GrPrint,GrLine, etc. to host framebuffer or SDL2 - Spike: run a simple TempleOS
.HCapplication unmodified
| Version | Milestone |
|---|---|
| 0.1 | Phase 0 complete |
| 0.2 | Phase 1 complete (current) |
| 0.2 | Phase 2 complete |
| 0.3 | Phase 3 LLVM JIT complete |
| 0.4 | Phases 4-7 complete |
| 0.5 | Tooling: fmt, LSP, tree-sitter |
| 0.6 | TempleOS compat + binary literals (current) |
| 0.3 | Phase 3 — JIT working |
| 0.4 | Phase 4 — AOT working |
| 0.5 | Phase 5 + 6 |
| 1.0 | Phase 7 complete, stable CLI |