diff --git a/lib/ocaml/runtime.sx b/lib/ocaml/runtime.sx index e1af957d..ce31974f 100644 --- a/lib/ocaml/runtime.sx +++ b/lib/ocaml/runtime.sx @@ -366,6 +366,18 @@ let printf fmt = print_string fmt end ;; + module Sys = struct + let os_type = \"SX\" + let word_size = 64 + let max_array_length = 4611686018427387903 + let max_string_length = 4611686018427387903 + let executable_name = \"ocaml-on-sx\" + let big_endian = false + let unix = true + let win32 = false + let cygwin = false + end ;; + module Hashtbl = struct let create n = _hashtbl_create n let add t k v = _hashtbl_add t k v diff --git a/lib/ocaml/test.sh b/lib/ocaml/test.sh index edda595a..a9eec931 100755 --- a/lib/ocaml/test.sh +++ b/lib/ocaml/test.sh @@ -1012,6 +1012,18 @@ cat > "$TMPFILE" << 'EPOCHS' (epoch 3102) (eval "(ocaml-type-of-program \"type t = A of bool | B of float;; A true\")") +;; ── Sys module stubs ────────────────────────────────────────── +(epoch 3200) +(eval "(ocaml-run \"Sys.os_type\")") +(epoch 3201) +(eval "(ocaml-run \"Sys.word_size\")") +(epoch 3202) +(eval "(ocaml-run \"Sys.unix\")") +(epoch 3203) +(eval "(ocaml-run \"Sys.win32\")") +(epoch 3204) +(eval "(ocaml-run \"Sys.executable_name\")") + EPOCHS OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null) @@ -1601,6 +1613,13 @@ check 3100 "shape -> Int" '"shape -> Int"' check 3101 "TStr 'hi' : tag" '"tag"' check 3102 "A true : t" '"t"' +# ── Sys stubs ────────────────────────────────────────────────── +check 3200 "Sys.os_type" '"SX"' +check 3201 "Sys.word_size" '64' +check 3202 "Sys.unix" 'true' +check 3203 "Sys.win32" 'false' +check 3204 "Sys.executable_name" '"ocaml-on-sx"' + TOTAL=$((PASS + FAIL)) if [ $FAIL -eq 0 ]; then echo "ok $PASS/$TOTAL OCaml-on-SX tests passed" diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index 32e5853f..bdec70c7 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -264,6 +264,10 @@ SX CEK evaluator (both JS and OCaml hosts) - [~] `Hashtbl`: `create`, `add`, `find`, `find_opt`, `replace`, `mem`, `length`. Backed by a one-element list cell holding a SX dict; keys coerced to strings via `str` for polymorphic-key support. +- [~] `Sys`: `os_type` (`"SX"`), `word_size`, `max_array_length`, + `max_string_length`, `executable_name`, `big_endian`, `unix`, + `win32`, `cygwin`. Constants only; `argv`/`getenv_opt`/`command` + pending (would need host platform integration). - [x] `String`: `length`, `get`, `sub`, `concat`, `uppercase_ascii`, `lowercase_ascii`, `starts_with`, `ends_with`, `contains`, `trim`, `split_on_char`, `replace_all`, `index_of`. @@ -379,6 +383,10 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means: _Newest first._ +- 2026-05-08 Phase 6 — `Sys` module constants (+5 tests, 414 total). + os_type, word_size, max_array_length, max_string_length, + executable_name, big_endian, unix, win32, cygwin. Constants-only + for now; `argv`/`getenv_opt`/`command` need host platform integration. - 2026-05-08 Phase 5 — parse simple type sources in user type-defs (+3 tests, 409 total). `ocaml-hm-parse-type-src` recognises primitive type names, tyvars `'a`, and `T list`/`T option`-style