Skip to content

Commit 80c651e

Browse files
hyperpolymathclaude
andcommitted
feat: implement Phase 1 — manifest, codegen, and ABI modules
Replace scaffold stubs with full Nim code generation pipeline: - Manifest: [project], [[functions]] (name, params, return-type, pragmas), [nim] (backend: c/cpp/js, gc: arc/orc/none, opt-level) with validation - ABI: NimProc, NimType, NimPragma, NimTemplate, CompilationTarget, GcStrategy with Display impls and rendering methods - Codegen/parser: parse manifest function signatures into typed ABI NimProc structs, handling ptr/ref/seq/array types - Codegen/nim_gen: generate .nim files with proc declarations, pragmas, stub bodies, doc comments, and wrapExportc helper template - Codegen/build_gen: generate nim compilation commands, nim.cfg, build.sh - 38 tests (28 unit + 10 integration), all passing, zero warnings - Example manifest in examples/fast-lib/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a083a8e commit 80c651e

11 files changed

Lines changed: 2807 additions & 55 deletions

File tree

Cargo.lock

Lines changed: 906 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/fast-lib/nimiser.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Example nimiser manifest: fast-lib
3+
# A minimal math library generated via Nim metaprogramming.
4+
5+
[project]
6+
name = "fast-lib"
7+
version = "0.1.0"
8+
description = "A fast math library compiled from Nim to C"
9+
author = "Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>"
10+
11+
[[functions]]
12+
name = "fast_add"
13+
return-type = "cint"
14+
pragmas = ["exportc", "cdecl"]
15+
doc = "Add two C integers with zero overhead."
16+
17+
[[functions.params]]
18+
name = "a"
19+
type = "cint"
20+
21+
[[functions.params]]
22+
name = "b"
23+
type = "cint"
24+
25+
[[functions]]
26+
name = "fast_multiply"
27+
return-type = "cdouble"
28+
pragmas = ["exportc", "cdecl", "noSideEffect"]
29+
doc = "Multiply two C doubles."
30+
31+
[[functions.params]]
32+
name = "x"
33+
type = "cdouble"
34+
35+
[[functions.params]]
36+
name = "y"
37+
type = "cdouble"
38+
39+
[[functions]]
40+
name = "fast_negate"
41+
return-type = "cint"
42+
pragmas = ["exportc", "cdecl", "inline", "noSideEffect"]
43+
doc = "Negate a C integer."
44+
45+
[[functions.params]]
46+
name = "val"
47+
type = "cint"
48+
49+
[[functions]]
50+
name = "fast_init"
51+
return-type = ""
52+
pragmas = ["exportc", "cdecl"]
53+
doc = "Initialise the library (no-op stub)."
54+
55+
[nim]
56+
backend = "c"
57+
gc = "arc"
58+
opt-level = "speed"

0 commit comments

Comments
 (0)