diff --git a/affinescript-deno-test/cli.affine b/affinescript-deno-test/cli.affine index ed5f7802..66cdf49a 100644 --- a/affinescript-deno-test/cli.affine +++ b/affinescript-deno-test/cli.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module cli; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -27,7 +24,7 @@ module cli; import { compileToWasm } from "./lib/compile.ts"; import { discoverTestFiles } from "./lib/discover.ts"; -function usage(): never { +fn usage(): never { console.error( "Usage: deno run --allow-read --allow-run --allow-env cli.ts \n" + "\n" + @@ -39,10 +36,10 @@ function usage(): never { } if (import.meta.main) { - const root = Deno.args[0]; + let root = Deno.args[0]; if (!root) usage(); - const sources = await discoverTestFiles(root); + let sources = await discoverTestFiles(root); if (sources.length === 0) { console.error(`No *_test.affine files found under ${root}`); Deno.exit(1); @@ -51,14 +48,13 @@ if (import.meta.main) { console.log(`Discovered ${sources.length} test file(s):`); for (const source of sources) { try { - const wasm = await compileToWasm(source); + let wasm = await compileToWasm(source); console.log(` ✓ ${source} → ${wasm}`); } catch (error) { - const message = error instanceof Error ? error.message : String(error); + let message = error instanceof Error ? error.message : String(error); console.error(` ✗ ${source}\n ${message}`); Deno.exit(1); } } } -==================================== */ diff --git a/affinescript-deno-test/example/smoke_driver.affine b/affinescript-deno-test/example/smoke_driver.affine index 04be5c0c..a872dbba 100644 --- a/affinescript-deno-test/example/smoke_driver.affine +++ b/affinescript-deno-test/example/smoke_driver.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module smoke_driver; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -21,4 +18,3 @@ import { runAll } from "../mod.ts"; await runAll(new URL("./", import.meta.url).pathname); -==================================== */ diff --git a/affinescript-deno-test/lib/compile.affine b/affinescript-deno-test/lib/compile.affine index 5d580df6..c5388073 100644 --- a/affinescript-deno-test/lib/compile.affine +++ b/affinescript-deno-test/lib/compile.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module compile; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -14,16 +11,16 @@ module compile; // Wraps the `affinescript compile` CLI. Given a `.affine` source file, // produces a sibling `.wasm` file and returns its absolute path. // -// The `AFFINESCRIPT_BIN` env var overrides the default path to the compiler. +// The `AFFINESCRIPT_BIN` env let overrides the default path to the compiler. // Default is the local dev-build at developer-ecosystem/nextgen-languages/ // affinescript/_build/install/default/bin/affinescript (useful while the // compiler is not on $PATH). -const DEFAULT_BIN = +let DEFAULT_BIN = "/var/mnt/eclipse/repos/developer-ecosystem/nextgen-languages/affinescript/_build/install/default/bin/affinescript"; /** Absolute path to the `affinescript` compiler binary. */ -export function resolveCompilerPath(): string { +fn resolveCompilerPath(): string { return Deno.env.get("AFFINESCRIPT_BIN") ?? DEFAULT_BIN; } @@ -32,20 +29,20 @@ export function resolveCompilerPath(): string { * path to the emitted `.wasm`. Throws with compiler stderr if compilation * fails. */ -export async function compileToWasm(sourcePath: string): Promise { - const absolute = sourcePath.startsWith("/") +async fn compileToWasm(sourcePath: string): string { + let absolute = sourcePath.startsWith("/") ? sourcePath : `${Deno.cwd()}/${sourcePath}`; - const wasmPath = absolute.replace(/\.(affine|afs|rattle|pyaff|jsaff)$/, ".wasm"); + let wasmPath = absolute.replace(/\.(affine|afs|rattle|pyaff|jsaff)$/, ".wasm"); if (wasmPath === absolute) { throw new Error( `compileToWasm: source file must end in .affine / .afs / .rattle / .pyaff / .jsaff — got ${sourcePath}`, ); } - const bin = resolveCompilerPath(); - const cmd = new Deno.Command(bin, { + let bin = resolveCompilerPath(); + let cmd = new Deno.Command(bin, { args: ["compile", absolute, "-o", wasmPath], stdout: "piped", stderr: "piped", @@ -53,8 +50,8 @@ export async function compileToWasm(sourcePath: string): Promise { const { code, stdout, stderr } = await cmd.output(); if (code !== 0) { - const out = new TextDecoder().decode(stdout); - const err = new TextDecoder().decode(stderr); + let out = new TextDecoder().decode(stdout); + let err = new TextDecoder().decode(stderr); throw new Error( `affinescript compile failed (exit ${code}) for ${sourcePath}\n` + `STDOUT:\n${out}\nSTDERR:\n${err}`, @@ -64,4 +61,3 @@ export async function compileToWasm(sourcePath: string): Promise { return wasmPath; } -==================================== */ diff --git a/affinescript-deno-test/lib/discover.affine b/affinescript-deno-test/lib/discover.affine index 40025422..0542c9cc 100644 --- a/affinescript-deno-test/lib/discover.affine +++ b/affinescript-deno-test/lib/discover.affine @@ -1,33 +1,30 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module discover; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // // affinescript-deno-test: discover.ts // // Glob-based discovery of AffineScript test files. -// Default convention: any file matching `*_test.affine` or `*.test.affine`. +// Default convention: unknown file matching `*_test.affine` or `*.test.affine`. import { walk } from "jsr:@std/fs@1/walk"; /** Default regex for matching AffineScript test files by filename. */ -export const DEFAULT_TEST_PATTERN = /(?:_test|\.test)\.(?:affine|afs|rattle|pyaff|jsaff)$/; +let DEFAULT_TEST_PATTERN = /(?:_test|\.test)\.(?:affine|afs|rattle|pyaff|jsaff)$/; /** * Recursively walk `root` and return absolute paths of files matching * `pattern` (default: `*_test.affine` or `*.test.affine`). */ -export async function discoverTestFiles( +async fn discoverTestFiles( root: string, pattern: RegExp = DEFAULT_TEST_PATTERN, -): Promise { - const absoluteRoot = root.startsWith("/") ? root : `${Deno.cwd()}/${root}`; +): string[] { + let absoluteRoot = root.startsWith("/") ? root : `${Deno.cwd()}/${root}`; const matches: string[] = []; for await (const entry of walk(absoluteRoot, { includeDirs: false, match: [pattern] })) { @@ -38,4 +35,3 @@ export async function discoverTestFiles( return matches; } -==================================== */ diff --git a/affinescript-deno-test/lib/runner.affine b/affinescript-deno-test/lib/runner.affine index e5d035ea..53a00e20 100644 --- a/affinescript-deno-test/lib/runner.affine +++ b/affinescript-deno-test/lib/runner.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module runner; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -13,13 +10,12 @@ module runner; // // Loads a compiled AffineScript WASM module and wraps every exported function // whose name starts with `test_` as a Deno.test() case. A test passes when -// the function returns `true`, fails when it returns `false`. +// the fn returns `true`, fails when it returns `false`. // // Convention (v0.2.0): each `.affine` file may define multiple tests via -// the `pub fn test_() -> Bool` syntax. Every `pub fn test_*` export -// becomes a separate Deno.test() case. Non-`pub` helpers stay internal to +// the `pub fn test_() -> Bool` syntax. Every `pub fn test_*` // becomes a separate Deno.test() case. Non-`pub` helpers stay internal to // the module. This relies on the AffineScript compiler honouring `fd_vis` -// in its WASM-export decision (commit ce324fa, both codegen.ml and +// in its WASM-decision (commit ce324fa, both codegen.ml and // codegen_gc.ml). // // Uses the existing @hyperpolymath/affine-js bridge for WASM loading and @@ -29,23 +25,23 @@ module runner; import { AffineModule } from "@hyperpolymath/affine-js"; /** Convention: every `pub fn` whose name begins with this prefix is a test. */ -export const TEST_PREFIX = "test_"; +let TEST_PREFIX = "test_"; /** Result shape returned by AffineScript Bool exports (via affine-js). */ -interface BoolValue { +struct BoolValue { kind: "bool"; value: boolean; } /** - * Derive the Deno.test() case name from the file basename + export name. - * For a wasm at `/path/to/math_test.wasm` with export `test_add`, yields + * Derive the Deno.test() case name from the file basename + name. + * For a wasm at `/path/to/math_test.wasm` with `test_add`, yields * `math / add`. */ -function caseName(wasmPath: string, exportName: string): string { - const base = wasmPath.split("/").pop() ?? wasmPath; - const fileStem = base.replace(/\.wasm$/, "").replace(/(_test|\.test)$/, ""); - const caseStem = exportName.replace(/^test_/, ""); +fn caseName(wasmPath: string, exportName: string): string { + let base = wasmPath.split("/").pop() ?? wasmPath; + let fileStem = base.replace(/\.wasm$/, "").replace(/(_test|\.test)$/, ""); + let caseStem = exportName.replace(/^test_/, ""); return `${fileStem} / ${caseStem}`; } @@ -55,7 +51,7 @@ function caseName(wasmPath: string, exportName: string): string { * do not use IO. For test modules that only return Bool, we can satisfy this * with a no-op that reports `0` bytes written on every call. */ -function makeWasiStub(): WebAssembly.ModuleImports { +fn makeWasiStub(): WebAssembly.ModuleImports { return { fd_write: ( _fd: number, @@ -71,22 +67,22 @@ function makeWasiStub(): WebAssembly.ModuleImports { } /** - * Register a Deno.test() case for every `test_*` export in the WASM module + * Register a Deno.test() case for every `test_*` in the WASM module * at `wasmPath`. Path should be absolute; relative paths resolve against CWD. * * Returns the number of tests registered. Throws if no `test_*` exports * are found (indicating a misconfigured file — at least one `pub fn test_*` * is expected). */ -export async function registerTestsFromWasm(wasmPath: string): Promise { - const absolute = wasmPath.startsWith("/") +async fn registerTestsFromWasm(wasmPath: string): number { + let absolute = wasmPath.startsWith("/") ? wasmPath : `${Deno.cwd()}/${wasmPath}`; - const bytes = await Deno.readFile(absolute); - const wasmMod = await WebAssembly.compile(bytes); - const neededImports = WebAssembly.Module.imports(wasmMod); - const needsWasi = neededImports.some((i) => i.module === "wasi_snapshot_preview1"); + let bytes = await Deno.readFile(absolute); + let wasmMod = await WebAssembly.compile(bytes); + let neededImports = WebAssembly.Module.imports(wasmMod); + let needsWasi = neededImports.some((i) => i.module === "wasi_snapshot_preview1"); // AffineModule.fromBytes only supplies imports under the "env" module key, // so when WASI is required we must take the alternative path: raw @@ -95,8 +91,8 @@ export async function registerTestsFromWasm(wasmPath: string): Promise { return await registerTestsWithWasi(bytes, wasmPath); } - const mod = await AffineModule.fromBytes(bytes); - const testExports = mod.functionExports.filter((name: string) => + let mod = await AffineModule.fromBytes(bytes); + let testExports = mod.functionExports.filter((name: string) => name.startsWith(TEST_PREFIX) ); @@ -110,7 +106,7 @@ export async function registerTestsFromWasm(wasmPath: string): Promise { for (const exportName of testExports) { Deno.test(caseName(wasmPath, exportName), () => { - const result = mod.call(exportName, { returnType: "bool" }) as BoolValue; + let result = mod.call(exportName, { returnType: "bool" }) as BoolValue; if (result.kind !== "bool") { throw new Error( `test '${exportName}' returned non-bool value: ${JSON.stringify(result)}`, @@ -129,39 +125,39 @@ export async function registerTestsFromWasm(wasmPath: string): Promise { * wasi_snapshot_preview1. Bypasses AffineModule because its constructor * only accepts imports under the "env" module key. */ -async function registerTestsWithWasi( +async fn registerTestsWithWasi( bytes: Uint8Array, wasmPath: string, -): Promise { +): number { // Copy into a fresh ArrayBuffer-backed Uint8Array so the TS BufferSource // overload matches (Deno's Uint8Array default-types to ArrayBufferLike, // which the WebAssembly.instantiate overload rejects). - const buf = new Uint8Array(bytes.byteLength); + let buf = new Uint8Array(bytes.byteLength); buf.set(bytes); const { instance } = await WebAssembly.instantiate(buf.buffer, { env: {}, wasi_snapshot_preview1: makeWasiStub(), }); - const testExports = Object.keys(instance.exports).filter( + let testExports = Object.keys(instance.exports).filter( (name) => typeof instance.exports[name] === "function" && name.startsWith(TEST_PREFIX), ); if (testExports.length === 0) { - const available = Object.keys(instance.exports).join(", "); + let available = Object.keys(instance.exports).join(", "); throw new Error( - `affinescript-deno-test: no '${TEST_PREFIX}*' function exports found in ${wasmPath}. ` + + `affinescript-deno-test: no '${TEST_PREFIX}*' fn exports found in ${wasmPath}. ` + `Available: [${available}]. ` + `Each test must be declared as 'pub fn test_() -> Bool'.`, ); } for (const exportName of testExports) { - const fn = instance.exports[exportName] as () => number; + let fn = instance.exports[exportName] as () => number; Deno.test(caseName(wasmPath, exportName), () => { - const raw = fn(); + let raw = fn(); // AffineScript compiles Bool to i32 (0 = false, 1 = true). if (raw !== 0 && raw !== 1) { throw new Error( @@ -177,4 +173,3 @@ async function registerTestsWithWasi( return testExports.length; } -==================================== */ diff --git a/affinescript-deno-test/mod.affine b/affinescript-deno-test/mod.affine index a27b438b..6ccea351 100644 --- a/affinescript-deno-test/mod.affine +++ b/affinescript-deno-test/mod.affine @@ -1,18 +1,15 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module mod; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // // affinescript-deno-test: mod.ts (public API) // // High-level entry point. Compiles matching AffineScript test files under a -// given root, then registers every `test_*` WASM export as a Deno.test() case. +// given root, then registers every `test_*` WASM as a Deno.test() case. // // Usage (library mode, from a harness script): // @@ -28,9 +25,9 @@ import { compileToWasm } from "./lib/compile.ts"; import { discoverTestFiles } from "./lib/discover.ts"; import { registerTestsFromWasm } from "./lib/runner.ts"; -export { compileToWasm, resolveCompilerPath } from "./lib/compile.ts"; -export { DEFAULT_TEST_PATTERN, discoverTestFiles } from "./lib/discover.ts"; -export { TEST_PREFIX, registerTestsFromWasm } from "./lib/runner.ts"; +{ compileToWasm, resolveCompilerPath } from "./lib/compile.ts"; +{ DEFAULT_TEST_PATTERN, discoverTestFiles } from "./lib/discover.ts"; +{ TEST_PREFIX, registerTestsFromWasm } from "./lib/runner.ts"; /** * Discover, compile, and register every AffineScript test file under `root`. @@ -38,8 +35,8 @@ export { TEST_PREFIX, registerTestsFromWasm } from "./lib/runner.ts"; * Returns the total number of test cases registered across all files. * Deno's test framework reports pass/fail per case when `deno test` runs. */ -export async function runAll(root: string): Promise { - const sources = await discoverTestFiles(root); +async fn runAll(root: string): number { + let sources = await discoverTestFiles(root); if (sources.length === 0) { throw new Error( `affinescript-deno-test: no test files found under ${root} ` + @@ -49,10 +46,9 @@ export async function runAll(root: string): Promise { let total = 0; for (const source of sources) { - const wasm = await compileToWasm(source); + let wasm = await compileToWasm(source); total += await registerTestsFromWasm(wasm); } return total; } -==================================== */ diff --git a/packages/affine-js/types.d.affine b/packages/affine-js/types.d.affine index 702224ed..71227560 100644 --- a/packages/affine-js/types.d.affine +++ b/packages/affine-js/types.d.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module types.d; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -20,19 +17,19 @@ module types.d; // ── AffineValue discriminated union ────────────────────────────────────────── -export type AffineInt = { kind: "int"; value: number }; -export type AffineFloat = { kind: "float"; value: number }; -export type AffineBool = { kind: "bool"; value: boolean }; -export type AffineUnit = { kind: "unit" }; -export type AffineString = { kind: "string"; value: string }; -export type AffineSome = { kind: "some"; value: AffineValue }; -export type AffineNone = { kind: "none" }; -export type AffineOk = { kind: "ok"; value: AffineValue }; -export type AffineErr = { kind: "err"; value: AffineValue }; -export type AffineArray = { kind: "array"; elements: AffineValue[] }; -export type AffineRecord = { kind: "record"; fields: Record }; - -export type AffineValue = +struct AffineInt { { kind: "int"; value: number }; +struct AffineFloat { { kind: "float"; value: number }; +struct AffineBool { { kind: "bool"; value: boolean }; +struct AffineUnit { { kind: "unit" }; +struct AffineString { { kind: "string"; value: string }; +struct AffineSome { { kind: "some"; value: AffineValue }; +struct AffineNone { { kind: "none" }; +struct AffineOk { { kind: "ok"; value: AffineValue }; +struct AffineErr { { kind: "err"; value: AffineValue }; +struct AffineArray { { kind: "array"; elements: AffineValue[] }; +struct AffineRecord { { kind: "record"; fields: Record }; + +struct AffineValue { | AffineInt | AffineFloat | AffineBool @@ -47,7 +44,7 @@ export type AffineValue = // ── Return type hint ────────────────────────────────────────────────────────── -export type AffineValueType = +struct AffineValueType { | "int" | "float" | "bool" @@ -60,7 +57,7 @@ export type AffineValueType = // ── LoadOptions ─────────────────────────────────────────────────────────────── -export interface LoadOptions { +struct LoadOptions { /** * Extra host imports merged with the default AffineScript runtime. * @@ -92,13 +89,13 @@ export interface LoadOptions { // ── Ownership (typed-wasm contract carrier) ─────────────────────────────────── -export type OwnershipKind = +struct OwnershipKind { | "unrestricted" | "linear" | "sharedBorrow" | "exclBorrow"; -export interface OwnershipEntry { +struct OwnershipEntry { funcIdx: number; paramKinds: OwnershipKind[]; retKind: OwnershipKind; @@ -106,7 +103,7 @@ export interface OwnershipEntry { // ── CallOptions ─────────────────────────────────────────────────────────────── -export interface CallOptions extends LoadOptions { +struct CallOptions extends LoadOptions { /** * Type hint for the return value unmarshaler. * @@ -119,19 +116,19 @@ export interface CallOptions extends LoadOptions { // ── AffineModule ────────────────────────────────────────────────────────────── -export declare class AffineModule { +declare struct AffineModule { /** * Load a compiled AffineScript `.wasm` file from the local filesystem. */ - static fromFile(path: string | URL, options?: LoadOptions): Promise; + static fromFile(path: string | URL, options?: LoadOptions): AffineModule; /** * Load a compiled AffineScript module from raw WASM bytes. */ - static fromBytes(bytes: Uint8Array | ArrayBuffer, options?: LoadOptions): Promise; + static fromBytes(bytes: Uint8Array | ArrayBuffer, options?: LoadOptions): AffineModule; /** - * Call a named export by name. + * Call a named by name. */ call(name: string, options?: CallOptions, ...args: AffineValue[]): AffineValue; @@ -159,45 +156,45 @@ export declare class AffineModule { // ── Host-agnostic loader (INT-02) ───────────────────────────────────────────── -export type Host = "deno" | "node" | "browser" | "unknown"; +struct Host { "deno" | "node" | "browser" | "unknown"; /** Detect the current JavaScript host by feature, not by user agent. */ -export declare function detectHost(): Host; +declare fn detectHost(): Host; /** Resolve a module specifier (URL, file path, or relative) to a URL. */ -export declare function resolveUrl(spec: string | URL, base?: string | URL): URL; +declare fn resolveUrl(spec: string | URL, base?: string | URL): URL; -/** Read a WASM module's bytes from any source, on any host. */ -export declare function readBytes( +/** Read a WASM module's bytes from unknown source, on unknown host. */ +declare fn readBytes( source: string | URL | Uint8Array | ArrayBuffer, options?: { base?: string | URL }, -): Promise; +): Uint8Array; /** Build the full WebAssembly import object (multi-namespace). */ -export declare function buildImportObject( +declare fn buildImportObject( runtimeImports: Record, options?: Pick, ): WebAssembly.Imports; /** Parse the `typedwasm.ownership` custom section. */ -export declare function parseOwnershipSection( +declare fn parseOwnershipSection( wasmModule: WebAssembly.Module, ): OwnershipEntry[]; // ── Top-level functions ─────────────────────────────────────────────────────── /** Load and run a compiled AffineScript program in one call. */ -export declare function run(path: string | URL, options?: LoadOptions): Promise; +declare fn run(path: string | URL, options?: LoadOptions): AffineValue; /** Marshal an AffineValue to a raw WASM operand. */ -export declare function marshal( +declare fn marshal( value: AffineValue, memory: WebAssembly.Memory, alloc: (n: number) => number, ): number; /** Unmarshal a raw WASM operand to an AffineValue. */ -export declare function unmarshal( +declare fn unmarshal( raw: number, valueType: AffineValueType, memory: WebAssembly.Memory, @@ -205,21 +202,20 @@ export declare function unmarshal( // ── AffineValue constructors ────────────────────────────────────────────────── -export declare function int(value: number): AffineInt; -export declare function float(value: number): AffineFloat; -export declare function bool(value: boolean): AffineBool; -export declare function unit(): AffineUnit; -export declare function string(value: string): AffineString; -export declare function some(value: AffineValue): AffineSome; -export declare function none(): AffineNone; -export declare function ok(value: AffineValue): AffineOk; -export declare function err(value: AffineValue): AffineErr; -export declare function array(elements: AffineValue[]): AffineArray; -export declare function record(fields: Record): AffineRecord; +declare fn int(value: number): AffineInt; +declare fn float(value: number): AffineFloat; +declare fn bool(value: boolean): AffineBool; +declare fn unit(): AffineUnit; +declare fn string(value: string): AffineString; +declare fn some(value: AffineValue): AffineSome; +declare fn none(): AffineNone; +declare fn ok(value: AffineValue): AffineOk; +declare fn err(value: AffineValue): AffineErr; +declare fn array(elements: AffineValue[]): AffineArray; +declare fn record(fields: Record): AffineRecord; // ── Runtime constants ───────────────────────────────────────────────────────── -export declare const AFFINE_TAG: Readonly<{ NONE: 0; SOME: 1; OK: 2; ERR: 3 }>; -export declare const AFFINE_SIZE: Readonly<{ INT: 4; FLOAT: 8; PTR: 4; TAG: 4; LEN: 4 }>; +declare const AFFINE_TAG: Readonly<{ NONE: 0; SOME: 1; OK: 2; ERR: 3 }>; +declare const AFFINE_SIZE: Readonly<{ INT: 4; FLOAT: 8; PTR: 4; TAG: 4; LEN: 4 }>; -==================================== */ diff --git a/packages/affinescript-cli/mod.d.affine b/packages/affinescript-cli/mod.d.affine index 4a0723ff..c4b07ff6 100644 --- a/packages/affinescript-cli/mod.d.affine +++ b/packages/affinescript-cli/mod.d.affine @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 -// Ported via Harvard Engine mechanical processor +// Ported via Harvard Engine (Semantic pass) module mod.d; -// TODO: Complete semantic implementation - -/* === ORIGINAL TYPESCRIPT CONTEXT === // SPDX-License-Identifier: MPL-2.0 // Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) // @@ -19,10 +16,10 @@ module mod.d; // where ReScript cannot" exception. /** ADR-019 release target triples this shim knows about. */ -export type Target = "linux-x64" | "macos-x64" | "macos-arm64"; +struct Target { "linux-x64" | "macos-x64" | "macos-arm64"; /** A single per-target entry in the {@link Pins} table. */ -export interface PinEntry { +struct PinEntry { /** Canonical Release asset URL — `affinescript-` raw executable. */ url: string; /** Lower-case hex SHA-256. Empty string ⇒ fail-closed for that target. */ @@ -33,7 +30,7 @@ export interface PinEntry { * The full pin table — ONE compiler version + ONE sha256 per target, per * shim release. Filled in `pins.js` when a `v*` tag is cut. */ -export interface Pins { +struct Pins { /** The pinned compiler tag (e.g. `"v0.1.1"`). */ version: string; /** Per-target download + checksum entries. Targets without a sha256 @@ -42,7 +39,7 @@ export interface Pins { } /** Options accepted by {@link resolveCompiler} and {@link run}. */ -export interface ResolveOptions { +struct ResolveOptions { /** Override the embedded pin table (test seam). */ pins?: Pins; /** Override the global `fetch` (test seam). */ @@ -53,16 +50,16 @@ export interface ResolveOptions { * Map a host OS/arch to one of the supported ADR-019 release targets. * Throws if the host isn't covered (e.g. windows-x64 is a tracked follow-up). */ -export function hostTarget(os?: string, arch?: string): Target; +fn hostTarget(os?: string, arch?: string): Target; /** Lower-case hex of the SHA-256 of `bytes`. */ -export function sha256Hex(bytes: ArrayBuffer | Uint8Array): Promise; +fn sha256Hex(bytes: ArrayBuffer | Uint8Array): string; /** * Absolute path the shim caches a pinned binary at. Resolves * `AFFINESCRIPT_CACHE` → `XDG_CACHE_HOME` → `$HOME/.cache` → `TMPDIR` → `/tmp`. */ -export function cachePath(version: string, target: Target): string; +fn cachePath(version: string, target: Target): string; /** * Resolve a runnable compiler binary path for the host. On a cache @@ -71,13 +68,12 @@ export function cachePath(version: string, target: Target): string; * bit set, and returns the path. Throws on checksum mismatch (refuses * to cache or run the tampered bytes). */ -export function resolveCompiler(opts?: ResolveOptions): Promise; +fn resolveCompiler(opts?: ResolveOptions): string; /** * Resolve via {@link resolveCompiler}, then `Deno.Command`-spawn the * binary with `args`, inheriting stdio. Returns the child's exit code * (caller decides whether to `Deno.exit()`). */ -export function run(args?: string[], opts?: ResolveOptions): Promise; +fn run(args?: string[], opts?: ResolveOptions): number; -==================================== */