interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / front / cases / nom-wrap.sh

26 lines · 1085 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# Regenerates the wrapped struct run units nom_<name>.om from seed/omc/tests/struct/<name>.om.
4# ng front-ir lowers only `fn main to int`; these fixtures return uint, ulong or long, so main becomes `subject`
5# and a new `fn main to int` returns it as an int. Run from the repository root:
6# sh seed/ng/front/cases/nom-wrap.sh [check]
7# With `check` nothing is written: exit 1 if a copy differs from what the originals generate.
8set -e
9bad=0
10for n in t1 t1x t1y t2 t4 t5 t6 t7 t7b t8 t9; do
11 src=seed/omc/tests/struct/$n.om
12 out=seed/ng/front/cases/nom_$n.om
13 tmp=$(mktemp)
14 {
15 printf 'note Wrapped copy of %s for gate-front-ir: main to uint, ulong or long becomes subject (nom-wrap.sh).\n' "$src"
16 sed 's/^fn main to \(uint\|ulong\|long\)$/fn subject to \1/' "$src"
17 printf 'fn main to int\nret int subject\nend\n'
18 } > "$tmp"
19 if [ "$1" = check ]; then
20 cmp -s "$tmp" "$out" || { echo "differs: $out"; bad=1; }
21 rm -f "$tmp"
22 else
23 mv "$tmp" "$out"
24 fi
25done
26exit $bad