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
omega-mv / seed / omc / sites / found-ca_st-1.om
| 1 | note sites: found by a one-token change of a tracked program (121 to 300 lines); reaches the omc error site in ca_st (code 19) |
| 2 | note SC1-Q API and status contract frozen in README.md. Raw structs are trusted not sealed. |
| 3 | struct bqty val ulong cap ulong end |
| 4 | struct qobj ident ulong ver ulong extent ulong end |
| 5 | struct qslic ident ulong ver ulong off ulong count ulong end |
| 6 | |
| 7 | fn qword out edit bqty raw ulong cap ulong to int |
| 8 | if gt raw cap |
| 9 | ret int 3 |
| 10 | end |
| 11 | put out val raw |
| 12 | put out cap cap |
| 13 | ret int 0 |
| 14 | end |
| 15 | |
| 16 | fn qsigned out edit bqty raw long cap ulong to int |
| 17 | if lt raw long 0 |
| 18 | ret int 2 |
| 19 | end |
| 20 | ret qword out ulong raw cap |
| 21 | end |
| 22 | |
| 23 | fn qvalid a view bqty to int |
| 24 | if gt get a val get a cap |
| 25 | ret int 1 |
| 26 | end |
| 27 | ret int 0 |
| 28 | end |
| 29 | |
| 30 | fn qpair a view bqty b view bqty to int |
| 31 | if ne qvalid a int 0 |
| 32 | ret int 1 |
| 33 | end |
| 34 | if ne qvalid b int 0 |
| 35 | ret int 1 |
| 36 | end |
| 37 | if ne get a cap get b cap |
| 38 | ret int 2 |
| 39 | end |
| 40 | ret int 0 |
| 41 | end |
| 42 | |
| 43 | fn qadd out edit bqty a view bqty b view bqty to int |
| 44 | rc = qpair a a |
| 45 | if ne rc int 0 |
| 46 | ret rc |
| 47 | end |
| 48 | note Q1_ADD_GUARD mutation removes this check only. |
| 49 | if gt get b val sub get a cap get a val |
| 50 | ret int 3 |
| 51 | end |
| 52 | put out val add get a val get b val |
| 53 | put out cap get a cap |
| 54 | ret int 0 |
| 55 | end |
| 56 | |
| 57 | fn qsub out edit bqty a view bqty b view bqty to int |
| 58 | rc = qpair a b |
| 59 | if ne rc int 0 |
| 60 | ret rc |
| 61 | end |
| 62 | if gt get b val get a val |
| 63 | ret int 3 |
| 64 | end |
| 65 | put out val sub get a val get b val |
| 66 | put out cap get a cap |
| 67 | ret int 0 |
| 68 | end |
| 69 | |
| 70 | fn qmul out edit bqty a view bqty b view bqty to int |
| 71 | rc = qpair a b |
| 72 | if ne rc int 0 |
| 73 | ret rc |
| 74 | end |
| 75 | note Q4_MUL_GUARD mutation removes this check only. |
| 76 | if ne get a val ulong 0 |
| 77 | if gt get b val div get a cap get a val |
| 78 | ret int 3 |
| 79 | end |
| 80 | end |
| 81 | put out val mul get a val get b val |
| 82 | put out cap get a cap |
| 83 | ret int 0 |
| 84 | end |
| 85 | |
| 86 | fn qnarrow out edit bqty a view bqty cap ulong to int |
| 87 | rc = qvalid a |
| 88 | if ne rc int 0 |
| 89 | ret rc |
| 90 | end |
| 91 | if gt cap get a cap |
| 92 | ret int 2 |
| 93 | end |
| 94 | if gt get a val cap |
| 95 | ret int 3 |
| 96 | end |
| 97 | put out val get a val |
| 98 | put out cap cap |
| 99 | ret int 0 |
| 100 | end |
| 101 | |
| 102 | fn qnext out edit bqty a view bqty to int |
| 103 | rc = qvalid a |
| 104 | if ne rc int 0 |
| 105 | ret rc |
| 106 | end |
| 107 | if eq get a val get a cap |
| 108 | ret int 3 |
| 109 | end |
| 110 | put out val add get a val ulong 1 |
| 111 | put out cap get a cap |
| 112 | ret int 0 |
| 113 | end |
| 114 | |
| 115 | fn qtyslice out edit qslic off view bqty count view bqty expect view qobj current view qobj to int |
| 116 | if ne get expect ident get current ident |
| 117 | ret int 4 |
| 118 | end |
| 119 | if ne get expect ver get current ver |
| 120 | ret int 4 |
| 121 | end |
| 122 | if ne get expect extent get current extent |
| 123 | ret int 4 |
| 124 | end |
| 125 | rc = qpair off count |
| 126 | if ne rc int 0 |
| 127 | ret rc |
| 128 | end |
| 129 | if ne get off cap get current extent |
| 130 | ret int 2 |
| 131 | end |
| 132 | if gt get off val get current extent |
| 133 | ret int 3 |
| 134 | end |
| 135 | if gt get count val sub get current extent get off val |
| 136 | ret int 3 |
| 137 | end |
| 138 | put out ident get current ident |
| 139 | put out ver get current ver |
| 140 | put out off get off val |
| 141 | put out count get count val |
| 142 | ret int 0 |
| 143 | end |