diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 diff --git a/BUILDING.md b/BUILDING.md index 5e031fea..6e90c8a6 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -40,6 +40,22 @@ npm run build `scripts/build-vendor.sh` clones and builds static archives for libgc, cJSON, libuv, tree-sitter, and libwebsockets into `vendor/`. It's idempotent — re-running skips already-built libraries. +## Run + +After building, the compiler is available as a Node.js script: + +```bash +node dist/chad-node.js build hello.ts -o hello +./hello +``` + +For a ~10x faster compiler, build the native binary once: + +```bash +node dist/chad-node.js build src/chad-native.ts -o .build/chad +# Now tests and scripts auto-use .build/chad instead of node dist/chad-node.js +``` + ## Verify ```bash @@ -95,11 +111,13 @@ bash scripts/build-target-sdk.sh ## Self-Hosting (Stage 0) -ChadScript can compile its own compiler to a native binary: +ChadScript can compile its own compiler to a native binary (this is what `scripts/self-hosting.sh` automates): ```bash -chad build src/chad-native.ts -o /tmp/chad-stage0 +# Stage 0: Node.js compiler produces a native binary +node dist/chad-node.js build src/chad-native.ts -o /tmp/chad-stage0 +# Stage 1: that native binary recompiles itself /tmp/chad-stage0 build src/chad-native.ts -o /tmp/chad-stage1 ``` diff --git a/c_bridges/yyjson-bridge.c b/c_bridges/yyjson-bridge.c index ac230206..f7393046 100644 --- a/c_bridges/yyjson-bridge.c +++ b/c_bridges/yyjson-bridge.c @@ -104,6 +104,20 @@ void *csyyjson_create_obj(void) { return (void *)doc; } +void *csyyjson_create_arr(void) { + yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); + if (!doc) return NULL; + yyjson_mut_val *root = yyjson_mut_arr(doc); + if (!root) { yyjson_mut_doc_free(doc); return NULL; } + yyjson_mut_doc_set_root(doc, root); + return (void *)doc; +} + +void *csyyjson_mut_arr_add_obj(void *doc, void *arr) { + if (!doc || !arr) return NULL; + return (void *)yyjson_mut_arr_add_obj((yyjson_mut_doc *)doc, (yyjson_mut_val *)arr); +} + void *csyyjson_mut_get_root(void *doc) { if (!doc) return NULL; return (void *)yyjson_mut_doc_get_root((yyjson_mut_doc *)doc); diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 1a900d3b..797473e1 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -17,13 +17,6 @@ export default defineConfig({ languages: [llvmGrammar], }, - transformPageData(pageData) { - const mdPath = path.resolve(__dirname, '..', pageData.relativePath) - try { - pageData.frontmatter.__rawMarkdown = fs.readFileSync(mdPath, 'utf-8') - } catch {} - }, - themeConfig: { search: { provider: 'local' @@ -40,11 +33,11 @@ export default defineConfig({ { text: 'Getting Started', items: [ - { text: 'Language Support', link: '/language/limitations' }, + { text: 'About ChadScript', link: '/language/architecture' }, { text: 'Installation', link: '/getting-started/installation' }, { text: 'Examples', link: '/getting-started/quickstart' }, - { text: 'How it Works', link: '/language/architecture' }, { text: 'CLI Reference', link: '/getting-started/cli' }, + { text: 'Supported Features', link: '/language/limitations' }, { text: 'Debugging', link: '/getting-started/debugging' } ] }, @@ -84,12 +77,6 @@ export default defineConfig({ { text: 'Benchmarks', link: '/benchmarks' } ] }, - { - text: 'Resources', - items: [ - { text: 'FAQ', link: '/faq' } - ] - } ], socialLinks: [ diff --git a/docs/.vitepress/theme/CopyMarkdown.vue b/docs/.vitepress/theme/CopyMarkdown.vue index 291cdc84..a2d7087e 100644 --- a/docs/.vitepress/theme/CopyMarkdown.vue +++ b/docs/.vitepress/theme/CopyMarkdown.vue @@ -1,29 +1,49 @@ +