omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
GitHub aien-dev/omega-mv#843 (code only)
Apply it
git checkout -b patch-803c38b4e35023a9 0b77e6ea294aa3d69ccbdb86b9c14d133abea689 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/803c38b4e35023a9.patch | git am
Provenance
github-import 1
aien-dev/omega-mv
843
3f6579b449a5a3a4458dc2bc443bd2a9e51773ff
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":843,"url":"https://github.com/aien-dev/omega-mv/pull/843","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:47Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 35aa2238f..fd475526b 100644 --- a/.crumb +++ b/.crumb @@ -42,68 +42,68 @@ "children": [ { "digest": "9f19f11674ca5dfc3c9c3ae35fe6106557aee9583210da13d257e1b9d88e052c", - "last_commit": "d863780e", + "last_commit": "d863780eb", "name": "calibration", "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "26c2fbf4515e981db72f56dad2fc3fe0667c469551cf6071e28ac50005a36e42", - "last_commit": "943f5139", + "digest": "8384ea718539fd98ebf1b5d395bbccd15543651aca19b509530582a6c0c07216", + "last_commit": "3e5a0e770", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { "digest": "536f7b8db9a92a1f586bad4379d47544a30d1b8e83c2d799c18e66cf8660c9ae", - "last_commit": "30bb116c", + "last_commit": "30bb116cc", "name": "doctrine", "purpose": "Directory doctrine. Purpose not yet described by a human." }, { "digest": "4947c0eb38550826cdfaba5d08384f3ebd284b82ab456ecf276617ce2ef998fd", - "last_commit": "43f25831", + "last_commit": "43f25831b", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, { "digest": "62b92244c52fa8af6f511012dee2967e98dff162cc1d8bf45d0b2f15cb0adc5f", - "last_commit": "450bbefd", + "last_commit": "450bbefd4", "name": "research", "purpose": "Directory research. Purpose not yet described by a human." }, { "digest": "8bbd5f74b01446007499a9a9be4e9f50f4364af0f578d9cdf26a2afd84e3bb63", - "last_commit": "faebae8c", + "last_commit": "faebae8c1", "name": "spec", "purpose": "Directory spec. Purpose not yet described by a human." }, { "digest": "f390041dbba29a5707b5652e20e6bffd69e0a1f1ebfc493736ff5266370fa4aa", - "last_commit": "82a399b9", + "last_commit": "82a399b9f", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { "digest": "d75dd95349e3cd5e180a91ec848d3e25ac9c3b693f96d4397c9646e37823cba9", - "last_commit": "45f7d769", + "last_commit": "45f7d7691", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, { "digest": "4e83dea21da137c30076c2dc0ca4f3a488f576f30a94e334558ad5ea523f3a6b", - "last_commit": "a50c3bd4", + "last_commit": "a50c3bd41", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:86ef1d4da867572dbd97c75562b8066d916c4b712e883715e0c3bdd3a13b5f1f", - "compiled_at": "2026-10-26T19:28:07Z", + "children_root": "sha256:9462674732828713856fc2048f30a8816e85e87961a90566bd504d95dfb76920", + "compiled_at": "2026-10-26T22:09:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:cbd1d776bb45a312fa9e1d63b688b2085834b584fb1bf95d56e96eefa4d90c28", + "digest": "sha256:461fa12846691d548e065216f067a152ae8afb22bd0c2c2f5caaecdced3f6731", "evidence_files": 12477, "evidence_root": "sha256:9d96c8c22e5c574c4768d1eadd333b9750f73cd27be276a0f190c876960008a1", - "files": 17297, - "generated_at_commit": "813d6c4385665b61485ee9d1fa91c0c213ed4ce3", - "source_tree": "sha256:028d088bf1a5bb9001b4082b459ef4efaeaa6e33e4840a5e73a9a5ca07ae4ffe" + "files": 17322, + "generated_at_commit": "3e5a0e770532eb64427d0a39274b7cbf4b3ccd64", + "source_tree": "sha256:37fec69081f187158810d1205d3976681b1ffb33c329d57d45e47983c6fc790f" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index dcf015737..e8def997c 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -46,92 +46,92 @@ "children": [ { "digest": "640f6b7b818c769ab0dcd91437d58dd3251044084d2ae3785f000d30d2bb768a", - "last_commit": "a927bd6c", + "last_commit": "a927bd6c2", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, { "digest": "e7ac2460455a35b96b01dab649dcdc2cdf5bb4657bf230b91272c64fe1bf82cf", - "last_commit": "d48ab89e", + "last_commit": "d48ab89e5", "name": "autodiff", "purpose": "M21 OMEGA_AUTODIFF scope, op and error-contract table, status (not qualified)" }, { "digest": "7506b1a8659e6de84e1be31a281c8d046e4946de6ed29451155bb56cda5cb365", - "last_commit": "6637b32b", + "last_commit": "6637b32b6", "name": "brownian", "purpose": "Directory docs/brownian. Purpose not yet described by a human." }, { "digest": "1b01542d91e3b1c7c5263d6b393338a3d9d40e138a12ec833ce7852d83887ce2", - "last_commit": "5901baa5", + "last_commit": "5901baa51", "name": "crumbs", "purpose": "Directory docs/crumbs. Purpose not yet described by a human." }, { "digest": "e9baaaeec04be41a57c4a2d6a540b01a682c70d4db96cb4af4e1a9912a133aa9", - "last_commit": "55d05d6a", + "last_commit": "55d05d6a5", "name": "dual", "purpose": "DUAL (ARCH-0031) documents in omega: applicability experiment method and findings (APPLICABILITY" }, { "digest": "56a5a999ce726e90d89c1c88b9e20c81857c8e6ee82af8d651ac80ea70e2c46d", - "last_commit": "38a6a569", + "last_commit": "38a6a569b", "name": "estimation", "purpose": "Directory docs/estimation. Purpose not yet described by a human." }, { "digest": "8b926a045985692f116d9469af5aaa06d778bca78cf5d7e891e68c2486ed789e", - "last_commit": "8ec82485", + "last_commit": "8ec82485d", "name": "numeric", "purpose": "Directory docs/numeric. Purpose not yet described by a human." }, { "digest": "1a26b15f795aa3581a03400a21d5635e85c71f3f544fcc3676fa58064402c7ad", - "last_commit": "968734c7", + "last_commit": "968734c7e", "name": "osc", "purpose": "Directory docs/osc. Purpose not yet described by a human." }, { "digest": "645b6abb9d46a13dff6c9091d79acf0318fcfdc447a2dc50a3b70cd0dcfaa548", - "last_commit": "968734c7", + "last_commit": "968734c7e", "name": "polyglot", "purpose": "Directory docs/polyglot. Purpose not yet described by a human." }, { "digest": "46d3e2d59a468271e044ccd2398eb32345df6436c15eb6d8c703953c838023a9", - "last_commit": "dd67f6bd", + "last_commit": "dd67f6bd7", "name": "reservoir", "purpose": "Reservoir reference and contracts (omega#440): RESERVOIR_REFERENCE.md pins the authors' paper an" }, { "digest": "2ab37838f8694e5060a3789f08a16146996050af949fba329ed805429d85f695", - "last_commit": "f633e343", + "last_commit": "f633e3430", "name": "tensor", "purpose": "M20 OMEGA_TENSOR spec and qualification checklist" }, { "digest": "41ab5cf8617e9583dcda75292e1e851e1ec4187b69d5d00b5eb354f1ee55c9d5", - "last_commit": "54826a37", + "last_commit": "54826a37f", "name": "train", "purpose": "Directory docs/train. Purpose not yet described by a human." }, { "digest": "5db2869ff0b78866ad0ce38f77b262e81fdbc89408e94968491c4e6548177278", - "last_commit": "968734c7", + "last_commit": "968734c7e", "name": "turing", "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], "children_root": "sha256:c81d43c0c392dfec2b6ed5b38ba95ea7c592782b283950e32b777e7b9cfd9d61", - "compiled_at": "2026-10-26T17:56:57Z", + "compiled_at": "2026-10-26T22:09:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:26c2fbf4515e981db72f56dad2fc3fe0667c469551cf6071e28ac50005a36e42", + "digest": "sha256:8384ea718539fd98ebf1b5d395bbccd15543651aca19b509530582a6c0c07216", "evidence_files": 34, "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", "files": 135, - "generated_at_commit": "943f5139f3f91f586ca03e707332afb2048d59d2", - "source_tree": "sha256:e91c9c4dc91d9680759d217e532ccacbaceea2f0ae8acc0b1ee957e627f1381d" + "generated_at_commit": "3e5a0e770532eb64427d0a39274b7cbf4b3ccd64", + "source_tree": "sha256:616775281907becd1d75136b99ab95b0a72d7438777f763177e06e198b078f48" }, "owner_lane": "", "provenance": { diff --git a/docs/one_layer/OMEGESE.md b/docs/one_layer/OMEGESE.md index 119c55955..010468c30 100644 --- a/docs/one_layer/OMEGESE.md +++ b/docs/one_layer/OMEGESE.md @@ -640,7 +640,7 @@ section lists what omc implements of it. Fixtures, expected results and compiled meaning and, for the C2 manifest, its exact output bytes or error. - **Opt-in.** Leading blank lines and `note` lines are skipped; when the next line is exactly `om2`, - `om2 diag` or `om2 fmt` (no other bytes on it) the unit is OM-2. Any other line leaves the unit OM-1, + `om2 diag`, `om2 fmt` or `om2 query` (no other bytes on it) the unit is OM-2. Any other line leaves the unit OM-1, where the `om2` line itself is error 16 as before. The words of this section are reserved only in an OM-2 unit: `rotr rotl unroll inline fresh abstract seal open holds layout field at little big part out export ops`. Using one as a name there is error 16; an OM-1 unit keeps them as ordinary names. @@ -666,6 +666,37 @@ meaning and, for the C2 manifest, its exact output bytes or error. where it is kept; no blanks at a line end; a whitespace-only line empty; one LF after the last line. A CR anywhere and blank lines at the end are error 6. fmt never adds or removes a line, is idempotent, and compile(fmt(x)) is byte-identical to compile(x). +- **`om2 query`.** Only when the input's first line, at byte 0, is `om2 query` (error 16 elsewhere, in + an `om2 fmt` rest included, and when the rest starts with `om2 fmt` or `om2 query`). The rest is compiled as a unit of its own + as for `om2 fmt`; a lead-placement error 16 goes to stderr against the whole input. Under the lead no + program is ever written. A rest with no `??` line that compiles writes the one line + `{"check":{"code":0,"status":"VALID-UNPROVEN"}}` (well formed only, nothing proven), exit 0. Any omc + error in the rest writes `{"check":{"code":C,"line":L,"status":"INVALID"}}` to stdout, nothing to + stderr, exit 1; with a hole the error lies before it. When one line of the rest is only `??` (blanks + around it allowed) and the compiler reaches it in statement position, nothing else is compiled: stdout + gets one JSON line and the exit is 0: + `{"hole":{"line":L,"kind":"statement","fn_line":F,"depth":D},"scope":[...],"fns":[...],"obligations": + {"function":"...","open":[...],"regs_free":R,"contracts":[...],"effects":[...]}}`. Lines count from 1 + at the first line of the rest. `scope` is every visible name (a shadowed one is left out) in name-table + (declaration) order, as `{"name","type"}` plus `"writable":true` for a global pool, a `new` array or an + `edit`/`out` parameter; `type` is the base type with `[]` for an array, `struct` or `abstract` for + those names. `fns` is every function line of the unit in source order (omc reads the function lines + before the bodies). `open` lists the open blocks + innermost first (`if`, `else`, `while`, `for`, `inline`) and ends with `fn`; `depth` is their count. + `regs_free` is 16 minus parameter and held registers. `contracts` are the function's `requires`/ + `ensures` lines and the `invariant` lines of open loops, outermost first. `effects` lists each host word + the function used before the hole as `word:class` (`io fs net proc env clock random device`), once, in + first-use order, host words in inlined callees included. Two `??` lines write + `{"error":"more than one ?? hole"}` and a `??` outside a function writes + `{"error":"the hole is not inside a function"}`, both with exit 1. A `??` in value position is not + answered (value holes are the black-box oracle's, stage 1): where omc reads it as an unknown name it + writes `{"check":{"code":3,"line":L,"status":"UNKNOWN","why":"value holes: use omq (stage 1)"}}`, + exit 1. Not covered: a `??` in a position that raises another error is that error's INVALID line, and + the INVALID line carries only code, line and status, none of omq's diagnostic fields or repairs (the + `fix_move_up` of error 3, `fix_rename` of 13, `fix_append_end` of 15). The key names and shapes are + those of the black-box oracle `seed/query/omq.om`; `seed/omc/gate19.sh` compares them on its 12 cases + (statement holes, error objects, INVALID lines, value-hole refusals). Without the lead line `??` is refused + as before (error 4 in a statement, error 3 as a value, error 16 at the top level). - **Rotate.** `rotr x n` and `rotl x n`: x and n of one unsigned type (uchar, ushort, uint, ulong; else error 7), the result x's type. n outside 0..w-1 traps 7 at run time, a number n included. uint/ulong with a number n give one `ROR` (immediate, EXTR); otherwise the amount check, then `RORV` (rotl through diff --git a/seed/README.md b/seed/README.md index 17a73cac5..fab6baaa3 100644 --- a/seed/README.md +++ b/seed/README.md @@ -956,6 +956,36 @@ keep their error 9 at the line that uses them. - `seed/omc/omc.om`, 11,131 lines and 379 functions. The committed `seed/out/omc` is not refreshed in this change; the integration owner reseeds once per batch. +## Rung R52: om2 query, the white-box hole interface + +A unit whose first line, at byte 0, is `om2 query` is compiled like an `om2 fmt` rest and never writes +a program. When one line of the rest is only `??` and the compiler reaches it as a statement, omc +writes one JSON line: the visible names with types and writability, the function lines, the open +blocks innermost first, the free registers, the contracts in force and the host-word effects used so +far (`docs/one_layer/OMEGESE.md` 9.13). Without a hole the answer is the check alone +(`VALID-UNPROVEN`, exit 0); an omc error is `{"check":{"code","line","status":"INVALID"}}`, exit 1, +with the line counted in the rest as omq counts it; a `??` read as a value is refused with status +`UNKNOWN` (value holes stay with the black-box oracle). The key names and shapes are those of +`seed/query/omq.om` (#838), so an agent can switch from the oracle to the compiler without a new +parser. Names are read only through `nm_name`/`findname`, so the 63-byte name change (#837) needs no +edit here. + +- `gate19` runs all 12 cases of omq at `df23dc7b1`: five statement holes compared with omq's goldens + (hole, scope, fns, obligations), a negative control (a dropped scope name must fail), the two error + objects, three INVALID lines (errors 3, 13, 15: code, line and status equal omq's), two value-hole + refusals (exact line, exit 1), twelve rows proving `??` without the lead keeps its old refusal code + and line, a no-hole unit that writes only `VALID-UNPROVEN`, and four lead-placement refusals. + Against the previous compiler (`2c824805…`) it fails at `arr_call` with error 16. +- Off the query path the output is unchanged on what was checked: the 823 tracked `.om` files give the + same bytes, stderr and exit under both compilers, and the frozen C2 manifest gives the same verdict + and output digest on all 5,876 cases (the six declared failures included). +- Where the two disagree on other holes, the compiler is the reference. omq at `f1e4c6170` matches the + statement-hole answers of the previous stage (`2c3124f6…`) on 625 of 827 sampled holes; the rest + are omq's effects (whole function, with repeats), an empty type for abstract names, first-mention + scope order, and one inline function with a fresh caller (`seed/query/README.md`). +- `seed/omc/omc.om`, 12,736 lines and 425 functions. The committed `seed/out/omc` is not refreshed in + this change; the integration owner reseeds once per batch. + ## How the checks stay honest - `check/a64check.c` and `check/audit.sh` are reference checks only. They call the repo's existing C diff --git a/seed/host/check.sh b/seed/host/check.sh index 4b294cb10..7a0848729 100644 --- a/seed/host/check.sh +++ b/seed/host/check.sh @@ -21,6 +21,7 @@ sh seed/omc/gate15.sh sh seed/omc/gate16.sh sh seed/omc/gate17.sh sh seed/omc/gate18.sh +sh seed/omc/gate19.sh # Executable contracts use the existing fail-closed Omega conductor. B=build/seed/contracts mkdir -p "$B" diff --git a/seed/host/regression.sh b/seed/host/regression.sh index ae3fc9f47..31663e311 100644 --- a/seed/host/regression.sh +++ b/seed/host/regression.sh @@ -6,11 +6,12 @@ mkdir -p build/seed/host stage=$(mktemp -d build/seed/host/regression.XXXXXX) trap 'rm -rf "$stage"' EXIT HUP INT TERM # Struct, break, trap, f32 and f64 are omc-only features (OMEGESE 9.7 to 9.9): om4 refuses them by -# design, and gate6, gate7 and gate8 own those semantics. The strict byte-equality corpus leaves out -# those fixture directories and keeps everything else under the full comparison. +# design, and gate6, gate7 and gate8 own those semantics. The query fixtures hold a `??` hole, which +# only omc's om2 query answers (gate19 owns them). The strict byte-equality corpus leaves out those +# fixture directories and keeps everything else under the full comparison. : > "$stage/inputs" git ls-files seed/rung4/tests seed/omc/tests tests/one_layer/omegese tools/exp445/arms/examples \ - | grep -vE '^seed/omc/tests/(struct|loop|float|paren|layout|keywords)/' \ + | grep -vE '^seed/omc/tests/(struct|loop|float|paren|layout|keywords|query)/' \ | sed -n '/\.om$/p; /\.omegese$/p' > "$stage/all" while IFS= read -r f; do [ -f "$f" ] || continue diff --git a/seed/omc/gate19.sh b/seed/omc/gate19.sh new file mode 100755 index 000000000..ff7f02ef6 --- /dev/null +++ b/seed/omc/gate19.sh @@ -0,0 +1,162 @@ +#!/bin/sh +# gate19.sh -- om2 query, the white-box hole interface (OMEGESE.md 9.13). The cases in seed/omc/tests/query +# and their *.omq.json goldens are copied from the black-box oracle seed/query/omq.om (aien-dev/omega-mv +# #838, feat/omc-query at df23dc7b1). For every statement hole, om2 query must print one JSON line whose +# hole, scope, fns and obligations equal omq's (omq's check, next and compiles come from witness compiles +# and are not part of the white-box answer). The two error objects must carry omq's error text. An omc +# error under om2 query is one JSON check line (code and line as omq's, status INVALID), exit 1; a value +# hole is refused with status UNKNOWN (value holes are omq's, stage 1), exit 1. Neither writes stderr or +# a program. A deliberately wrong answer (a name dropped from scope) must fail the comparison (negative +# control). Without the lead line, ?? stays the refusal it was before om2 query (same code and line), and +# om2 query on a program without a hole writes only its check (VALID-UNPROVEN), no program. +set -eu +R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) +cd "$R" +O=${OMC:-seed/out/omc} +[ -x "$O" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$O" >&2; exit 1; } +D=seed/omc/tests/query +mkdir -p build/seed/r19 +T=$(mktemp -d build/seed/r19/q.XXXXXX) +trap 'rm -rf "$T"' EXIT HUP INT TERM +bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } +n=0 + +# field FILE KEY: the value of top-level key KEY in the one-line JSON object in FILE ("" when absent) +field() { + awk -v key="$2" '{ + s = $0; L = length(s); d = 0; q = 0; want = "\"" key "\":"; out = "" + for (i = 1; i <= L; i++) { + c = substr(s, i, 1) + if (q) { if (c == "\\") { i++; continue } if (c == "\"") q = 0; continue } + if (c == "\"") { + if (d == 1 && substr(s, i, length(want)) == want) { + st = i + length(want); e = st; dd = 0; qq = 0 + for (; e <= L; e++) { + x = substr(s, e, 1) + if (qq) { if (x == "\\") { e++; continue } if (x == "\"") qq = 0; continue } + if (x == "\"") { qq = 1; continue } + if (x == "{" || x == "[") dd++ + if (x == "}" || x == "]") { if (dd == 0) break; dd-- } + if (x == "," && dd == 0) break + } + out = substr(s, st, e - st); break + } + q = 1; continue + } + if (c == "{" || c == "[") d++ + if (c == "}" || c == "]") d-- + } + print out + }' "$1" +} + +# same WHITE OMQ: hole, scope, fns and obligations of the two answers are equal and present +same() { + for k in hole scope fns obligations; do + a=$(field "$1" "$k"); b=$(field "$2" "$k") + [ -n "$a" ] && [ "$a" = "$b" ] || { printf '%s differs: %s | %s\n' "$k" "$a" "$b"; return 1; } + done + return 0 +} + +for c in arr_call else_ret stmt_effects stmt_loop stmt_om2; do + { printf 'om2 query\n'; cat "$D/$c.om"; } > "$T/$c.in" + set +e; "$O" < "$T/$c.in" > "$T/$c.out" 2> "$T/$c.err"; rc=$?; set -e + [ "$rc" = 0 ] || bad "$c: om2 query exit $rc, wanted 0" + [ -s "$T/$c.err" ] && bad "$c: om2 query wrote stderr" + [ "$(wc -l < "$T/$c.out")" = 1 ] || bad "$c: om2 query output is not one line" + same "$T/$c.out" "$D/$c.omq.json" > "$T/$c.why" || bad "$c: $(cat "$T/$c.why")" + n=$((n + 1)) +done +printf 'PASS gate19 %s statement holes: hole, scope, fns and obligations equal omq\n' "$n" + +# negative control: drop the first scope name from a correct answer; the comparison must fail +sed 's/"scope":\[{[^}]*},/"scope":[/' "$T/stmt_loop.out" > "$T/mutant.out" +cmp -s "$T/mutant.out" "$T/stmt_loop.out" && bad "negative control: the mutant equals the answer" +if same "$T/mutant.out" "$D/stmt_loop.omq.json" > "$T/mutant.why"; then + bad "negative control: a dropped scope name passed" +fi +printf 'PASS gate19 negative control: a dropped scope name fails (%s)\n' "$(cut -c1-40 "$T/mutant.why")" + +for c in outside twoholes; do + { printf 'om2 query\n'; cat "$D/$c.om"; } > "$T/$c.in" + set +e; "$O" < "$T/$c.in" > "$T/$c.out" 2> /dev/null; rc=$?; set -e + [ "$rc" = 1 ] || bad "$c: om2 query exit $rc, wanted 1" + a=$(field "$T/$c.out" error); b=$(field "$D/$c.omq.json" error) + [ -n "$a" ] && [ "$a" = "$b" ] || bad "$c: error $a, omq $b" +done +printf 'PASS gate19 error objects: hole outside a function, more than one hole\n' + +# answer: run om2 query on case C; exit WANT, nothing on stderr, exactly one line on stdout +answer() { + { printf 'om2 query\n'; cat "$D/$1.om"; } > "$T/$1.in" + set +e; "$O" < "$T/$1.in" > "$T/$1.out" 2> "$T/$1.err"; rc=$?; set -e + [ "$rc" = "$2" ] || bad "$1: om2 query exit $rc, wanted $2" + [ -s "$T/$1.err" ] && bad "$1: om2 query wrote stderr" + [ "$(wc -l < "$T/$1.out")" = 1 ] && [ "$(wc -c < "$T/$1.out")" = "$(head -n 1 "$T/$1.out" | wc -c)" ] || + bad "$1: om2 query output is not exactly one line" +} + +# INVALID: the omc error is the answer; check.code, check.line and check.status equal omq's +for c in err3 err13 err15; do + answer "$c" 1 + field "$T/$c.out" check > "$T/$c.wc" + field "$D/$c.omq.json" check > "$T/$c.oc" + for k in code line status; do + a=$(field "$T/$c.wc" "$k"); b=$(field "$T/$c.oc" "$k") + [ -n "$a" ] && [ "$a" = "$b" ] || bad "$c: check.$k $a, omq $b" + done +done +printf 'PASS gate19 INVALID: errors 3, 13 and 15 answer omq'"'"'s check code, line and status (3 rows)\n' + +# value holes: refused with the exact UNKNOWN line at omq's hole line, and nothing else on stdout +for c in ret_value value_om2; do + answer "$c" 1 + field "$D/$c.omq.json" hole > "$T/$c.oh" + [ "$(field "$T/$c.oh" kind)" = '"value"' ] || bad "$c: omq does not see a value hole" + printf '{"check":{"code":3,"line":%s,"status":"UNKNOWN","why":"value holes: use omq (stage 1)"}}\n' \ + "$(field "$T/$c.oh" line)" > "$T/$c.want" + cmp -s "$T/$c.want" "$T/$c.out" || bad "$c: $(cat "$T/$c.out")" +done +printf 'PASS gate19 value holes: refused as UNKNOWN at omq'"'"'s hole line, exit 1, no program (2 rows)\n' + +# off: ?? without the lead line is refused exactly as before om2 query (base omc 2c824805 at 0b77e6ea) +while read -r c want code; do + set +e; "$O" < "$D/$c.om" > /dev/null 2> "$T/off.err"; rc=$?; set -e + got=$(tr ' ' _ < "$T/off.err") + [ "$rc" = "$code" ] && [ "$got" = "$want" ] || bad "$c off: exit $rc '$got', wanted $code '$want'" +done <<'ROWS' +arr_call omc:_line_10:_error_4 4 +else_ret omc:_line_6:_error_4 4 +stmt_effects omc:_line_9:_error_4 4 +stmt_loop omc:_line_6:_error_4 4 +stmt_om2 omc:_line_11:_error_4 4 +outside omc:_line_2:_error_16 16 +twoholes omc:_line_3:_error_4 4 +err3 omc:_line_2:_error_3 3 +err13 omc:_line_2:_error_13 13 +err15 omc:_line_5:_error_15 15 +ret_value omc:_line_3:_error_3 3 +value_om2 omc:_line_10:_error_3 3 +ROWS +printf 'PASS gate19 off: ?? without om2 query keeps the refusal code and line (12 rows)\n' + +# no hole: om2 query writes only the check, never a program; the program alone still compiles +sed '/^ *??$/d' "$D/stmt_loop.om" > "$T/nohole.om" +{ printf 'om2 query\n'; cat "$T/nohole.om"; } > "$T/nohole.in" +"$O" < "$T/nohole.om" > "$T/nohole.a" +set +e; "$O" < "$T/nohole.in" > "$T/nohole.b" 2> "$T/nohole.err"; rc=$?; set -e +printf '{"check":{"code":0,"status":"VALID-UNPROVEN"}}\n' > "$T/nohole.want" +[ -s "$T/nohole.a" ] && [ "$rc" = 0 ] && [ ! -s "$T/nohole.err" ] && cmp -s "$T/nohole.want" "$T/nohole.b" || + bad "no hole: om2 query exit $rc, output $(head -c 60 "$T/nohole.b" | od -An -c | head -n 1)" +printf 'PASS gate19 no hole: om2 query writes only VALID-UNPROVEN, exit 0, no program\n' + +# lead placement: om2 query only at byte 0, never inside an om2 fmt or om2 query rest (error 16, line 2) +for lead in 'note x\nom2 query\n' 'om2 query\nom2 query\n' 'om2 query\nom2 fmt\n' 'om2 fmt\nom2 query\n'; do + { printf "$lead"; cat "$D/stmt_loop.om"; } > "$T/lead.in" + set +e; "$O" < "$T/lead.in" > "$T/lead.out" 2> "$T/lead.err"; rc=$?; set -e + [ "$rc" = 16 ] && [ "$(cat "$T/lead.err")" = 'omc: line 2: error 16' ] && [ ! -s "$T/lead.out" ] || + bad "lead $lead: exit $rc, $(cat "$T/lead.err")" +done +printf 'PASS gate19 lead: om2 query after a note, after om2 query or om2 fmt, or before om2 fmt is error 16 (4 rows)\n' +exit 0 diff --git a/seed/omc/omc.om b/seed/omc/omc.om index eed86971c..3762650f6 100644 --- a/seed/omc/omc.om +++ b/seed/omc/omc.om @@ -20,9 +20,10 @@ global out uchar 8388608 global oc ulong 1 note ---- OM-2 profile (spec/omegese-om2.md, OMEGESE.md 9.13). om2 is 1 in an OM-2 unit (its first line -note that is not a note or blank is exactly om2, om2 diag or om2 fmt); om2m 0 compile, 1 diag, 2 fmt; -note om2ln/om2pos the line number and offset of that line; fmtm 1 while a unit is formatted; lbase and -note sbase shift reported lines and bytes back to the original input in fmt mode; tka/tkb the byte span of +note that is not a note or blank is exactly om2, om2 diag, om2 fmt or om2 query); om2m 0 compile, 1 diag, +note 2 fmt, 3 query; om2ln/om2pos the line number and offset of that line; fmtm 1 while a unit is +note formatted; lbase and sbase shift reported lines and bytes back to the original input in fmt and query +note mode; tka/tkb the byte span of note the last token; dexp what was being read (0 word 1 value 2 type 3 name 4 number 5 end 6 newline); note dsev 0 derived, 2 unknown (an undeclared function or struct), 3 error ---- global om2 ulong 1 @@ -36,6 +37,17 @@ global tka ulong 1 global tkb ulong 1 global dexp ulong 1 global dsev ulong 1 +note ---- om2 query: qmode 1 while the unit after an om2 query line is compiled; qel/qelp/qell the host +note word codes function qefl used (qen of them, first use first) with the span of that first use; qcl +note host word code -> effect class; qfst 1 before the first element of the open JSON list ---- +global qmode ulong 1 +global qefl ulong 1 +global qen ulong 1 +global qel ulong 256 +global qelp ulong 256 +global qell ulong 256 +global qcl uchar 256 +global qfst ulong 1 note ---- executable contracts: OM-2 debug by default, release erases only validated pure predicates. note Function prefixes are replayed at returns with their declaration scope, including inline frames. @@ -289,8 +301,12 @@ mputb get d j end end -note fail: write "omc: line N: error E" to stderr (fd 2) and exit with the code +note fail: write "omc: line N: error E" to stderr (fd 2) and exit with the code; in query mode the error +note is the answer instead (qfail) fn fail code ulong to void +if ne get qmode 0 0 +qfail code +end put mc 0 0 mputb 111 mputb 109 @@ -1413,6 +1429,11 @@ if ne lineis q 32771382692703599 7 0 r = ulong 3 end if eq r 0 +if ne qlead q 0 +r = ulong 4 +end +end +if eq r 0 r = cp_mode q end end @@ -1562,7 +1583,7 @@ put om2m 0 0 put om2ln 0 0 put fmtm 0 1 om2lead -if eq get om2m 0 2 +if ge get om2m 0 2 put line 0 get om2ln 0 put tka 0 get om2pos 0 put tkb 0 get om2pos 0 @@ -2294,6 +2315,8 @@ global bnames ulong 512 global bheld ulong 512 global bdead ulong 512 global nb ulong 1 +note bsrc: the input place where each block's body starts (after its head line), for om2 query +global bsrc ulong 512 global curfn ulong 1 note ---- break fixups (1024): output offset of the branch, block index of the loop it leaves ---- global brkpos ulong 1024 @@ -2670,6 +2693,7 @@ put bhead n head put breg n reg put btyp n ty put bdead n 0 +put bsrc n get cur 0 put nb 0 add n 1 fz_push n end @@ -6181,6 +6205,7 @@ if or eq c 77 eq c 193 fail 9 end if or or and ge c 100 le c 177 eq c 197 and ge c 220 le c 222 +qefx c hostval c dst ret end @@ -6225,6 +6250,7 @@ vdone 3 get nm_len sub e 1 5 ret end if or eq c 53 eq c 54 +qefx c x = mul get depth 0 32 put fr add x 8 get nslot 0 rdval 0 8 255 0 @@ -6796,6 +6822,7 @@ end note s_exit: exit value (int): Linux exit (system call 93: MOVZ X8, #93, C6.2.285; SVC #0, C6.2.466); the note path ends. om4 S_EXIT. fn s_exit to void +qefx 82 rdval 0 8 255 0 if ne get rt 0 8 fail 7 @@ -8148,8 +8175,21 @@ eol end note ======== the end of the input: the output ======== -note writeout: the output from byte st to the end, to stdout (error 2), then exit 0. om4 WRITEOUT. +note writeout: the output from byte st to the end, to stdout (error 2), then exit 0. om4 WRITEOUT. In query +note mode a program without a hole that compiles writes no program, only its check (VALID-UNPROVEN). fn writeout st ulong to void +if ne get qmode 0 0 +put oc 0 0 +qs 2480185306991764091 8 +qs 2478497599504677690 8 +qs 8386112018983956538 8 +qs 5494767725372928885 8 +qs 5715719174453281865 8 +qs 137976399938902 6 +qb 10 +put qmode 0 0 +qout 0 +end if ne get fmtm 0 0 fmtout end @@ -8422,6 +8462,9 @@ end if ne k 1 fail 16 end +if ne get qmode 0 0 +qhole +end if ne get om2 0 0 if eq get line 0 get om2ln 0 skipnl @@ -11985,6 +12028,656 @@ put cur 0 p put line 0 l end +note ======== om2 query: the state held at a statement hole (OMEGESE.md 9.13) ======== +note qlead: 1 when the line at q is exactly om2 query (9 bytes, so om2 and the space are read byte by byte) +fn qlead q ulong to ulong +if gt add q 9 get inlen 0 +ret 0 +end +if ne get inp q 111 +ret 0 +end +if ne get inp add q 1 109 +ret 0 +end +if ne get inp add q 2 50 +ret 0 +end +if ne get inp add q 3 32 +ret 0 +end +ret lineis add q 4 521610294641 5 +end + +note qprep: as fmtprep, the rest after the om2 query line is a unit of its own (OM-1 or OM-2 by its own +note first line; om2 fmt or a second om2 query there is error 16); lines are reported against the whole +note input. More than one line that is only ?? writes the error object and exits 1 before compiling. +fn qprep to void +if ne get om2pos 0 0 +put line 0 get om2ln 0 +put tka 0 get om2pos 0 +put tkb 0 get om2pos 0 +fail 16 +end +e = get inlen 0 +r = skipln get om2pos 0 +put lbase 0 get om2ln 0 +put sbase 0 r +n = sub e r +j = ulong 0 +while lt j n +put inp j get inp add r j +j = add j 1 +end +put inlen 0 n +put om2 0 0 +put om2m 0 0 +put om2ln 0 0 +om2lead +if or eq get om2m 0 2 eq get om2m 0 3 +put line 0 get om2ln 0 +put tka 0 get om2pos 0 +put tkb 0 get om2pos 0 +fail 16 +end +put qmode 0 1 +qclinit +if gt qholes 1 +put oc 0 0 +qs 2482168881970750075 8 +qs 8367799649824481850 8 +qs 2334393405426000232 8 +qs 2478506395681439551 8 +qs 125 1 +qb 10 +qout 1 +end +end + +note qholes: the number of lines whose only word is ?? +fn qholes to ulong +e = get inlen 0 +p = ulong 0 +c = ulong 0 +while lt p e +q = skipbl p +if lt add q 1 e +if and eq get inp q 63 eq get inp add q 1 63 +s = skipbl add q 2 +if ge s e +c = add c 1 +else +if eq get inp s 10 +c = add c 1 +end +end +end +end +p = skipln q +end +ret c +end + +note qclinit: host-word code -> effect class, the classes of seed/query/omq.om (hostw): 1 io 2 fs 3 net +note 4 proc 5 env 6 clock 7 random 8 device +fn qclinit to void +put qcl 53 1 +put qcl 54 1 +put qcl 82 1 +put qcl 100 2 +put qcl 101 2 +put qcl 102 2 +put qcl 103 2 +put qcl 104 3 +put qcl 105 3 +put qcl 106 3 +put qcl 107 4 +put qcl 108 4 +put qcl 109 6 +put qcl 110 2 +put qcl 111 2 +put qcl 112 2 +put qcl 113 2 +put qcl 114 3 +put qcl 115 3 +put qcl 116 4 +put qcl 117 2 +put qcl 118 3 +put qcl 119 3 +put qcl 120 6 +put qcl 121 5 +put qcl 122 5 +put qcl 123 4 +put qcl 124 4 +put qcl 125 2 +put qcl 126 2 +put qcl 127 4 +put qcl 128 4 +put qcl 129 4 +put qcl 130 6 +put qcl 131 3 +put qcl 132 2 +put qcl 133 2 +put qcl 134 3 +put qcl 135 7 +put qcl 136 5 +put qcl 137 5 +put qcl 138 2 +put qcl 139 2 +put qcl 140 2 +put qcl 141 2 +put qcl 142 2 +put qcl 143 2 +put qcl 144 2 +put qcl 145 4 +put qcl 146 4 +put qcl 147 4 +put qcl 148 4 +put qcl 149 2 +put qcl 150 2 +put qcl 151 2 +put qcl 153 2 +put qcl 154 4 +put qcl 155 2 +put qcl 156 2 +put qcl 157 2 +put qcl 158 4 +put qcl 159 4 +put qcl 160 4 +put qcl 161 2 +put qcl 162 2 +put qcl 163 4 +put qcl 164 2 +put qcl 165 3 +put qcl 166 8 +put qcl 167 8 +put qcl 168 8 +put qcl 169 8 +put qcl 170 8 +put qcl 171 8 +put qcl 172 8 +put qcl 173 8 +put qcl 174 8 +put qcl 175 8 +put qcl 176 8 +put qcl 177 8 +put qcl 197 2 +put qcl 220 3 +put qcl 221 4 +put qcl 222 3 +end + +note qefx: in query mode, record the first use of host word c (its input span ts/tl) in function curfn +fn qefx c ulong to void +if eq get qmode 0 0 +ret +end +f = get curfn 0 +if ne get qefl 0 f +put qefl 0 f +put qen 0 0 +end +n = get qen 0 +i = ulong 0 +while lt i n +if eq get qel i c +ret +end +i = add i 1 +end +if ge n 256 +ret +end +put qel n c +put qelp n get ts 0 +put qell n get tl 0 +put qen 0 add n 1 +end + +fn qb b uchar to void +emitb b +end + +note qs: the low n bytes of the packed word w +fn qs w ulong n ulong to void +x = w +i = ulong 0 +while lt i n +qb uchar and x 255 +x = shr x 8 +i = add i 1 +end +end + +note qsep: a comma before every element of a list but its first (qfst 1 at the list's opening bracket) +fn qsep to void +if eq get qfst 0 0 +qb 44 +end +put qfst 0 0 +end + +fn qnum v ulong to void +d = new uchar 20 0 +i = ulong 0 +x = v +put d 0 uchar add rem x 10 48 +x = div x 10 +i = add i 1 +while gt x 0 +put d i uchar add rem x 10 48 +x = div x 10 +i = add i 1 +end +j = i +while gt j 0 +j = sub j 1 +qb get d j +end +end + +note qtxt: a JSON string of the input bytes from a to the end of its line (as omq: quote and backslash +note escaped, tab as \t, another byte below 32 as a space) +fn qtxt a ulong to void +qb 34 +e = get inlen 0 +p = a +go = true +while go +if ge p e +go = false +else +b = get inp p +if eq b 10 +go = false +else +if or eq b 34 eq b 92 +qb 92 +qb b +else +if eq b 9 +qb 92 +qb 116 +else +if lt b 32 +qb 32 +else +qb b +end +end +end +p = add p 1 +end +end +end +qb 34 +end + +note qline: the line holding input place p, from its first word +fn qline p ulong to void +a = p +go = true +while go +if eq a 0 +go = false +else +if eq get inp sub a 1 10 +go = false +else +a = sub a 1 +end +end +end +qtxt skipbl a +end + +note qlnof: the line number of input place p +fn qlnof p ulong to ulong +n = ulong 1 +i = ulong 0 +while lt i p +if eq get inp i 10 +n = add n 1 +end +i = add i 1 +end +ret n +end + +note qname: the bytes of name i. The one place that reads the packing of the name store (nm_name): a +note change to name storage changes this function only. +fn qname i ulong to void +x = get nm_name i +n = ulong 0 +while and lt n 8 ne and x 255 0 +qb uchar and x 255 +x = shr x 8 +n = add n 1 +end +end + +note qtype: the type of name i as omq prints it; an array (kinds 1..5) gets []; struct and abstract types +note are printed by class only +fn qtype i ulong to void +t = ulong get nm_type i +if eq t 1 +qs 1819242338 4 +end +if eq t 2 +qs 491260502901 5 +end +if eq t 3 +qs 128034844210037 6 +end +if eq t 4 +qs 1953393013 4 +end +if eq t 5 +qs 444234427509 5 +end +if eq t 6 +qs 1702132066 4 +end +if eq t 7 +qs 500136110195 5 +end +if eq t 8 +qs 7630441 3 +end +if eq t 9 +qs 1735290732 4 +end +if eq t 10 +qs 3289958 3 +end +if eq t 11 +qs 3421798 3 +end +if and ge t 16 lt t 64 +qs 127970521019507 6 +end +if ge t 64 +qs 8386654075301880417 8 +end +k = ulong get nm_kind i +if and ge k 1 le k 5 +qs 23899 2 +end +end + +note qbk: an open block's word (bkind 1 if, 2 else, 3 while, 4 for, 5 unrolled for, 6 inline frame) +fn qbk k ulong to void +if eq k 1 +qs 577136930 4 +end +if eq k 2 +qs 37819123524898 6 +end +if eq k 3 +qs 9681665507489570 7 +end +if or eq k 4 eq k 5 +qs 147948791330 5 +end +if eq k 6 +qs 2478508569007122722 8 +end +end + +note qcon: the clauses in force (OM-2): the function's prefix clauses, then the invariants of the open +note loops, outermost first (bsrc: the input place after each loop's head line) +fn qcon to void +if eq get om2 0 0 +ret +end +put cur 0 get cfpos 0 +put line 0 get cfline 0 +k = cp_next +while ne k 0 +qsep +qtxt get ts 0 +skipnl +k = cp_next +end +n = get nb 0 +i = ulong 0 +while lt i n +b = get bkind i +if and ge b 3 le b 5 +put cur 0 get bsrc i +k = cp_next +while eq k 3 +qsep +qtxt get ts 0 +skipnl +k = cp_next +end +end +i = add i 1 +end +end + +note qeff: the host words the current function used up to the hole, first use first, as word:class +fn qeff to void +if ne get qefl 0 get curfn 0 +ret +end +n = get qen 0 +i = ulong 0 +while lt i n +qsep +qb 34 +a = get qelp i +j = ulong 0 +while lt j get qell i +qb get inp add a j +j = add j 1 +end +qb 58 +c = ulong get qcl get qel i +if eq c 1 +qs 28521 2 +end +if eq c 2 +qs 29542 2 +end +if eq c 3 +qs 7628142 3 +end +if eq c 4 +qs 1668248176 4 +end +if eq c 5 +qs 7761509 3 +end +if eq c 6 +qs 461229747299 5 +end +if eq c 7 +qs 120325193752946 6 +end +if eq c 8 +qs 111477645534564 6 +end +qb 34 +i = add i 1 +end +end + +note qout: the JSON line in out to stdout, then exit with code +fn qout code ulong to void +p = ulong 0 +go = true +while go +if ge p get oc 0 +go = false +else +n = write 1 out p sub get oc 0 p +if le n 0 +fail 2 +end +p = add p ulong n +end +end +exit int code +end + +note qfail: in query mode an omc error is the answer: one JSON line {"check":{"code","line","status"}} on +note stdout, nothing on stderr, exit 1. The line is the line in the unit after the om2 query line (as omq +note reports it). Error 3 at a ?? token is a value hole, which this interface does not answer: status +note UNKNOWN and a pointer to seed/query/omq.om. Any other error is INVALID: without a hole the program +note is rejected, and with a hole the error lies before it (the hole's answer is written when it is read). +fn qfail code ulong to void +put qmode 0 0 +vh = false +if eq code 3 +if eq get tl 0 2 +s = get ts 0 +if eq get inp s 63 +if eq get inp add s 1 63 +vh = true +end +end +end +end +put oc 0 0 +qs 2480185306991764091 8 +qs 2478497599504677690 8 +qs 58 1 +qnum code +qs 4189022128297484844 8 +qnum get line 0 +if vh +qs 8319683848551211564 8 +qs 5714587776987576866 8 +qs 8748373264820227671 8 +qs 7310868735955450402 8 +qs 2322295437311043616 8 +qs 2337770005634315125 8 +qs 3539940801804268328 8 +qs 2105352745 4 +else +qs 8319683848551211564 8 +qs 5494767914603133474 8 +qs 538970309705 5 +end +qb 10 +qout 1 +end + +note qhole: in query mode, at a statement hole (?? the only word on its line) write the held state as one +note JSON line (the scope, fns and obligations of seed/query/omq.om) and exit 0 with no program; a hole +note outside a function writes the error object and exits 1. Any other word returns. +fn qhole to void +if ne get tl 0 2 +ret +end +s = get ts 0 +if ne get inp s 63 +ret +end +if ne get inp add s 1 63 +ret +end +p = skipbl get cur 0 +if lt p get inlen 0 +if ne get inp p 10 +ret +end +end +put oc 0 0 +if eq get curret 0 0 +qs 2482168881970750075 8 +qs 8027701955704136250 8 +qs 8029390865705231724 8 +qs 7306080439996326004 8 +qs 8386668381597622560 8 +qs 537448574825 5 +qb 10 +qout 1 +end +qs 4189022119807951483 8 +qs 4189022128297484923 8 +qnum get line 0 +qs 4189021028785791532 8 +qs 7308609320817816354 8 +qs 6876545977996702830 8 +qs 63919405033836 6 +f = sub get curfn 0 1 +qnum qlnof get fn_off f +qs 2479359620953678380 8 +qs 58 1 +qnum add get nb 0 1 +qs 7309464668146379901 8 +qs 5978658 3 +put qfst 0 1 +n = get nn 0 +i = ulong 0 +while lt i n +if eq findname get nm_name i add i 1 +qsep +qs 4189022123868430971 8 +qs 34 1 +qname i +qs 2478510836879076386 8 +qs 8762 2 +qtype i +qb 34 +k = ulong get nm_kind i +if or or eq k 1 eq k 3 eq k 4 +qs 7089075284698669612 8 +qs 7310875413622973804 8 +end +qb 125 +end +i = add i 1 +end +qs 4189037521405095005 8 +qs 91 1 +put qfst 0 1 +j = ulong 0 +while lt j get nf 0 +qsep +qline get fn_off j +j = add j 1 +end +qs 7451606228488301661 8 +qs 4189037521560761441 8 +qs 7598807797348049531 8 +qs 975335023 4 +qline get fn_off f +qs 4189031985365066284 8 +qs 91 1 +put qfst 0 1 +i = get nb 0 +while gt i 0 +i = sub i 1 +qsep +qbk get bkind i +end +qsep +qs 577660450 4 +r = add get npar 0 get held 0 +v = ulong 0 +if lt r 16 +v = sub 16 r +end +qs 6877954741329079389 8 +qs 63919404446310 6 +qnum v +qs 7021802786688016940 8 +qs 100305244222563 6 +put qfst 0 1 +qcon +qs 7162243372372077661 8 +qs 391817360244 5 +put qfst 0 1 +qeff +qs 8224093 3 +qb 10 +qout 0 +end + note main: read all of stdin note (8 MiB at most, error 14; a read error is 1), find the mode, then one note statement per line from output byte 180 (om4 START .. STMT) @@ -12014,6 +12707,9 @@ om2lead if eq get om2m 0 2 fmtprep end +if eq get om2m 0 3 +qprep +end if ne ir_lead 0 put irmode 0 1 ir_run diff --git a/seed/omc/tests/query/arr_call.om b/seed/omc/tests/query/arr_call.om new file mode 100644 index 000000000..77f60db1a --- /dev/null +++ b/seed/omc/tests/query/arr_call.om @@ -0,0 +1,11 @@ +fn fill a edit uint 64 n ulong to void +put a 0 uint n +end +fn main to int +b = new uchar 64 0 +s = new uint 8 0 +k = new uint 64 0 +v ulong 5 +?? +ret int v +end diff --git a/seed/omc/tests/query/arr_call.omq.json b/seed/omc/tests/query/arr_call.omq.json new file mode 100644 index 000000000..7f4f6361a --- /dev/null +++ b/seed/omc/tests/query/arr_call.omq.json @@ -0,0 +1 @@ +{"hole":{"line":9,"kind":"statement","fn_line":4,"depth":1},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"b","type":"uchar[]","writable":true},{"name":"s","type":"uint[]","writable":true},{"name":"k","type":"uint[]","writable":true},{"name":"v","type":"ulong"}],"fns":["fn fill a edit uint 64 n ulong to void","fn main to int"],"next":["ret <int>","v = <ulong>","NEW = <value>","if <bool>","while <bool>","for NAME T COUNT","trap <1..255>","exit <int>","put b <ulong> <uchar>","put s <ulong> <uint>","put k <ulong> <uint>","fill k ulong 1"],"obligations":{"function":"fn main to int","open":["fn"],"regs_free":12,"contracts":[],"effects":[]},"compiles":57} diff --git a/seed/omc/tests/query/else_ret.om b/seed/omc/tests/query/else_ret.om new file mode 100644 index 000000000..533a82ba5 --- /dev/null +++ b/seed/omc/tests/query/else_ret.om @@ -0,0 +1,10 @@ +fn choose a int to int +if lt a 0 +ret neg a +else +?? +end +end +fn main to int +ret choose int 3 +end diff --git a/seed/omc/tests/query/else_ret.omq.json b/seed/omc/tests/query/else_ret.omq.json new file mode 100644 index 000000000..09983df83 --- /dev/null +++ b/seed/omc/tests/query/else_ret.omq.json @@ -0,0 +1 @@ +{"hole":{"line":5,"kind":"statement","fn_line":1,"depth":2},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"a","type":"int"}],"fns":["fn choose a int to int","fn main to int"],"next":["ret <int>","a = <int>","NEW = <value>","if <bool>","while <bool>","for NAME T COUNT","trap <1..255>","exit <int>","end"],"obligations":{"function":"fn choose a int to int","open":["else","fn"],"regs_free":15,"contracts":[],"effects":[]},"compiles":42} diff --git a/seed/omc/tests/query/err13.om b/seed/omc/tests/query/err13.om new file mode 100644 index 000000000..fe9561ece --- /dev/null +++ b/seed/omc/tests/query/err13.om @@ -0,0 +1,4 @@ +fn main to int +abcdefghijk = uint 1 +ret int abcdefghijk +end diff --git a/seed/omc/tests/query/err13.omq.json b/seed/omc/tests/query/err13.omq.json new file mode 100644 index 000000000..97b04c6df --- /dev/null +++ b/seed/omc/tests/query/err13.omq.json @@ -0,0 +1 @@ +{"check":{"code":13,"line":2,"sev":"unknown","col":1,"expect":"name","found":"abcdefghijk","obligation":"-","span":[15,26],"why":"name longer than 8 characters: shorten it","fix_rename":"abcdefg0","rc_after_fix":0,"status":"INVALID"},"compiles":5} diff --git a/seed/omc/tests/query/err15.om b/seed/omc/tests/query/err15.om new file mode 100644 index 000000000..f38e6b946 --- /dev/null +++ b/seed/omc/tests/query/err15.om @@ -0,0 +1,4 @@ +fn main to int +x = uint 1 +if eq x uint 1 +ret 0 diff --git a/seed/omc/tests/query/err15.omq.json b/seed/omc/tests/query/err15.omq.json new file mode 100644 index 000000000..e40dea205 --- /dev/null +++ b/seed/omc/tests/query/err15.omq.json @@ -0,0 +1 @@ +{"check":{"code":15,"line":5,"sev":"incomplete","col":1,"expect":"end","found":"","obligation":"-","span":[47,47],"why":"missing end: close every fn/if/while/for with end","fix_append_end":2,"rc_after_fix":18,"status":"INVALID"},"compiles":6} diff --git a/seed/omc/tests/query/err3.om b/seed/omc/tests/query/err3.om new file mode 100644 index 000000000..0ca4da28f --- /dev/null +++ b/seed/omc/tests/query/err3.om @@ -0,0 +1,5 @@ +fn main to int +x = get g 0 +ret int x +end +global g uint 1 diff --git a/seed/omc/tests/query/err3.omq.json b/seed/omc/tests/query/err3.omq.json new file mode 100644 index 000000000..0cd51ca21 --- /dev/null +++ b/seed/omc/tests/query/err3.omq.json @@ -0,0 +1 @@ +{"check":{"code":3,"line":2,"sev":"error","col":9,"expect":"name","found":"g","obligation":"-","span":[23,24],"why":"unknown name: define it before this line (globals, consts and texts above their first use; locals in an enclosing block that is still open)","fix_move_up":"global g uint 1","rc_after_fix":0,"status":"INVALID"},"compiles":5} diff --git a/seed/omc/tests/query/outside.om b/seed/omc/tests/query/outside.om new file mode 100644 index 000000000..a87b32ed9 --- /dev/null +++ b/seed/omc/tests/query/outside.om @@ -0,0 +1,2 @@ +global g uint 1 +?? diff --git a/seed/omc/tests/query/outside.omq.json b/seed/omc/tests/query/outside.omq.json new file mode 100644 index 000000000..d4905df79 --- /dev/null +++ b/seed/omc/tests/query/outside.omq.json @@ -0,0 +1 @@ +{"error":"the hole is not inside a function","compiles":2} diff --git a/seed/omc/tests/query/ret_value.om b/seed/omc/tests/query/ret_value.om new file mode 100644 index 000000000..8551647a4 --- /dev/null +++ b/seed/omc/tests/query/ret_value.om @@ -0,0 +1,4 @@ +fn main to int +n = uint 3 +ret int add n ?? +end diff --git a/seed/omc/tests/query/ret_value.omq.json b/seed/omc/tests/query/ret_value.omq.json new file mode 100644 index 000000000..255e68540 --- /dev/null +++ b/seed/omc/tests/query/ret_value.omq.json @@ -0,0 +1 @@ +{"hole":{"line":3,"kind":"value","fn_line":1,"depth":1},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"n","type":"uint"}],"fns":["fn main to int"],"expect":["uint"],"next":["n","add <uint> <uint>","sub <uint> <uint>","mul <uint> <uint>","div <uint> <uint>","rem <uint> <uint>","and <uint> <uint>","or <uint> <uint>","xor <uint> <uint>","shl <uint> <uint>","shr <uint> <uint>","uint <any>"],"obligations":{"function":"fn main to int","open":["fn"],"regs_free":15,"contracts":[],"effects":[]},"compiles":37} diff --git a/seed/omc/tests/query/stmt_effects.om b/seed/omc/tests/query/stmt_effects.om new file mode 100644 index 000000000..52e3c784d --- /dev/null +++ b/seed/omc/tests/query/stmt_effects.om @@ -0,0 +1,10 @@ +global tot ulong 1 +fn main to int +b = new uchar 4 65 +if true +z = ulong 5 +end +r = write 1 b 0 4 +?? +ret 0 +end diff --git a/seed/omc/tests/query/stmt_effects.omq.json b/seed/omc/tests/query/stmt_effects.omq.json new file mode 100644 index 000000000..3a28605ed --- /dev/null +++ b/seed/omc/tests/query/stmt_effects.omq.json @@ -0,0 +1 @@ +{"hole":{"line":8,"kind":"statement","fn_line":2,"depth":1},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"tot","type":"ulong[]","writable":true},{"name":"b","type":"uchar[]","writable":true},{"name":"r","type":"long"}],"fns":["fn main to int"],"next":["ret <int>","r = <long>","NEW = <value>","if <bool>","while <bool>","for NAME T COUNT","trap <1..255>","exit <int>","put tot <ulong> <ulong>","put b <ulong> <uchar>"],"obligations":{"function":"fn main to int","open":["fn"],"regs_free":14,"contracts":[],"effects":["write:io"]},"compiles":55} diff --git a/seed/omc/tests/query/stmt_loop.om b/seed/omc/tests/query/stmt_loop.om new file mode 100644 index 000000000..0954362fa --- /dev/null +++ b/seed/omc/tests/query/stmt_loop.om @@ -0,0 +1,13 @@ +global cnt ulong 4 +fn sum a view uint 8 n ulong to ulong +s = ulong 0 +for i ulong n +?? +end +ret s +end +fn main to int +b = new uint 8 1 +t = sum b 8 +ret int t +end diff --git a/seed/omc/tests/query/stmt_loop.omq.json b/seed/omc/tests/query/stmt_loop.omq.json new file mode 100644 index 000000000..0f65e0798 --- /dev/null +++ b/seed/omc/tests/query/stmt_loop.omq.json @@ -0,0 +1 @@ +{"hole":{"line":5,"kind":"statement","fn_line":2,"depth":2},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"cnt","type":"ulong[]","writable":true},{"name":"a","type":"uint[]"},{"name":"n","type":"ulong"},{"name":"s","type":"ulong"},{"name":"i","type":"ulong"}],"fns":["fn sum a view uint 8 n ulong to ulong","fn main to int"],"next":["ret <ulong>","n = <ulong>","s = <ulong>","i = <ulong>","NEW = <value>","if <bool>","while <bool>","for NAME T COUNT","break","continue","trap <1..255>","exit <int>","end","put cnt <ulong> <ulong>"],"obligations":{"function":"fn sum a view uint 8 n ulong to ulong","open":["for","fn"],"regs_free":11,"contracts":[],"effects":[]},"compiles":71} diff --git a/seed/omc/tests/query/stmt_om2.om b/seed/omc/tests/query/stmt_om2.om new file mode 100644 index 000000000..9c0b8dbf4 --- /dev/null +++ b/seed/omc/tests/query/stmt_om2.om @@ -0,0 +1,20 @@ +om2 +fn sq x uint to ulong +ret mul ulong x ulong x +end +fn sum a view uint 8 n ulong to ulong +requires le n 8 +s = ulong 0 +for i ulong n +invariant le i n +?? +end +ret s +end +fn main to int +b = new uint 8 1 +c = new uchar 2 65 +t = sum b 8 +r = write 1 c 0 2 +ret int t +end diff --git a/seed/omc/tests/query/stmt_om2.omq.json b/seed/omc/tests/query/stmt_om2.omq.json new file mode 100644 index 000000000..db92e3b92 --- /dev/null +++ b/seed/omc/tests/query/stmt_om2.omq.json @@ -0,0 +1 @@ +{"hole":{"line":10,"kind":"statement","fn_line":5,"depth":2},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"a","type":"uint[]"},{"name":"n","type":"ulong"},{"name":"s","type":"ulong"},{"name":"i","type":"ulong"}],"fns":["fn sq x uint to ulong","fn sum a view uint 8 n ulong to ulong","fn main to int"],"next":["ret <ulong>","n = <ulong>","s = <ulong>","i = <ulong>","NEW = <value>","if <bool>","while <bool>","for NAME T COUNT","break","continue","trap <1..255>","exit <int>","end","invariant <bool>"],"obligations":{"function":"fn sum a view uint 8 n ulong to ulong","open":["for","fn"],"regs_free":11,"contracts":["requires le n 8","invariant le i n"],"effects":[]},"compiles":66} diff --git a/seed/omc/tests/query/twoholes.om b/seed/omc/tests/query/twoholes.om new file mode 100644 index 000000000..d62bc91e6 --- /dev/null +++ b/seed/omc/tests/query/twoholes.om @@ -0,0 +1,4 @@ +fn main to int +?? +?? +end diff --git a/seed/omc/tests/query/twoholes.omq.json b/seed/omc/tests/query/twoholes.omq.json new file mode 100644 index 000000000..3aef4d5ea --- /dev/null +++ b/seed/omc/tests/query/twoholes.omq.json @@ -0,0 +1 @@ +{"error":"more than one ?? hole","compiles":2} diff --git a/seed/omc/tests/query/value_om2.om b/seed/omc/tests/query/value_om2.om new file mode 100644 index 000000000..935a18bbf --- /dev/null +++ b/seed/omc/tests/query/value_om2.om @@ -0,0 +1,20 @@ +om2 +fn sq x uint to ulong +ret mul ulong x ulong x +end +fn sum a view uint 8 n ulong to ulong +requires le n 8 +s = ulong 0 +for i ulong n +invariant le i n +s = add s ?? +end +ret s +end +fn main to int +b = new uint 8 1 +c = new uchar 2 65 +t = sum b 8 +r = write 1 c 0 2 +ret int t +end diff --git a/seed/omc/tests/query/value_om2.omq.json b/seed/omc/tests/query/value_om2.omq.json new file mode 100644 index 000000000..7ebe5f495 --- /dev/null +++ b/seed/omc/tests/query/value_om2.omq.json @@ -0,0 +1 @@ +{"hole":{"line":10,"kind":"value","fn_line":5,"depth":2},"check":{"code":0,"status":"INCOMPLETE"},"scope":[{"name":"a","type":"uint[]"},{"name":"n","type":"ulong"},{"name":"s","type":"ulong"},{"name":"i","type":"ulong"}],"fns":["fn sq x uint to ulong","fn sum a view uint 8 n ulong to ulong","fn main to int"],"expect":["ulong"],"next":["n","s","i","add <ulong> <ulong>","sub <ulong> <ulong>","mul <ulong> <ulong>","div <ulong> <ulong>","rem <ulong> <ulong>","and <ulong> <ulong>","or <ulong> <ulong>","xor <ulong> <ulong>","shl <ulong> <ulong>","shr <ulong> <ulong>","ulong <any>","len a","sq uint 1","sum a ulong 1"],"obligations":{"function":"fn sum a view uint 8 n ulong to ulong","open":["for","fn"],"regs_free":11,"contracts":["requires le n 8","invariant le i n"],"effects":[]},"compiles":68}