Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/visor/visor_world.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / visor / visor_world.om` 417 lines ยท 9975 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Pure seeded OM-2 Visor lane 6: read-only World view (port of src/visor/visor_world.c: 3 note VisorWorldView, visor_world_gap_append, visor_world_unattached and the two 4 note deterministic renderings). The runtime snapshot (src/visor/rx/visor_world_rx.c) 5 note is not part of the V1 omega binary and stays in C with tests/visor/test_visor_world.c. 6 note Depends on visor.om. 7 note The omega binary renders only the unattached view: tools/omega_ops.om vom_world calls 8 note vwld_unattached and then a rendering, and nothing else in omega fills the view 9 note (tests/visor/check_world_unattached.sh enforces both). That view, text and JSON, is 10 note pinned against the C by make test-visor-effect-parity (corpus command G). 11 12 const VWLD_MAX_OBJECTS ulong 32 13 14 text vwld_g_unatt "no resident World attached in this session: the V1 omega binary does not link the runtime (src/runtime); nothing here is observed" 15 text vwld_t_unattached "unattached" 16 text vwld_t_attached "attached" 17 text vwld_t_dash "-" 18 text vwld_t_none "none" 19 text vwld_t_sep "; " 20 text vwld_t_w "world: " 21 text vwld_t_state " state: " 22 text vwld_t_gen " generation: " 23 text vwld_t_genno " generation: (not observable)\n" 24 text vwld_t_res " resident objects: " 25 text vwld_t_shown " (shown " 26 text vwld_t_rpar ")\n" 27 text vwld_t_rxn " reactions: " 28 text vwld_t_act " active work: " 29 text vwld_t_pub " published results: " 30 text vwld_t_pubno " (not observable)" 31 text vwld_t_st " staged effects: " 32 text vwld_t_stno " staged effects: (not visible)\n" 33 text vwld_t_tail " publication tail: " 34 text vwld_t_dig " digest: " 35 text vwld_t_obj " object " 36 text vwld_t_gap " gap: " 37 text vwld_t_note " note: view only; this view holds no authority over the World\n" 38 text vwld_j_att "{\"attached\":" 39 text vwld_j_state ",\"state\":" 40 text vwld_j_gen ",\"generation\":" 41 text vwld_j_genobs ",\"generation_observable\":" 42 text vwld_j_res ",\"resident_object_count\":" 43 text vwld_j_rxn ",\"reaction_count\":" 44 text vwld_j_act ",\"active_work\":" 45 text vwld_j_pub ",\"published_results\":" 46 text vwld_j_st ",\"staged_effects\":" 47 text vwld_j_stv ",\"staged_effects_visible\":" 48 text vwld_j_tail ",\"publication_tail\":" 49 text vwld_j_dig ",\"digest\":" 50 text vwld_j_objs ",\"objects\":[" 51 text vwld_j_oid "{\"id\":" 52 text vwld_j_okind ",\"kind\":" 53 text vwld_j_ostate ",\"state\":" 54 text vwld_j_gap "],\"gap_note\":" 55 text vwld_j_auth ",\"authority\":false}" 56 text vwld_j_true "true" 57 text vwld_j_false "false" 58 text vwld_j_null "null" 59 text vwld_hx "`0123456789abcdef`" 60 61 note ---- VisorWorldView ---- 62 global vwld_generation ulong 1 63 global vwld_state uchar 64 64 global vwld_slen ulong 1 65 global vwld_res_cnt ulong 1 66 global vwld_act_cnt ulong 1 67 global vwld_rxn_cnt ulong 1 68 global vwld_pub_cnt ulong 1 69 global vwld_staged ulong 1 70 global vwld_staged_vis ulong 1 71 global vwld_pub_tail ulong 1 72 global vwld_digest uchar 72 73 global vwld_dlen ulong 1 74 global vwld_attached ulong 1 75 global vwld_gap uchar 256 76 global vwld_glen ulong 1 77 global vwld_obj_cnt ulong 1 78 global vwld_oid uchar 2304 79 global vwld_oidl ulong 32 80 global vwld_okind uchar 1024 81 global vwld_okl ulong 32 82 global vwld_ostate uchar 1024 83 global vwld_osl ulong 32 84 85 fn vwld_reset to void 86 put vwld_generation 0 0 87 put vwld_slen 0 0 88 put vwld_res_cnt 0 0 89 put vwld_act_cnt 0 0 90 put vwld_rxn_cnt 0 0 91 put vwld_pub_cnt 0 0 92 put vwld_staged 0 0 93 put vwld_staged_vis 0 0 94 put vwld_pub_tail 0 0 95 put vwld_dlen 0 0 96 put vwld_attached 0 0 97 put vwld_glen 0 0 98 put vwld_obj_cnt 0 0 99 end 100 101 note visor_world_gap_append: "; "-separated, bounded to 255 bytes (snprintf into 256). 102 fn vwld_gap_put c uchar to void 103 n = get vwld_glen 0 104 if lt n 255 105 put vwld_gap n c 106 put vwld_glen 0 add n 1 107 end 108 end 109 110 fn vwld_append_gap s view uchar * to void 111 sl = len s 112 if eq sl 0 113 ret 114 end 115 cur = get vwld_glen 0 116 if ge cur 255 117 ret 118 end 119 if gt cur 0 120 for i ulong 2 121 vwld_gap_put get vwld_t_sep i 122 end 123 end 124 for i ulong sl bound 4096 125 vwld_gap_put get s i 126 end 127 end 128 129 fn vwld_unattached to void 130 vwld_reset 131 sl = len vwld_t_unattached 132 for i ulong sl bound 64 133 put vwld_state i get vwld_t_unattached i 134 end 135 put vwld_slen 0 sl 136 vwld_append_gap vwld_g_unatt 137 end 138 139 note ---- bounded writer: the C Buf overflow makes the whole render -1 ---- 140 141 fn vwld_finish to long 142 if ne get v_ob_ovf 0 0 143 put v_ob_len 0 0 144 ret -1 145 end 146 ret long get v_ob_len 0 147 end 148 149 fn vwld_put_state_or_dash to void 150 sl = get vwld_slen 0 151 if eq sl 0 152 ob_puts vwld_t_dash 153 ret 154 end 155 for i ulong sl bound 64 156 ob_putc get vwld_state i 157 end 158 end 159 160 note "%-Ns" of field bytes [base, base+l) of buf sel (0 id, 1 kind, 2 state). 161 fn vwld_put_field sel ulong slot ulong w ulong to void 162 l = ulong 0 163 if eq sel 0 164 l = get vwld_oidl slot 165 for i ulong l bound 72 166 ob_putc get vwld_oid add mul slot 72 i 167 end 168 end 169 if eq sel 1 170 l = get vwld_okl slot 171 if eq l 0 172 ob_puts vwld_t_dash 173 l = 1 174 end 175 for i ulong get vwld_okl slot bound 32 176 ob_putc get vwld_okind add mul slot 32 i 177 end 178 end 179 if eq sel 2 180 l = get vwld_osl slot 181 if eq l 0 182 ob_puts vwld_t_dash 183 l = 1 184 end 185 for i ulong get vwld_osl slot bound 32 186 ob_putc get vwld_ostate add mul slot 32 i 187 end 188 end 189 if lt l w 190 for i ulong sub w l bound 32 191 ob_putc uchar 32 192 end 193 end 194 end 195 196 fn vwld_format_text n ulong to long 197 if eq n 0 198 ret -1 199 end 200 ob_reset sub n 1 201 ob_puts vwld_t_w 202 if ne get vwld_attached 0 0 203 ob_puts vwld_t_attached 204 else 205 ob_puts vwld_t_unattached 206 end 207 ob_putc uchar 10 208 ob_puts vwld_t_state 209 vwld_put_state_or_dash 210 ob_putc uchar 10 211 g = get vwld_generation 0 212 if ne g 0 213 ob_puts vwld_t_gen 214 ob_put_u64 g 215 ob_putc uchar 10 216 else 217 ob_puts vwld_t_genno 218 end 219 ob_puts vwld_t_res 220 ob_put_u64 get vwld_res_cnt 0 221 ob_puts vwld_t_shown 222 ob_put_u64 get vwld_obj_cnt 0 223 ob_puts vwld_t_rpar 224 ob_puts vwld_t_rxn 225 ob_put_u64 get vwld_rxn_cnt 0 226 ob_putc uchar 10 227 ob_puts vwld_t_act 228 ob_put_u64 get vwld_act_cnt 0 229 ob_putc uchar 10 230 ob_puts vwld_t_pub 231 pc = get vwld_pub_cnt 0 232 ob_put_u64 pc 233 if eq pc 0 234 ob_puts vwld_t_pubno 235 end 236 ob_putc uchar 10 237 if ne get vwld_staged_vis 0 0 238 ob_puts vwld_t_st 239 ob_put_u64 get vwld_staged 0 240 ob_putc uchar 10 241 else 242 ob_puts vwld_t_stno 243 end 244 ob_puts vwld_t_tail 245 ob_put_u64 get vwld_pub_tail 0 246 ob_putc uchar 10 247 ob_puts vwld_t_dig 248 dl = get vwld_dlen 0 249 if eq dl 0 250 ob_puts vwld_t_dash 251 else 252 for i ulong dl bound 72 253 ob_putc get vwld_digest i 254 end 255 end 256 ob_putc uchar 10 257 shown = get vwld_obj_cnt 0 258 if gt shown VWLD_MAX_OBJECTS 259 shown = VWLD_MAX_OBJECTS 260 end 261 for i ulong shown bound 32 262 ob_puts vwld_t_obj 263 vwld_put_field 0 i 22 264 ob_putc uchar 32 265 vwld_put_field 1 i 10 266 ob_putc uchar 32 267 vwld_put_field 2 i 0 268 ob_putc uchar 10 269 end 270 ob_puts vwld_t_gap 271 gl = get vwld_glen 0 272 if eq gl 0 273 ob_puts vwld_t_none 274 else 275 for i ulong gl bound 256 276 ob_putc get vwld_gap i 277 end 278 end 279 ob_putc uchar 10 280 ob_puts vwld_t_note 281 ret vwld_finish 282 end 283 284 note bjson_str byte: escapes ", \ and bytes below 0x20 (0x7F passes through here). 285 fn vwld_jbyte c ulong to void 286 if or eq c 34 eq c 92 287 ob_putc uchar 92 288 ob_putc uchar c 289 ret 290 end 291 if lt c 32 292 ob_putc uchar 92 293 ob_putc uchar 117 294 ob_putc uchar 48 295 ob_putc uchar 48 296 ob_putc get vwld_hx shr c 4 297 ob_putc get vwld_hx and c 15 298 ret 299 end 300 ob_putc uchar c 301 end 302 303 fn vwld_jtf b bool to void 304 if b 305 ob_puts vwld_j_true 306 else 307 ob_puts vwld_j_false 308 end 309 end 310 311 note A JSON string of field sel of object slot (C NULL kind/state renders null). 312 fn vwld_jfield sel ulong slot ulong to void 313 if and eq sel 1 eq get vwld_okl slot 0 314 ob_puts vwld_j_null 315 ret 316 end 317 if and eq sel 2 eq get vwld_osl slot 0 318 ob_puts vwld_j_null 319 ret 320 end 321 ob_putc uchar 34 322 if eq sel 0 323 for i ulong get vwld_oidl slot bound 72 324 vwld_jbyte ulong get vwld_oid add mul slot 72 i 325 end 326 end 327 if eq sel 1 328 for i ulong get vwld_okl slot bound 32 329 vwld_jbyte ulong get vwld_okind add mul slot 32 i 330 end 331 end 332 if eq sel 2 333 for i ulong get vwld_osl slot bound 32 334 vwld_jbyte ulong get vwld_ostate add mul slot 32 i 335 end 336 end 337 ob_putc uchar 34 338 end 339 340 fn vwld_json_head to void 341 ob_puts vwld_j_att 342 vwld_jtf ne get vwld_attached 0 0 343 ob_puts vwld_j_state 344 sl = get vwld_slen 0 345 if eq sl 0 346 ob_puts vwld_j_null 347 else 348 ob_putc uchar 34 349 for i ulong sl bound 64 350 vwld_jbyte ulong get vwld_state i 351 end 352 ob_putc uchar 34 353 end 354 g = get vwld_generation 0 355 ob_puts vwld_j_gen 356 ob_put_u64 g 357 ob_puts vwld_j_genobs 358 vwld_jtf ne g 0 359 ob_puts vwld_j_res 360 ob_put_u64 get vwld_res_cnt 0 361 ob_puts vwld_j_rxn 362 ob_put_u64 get vwld_rxn_cnt 0 363 ob_puts vwld_j_act 364 ob_put_u64 get vwld_act_cnt 0 365 ob_puts vwld_j_pub 366 ob_put_u64 get vwld_pub_cnt 0 367 ob_puts vwld_j_st 368 ob_put_u64 get vwld_staged 0 369 ob_puts vwld_j_stv 370 vwld_jtf ne get vwld_staged_vis 0 0 371 ob_puts vwld_j_tail 372 ob_put_u64 get vwld_pub_tail 0 373 ob_puts vwld_j_dig 374 dl = get vwld_dlen 0 375 if eq dl 0 376 ob_puts vwld_j_null 377 else 378 ob_putc uchar 34 379 for i ulong dl bound 72 380 vwld_jbyte ulong get vwld_digest i 381 end 382 ob_putc uchar 34 383 end 384 end 385 386 fn vwld_format_json n ulong to long 387 if eq n 0 388 ret -1 389 end 390 ob_reset sub n 1 391 vwld_json_head 392 ob_puts vwld_j_objs 393 shown = get vwld_obj_cnt 0 394 if gt shown VWLD_MAX_OBJECTS 395 shown = VWLD_MAX_OBJECTS 396 end 397 for i ulong shown bound 32 398 if gt i 0 399 ob_putc uchar 44 400 end 401 ob_puts vwld_j_oid 402 vwld_jfield 0 i 403 ob_puts vwld_j_okind 404 vwld_jfield 1 i 405 ob_puts vwld_j_ostate 406 vwld_jfield 2 i 407 ob_putc uchar 125 408 end 409 ob_puts vwld_j_gap 410 ob_putc uchar 34 411 for i ulong get vwld_glen 0 bound 256 412 vwld_jbyte ulong get vwld_gap i 413 end 414 ob_putc uchar 34 415 ob_puts vwld_j_auth 416 ret vwld_finish 417 end