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 / bridge / shlib / imp.om

61 lines · 2074 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0
3note bridge/shlib/imp.om: the unit of the gate's import library (imp.tsv): imports from the dependency library
4note (dep.om) and the C library, frame exports over three states, and a lock (imp.tsv's lock row).
5extern fn omega_dep_twice a ulong to ulong
6extern fn omega_dep_dirty to int
7extern fn omega_dep_sub a ulong b ulong to ulong
8extern fn omega_dep_rd c view uint 1024 to uint
9extern fn strlen s view uchar 4096 to ulong
10note many values live across each import call: omc keeps them over the BL, the veneer keeps x7 and x30
11export fn omega_imp_live fr view ulong 11 to ulong
12a = get fr 0
13b = add a 1
14c = add a 2
15d = add a 3
16e = add a 4
17f = add a 5
18g = omega_dep_twice a
19h = omega_dep_twice b
20ret add add add add add add c d e f g h b
21end
22note a counter in state ImpS: 1, 2, 3 over the calls
23export fn omega_imp_count fr view ulong 11 s edit ulong 8 to ulong
24put s 0 add get s 0 1
25ret get s 0
26end
27note a trap inside a frame export: the lock must be released on the trap path
28export fn omega_imp_trap fr view ulong 11 to ulong
29ret div get fr 0 get fr 1
30end
31note a dirty result imported as int: omc's int add traps without the veneer's sign extension
32export fn omega_imp_dirty fr view ulong 11 to int
33ret add omega_dep_dirty int 1
34end
35note the import row of omega_dep_sub swaps its arguments
36export fn omega_imp_swap fr view ulong 11 to ulong
37ret omega_dep_sub get fr 0 get fr 1
38end
39note the import row of omega_dep_rd moves the pointer by 8 bytes (two uints)
40export fn omega_imp_off fr view ulong 11 t edit uint 1024 to uint
41put t 2 uint get fr 0
42ret omega_dep_rd t
43end
44note the C library's strlen over the text state ImpT
45export fn omega_imp_strlen fr view ulong 11 t edit uchar 4096 to ulong
46for i ulong get fr 0 bound 4095
47put t i 97
48end
49put t get fr 0 0
50ret strlen t
51end
52note the frame: the second C argument, and the state addresses (fr 8..10) are 64-byte aligned and distinct
53export fn omega_imp_frame fr view ulong 11 to ulong
54if ne and get fr 8 63 0
55ret 1000
56end
57if eq get fr 8 get fr 9
58ret 1001
59end
60ret get fr 1
61end