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/tools/omegese/omegese.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 / tools / omegese / omegese.om` 8661 lines ยท 163668 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 note 4 note tools/omegese/omegese.om -- Pure seeded OM-2 port of tools/omegese/omegese.c. 5 note Spec: docs/one_layer/OMEGESE.md. 6 om2 7 8 const MAX_IN ulong `1048576` 9 const MAX_WORDS ulong 96 10 const MAX_REGS ulong 480 11 const MAX_BLOCKS ulong 512 12 const MAX_FUNCS ulong 32 13 const MAX_PARAMS ulong 6 14 const MAX_NAMES ulong 512 15 const MAX_FRAMES ulong 64 16 const MAX_CONSTS ulong 256 17 const NAME_MAX_LEN ulong 63 18 const MAX_OWN ulong 64 19 const MAX_OWQ ulong 256 20 const MAX_FILL ulong 768 21 const RL_BASE ulong 800 22 23 const T_BOOL ulong 0 24 const T_U8 ulong 1 25 const T_U16 ulong 2 26 const T_U32 ulong 3 27 const T_U64 ulong 4 28 const T_I8 ulong 5 29 const T_I16 ulong 6 30 const T_I32 ulong 7 31 const T_I64 ulong 8 32 const T_NSCALAR ulong 9 33 34 const R_NONE ulong 0 35 const R_OWN ulong 1 36 const R_MUT ulong 2 37 const R_SHARED ulong 3 38 39 const S_ALL ulong 511 40 const S_INT ulong 510 41 const S_SIGNED ulong 480 42 43 const OP_ADD ulong 0 44 const OP_SUB ulong 1 45 const OP_MUL ulong 2 46 const OP_DIV ulong 3 47 const OP_REM ulong 4 48 const OP_AND ulong 5 49 const OP_OR ulong 6 50 const OP_XOR ulong 7 51 const OP_SHL ulong 8 52 const OP_SHR ulong 9 53 const OP_EQ ulong 10 54 const OP_NE ulong 11 55 const OP_LT ulong 12 56 const OP_LE ulong 13 57 const OP_GT ulong 14 58 const OP_GE ulong 15 59 const OP_NEG ulong 16 60 const OP_NOT ulong 17 61 const OP_GET ulong 18 62 const OP_NEW ulong 19 63 const OP_N ulong 20 64 65 const NKW ulong 17 66 const NKWO ulong 17 67 const NFIXED ulong 57 68 69 const F_FN ulong 0 70 const F_IF ulong 1 71 const F_WHILE ulong 2 72 const F_FOR ulong 3 73 74 const OS_U ulong 1 75 const OS_L ulong 2 76 const OS_D ulong 4 77 78 const OW_USE ulong 0 79 const OW_FREE ulong 1 80 const OW_BIRTH ulong 2 81 const OW_RET ulong 3 82 83 const L_NO ulong 0 84 const L_TYPED ulong 1 85 const L_OPEN ulong 2 86 87 const A_NONE ulong 0 88 const A_ANY ulong 1 89 const A_EXACT ulong 2 90 const A_BIND ulong 3 91 92 const AN_GET ulong 0 93 const AN_PUT ulong 1 94 const AN_FREE ulong 2 95 const AN_REF ulong 3 96 97 const M_HUMAN ulong 0 98 const M_MACHINE ulong 1 99 const M_COMPLETE ulong 2 100 101 const BIG ulong `2000000` 102 103 note ---- text literals ---- 104 text t_empty "" 105 text t_sp " " 106 text t_nl "\n" 107 text t_comma ", " 108 text t_colon ":" 109 text t_sq "'" 110 text t_lpar "(" 111 text t_rpar ")" 112 text t_eqs "=" 113 text t_dots "..." 114 text t_dotdot ".." 115 text t_0 "0" 116 text t_1 "1" 117 text t_1m "`1000000`" 118 text t_dash "-" 119 text t_under "_" 120 text t_n "n" 121 122 note scalar type words (GW) 123 text tg_bool "bool" 124 text tg_uchar "uchar" 125 text tg_ushort "ushort" 126 text tg_uint "uint" 127 text tg_ulong "ulong" 128 text tg_byte "byte" 129 text tg_short "short" 130 text tg_int "int" 131 text tg_long "long" 132 133 note IR scalar names (IRN) 134 text ti_u8 "u8" 135 text ti_u16 "u16" 136 text ti_u32 "u32" 137 text ti_u64 "u64" 138 text ti_i8 "i8" 139 text ti_i16 "i16" 140 text ti_i32 "i32" 141 text ti_i64 "i64" 142 143 note ref words (REFW / REFIR) 144 text tr_own "own" 145 text tr_edit "edit" 146 text tr_view "view" 147 text tri_mut "mut" 148 text tri_shared "shared" 149 150 note ops (OPW / IROP) 151 text to_add "add" 152 text to_sub "sub" 153 text to_mul "mul" 154 text to_div "div" 155 text to_rem "rem" 156 text to_and "and" 157 text to_or "or" 158 text to_xor "xor" 159 text to_shl "shl" 160 text to_shr "shr" 161 text to_eq "eq" 162 text to_ne "ne" 163 text to_lt "lt" 164 text to_le "le" 165 text to_gt "gt" 166 text to_ge "ge" 167 text to_neg "neg" 168 text to_not "not" 169 text to_get "get" 170 text to_new "new" 171 text tir_bnot "bnot" 172 text tir_load "load" 173 text tir_alloc "alloc" 174 175 note keywords (KW) 176 text tk_fn "fn" 177 text tk_to "to" 178 text tk_void "void" 179 text tk_end "end" 180 text tk_else "else" 181 text tk_if "if" 182 text tk_while "while" 183 text tk_for "for" 184 text tk_break "break" 185 text tk_ret "ret" 186 text tk_trap "trap" 187 text tk_put "put" 188 text tk_free "free" 189 text tk_true "true" 190 text tk_false "false" 191 text tk_bound "bound" 192 193 note CLI / subcommand texts 194 text tc_words "words" 195 text tc_next "next" 196 text tc_machine "--machine" 197 text tc_complete "complete" 198 text tc_emit "emit" 199 text tc_usage "usage: omegese emit | omegese next [--machine] | omegese complete | omegese words\n" 200 text tc_open_err ": cannot open\n" 201 text tc_write_err ": write error\n" 202 text tc_large_err ": larger than `1048576` bytes\n" 203 text tc_zero_err "REFUSED omegese: a zero byte in the input\n" 204 text tc_refused "REFUSED omegese: " 205 text tc_ref_pfx "REFUSED omegese: line " 206 text tc_ref_mid ": no text after this prefix makes a program emit accepts (" 207 text tc_ref_end ")\n" 208 text tc_line "line " 209 text tc_cosp ": " 210 211 note JSON fragments 212 text tj_head "{\"functions\": [" 213 text tj_tail "\n]}\n" 214 text tj_fn1 "\n {\"name\": \"" 215 text tj_fn2 "\", \"params\": [" 216 text tj_fn3 "], \"ret\": \"" 217 text tj_fn4 "\", \"locals\": [" 218 text tj_fn5 "],\n \"blocks\": [" 219 text tj_fn6 "\n ]}" 220 text tj_blk "\n [" 221 text tj_const1 "{\"op\": \"const\", \"dst\": " 222 text tj_const2 ", \"value\": " 223 text tj_br "\"op\": \"br\", \"to\": @" 224 text tj_mov1 "\"op\": \"mov\", \"dst\": " 225 text tj_a ", \"a\": " 226 text tj_b ", \"b\": " 227 text tj_call1 "\"op\": \"call\", \"func\": \"" 228 text tj_call2 "\", \"args\": [" 229 text tj_call_dst "], \"dst\": " 230 text tj_op1 "\"op\": \"" 231 text tj_dst "\", \"dst\": " 232 text tj_load1 "\"op\": \"load\", \"dst\": " 233 text tj_arr ", \"arr\": " 234 text tj_idx ", \"index\": " 235 text tj_alloc1 "\"op\": \"alloc\", \"dst\": " 236 text tj_init ", \"init\": " 237 text tj_cbr1 "\"op\": \"cbr\", \"cond\": " 238 text tj_then ", \"then\": @" 239 text tj_else "@, \"else\": @" 240 text tj_trap "\"op\": \"trap\", \"code\": " 241 text tj_ret0 "\"op\": \"ret\"" 242 text tj_reta "\"op\": \"ret\", \"a\": " 243 text tj_store "\"op\": \"store\", \"arr\": " 244 text tj_val ", \"value\": " 245 text tj_rel "\"op\": \"release\", \"arr\": " 246 247 note oracle output texts 248 text tm_word "word " 249 text tm_newname "newname" 250 text tm_number "number " 251 text tm_lpar "(\n" 252 text tm_rpar ")\n" 253 text tm_space "space\n" 254 text tm_newline "newline\n" 255 text tm_eof "eof\n" 256 text th_assign "assign" 257 text th_names "names" 258 text th_number "number" 259 text th_newname "new-name" 260 text th_anyname " any name not in use" 261 text th_words "words" 262 text th_lpar " (" 263 text th_rpar " )" 264 text th_space " (space)" 265 text th_newline " (newline)" 266 text th_eof " (end of input)" 267 268 note error message texts 269 text te_no_comp "no completion fits in one line" 270 text te_max_regs "more than 480 values in one function" 271 text te_max_blks "more than 512 blocks in one function" 272 text te_not_name "' is not a name (a letter or _, then letters, digits or _)" 273 text te_is_kw "' is a word of the language, not a name" 274 text te_is_fn "' is a function name" 275 text te_dup_name "' is already a name here; pick a new name" 276 text te_max_names "more than 512 names" 277 text te_unread "' is written but never read (a typo, or a value left unused)" 278 text te_max_owq "more than 256 ownership checks wait for their loops to end" 279 text te_own_dead "' holds no array here: it was freed or moved on every path to this line" 280 text te_own_leak "' still holds an array on some path to this line; free it before it gets another" 281 text te_own_dbl "' holds no array here: it was already freed or moved on every path to this line" 282 text te_own_ret "' still holds its array at this return on some path; free it first" 283 text te_own_ret_oos "an array whose name is out of scope here still holds its data on some path to this return; free it inside its block, or end this path with trap" 284 text te_max_frames "more than 64 nested blocks" 285 text te_own_oos "an array out of scope here" 286 text te_own_luse1 "' holds no array at line " 287 text te_own_luse2 " on every path, once this loop is closed: it was freed or moved and the loop gives it no new one" 288 text te_own_lbirth1 "' still holds an array at line " 289 text te_own_lbirth2 " on some path, once this loop is closed, where it gets another; free it first" 290 text te_own_lret1 "' still holds its array at the return on line " 291 text te_own_lret2 " on some path, once this loop is closed; free it first" 292 text te_dead_line "this line can never run: the path already ended (ret, trap or break)" 293 text te_num_arr "': a number cannot be an array" 294 text te_not_bool "' is not a bool (true or false)" 295 text te_not_whole "' is not a whole number for " 296 text te_cant_neg " cannot be negative (" 297 text te_no_fit " does not fit " 298 text te_max_consts "more than 256 distinct numbers in one function" 299 text te_type_miss "a type is missing" 300 text te_not_type "' is not a type (uint ..., or own/edit/view )" 301 text te_arr_type1 "an array type is " 302 text te_arr_type2 " " 303 text te_not_elem "' is not an element type" 304 text te_arr_len1 "array length '" 305 text te_arr_len2 "' must be 1..64" 306 text te_no_arr "no array of a fitting type is in scope here" 307 text te_write_type1 "this writes " 308 text te_write_type2 " but the name holds " 309 text te_unmatched_rp "')' has no matching '('" 310 text te_unmatched_lp "'(' has no matching ')'" 311 text te_has " has " 312 text te_val_after " value after it; it takes " 313 text te_vals_after " values after it; it takes " 314 text te_paren_extra1 "( ... ) must hold exactly one value; '" 315 text te_paren_extra2 "' is extra" 316 text te_extra_end "extra words at the end of the line: '" 317 text te_all_arr_dead "every array that fits here holds nothing: it was freed or moved on every path to this line" 318 text te_takes_arr " takes an array name here, not '" 319 text te_not_arr "' is not an array" 320 text te_not_scope "' is not a name in scope here" 321 text te_arg_num "' is a number; " 322 text te_takes " takes " 323 text te_there " there" 324 text te_is "' is " 325 text te_empty_par "( ) holds no value; ( ... ) must hold exactly one value" 326 text te_miss_lp "a value is missing after '('" 327 text te_bad_num "' is not a number (digits, an optional minus sign, no leading zeros, no -0)" 328 text te_self_call " cannot call itself (calls go to earlier functions only)" 329 text te_ret_void " returns nothing; call it on its own line" 330 text te_arr_conv "' is an array; only numbers convert" 331 text te_bool_conv "bool does not convert to or from numbers; compare instead (ne x 0)" 332 text te_own_moves "own moves an own array; '" 333 text te_edit_view "edit needs an own or edit array; '" 334 text te_is_view "' is view only" 335 text te_unk_word "' is not a name in scope here, nor an op, a type or a function" 336 text te_unk_num1 ": the type of this number is unknown; write " 337 text te_needs_nb " needs a number or bool" 338 text te_neg_signed "neg needs a signed number; '" 339 text te_idx_int1 "index '" 340 text te_idx_int2 "' is not a whole number" 341 text te_new_top "new makes an array for a name: write it on its own line (x = new ...)" 342 text te_init_type1 "starting value '" 343 text te_init_type2 "', not " 344 text te_not_arr_op " works on numbers, not arrays" 345 text te_need_int_op " needs whole numbers, not bool" 346 text te_two_nums ": two numbers; give one of them a name first" 347 text te_shift_int "shifts need whole numbers" 348 text te_two_same " needs two values of one type: '" 349 text te_stands_alone " stands alone" 350 text te_needs_cond " needs a condition" 351 text te_cond_bool "a condition must be a bool; this is " 352 text te_fn_in_fn "fn inside a function: close the function with end first" 353 text te_max_funcs "more than 32 functions" 354 text te_fn_syn "fn ... to " 355 text te_bad_fn "' cannot be a function name" 356 text te_dup_fn1 "function '" 357 text te_dup_fn2 "' is already defined" 358 text te_fn_to "fn needs 'to ' or 'to void' at the end" 359 text te_max_params "more than 6 parameters" 360 text te_dup_param1 "parameter '" 361 text te_dup_param2 "' is named twice" 362 text te_fn_ret_arr "a function returns a number or bool, not an array" 363 text te_after_ret "' after the return type" 364 text te_bound_miss "bound needs a number 1..`1000000`" 365 text te_bound_rng1 "bound '" 366 text te_bound_rng2 "' must be 1..`1000000`" 367 text te_for_syn "for " 368 text te_not_int_ty "' is not a whole-number type" 369 text te_cnt_rng1 "count '" 370 text te_cnt_rng2 "' must be 0..`1000000`" 371 text te_no_ret " can reach its end without ret" 372 text te_else_no_if "else without an open if" 373 text te_brk_no_loop "break outside a loop" 374 text te_ret_alone " returns nothing: ret stands alone" 375 text te_ret_need1 " returns " 376 text te_ret_need2 ": ret needs a value" 377 text te_ret_type1 "this is " 378 text te_ret_type2 "; " 379 text te_trap_syn "trap " 380 text te_put_view "' is view only; put needs an own or edit array" 381 text te_put_ty "; the array holds " 382 text te_free_own "' is not an own array" 383 text te_call_keep1 "; keep it: = " 384 text te_call_keep2 " ..." 385 text te_no_start "' does not start a line (a name =, if, while, for, ret, put, free, trap, break, else, end, or a call)" 386 text te_loop_ctr "' is the loop counter; it cannot be assigned" 387 text te_cant_name "' cannot be a name" 388 text te_val_miss "a value is missing after '" 389 text te_num_unk "': the type of this number is unknown; write " 390 text te_max_words "more than 96 words on one line" 391 text te_bad_char1 "character '" 392 text te_bad_char2 "' is not part of Omegese" 393 text te_eof_in_fn1 "the input ends inside function '" 394 text te_eof_in_fn2 "' (missing end)" 395 text te_no_fn "no function" 396 397 note ---- globals ---- 398 global g_arg1 uchar 4096 399 global g_arg2 uchar 4096 400 global g_arg3 uchar 4096 401 global g_src uchar * 402 global g_out uchar * 403 global g_so uchar 65536 404 global g_err uchar 512 405 406 note scalar globals: 407 note g_st[0]=src_len [1]=out_n [2]=so_n [3]=err_n [4]=line [5]=nfuncs [6]=in_fn 408 note [7]=nregs [8]=nparams [9]=nnames [10]=depth [11]=nconsts [12]=nblocks 409 note [13]=norder [14]=cur(stored as cur+1, 0=none) [15]=nframes 410 note [16]=nown [17]=nowq [18]=own_pk(+1, 0=none) [19]=g_loops 411 note [20]=ln [21]=lp [22]=pdepth [23]=lw_base 412 note [24]=g_fill [25]=g_quiet [26]=g_ret [27]=g_rfloor [28]=g_pick [29]=g_nopt 413 note [30]=g_gen(+1, 0=none) [31]=wpool_n [32]=wbase [33]=wmark 414 note [34]=nW [35]=g_tline [36]=g_U_off [37]=g_U_len [38]=g_fl [39]=g_phase 415 note [40]=bops_n [41]=op_cnt [42]=vsp [43]=nids [44]=close_n [45]=g_cur_op_blk 416 note [46]=g_cur_op_start [47]=g_lit_neg [48]=g_lit_mag [49]=g_r128_hi [50]=g_r128_lo 417 global g_st ulong 64 418 419 note word pool & line words 420 global g_wpool uchar * 421 global g_lw_off ulong 1024 422 global g_lw_len ulong 1024 423 global g_W_off ulong 128 424 global g_W_len ulong 128 425 426 note funcs (32) 427 global g_fn_name uchar 2048 428 global g_fn_nlen ulong 32 429 global g_fn_np ulong 32 430 global g_fn_p ulong 192 431 global g_fn_hret ulong 32 432 global g_fn_ret ulong 32 433 434 note regs (480) 435 global g_regs ulong 480 436 437 note names (512) 438 global g_nm_str uchar 32768 439 global g_nm_len ulong 512 440 global g_nm_reg ulong 512 441 global g_nm_dep ulong 512 442 global g_nm_fix ulong 512 443 global g_nm_rd ulong 512 444 global g_taken uchar 512 445 446 note consts (256) 447 global g_ck_t ulong 256 448 global g_ck_neg ulong 256 449 global g_ck_mag ulong 256 450 global g_ck_reg ulong 256 451 452 note blocks (512) + op pool 453 global g_blk_nops ulong 512 454 global g_blk_ord long 512 455 global g_blk_refd ulong 512 456 global g_blk_head long 512 457 global g_blk_tail long 512 458 global g_bops uchar * 459 global g_op_off ulong * 460 global g_op_len ulong * 461 global g_op_next long * 462 463 note frames (64) 464 global g_fr_kind ulong 64 465 global g_fr_dep ulong 64 466 global g_fr_els long 64 467 global g_fr_join long 64 468 global g_fr_hels ulong 64 469 global g_fr_head long 64 470 global g_fr_exit long 64 471 global g_fr_ctr long 64 472 global g_fr_ohas ulong 64 473 global g_fr_oin_b uchar 4096 474 global g_fr_oin_m ulong 4096 475 global g_fr_oacc_b uchar 4096 476 global g_fr_oacc_m ulong 4096 477 global g_fr_opost_b uchar 4096 478 global g_fr_opost_m ulong 4096 479 480 note ownership (64) & deferred queue (256) 481 global g_own_reg ulong 64 482 global g_ost_b uchar 64 483 global g_ost_m ulong 64 484 global g_opnd_b uchar 64 485 global g_opnd_m ulong 64 486 global g_owq_k ulong 256 487 global g_owq_kind ulong 256 488 global g_owq_s ulong 256 489 global g_owq_line ulong 256 490 global g_owq_ob uchar 256 491 global g_owq_om ulong 256 492 global g_owq_nm uchar 16384 493 global g_owq_nlen ulong 256 494 global g_hb uchar 64 495 global g_hm ulong 64 496 global g_bmap long 512 497 global g_bord ulong 512 498 global g_i128_hi long 16 499 500 note Val stack (2048) 501 global g_v_lit ulong 2048 502 global g_v_word long 2048 503 global g_v_reg long 2048 504 global g_v_konst ulong 2048 505 global g_v_head long 2048 506 global g_v_arity ulong 2048 507 global g_v_paren ulong 2048 508 global g_v_a ulong 2048 509 global g_v_b ulong 2048 510 global g_v_t ulong 2048 511 512 note S0 snapshot for oracle 513 global s0_st ulong 16 514 global s0_fn_name uchar 2048 515 global s0_fn_nlen ulong 32 516 global s0_fn_np ulong 32 517 global s0_fn_p ulong 192 518 global s0_fn_hret ulong 32 519 global s0_fn_ret ulong 32 520 global s0_regs ulong 480 521 global s0_nm_str uchar 32768 522 global s0_nm_len ulong 512 523 global s0_nm_reg ulong 512 524 global s0_nm_dep ulong 512 525 global s0_nm_fix ulong 512 526 global s0_nm_rd ulong 512 527 global s0_ck_t ulong 256 528 global s0_ck_neg ulong 256 529 global s0_ck_mag ulong 256 530 global s0_ck_reg ulong 256 531 global s0_blk_nops ulong 512 532 global s0_blk_ord long 512 533 global s0_blk_refd ulong 512 534 global s0_fr_kind ulong 64 535 global s0_fr_dep ulong 64 536 global s0_fr_els long 64 537 global s0_fr_join long 64 538 global s0_fr_hels ulong 64 539 global s0_fr_head long 64 540 global s0_fr_exit long 64 541 global s0_fr_ctr long 64 542 global s0_fr_ohas ulong 64 543 global s0_fr_oin_b uchar 4096 544 global s0_fr_oin_m ulong 4096 545 global s0_fr_oacc_b uchar 4096 546 global s0_fr_oacc_m ulong 4096 547 global s0_fr_opost_b uchar 4096 548 global s0_fr_opost_m ulong 4096 549 global s0_own_reg ulong 64 550 global s0_ost_b uchar 64 551 global s0_ost_m ulong 64 552 global s0_owq_k ulong 256 553 global s0_owq_kind ulong 256 554 global s0_owq_s ulong 256 555 global s0_owq_line ulong 256 556 global s0_owq_ob uchar 256 557 global s0_owq_om ulong 256 558 global s0_owq_nm uchar 16384 559 global s0_owq_nlen ulong 256 560 561 note oracle buffers 562 global g_close uchar * 563 global g_ids_str uchar * 564 global g_ids_len ulong * 565 global g_ids_kind ulong * 566 global g_ids_leg uchar * 567 global g_genb uchar * 568 global g_genb_n ulong 1 569 global g_tl uchar * 570 global g_tl_n ulong 1 571 global g_tl2 uchar * 572 global g_tl2_n ulong 1 573 global g_bx uchar * 574 global g_bx_n ulong 1 575 global g_hbuf uchar * 576 global g_hbuf_n ulong 1 577 global g_lineb uchar 256 578 global g_lineb_n ulong 1 579 global g_fresh uchar 32 580 global g_fresh_n ulong 1 581 global g_rep uchar 80 582 global g_rep_n ulong 1 583 global g_num1 uchar 64 584 global g_num1_n ulong 1 585 global g_num2 uchar 64 586 global g_num2_n ulong 1 587 global g_fx uchar 64 588 global g_bp_hi long 128 589 global g_bp_lo ulong 128 590 global g_lo_hi long 256 591 global g_lo_lo ulong 256 592 global g_hi_hi long 256 593 global g_hi_lo ulong 256 594 595 note ---- I/O & buffer helpers ---- 596 fn wr_so_all fd int n ulong to bool 597 off = ulong 0 598 while lt off n bound 65536 599 k = write fd g_so off sub n off 600 if eq k neg long 4 601 continue 602 end 603 if le k 0 604 ret false 605 end 606 off = add off ulong k 607 end 608 ret true 609 end 610 611 fn so_flush to void 612 n = get g_st 2 613 if gt n 0 614 ok = wr_so_all 1 n 615 put g_st 2 0 616 end 617 end 618 619 fn so_c c uchar to void 620 n = get g_st 2 621 if ge n 65536 622 so_flush 623 n = ulong 0 624 end 625 put g_so n c 626 put g_st 2 add n 1 627 end 628 629 fn so_t s view uchar * to void 630 n = len s 631 for i ulong n bound 4096 632 so_c get s i 633 end 634 end 635 636 fn so_u64 v ulong to void 637 tmp = new uchar 24 0 638 if eq v 0 639 so_c 48 640 ret 641 end 642 k = ulong 0 643 while gt v 0 bound 32 644 d = rem v 10 645 put tmp k uchar add 48 d 646 v = div v 10 647 k = add k 1 648 end 649 while gt k 0 bound 32 650 k = sub k 1 651 so_c get tmp k 652 end 653 end 654 655 fn so_wpool off ulong n ulong to void 656 for i ulong n bound 65536 657 so_c get g_wpool add off i 658 end 659 end 660 661 fn so_err_buf off ulong n ulong to void 662 for i ulong n bound 512 663 so_c get g_err add off i 664 end 665 end 666 667 fn so_ids_name idx ulong to void 668 off = mul idx 64 669 n = get g_ids_len idx 670 for i ulong n bound 64 671 so_c get g_ids_str add off i 672 end 673 end 674 675 fn so_num1 to void 676 n = get g_num1_n 0 677 for i ulong n bound 64 678 so_c get g_num1 i 679 end 680 end 681 682 fn so_num2 to void 683 n = get g_num2_n 0 684 for i ulong n bound 64 685 so_c get g_num2 i 686 end 687 end 688 689 fn so_close to void 690 n = get g_st 44 691 for i ulong n bound BIG 692 so_c get g_close i 693 end 694 end 695 696 fn out_c c uchar to void 697 n = get g_st 1 698 if ge n len g_out 699 nc = mul n 2 700 if lt nc 4096 701 nc = 4096 702 end 703 r = enlarge g_out nc 704 if lt r 0 705 exit 2 706 end 707 end 708 put g_out n c 709 put g_st 1 add n 1 710 end 711 712 fn out_t s view uchar * to void 713 n = len s 714 for i ulong n bound 4096 715 out_c get s i 716 end 717 end 718 719 fn out_u64 v ulong to void 720 tmp = new uchar 24 0 721 if eq v 0 722 out_c 48 723 ret 724 end 725 k = ulong 0 726 while gt v 0 bound 32 727 d = rem v 10 728 put tmp k uchar add 48 d 729 v = div v 10 730 k = add k 1 731 end 732 while gt k 0 bound 32 733 k = sub k 1 734 out_c get tmp k 735 end 736 end 737 738 fn out_fn_name fi ulong to void 739 off = mul fi 64 740 n = get g_fn_nlen fi 741 for i ulong n bound 64 742 out_c get g_fn_name add off i 743 end 744 end 745 746 fn close_c c uchar to void 747 n = get g_st 44 748 if ge n len g_close 749 nc = mul n 2 750 if lt nc 1024 751 nc = 1024 752 end 753 r = enlarge g_close nc 754 if lt r 0 755 exit 2 756 end 757 end 758 put g_close n c 759 put g_st 44 add n 1 760 end 761 762 fn close_lineb to void 763 n = get g_lineb_n 0 764 for i ulong n bound 256 765 close_c get g_lineb i 766 end 767 close_c 10 768 end 769 770 fn hbuf_c c uchar to void 771 n = get g_hbuf_n 0 772 if ge n len g_hbuf 773 nc = mul n 2 774 if lt nc 1024 775 nc = 1024 776 end 777 r = enlarge g_hbuf nc 778 if lt r 0 779 exit 2 780 end 781 end 782 put g_hbuf n c 783 put g_hbuf_n 0 add n 1 784 end 785 786 fn hbuf_t s view uchar * to void 787 n = len s 788 for i ulong n bound 256 789 hbuf_c get s i 790 end 791 end 792 793 fn hbuf_ids idx ulong to void 794 off = mul idx 64 795 n = get g_ids_len idx 796 for i ulong n bound 64 797 hbuf_c get g_ids_str add off i 798 end 799 end 800 801 fn hbuf_num1 to void 802 n = get g_num1_n 0 803 for i ulong n bound 64 804 hbuf_c get g_num1 i 805 end 806 end 807 808 fn hbuf_num2 to void 809 n = get g_num2_n 0 810 for i ulong n bound 64 811 hbuf_c get g_num2 i 812 end 813 end 814 815 fn genb_c c uchar to void 816 n = get g_genb_n 0 817 if ge n len g_genb 818 nc = mul n 2 819 if lt nc 1024 820 nc = 1024 821 end 822 r = enlarge g_genb nc 823 if lt r 0 824 exit 2 825 end 826 end 827 put g_genb n c 828 put g_genb_n 0 add n 1 829 end 830 831 fn genb_t s view uchar * to void 832 n = len s 833 for i ulong n bound 256 834 genb_c get s i 835 end 836 end 837 838 fn genb_u64 v ulong to void 839 tmp = new uchar 24 0 840 if eq v 0 841 genb_c 48 842 ret 843 end 844 k = ulong 0 845 while gt v 0 bound 32 846 d = rem v 10 847 put tmp k uchar add 48 d 848 v = div v 10 849 k = add k 1 850 end 851 while gt k 0 bound 32 852 k = sub k 1 853 genb_c get tmp k 854 end 855 end 856 857 fn genb_nm idx ulong to void 858 off = mul idx 64 859 n = get g_nm_len idx 860 for i ulong n bound 64 861 genb_c get g_nm_str add off i 862 end 863 end 864 865 fn tl_c use2 ulong c uchar to void 866 if eq use2 0 867 n = get g_tl_n 0 868 if ge n len g_tl 869 nc = mul n 2 870 if lt nc 1024 871 nc = 1024 872 end 873 r = enlarge g_tl nc 874 if lt r 0 875 exit 2 876 end 877 end 878 put g_tl n c 879 put g_tl_n 0 add n 1 880 else 881 n = get g_tl2_n 0 882 if ge n len g_tl2 883 nc = mul n 2 884 if lt nc 1024 885 nc = 1024 886 end 887 r = enlarge g_tl2 nc 888 if lt r 0 889 exit 2 890 end 891 end 892 put g_tl2 n c 893 put g_tl2_n 0 add n 1 894 end 895 end 896 897 fn tl_t use2 ulong s view uchar * to void 898 n = len s 899 for i ulong n bound 256 900 tl_c use2 get s i 901 end 902 end 903 904 fn tl_nm use2 ulong idx ulong to void 905 off = mul idx 64 906 n = get g_nm_len idx 907 for i ulong n bound 64 908 tl_c use2 get g_nm_str add off i 909 end 910 end 911 912 fn tl_fn use2 ulong fi ulong to void 913 off = mul fi 64 914 n = get g_fn_nlen fi 915 for i ulong n bound 64 916 tl_c use2 get g_fn_name add off i 917 end 918 end 919 920 fn tl_bx use2 ulong to void 921 n = get g_bx_n 0 922 for i ulong n bound 65536 923 tl_c use2 get g_bx i 924 end 925 end 926 927 fn bx_c c uchar to void 928 n = get g_bx_n 0 929 if ge n len g_bx 930 nc = mul n 2 931 if lt nc 1024 932 nc = 1024 933 end 934 r = enlarge g_bx nc 935 if lt r 0 936 exit 2 937 end 938 end 939 put g_bx n c 940 put g_bx_n 0 add n 1 941 end 942 943 fn bx_t s view uchar * to void 944 n = len s 945 for i ulong n bound 256 946 bx_c get s i 947 end 948 end 949 950 fn lb_c c uchar to void 951 n = get g_lineb_n 0 952 if lt n 255 953 put g_lineb n c 954 put g_lineb_n 0 add n 1 955 end 956 end 957 958 fn lb_t s view uchar * to void 959 n = len s 960 for i ulong n bound 256 961 lb_c get s i 962 end 963 end 964 965 fn lb_u64 v ulong to void 966 tmp = new uchar 24 0 967 if eq v 0 968 lb_c 48 969 ret 970 end 971 k = ulong 0 972 while gt v 0 bound 32 973 d = rem v 10 974 put tmp k uchar add 48 d 975 v = div v 10 976 k = add k 1 977 end 978 while gt k 0 bound 32 979 k = sub k 1 980 lb_c get tmp k 981 end 982 end 983 984 fn lb_nm idx ulong to void 985 off = mul idx 64 986 n = get g_nm_len idx 987 for i ulong n bound 64 988 lb_c get g_nm_str add off i 989 end 990 end 991 992 fn lb_fresh to void 993 n = get g_fresh_n 0 994 for i ulong n bound 32 995 lb_c get g_fresh i 996 end 997 end 998 999 note ---- word pool helpers ---- 1000 fn wp_push_c c uchar to void 1001 n = get g_st 31 1002 if ge n len g_wpool 1003 nc = mul n 2 1004 if lt nc 4096 1005 nc = 4096 1006 end 1007 r = enlarge g_wpool nc 1008 if lt r 0 1009 exit 2 1010 end 1011 end 1012 put g_wpool n c 1013 put g_st 31 add n 1 1014 end 1015 1016 fn wp_push_t s view uchar * to ulong 1017 off = get g_st 31 1018 n = len s 1019 for i ulong n bound 256 1020 wp_push_c get s i 1021 end 1022 ret off 1023 end 1024 1025 fn w_off idx ulong to ulong 1026 ret get g_lw_off add get g_st 23 idx 1027 end 1028 1029 fn w_len idx ulong to ulong 1030 ret get g_lw_len add get g_st 23 idx 1031 end 1032 1033 fn wp_eq_t off ulong n ulong s view uchar * to bool 1034 if ne n len s 1035 ret false 1036 end 1037 for i ulong n bound 256 1038 if ne get g_wpool add off i get s i 1039 ret false 1040 end 1041 end 1042 ret true 1043 end 1044 1045 fn w_eq_t idx ulong s view uchar * to bool 1046 ret wp_eq_t w_off idx w_len idx s 1047 end 1048 1049 fn wp_eq_wp o1 ulong n1 ulong o2 ulong n2 ulong to bool 1050 if ne n1 n2 1051 ret false 1052 end 1053 for i ulong n1 bound 256 1054 if ne get g_wpool add o1 i get g_wpool add o2 i 1055 ret false 1056 end 1057 end 1058 ret true 1059 end 1060 1061 fn wp_eq_nm off ulong n ulong idx ulong to bool 1062 if ne n get g_nm_len idx 1063 ret false 1064 end 1065 no = mul idx 64 1066 for i ulong n bound 64 1067 if ne get g_wpool add off i get g_nm_str add no i 1068 ret false 1069 end 1070 end 1071 ret true 1072 end 1073 1074 fn wp_eq_fn off ulong n ulong fi ulong to bool 1075 if ne n get g_fn_nlen fi 1076 ret false 1077 end 1078 fo = mul fi 64 1079 for i ulong n bound 64 1080 if ne get g_wpool add off i get g_fn_name add fo i 1081 ret false 1082 end 1083 end 1084 ret true 1085 end 1086 1087 fn is_alpha c uchar to bool 1088 if and ge c 65 le c 90 1089 ret true 1090 end 1091 if and ge c 97 le c 122 1092 ret true 1093 end 1094 ret false 1095 end 1096 1097 fn is_digit c uchar to bool 1098 ret and ge c 48 le c 57 1099 end 1100 1101 fn is_alnum c uchar to bool 1102 ret or is_alpha c is_digit c 1103 end 1104 1105 fn valid_ident_wp off ulong n ulong to bool 1106 if or eq n 0 gt n NAME_MAX_LEN 1107 ret false 1108 end 1109 c0 = get g_wpool off 1110 if not or is_alpha c0 eq c0 95 1111 ret false 1112 end 1113 for i ulong n bound 64 1114 c = get g_wpool add off i 1115 if not or is_alnum c eq c 95 1116 ret false 1117 end 1118 end 1119 ret true 1120 end 1121 1122 note ---- type & word tables ---- 1123 fn ty_make rf ulong s ulong l ulong to ulong 1124 ret or rf or shl s 4 shl l 8 1125 end 1126 1127 fn ty_ref t ulong to ulong 1128 ret and t 15 1129 end 1130 1131 fn ty_s t ulong to ulong 1132 ret and shr t 4 15 1133 end 1134 1135 fn ty_len t ulong to ulong 1136 ret shr t 8 1137 end 1138 1139 fn ty_is_int t ulong to bool 1140 ret and eq ty_ref t R_NONE ne ty_s t T_BOOL 1141 end 1142 1143 fn is_signed s ulong to bool 1144 ret ge s T_I8 1145 end 1146 1147 fn scalar_bits s ulong to ulong 1148 if eq s T_BOOL 1149 ret 1 1150 end 1151 if or eq s T_U8 eq s T_I8 1152 ret 8 1153 end 1154 if or eq s T_U16 eq s T_I16 1155 ret 16 1156 end 1157 if or eq s T_U32 eq s T_I32 1158 ret 32 1159 end 1160 ret 64 1161 end 1162 1163 fn gw_len s ulong to ulong 1164 if eq s 0 1165 ret len tg_bool 1166 end 1167 if eq s 1 1168 ret len tg_uchar 1169 end 1170 if eq s 2 1171 ret len tg_ushort 1172 end 1173 if eq s 3 1174 ret len tg_uint 1175 end 1176 if eq s 4 1177 ret len tg_ulong 1178 end 1179 if eq s 5 1180 ret len tg_byte 1181 end 1182 if eq s 6 1183 ret len tg_short 1184 end 1185 if eq s 7 1186 ret len tg_int 1187 end 1188 ret len tg_long 1189 end 1190 1191 fn err_c c uchar to void 1192 n = get g_st 3 1193 if lt n 511 1194 put g_err n c 1195 put g_st 3 add n 1 1196 end 1197 end 1198 1199 fn err_t s view uchar * to void 1200 n = len s 1201 for i ulong n bound 512 1202 err_c get s i 1203 end 1204 end 1205 1206 fn err_u64 v ulong to void 1207 tmp = new uchar 24 0 1208 if eq v 0 1209 err_c 48 1210 ret 1211 end 1212 k = ulong 0 1213 while gt v 0 bound 32 1214 d = rem v 10 1215 put tmp k uchar add 48 d 1216 v = div v 10 1217 k = add k 1 1218 end 1219 while gt k 0 bound 32 1220 k = sub k 1 1221 err_c get tmp k 1222 end 1223 end 1224 1225 fn err_start to void 1226 put g_st 3 0 1227 err_t tc_line 1228 err_u64 get g_st 4 1229 err_t tc_cosp 1230 end 1231 1232 fn err_wp off ulong n ulong to void 1233 for i ulong n bound 256 1234 err_c get g_wpool add off i 1235 end 1236 end 1237 1238 fn err_w idx ulong to void 1239 err_wp w_off idx w_len idx 1240 end 1241 1242 fn err_nm idx ulong to void 1243 off = mul idx 64 1244 n = get g_nm_len idx 1245 for i ulong n bound 64 1246 err_c get g_nm_str add off i 1247 end 1248 end 1249 1250 fn err_fn fi ulong to void 1251 off = mul fi 64 1252 n = get g_fn_nlen fi 1253 for i ulong n bound 64 1254 err_c get g_fn_name add off i 1255 end 1256 end 1257 1258 fn err_gw s ulong to void 1259 if eq s 0 1260 err_t tg_bool 1261 else 1262 if eq s 1 1263 err_t tg_uchar 1264 else 1265 if eq s 2 1266 err_t tg_ushort 1267 else 1268 if eq s 3 1269 err_t tg_uint 1270 else 1271 if eq s 4 1272 err_t tg_ulong 1273 else 1274 if eq s 5 1275 err_t tg_byte 1276 else 1277 if eq s 6 1278 err_t tg_short 1279 else 1280 if eq s 7 1281 err_t tg_int 1282 else 1283 err_t tg_long 1284 end 1285 end 1286 end 1287 end 1288 end 1289 end 1290 end 1291 end 1292 end 1293 1294 fn err_refw rf ulong to void 1295 if eq rf R_OWN 1296 err_t tr_own 1297 else 1298 if eq rf R_MUT 1299 err_t tr_edit 1300 else 1301 if eq rf R_SHARED 1302 err_t tr_view 1303 end 1304 end 1305 end 1306 end 1307 1308 fn err_ty t ulong to void 1309 rf = ty_ref t 1310 if eq rf R_NONE 1311 err_gw ty_s t 1312 ret 1313 end 1314 err_refw rf 1315 err_c 32 1316 err_gw ty_s t 1317 err_c 32 1318 err_u64 ty_len t 1319 end 1320 1321 fn err_opw o ulong to void 1322 if eq o 0 1323 err_t to_add 1324 ret 1325 end 1326 if eq o 1 1327 err_t to_sub 1328 ret 1329 end 1330 if eq o 2 1331 err_t to_mul 1332 ret 1333 end 1334 if eq o 3 1335 err_t to_div 1336 ret 1337 end 1338 if eq o 4 1339 err_t to_rem 1340 ret 1341 end 1342 if eq o 5 1343 err_t to_and 1344 ret 1345 end 1346 if eq o 6 1347 err_t to_or 1348 ret 1349 end 1350 if eq o 7 1351 err_t to_xor 1352 ret 1353 end 1354 if eq o 8 1355 err_t to_shl 1356 ret 1357 end 1358 if eq o 9 1359 err_t to_shr 1360 ret 1361 end 1362 if eq o 10 1363 err_t to_eq 1364 ret 1365 end 1366 if eq o 11 1367 err_t to_ne 1368 ret 1369 end 1370 if eq o 12 1371 err_t to_lt 1372 ret 1373 end 1374 if eq o 13 1375 err_t to_le 1376 ret 1377 end 1378 if eq o 14 1379 err_t to_gt 1380 ret 1381 end 1382 if eq o 15 1383 err_t to_ge 1384 ret 1385 end 1386 if eq o 16 1387 err_t to_neg 1388 ret 1389 end 1390 if eq o 17 1391 err_t to_not 1392 ret 1393 end 1394 if eq o 18 1395 err_t to_get 1396 ret 1397 end 1398 err_t to_new 1399 end 1400 1401 fn err_span a ulong b ulong to void 1402 sbuf = new uchar 80 0 1403 sn = ulong 0 1404 ln = get g_st 20 1405 i = a 1406 while and lt i b and lt i ln lt sn 79 bound 1024 1407 sp = false 1408 if gt i a 1409 if and not w_eq_t sub i 1 t_lpar not w_eq_t i t_rpar 1410 sp = true 1411 end 1412 end 1413 if sp 1414 if lt sn 79 1415 put sbuf sn 32 1416 sn = add sn 1 1417 end 1418 end 1419 wo = w_off i 1420 wl = w_len i 1421 j = ulong 0 1422 while lt j wl bound 256 1423 if ge sn 79 1424 put sbuf 76 46 1425 put sbuf 77 46 1426 put sbuf 78 46 1427 sn = 79 1428 break 1429 end 1430 put sbuf sn get g_wpool add wo j 1431 sn = add sn 1 1432 j = add j 1 1433 end 1434 if and eq sn 79 lt j wl 1435 put sbuf 76 46 1436 put sbuf 77 46 1437 put sbuf 78 46 1438 break 1439 end 1440 i = add i 1 1441 end 1442 for k ulong sn bound 80 1443 err_c get sbuf k 1444 end 1445 end 1446 1447 fn out_irn s ulong to void 1448 if eq s 0 1449 out_t tg_bool 1450 ret 1451 end 1452 if eq s 1 1453 out_t ti_u8 1454 ret 1455 end 1456 if eq s 2 1457 out_t ti_u16 1458 ret 1459 end 1460 if eq s 3 1461 out_t ti_u32 1462 ret 1463 end 1464 if eq s 4 1465 out_t ti_u64 1466 ret 1467 end 1468 if eq s 5 1469 out_t ti_i8 1470 ret 1471 end 1472 if eq s 6 1473 out_t ti_i16 1474 ret 1475 end 1476 if eq s 7 1477 out_t ti_i32 1478 ret 1479 end 1480 out_t ti_i64 1481 end 1482 1483 fn out_tir t ulong to void 1484 rf = ty_ref t 1485 if eq rf R_NONE 1486 out_irn ty_s t 1487 ret 1488 end 1489 if eq rf R_OWN 1490 out_t tr_own 1491 else 1492 if eq rf R_MUT 1493 out_t tri_mut 1494 else 1495 out_t tri_shared 1496 end 1497 end 1498 out_c 58 1499 out_irn ty_s t 1500 out_c 58 1501 out_u64 ty_len t 1502 end 1503 1504 fn genb_gw s ulong to void 1505 if eq s 0 1506 genb_t tg_bool 1507 ret 1508 end 1509 if eq s 1 1510 genb_t tg_uchar 1511 ret 1512 end 1513 if eq s 2 1514 genb_t tg_ushort 1515 ret 1516 end 1517 if eq s 3 1518 genb_t tg_uint 1519 ret 1520 end 1521 if eq s 4 1522 genb_t tg_ulong 1523 ret 1524 end 1525 if eq s 5 1526 genb_t tg_byte 1527 ret 1528 end 1529 if eq s 6 1530 genb_t tg_short 1531 ret 1532 end 1533 if eq s 7 1534 genb_t tg_int 1535 ret 1536 end 1537 genb_t tg_long 1538 end 1539 1540 fn genb_refw rf ulong to void 1541 if eq rf R_OWN 1542 genb_t tr_own 1543 ret 1544 end 1545 if eq rf R_MUT 1546 genb_t tr_edit 1547 ret 1548 end 1549 genb_t tr_view 1550 end 1551 1552 fn tl_gw use2 ulong s ulong to void 1553 if eq s 0 1554 tl_t use2 tg_bool 1555 ret 1556 end 1557 if eq s 1 1558 tl_t use2 tg_uchar 1559 ret 1560 end 1561 if eq s 2 1562 tl_t use2 tg_ushort 1563 ret 1564 end 1565 if eq s 3 1566 tl_t use2 tg_uint 1567 ret 1568 end 1569 if eq s 4 1570 tl_t use2 tg_ulong 1571 ret 1572 end 1573 if eq s 5 1574 tl_t use2 tg_byte 1575 ret 1576 end 1577 if eq s 6 1578 tl_t use2 tg_short 1579 ret 1580 end 1581 if eq s 7 1582 tl_t use2 tg_int 1583 ret 1584 end 1585 tl_t use2 tg_long 1586 end 1587 1588 fn lb_gw s ulong to void 1589 if eq s 0 1590 lb_t tg_bool 1591 ret 1592 end 1593 if eq s 1 1594 lb_t tg_uchar 1595 ret 1596 end 1597 if eq s 2 1598 lb_t tg_ushort 1599 ret 1600 end 1601 if eq s 3 1602 lb_t tg_uint 1603 ret 1604 end 1605 if eq s 4 1606 lb_t tg_ulong 1607 ret 1608 end 1609 if eq s 5 1610 lb_t tg_byte 1611 ret 1612 end 1613 if eq s 6 1614 lb_t tg_short 1615 ret 1616 end 1617 if eq s 7 1618 lb_t tg_int 1619 ret 1620 end 1621 lb_t tg_long 1622 end 1623 1624 fn scalar_word_wp off ulong n ulong to long 1625 if wp_eq_t off n tg_bool 1626 ret 0 1627 end 1628 if or wp_eq_t off n tg_uchar wp_eq_t off n ti_u8 1629 ret 1 1630 end 1631 if or wp_eq_t off n tg_ushort wp_eq_t off n ti_u16 1632 ret 2 1633 end 1634 if or wp_eq_t off n tg_uint wp_eq_t off n ti_u32 1635 ret 3 1636 end 1637 if or wp_eq_t off n tg_ulong wp_eq_t off n ti_u64 1638 ret 4 1639 end 1640 if or wp_eq_t off n tg_byte wp_eq_t off n ti_i8 1641 ret 5 1642 end 1643 if or wp_eq_t off n tg_short wp_eq_t off n ti_i16 1644 ret 6 1645 end 1646 if or wp_eq_t off n tg_int wp_eq_t off n ti_i32 1647 ret 7 1648 end 1649 if or wp_eq_t off n tg_long wp_eq_t off n ti_i64 1650 ret 8 1651 end 1652 ret neg long 1 1653 end 1654 1655 fn ref_word_wp off ulong n ulong to long 1656 if wp_eq_t off n tr_own 1657 ret 1 1658 end 1659 if wp_eq_t off n tr_edit 1660 ret 2 1661 end 1662 if wp_eq_t off n tr_view 1663 ret 3 1664 end 1665 ret neg long 1 1666 end 1667 1668 fn op_word_wp off ulong n ulong to long 1669 if wp_eq_t off n to_add 1670 ret 0 1671 end 1672 if wp_eq_t off n to_sub 1673 ret 1 1674 end 1675 if wp_eq_t off n to_mul 1676 ret 2 1677 end 1678 if wp_eq_t off n to_div 1679 ret 3 1680 end 1681 if wp_eq_t off n to_rem 1682 ret 4 1683 end 1684 if wp_eq_t off n to_and 1685 ret 5 1686 end 1687 if wp_eq_t off n to_or 1688 ret 6 1689 end 1690 if wp_eq_t off n to_xor 1691 ret 7 1692 end 1693 if wp_eq_t off n to_shl 1694 ret 8 1695 end 1696 if wp_eq_t off n to_shr 1697 ret 9 1698 end 1699 if wp_eq_t off n to_eq 1700 ret 10 1701 end 1702 if wp_eq_t off n to_ne 1703 ret 11 1704 end 1705 if wp_eq_t off n to_lt 1706 ret 12 1707 end 1708 if wp_eq_t off n to_le 1709 ret 13 1710 end 1711 if wp_eq_t off n to_gt 1712 ret 14 1713 end 1714 if wp_eq_t off n to_ge 1715 ret 15 1716 end 1717 if wp_eq_t off n to_neg 1718 ret 16 1719 end 1720 if wp_eq_t off n to_not 1721 ret 17 1722 end 1723 if wp_eq_t off n to_get 1724 ret 18 1725 end 1726 if wp_eq_t off n to_new 1727 ret 19 1728 end 1729 ret neg long 1 1730 end 1731 1732 fn kw_word_wp off ulong n ulong to long 1733 if wp_eq_t off n tk_fn 1734 ret 0 1735 end 1736 if wp_eq_t off n tk_to 1737 ret 1 1738 end 1739 if wp_eq_t off n tk_void 1740 ret 2 1741 end 1742 if wp_eq_t off n tk_end 1743 ret 3 1744 end 1745 if wp_eq_t off n tk_else 1746 ret 4 1747 end 1748 if wp_eq_t off n tk_if 1749 ret 5 1750 end 1751 if wp_eq_t off n tk_while 1752 ret 6 1753 end 1754 if wp_eq_t off n tk_for 1755 ret 7 1756 end 1757 if wp_eq_t off n tk_break 1758 ret 8 1759 end 1760 if wp_eq_t off n tk_ret 1761 ret 9 1762 end 1763 if wp_eq_t off n tk_trap 1764 ret 10 1765 end 1766 if wp_eq_t off n tk_put 1767 ret 11 1768 end 1769 if wp_eq_t off n tk_free 1770 ret 12 1771 end 1772 if wp_eq_t off n tk_true 1773 ret 13 1774 end 1775 if wp_eq_t off n tk_false 1776 ret 14 1777 end 1778 if wp_eq_t off n tk_bound 1779 ret 15 1780 end 1781 if wp_eq_t off n t_eqs 1782 ret 16 1783 end 1784 ret neg long 1 1785 end 1786 1787 fn reserved_wp off ulong n ulong to bool 1788 if ge scalar_word_wp off n 0 1789 ret true 1790 end 1791 if ge ref_word_wp off n 0 1792 ret true 1793 end 1794 if ge op_word_wp off n 0 1795 ret true 1796 end 1797 if ge kw_word_wp off n 0 1798 ret true 1799 end 1800 ret false 1801 end 1802 1803 fn is_term_wp off ulong n ulong to bool 1804 if wp_eq_t off n t_rpar 1805 ret true 1806 end 1807 k = kw_word_wp off n 1808 if and ge k 0 and ne k 13 ne k 14 1809 ret true 1810 end 1811 ret false 1812 end 1813 1814 fn is_shift o ulong to bool 1815 ret or eq o OP_SHL eq o OP_SHR 1816 end 1817 1818 fn is_cmp o ulong to bool 1819 ret and ge o OP_EQ le o OP_GE 1820 end 1821 1822 fn is_arith o ulong to bool 1823 ret le o OP_REM 1824 end 1825 1826 note ---- op pool emission ---- 1827 fn bops_c c uchar to void 1828 n = get g_st 40 1829 if ge n len g_bops 1830 nc = mul n 2 1831 if lt nc 4096 1832 nc = 4096 1833 end 1834 r = enlarge g_bops nc 1835 if lt r 0 1836 exit 2 1837 end 1838 end 1839 put g_bops n c 1840 put g_st 40 add n 1 1841 end 1842 1843 fn bops_t s view uchar * to void 1844 n = len s 1845 for i ulong n bound 256 1846 bops_c get s i 1847 end 1848 end 1849 1850 fn bops_u64 v ulong to void 1851 tmp = new uchar 24 0 1852 if eq v 0 1853 bops_c 48 1854 ret 1855 end 1856 k = ulong 0 1857 while gt v 0 bound 32 1858 d = rem v 10 1859 put tmp k uchar add 48 d 1860 v = div v 10 1861 k = add k 1 1862 end 1863 while gt k 0 bound 32 1864 k = sub k 1 1865 bops_c get tmp k 1866 end 1867 end 1868 1869 fn bops_fn fi ulong to void 1870 off = mul fi 64 1871 n = get g_fn_nlen fi 1872 for i ulong n bound 64 1873 bops_c get g_fn_name add off i 1874 end 1875 end 1876 1877 fn bops_irop o ulong to void 1878 if eq o 0 1879 bops_t to_add 1880 ret 1881 end 1882 if eq o 1 1883 bops_t to_sub 1884 ret 1885 end 1886 if eq o 2 1887 bops_t to_mul 1888 ret 1889 end 1890 if eq o 3 1891 bops_t to_div 1892 ret 1893 end 1894 if eq o 4 1895 bops_t to_rem 1896 ret 1897 end 1898 if eq o 5 1899 bops_t to_and 1900 ret 1901 end 1902 if eq o 6 1903 bops_t to_or 1904 ret 1905 end 1906 if eq o 7 1907 bops_t to_xor 1908 ret 1909 end 1910 if eq o 8 1911 bops_t to_shl 1912 ret 1913 end 1914 if eq o 9 1915 bops_t to_shr 1916 ret 1917 end 1918 if eq o 10 1919 bops_t to_eq 1920 ret 1921 end 1922 if eq o 11 1923 bops_t to_ne 1924 ret 1925 end 1926 if eq o 12 1927 bops_t to_lt 1928 ret 1929 end 1930 if eq o 13 1931 bops_t to_le 1932 ret 1933 end 1934 if eq o 14 1935 bops_t to_gt 1936 ret 1937 end 1938 if eq o 15 1939 bops_t to_ge 1940 ret 1941 end 1942 bops_t to_neg 1943 end 1944 1945 fn op_check_cur to long 1946 if eq get g_st 14 0 1947 err_start 1948 err_t te_dead_line 1949 ret neg long 1 1950 end 1951 ret 0 1952 end 1953 1954 fn op_begin to long 1955 r = op_check_cur 1956 if lt r 0 1957 ret r 1958 end 1959 if ne get g_st 25 0 1960 ret 0 1961 end 1962 b = sub get g_st 14 1 1963 put g_st 45 b 1964 put g_st 46 get g_st 40 1965 ret 0 1966 end 1967 1968 fn op_finish to void 1969 if ne get g_st 25 0 1970 ret 1971 end 1972 b = get g_st 45 1973 start = get g_st 46 1974 endp = get g_st 40 1975 oc = get g_st 41 1976 if ge oc len g_op_off 1977 nc = mul oc 2 1978 if lt nc 1024 1979 nc = 1024 1980 end 1981 r1 = enlarge g_op_off nc 1982 r2 = enlarge g_op_len nc 1983 r3 = enlarge g_op_next nc 1984 if or lt r1 0 or lt r2 0 lt r3 0 1985 exit 2 1986 end 1987 end 1988 put g_op_off oc start 1989 put g_op_len oc sub endp start 1990 put g_op_next oc neg long 1 1991 tail = get g_blk_tail b 1992 if lt tail 0 1993 put g_blk_head b long oc 1994 else 1995 put g_op_next ulong tail long oc 1996 end 1997 put g_blk_tail b long oc 1998 put g_blk_nops b add get g_blk_nops b 1 1999 put g_st 41 add oc 1 2000 end 2001 2002 fn emit_br to_b ulong to long 2003 put g_blk_refd to_b 1 2004 r = op_begin 2005 if lt r 0 2006 ret r 2007 end 2008 if eq get g_st 25 0 2009 bops_t tj_br 2010 bops_u64 to_b 2011 bops_c 64 2012 op_finish 2013 end 2014 put g_st 14 0 2015 ret 0 2016 end 2017 2018 fn emit_mov dst ulong a ulong to long 2019 r = op_begin 2020 if lt r 0 2021 ret r 2022 end 2023 if eq get g_st 25 0 2024 bops_t tj_mov1 2025 bops_u64 dst 2026 bops_t tj_a 2027 bops_u64 a 2028 op_finish 2029 end 2030 ret 0 2031 end 2032 2033 fn emit_cbr cond_r ulong th ulong el ulong to long 2034 r = op_begin 2035 if lt r 0 2036 ret r 2037 end 2038 if eq get g_st 25 0 2039 bops_t tj_cbr1 2040 bops_u64 cond_r 2041 bops_t tj_then 2042 bops_u64 th 2043 bops_t tj_else 2044 bops_u64 el 2045 bops_c 64 2046 op_finish 2047 end 2048 ret 0 2049 end 2050 2051 fn emit_binop o ulong dst ulong a ulong b ulong to long 2052 r = op_begin 2053 if lt r 0 2054 ret r 2055 end 2056 if eq get g_st 25 0 2057 bops_t tj_op1 2058 bops_irop o 2059 bops_t tj_dst 2060 bops_u64 dst 2061 bops_t tj_a 2062 bops_u64 a 2063 bops_t tj_b 2064 bops_u64 b 2065 op_finish 2066 end 2067 ret 0 2068 end 2069 2070 fn emit_unop is_neg ulong is_bool ulong dst ulong a ulong to long 2071 r = op_begin 2072 if lt r 0 2073 ret r 2074 end 2075 if eq get g_st 25 0 2076 bops_t tj_op1 2077 if ne is_neg 0 2078 bops_t to_neg 2079 else 2080 if ne is_bool 0 2081 bops_t to_not 2082 else 2083 bops_t tir_bnot 2084 end 2085 end 2086 bops_t tj_dst 2087 bops_u64 dst 2088 bops_t tj_a 2089 bops_u64 a 2090 op_finish 2091 end 2092 ret 0 2093 end 2094 2095 fn emit_cast is_mov ulong dst ulong a ulong to long 2096 r = op_begin 2097 if lt r 0 2098 ret r 2099 end 2100 if eq get g_st 25 0 2101 if ne is_mov 0 2102 bops_t tj_mov1 2103 else 2104 bops_t tj_op1 2105 bops_c 99 2106 bops_c 97 2107 bops_c 115 2108 bops_c 116 2109 bops_t tj_dst 2110 end 2111 bops_u64 dst 2112 bops_t tj_a 2113 bops_u64 a 2114 op_finish 2115 end 2116 ret 0 2117 end 2118 2119 fn emit_load dst ulong arr ulong idx ulong to long 2120 r = op_begin 2121 if lt r 0 2122 ret r 2123 end 2124 if eq get g_st 25 0 2125 bops_t tj_load1 2126 bops_u64 dst 2127 bops_t tj_arr 2128 bops_u64 arr 2129 bops_t tj_idx 2130 bops_u64 idx 2131 op_finish 2132 end 2133 ret 0 2134 end 2135 2136 fn emit_alloc dst ulong init_r ulong to long 2137 r = op_begin 2138 if lt r 0 2139 ret r 2140 end 2141 if eq get g_st 25 0 2142 bops_t tj_alloc1 2143 bops_u64 dst 2144 bops_t tj_init 2145 bops_u64 init_r 2146 op_finish 2147 end 2148 ret 0 2149 end 2150 2151 fn emit_store arr ulong idx ulong val_r ulong to long 2152 r = op_begin 2153 if lt r 0 2154 ret r 2155 end 2156 if eq get g_st 25 0 2157 bops_t tj_store 2158 bops_u64 arr 2159 bops_t tj_idx 2160 bops_u64 idx 2161 bops_t tj_val 2162 bops_u64 val_r 2163 op_finish 2164 end 2165 ret 0 2166 end 2167 2168 fn emit_release arr ulong to long 2169 r = op_begin 2170 if lt r 0 2171 ret r 2172 end 2173 if eq get g_st 25 0 2174 bops_t tj_rel 2175 bops_u64 arr 2176 op_finish 2177 end 2178 ret 0 2179 end 2180 2181 fn emit_trap code ulong to long 2182 r = op_begin 2183 if lt r 0 2184 ret r 2185 end 2186 if eq get g_st 25 0 2187 bops_t tj_trap 2188 bops_u64 code 2189 op_finish 2190 end 2191 ret 0 2192 end 2193 2194 fn emit_ret_void to long 2195 r = op_begin 2196 if lt r 0 2197 ret r 2198 end 2199 if eq get g_st 25 0 2200 bops_t tj_ret0 2201 op_finish 2202 end 2203 ret 0 2204 end 2205 2206 fn emit_ret_val a ulong to long 2207 r = op_begin 2208 if lt r 0 2209 ret r 2210 end 2211 if eq get g_st 25 0 2212 bops_t tj_reta 2213 bops_u64 a 2214 op_finish 2215 end 2216 ret 0 2217 end 2218 2219 note ---- ownership helpers ---- 2220 fn msb64 x ulong to ulong 2221 r = ulong 0 2222 if ge x shl ulong 1 32 2223 x = shr x 32 2224 r = add r 32 2225 end 2226 if ge x shl ulong 1 16 2227 x = shr x 16 2228 r = add r 16 2229 end 2230 if ge x 256 2231 x = shr x 8 2232 r = add r 8 2233 end 2234 if ge x 16 2235 x = shr x 4 2236 r = add r 4 2237 end 2238 if ge x 4 2239 x = shr x 2 2240 r = add r 2 2241 end 2242 if ge x 2 2243 r = add r 1 2244 end 2245 ret r 2246 end 2247 2248 fn below_mask f ulong to ulong 2249 if ge f 64 2250 ret sub ulong 0 1 2251 end 2252 ret sub shl ulong 1 f 1 2253 end 2254 2255 fn own_slot r ulong to long 2256 nown = get g_st 16 2257 for s ulong nown bound 64 2258 if eq get g_own_reg s r 2259 ret long s 2260 end 2261 end 2262 ret neg long 1 2263 end 2264 2265 fn own_track r ulong to void 2266 nown = get g_st 16 2267 if ge nown MAX_OWN 2268 ret 2269 end 2270 s = nown 2271 put g_st 16 add nown 1 2272 put g_own_reg s r 2273 nf = get g_st 15 2274 gl = get g_st 19 2275 for f ulong nf bound 64 2276 if ge f MAX_FRAMES 2277 break 2278 end 2279 fk = get g_fr_kind f 2280 isl = or eq fk F_WHILE eq fk F_FOR 2281 idx = add mul f MAX_OWN s 2282 put g_fr_oin_b idx uchar OS_U 2283 put g_fr_oin_m idx and gl below_mask f 2284 if isl 2285 put g_fr_oacc_b idx uchar OS_U 2286 put g_fr_oacc_m idx and gl below_mask add f 1 2287 else 2288 put g_fr_oacc_b idx uchar OS_U 2289 put g_fr_oacc_m idx and gl below_mask f 2290 end 2291 put g_fr_opost_b idx uchar OS_U 2292 put g_fr_opost_m idx and gl below_mask add f 1 2293 end 2294 pk1 = get g_st 18 2295 if gt pk1 0 2296 put g_opnd_b s uchar OS_U 2297 put g_opnd_m s and gl below_mask sub pk1 1 2298 end 2299 put g_ost_b s uchar OS_U 2300 put g_ost_m s gl 2301 end 2302 2303 fn own_label r ulong to long 2304 nn = get g_st 9 2305 i = nn 2306 while gt i 0 bound 512 2307 i = sub i 1 2308 if eq get g_nm_reg i r 2309 ret long i 2310 end 2311 end 2312 ret neg long 1 2313 end 2314 2315 fn os_none b uchar m ulong to bool 2316 ret and eq m 0 eq and ulong b OS_L 0 2317 end 2318 2319 fn os_only b uchar m ulong to bool 2320 ret and eq m 0 eq ulong b OS_L 2321 end 2322 2323 fn own_dead r ulong to bool 2324 s = own_slot r 2325 if lt s 0 2326 ret false 2327 end 2328 su = ulong s 2329 ret os_none get g_ost_b su get g_ost_m su 2330 end 2331 2332 fn copy_nm_to_owq nq ulong ni long to void 2333 if ge ni 0 2334 nu = ulong ni 2335 nl = get g_nm_len nu 2336 put g_owq_nlen nq nl 2337 dst = mul nq 64 2338 src = mul nu 64 2339 for j ulong nl bound 64 2340 put g_owq_nm add dst j get g_nm_str add src j 2341 end 2342 else 2343 put g_owq_nlen nq 0 2344 end 2345 end 2346 2347 fn own_defer kind ulong s ulong ob uchar om ulong to long 2348 k = msb64 om 2349 nq = get g_st 17 2350 for i ulong nq bound 256 2351 if ne get g_owq_k i k 2352 continue 2353 end 2354 if ne get g_owq_kind i kind 2355 continue 2356 end 2357 if ne get g_owq_s i s 2358 continue 2359 end 2360 if ne get g_owq_ob i ob 2361 continue 2362 end 2363 if eq get g_owq_om i om 2364 ret 0 2365 end 2366 end 2367 if ge nq MAX_OWQ 2368 err_start 2369 err_t te_max_owq 2370 ret neg long 1 2371 end 2372 put g_owq_k nq k 2373 put g_owq_kind nq kind 2374 put g_owq_s nq s 2375 put g_owq_line nq get g_st 4 2376 put g_owq_ob nq ob 2377 put g_owq_om nq om 2378 copy_nm_to_owq nq own_label get g_own_reg s 2379 put g_st 17 add nq 1 2380 ret 0 2381 end 2382 2383 fn err_own_lbl r ulong to void 2384 ni = own_label r 2385 if ge ni 0 2386 err_nm ulong ni 2387 else 2388 err_t tr_own 2389 end 2390 end 2391 2392 fn own_use r ulong to long 2393 s = own_slot r 2394 if lt s 0 2395 ret 0 2396 end 2397 su = ulong s 2398 ob = get g_ost_b su 2399 om = get g_ost_m su 2400 if os_none ob om 2401 err_start 2402 err_c 39 2403 err_own_lbl r 2404 err_t te_own_dead 2405 ret neg long 1 2406 end 2407 if and ne om 0 eq and ulong ob OS_L 0 2408 ret own_defer OW_USE su ob om 2409 end 2410 ret 0 2411 end 2412 2413 fn own_kill r ulong to long 2414 rc = own_use r 2415 if lt rc 0 2416 ret rc 2417 end 2418 s = own_slot r 2419 if ge s 0 2420 su = ulong s 2421 put g_ost_b su uchar OS_D 2422 put g_ost_m su 0 2423 end 2424 ret 0 2425 end 2426 2427 fn own_birth r ulong to long 2428 s = own_slot r 2429 if lt s 0 2430 ret 0 2431 end 2432 su = ulong s 2433 ob = get g_ost_b su 2434 om = get g_ost_m su 2435 if and eq om 0 ne and ulong ob OS_L 0 2436 err_start 2437 err_c 39 2438 err_own_lbl r 2439 err_t te_own_leak 2440 ret neg long 1 2441 end 2442 if ne om 0 2443 rc = own_defer OW_BIRTH su ob om 2444 if lt rc 0 2445 ret rc 2446 end 2447 end 2448 put g_ost_b su uchar OS_L 2449 put g_ost_m su 0 2450 ret 0 2451 end 2452 2453 fn own_release r ulong to long 2454 s = own_slot r 2455 if lt s 0 2456 ret 0 2457 end 2458 su = ulong s 2459 ob = get g_ost_b su 2460 om = get g_ost_m su 2461 if os_none ob om 2462 err_start 2463 err_c 39 2464 err_own_lbl r 2465 err_t te_own_dbl 2466 ret neg long 1 2467 end 2468 if and ne om 0 eq and ulong ob OS_L 0 2469 rc = own_defer OW_FREE su ob om 2470 if lt rc 0 2471 ret rc 2472 end 2473 end 2474 put g_ost_b su uchar OS_D 2475 put g_ost_m su 0 2476 ret 0 2477 end 2478 2479 fn own_mov dst ulong a ulong to long 2480 if ne ty_ref get g_regs a R_OWN 2481 ret 0 2482 end 2483 if eq ty_ref get g_regs dst R_OWN 2484 rc = own_kill a 2485 if lt rc 0 2486 ret rc 2487 end 2488 ret own_birth dst 2489 end 2490 ret own_use a 2491 end 2492 2493 fn own_ret to long 2494 nown = get g_st 16 2495 for s ulong nown bound 64 2496 ob = get g_ost_b s 2497 om = get g_ost_m s 2498 if and eq om 0 ne and ulong ob OS_L 0 2499 ni = own_label get g_own_reg s 2500 err_start 2501 if ge ni 0 2502 err_c 39 2503 err_nm ulong ni 2504 err_t te_own_ret 2505 else 2506 err_t te_own_ret_oos 2507 end 2508 ret neg long 1 2509 end 2510 end 2511 for s ulong nown bound 64 2512 om = get g_ost_m s 2513 if ne om 0 2514 rc = own_defer OW_RET s get g_ost_b s om 2515 if lt rc 0 2516 ret rc 2517 end 2518 end 2519 end 2520 ret 0 2521 end 2522 2523 fn own_loop_open to long 2524 k = get g_st 15 2525 if ge k MAX_FRAMES 2526 err_start 2527 err_t te_max_frames 2528 ret neg long 1 2529 end 2530 nown = get g_st 16 2531 bit = shl ulong 1 k 2532 for s ulong nown bound 64 2533 put g_opnd_b s get g_ost_b s 2534 put g_opnd_m s get g_ost_m s 2535 put g_ost_b s 0 2536 put g_ost_m s bit 2537 end 2538 put g_st 18 add k 1 2539 put g_st 19 or get g_st 19 bit 2540 ret 0 2541 end 2542 2543 fn own_loop_pushed fi ulong to void 2544 nown = get g_st 16 2545 base = mul fi MAX_OWN 2546 for s ulong nown bound 64 2547 idx = add base s 2548 put g_fr_oin_b idx get g_opnd_b s 2549 put g_fr_oin_m idx get g_opnd_m s 2550 put g_fr_opost_b idx get g_ost_b s 2551 put g_fr_opost_m idx get g_ost_m s 2552 end 2553 put g_fr_ohas fi 0 2554 put g_st 18 0 2555 end 2556 2557 fn err_owq_nm i ulong to void 2558 enl = get g_owq_nlen i 2559 if gt enl 0 2560 off = mul i 64 2561 for j ulong enl bound 64 2562 err_c get g_owq_nm add off j 2563 end 2564 else 2565 err_t te_own_oos 2566 end 2567 end 2568 2569 fn owq_move keep ulong i ulong to void 2570 if eq keep i 2571 ret 2572 end 2573 put g_owq_k keep get g_owq_k i 2574 put g_owq_kind keep get g_owq_kind i 2575 put g_owq_s keep get g_owq_s i 2576 put g_owq_line keep get g_owq_line i 2577 put g_owq_ob keep get g_owq_ob i 2578 put g_owq_om keep get g_owq_om i 2579 enl = get g_owq_nlen i 2580 put g_owq_nlen keep enl 2581 dst = mul keep 64 2582 src = mul i 64 2583 for j ulong enl bound 64 2584 put g_owq_nm add dst j get g_owq_nm add src j 2585 end 2586 end 2587 2588 fn owq_check_closed i ulong eb uchar to long 2589 ekind = get g_owq_kind i 2590 has_l = ne and ulong eb OS_L 0 2591 if and or eq ekind OW_USE eq ekind OW_FREE not has_l 2592 err_start 2593 err_c 39 2594 err_owq_nm i 2595 err_t te_own_luse1 2596 err_u64 get g_owq_line i 2597 err_t te_own_luse2 2598 ret neg long 1 2599 end 2600 if and eq ekind OW_BIRTH has_l 2601 err_start 2602 err_c 39 2603 err_owq_nm i 2604 err_t te_own_lbirth1 2605 err_u64 get g_owq_line i 2606 err_t te_own_lbirth2 2607 ret neg long 1 2608 end 2609 if and eq ekind OW_RET has_l 2610 err_start 2611 err_c 39 2612 err_owq_nm i 2613 err_t te_own_lret1 2614 err_u64 get g_owq_line i 2615 err_t te_own_lret2 2616 ret neg long 1 2617 end 2618 ret 0 2619 end 2620 2621 fn own_loop_close_owq k ulong kb ulong to long 2622 nq = get g_st 17 2623 keep = ulong 0 2624 for i ulong nq bound 256 2625 if eq get g_owq_k i k 2626 es = get g_owq_s i 2627 eb = get g_owq_ob i 2628 em = get g_owq_om i 2629 if ne and em kb 0 2630 eb = uchar or ulong eb ulong get g_hb es 2631 em = or and em xor kb sub ulong 0 1 get g_hm es 2632 end 2633 if ne em 0 2634 put g_owq_k i msb64 em 2635 put g_owq_ob i eb 2636 put g_owq_om i em 2637 else 2638 if lt owq_check_closed i eb 0 2639 ret neg long 1 2640 end 2641 continue 2642 end 2643 end 2644 owq_move keep i 2645 keep = add keep 1 2646 end 2647 put g_st 17 keep 2648 ret 0 2649 end 2650 2651 fn own_loop_close_slot k ulong s ulong to void 2652 kb = shl ulong 1 k 2653 nkb = xor kb sub ulong 0 1 2654 idx = add mul k MAX_OWN s 2655 hsb = get g_fr_oin_b idx 2656 hsm = get g_fr_oin_m idx 2657 if gt get g_st 14 0 2658 hsb = uchar or ulong hsb ulong get g_ost_b s 2659 hsm = or hsm and get g_ost_m s nkb 2660 end 2661 put g_hb s hsb 2662 put g_hm s hsm 2663 xb = get g_fr_opost_b idx 2664 xm = get g_fr_opost_m idx 2665 if ne and xm kb 0 2666 xb = uchar or ulong xb ulong hsb 2667 xm = or and xm nkb hsm 2668 end 2669 if ne get g_fr_ohas k 0 2670 ab = get g_fr_oacc_b idx 2671 am = get g_fr_oacc_m idx 2672 if ne and am kb 0 2673 ab = uchar or ulong ab ulong hsb 2674 am = or and am nkb hsm 2675 end 2676 xb = uchar or ulong xb ulong ab 2677 xm = or xm am 2678 end 2679 put g_ost_b s xb 2680 put g_ost_m s xm 2681 end 2682 2683 fn own_loop_close k ulong to long 2684 kb = shl ulong 1 k 2685 nown = get g_st 16 2686 for s ulong nown bound 64 2687 own_loop_close_slot k s 2688 end 2689 put g_st 19 and get g_st 19 xor kb sub ulong 0 1 2690 ret own_loop_close_owq k kb 2691 end 2692 2693 fn own_save_oin fi ulong to void 2694 nown = get g_st 16 2695 base = mul fi MAX_OWN 2696 for s ulong nown bound 64 2697 put g_fr_oin_b add base s get g_ost_b s 2698 put g_fr_oin_m add base s get g_ost_m s 2699 end 2700 end 2701 2702 fn own_save_oacc fi ulong to void 2703 nown = get g_st 16 2704 base = mul fi MAX_OWN 2705 for s ulong nown bound 64 2706 put g_fr_oacc_b add base s get g_ost_b s 2707 put g_fr_oacc_m add base s get g_ost_m s 2708 end 2709 end 2710 2711 fn own_join_oacc fi ulong has ulong to void 2712 nown = get g_st 16 2713 base = mul fi MAX_OWN 2714 for s ulong nown bound 64 2715 idx = add base s 2716 if ne has 0 2717 put g_fr_oacc_b idx uchar or ulong get g_fr_oacc_b idx ulong get g_ost_b s 2718 put g_fr_oacc_m idx or get g_fr_oacc_m idx get g_ost_m s 2719 else 2720 put g_fr_oacc_b idx get g_ost_b s 2721 put g_fr_oacc_m idx get g_ost_m s 2722 end 2723 end 2724 end 2725 2726 fn own_if_end fi ulong to void 2727 hels = ne get g_fr_hels fi 0 2728 if and hels eq get g_fr_ohas fi 0 2729 ret 2730 end 2731 nown = get g_st 16 2732 base = mul fi MAX_OWN 2733 has_cur = gt get g_st 14 0 2734 for s ulong nown bound 64 2735 idx = add base s 2736 ob = uchar 0 2737 om = ulong 0 2738 if hels 2739 ob = get g_fr_oacc_b idx 2740 om = get g_fr_oacc_m idx 2741 else 2742 ob = get g_fr_oin_b idx 2743 om = get g_fr_oin_m idx 2744 end 2745 if has_cur 2746 put g_ost_b s uchar or ulong get g_ost_b s ulong ob 2747 put g_ost_m s or get g_ost_m s om 2748 else 2749 put g_ost_b s ob 2750 put g_ost_m s om 2751 end 2752 end 2753 end 2754 2755 note ---- regs, blocks, names, funcs ---- 2756 fn new_reg t ulong to long 2757 nr = get g_st 7 2758 if ge nr MAX_REGS 2759 err_start 2760 err_t te_max_regs 2761 ret neg long 1 2762 end 2763 put g_regs nr t 2764 if eq ty_ref t R_OWN 2765 own_track nr 2766 end 2767 put g_st 7 add nr 1 2768 ret long nr 2769 end 2770 2771 fn new_block to long 2772 nb = get g_st 12 2773 if ge nb MAX_BLOCKS 2774 err_start 2775 err_t te_max_blks 2776 ret neg long 1 2777 end 2778 put g_blk_nops nb 0 2779 put g_blk_ord nb neg long 1 2780 put g_blk_refd nb 0 2781 put g_blk_head nb neg long 1 2782 put g_blk_tail nb neg long 1 2783 put g_st 12 add nb 1 2784 ret long nb 2785 end 2786 2787 fn start_block b ulong to void 2788 no = get g_st 13 2789 put g_blk_ord b long no 2790 put g_st 13 add no 1 2791 put g_st 14 add b 1 2792 end 2793 2794 fn find_name_wp off ulong n ulong to long 2795 nn = get g_st 9 2796 i = nn 2797 while gt i 0 bound 512 2798 i = sub i 1 2799 if wp_eq_nm off n i 2800 ret long i 2801 end 2802 end 2803 ret neg long 1 2804 end 2805 2806 fn find_func_wp off ulong n ulong to long 2807 nf = get g_st 5 2808 for i ulong nf bound 32 2809 if wp_eq_fn off n i 2810 ret long i 2811 end 2812 end 2813 ret neg long 1 2814 end 2815 2816 fn find_callable_wp off ulong n ulong to long 2817 g = find_func_wp off n 2818 if lt g 0 2819 ret neg long 1 2820 end 2821 if and ne get g_st 6 0 eq ulong g sub get g_st 5 1 2822 ret neg long 1 2823 end 2824 ret g 2825 end 2826 2827 fn check_new_name_wp off ulong n ulong to long 2828 if not valid_ident_wp off n 2829 err_start 2830 err_c 39 2831 err_wp off n 2832 err_t te_not_name 2833 ret neg long 1 2834 end 2835 if reserved_wp off n 2836 err_start 2837 err_c 39 2838 err_wp off n 2839 err_t te_is_kw 2840 ret neg long 1 2841 end 2842 if ge find_func_wp off n 0 2843 err_start 2844 err_c 39 2845 err_wp off n 2846 err_t te_is_fn 2847 ret neg long 1 2848 end 2849 if ge find_name_wp off n 0 2850 err_start 2851 err_c 39 2852 err_wp off n 2853 err_t te_dup_name 2854 ret neg long 1 2855 end 2856 ret 0 2857 end 2858 2859 fn bind_name_wp off ulong n ulong reg ulong fixed ulong to long 2860 rc = check_new_name_wp off n 2861 if lt rc 0 2862 ret rc 2863 end 2864 nn = get g_st 9 2865 if ge nn MAX_NAMES 2866 err_start 2867 err_t te_max_names 2868 ret neg long 1 2869 end 2870 dst = mul nn 64 2871 for i ulong n bound 64 2872 put g_nm_str add dst i get g_wpool add off i 2873 end 2874 put g_nm_len nn n 2875 put g_nm_reg nn reg 2876 put g_nm_dep nn get g_st 10 2877 put g_nm_fix nn fixed 2878 put g_nm_rd nn 0 2879 put g_st 9 add nn 1 2880 ret 0 2881 end 2882 2883 fn pop_scope to long 2884 dep = get g_st 10 2885 nn = get g_st 9 2886 while gt nn 0 bound 512 2887 idx = sub nn 1 2888 if le get g_nm_dep idx sub dep 1 2889 break 2890 end 2891 if and eq get g_nm_fix idx 0 eq get g_nm_rd idx 0 2892 put g_st 9 nn 2893 err_start 2894 err_c 39 2895 err_nm idx 2896 err_t te_unread 2897 ret neg long 1 2898 end 2899 nn = idx 2900 end 2901 put g_st 9 nn 2902 put g_st 10 sub dep 1 2903 ret 0 2904 end 2905 2906 note ---- literals ---- 2907 fn parse_lit_wp off ulong n ulong to bool 2908 if eq n 0 2909 ret false 2910 end 2911 p = ulong 0 2912 is_neg = ulong 0 2913 if eq get g_wpool off 45 2914 is_neg = 1 2915 p = 1 2916 end 2917 if ge p n 2918 ret false 2919 end 2920 c0 = get g_wpool add off p 2921 if not is_digit c0 2922 ret false 2923 end 2924 if and eq c0 48 gt sub n p 1 2925 ret false 2926 end 2927 v = ulong 0 2928 umax = sub ulong 0 1 2929 while lt p n bound 64 2930 c = get g_wpool add off p 2931 if not is_digit c 2932 ret false 2933 end 2934 d = ulong sub c 48 2935 if gt v div sub umax d 10 2936 ret false 2937 end 2938 v = add mul v 10 d 2939 p = add p 1 2940 end 2941 if and ne is_neg 0 eq v 0 2942 ret false 2943 end 2944 put g_st 47 is_neg 2945 put g_st 48 v 2946 ret true 2947 end 2948 2949 fn is_lit_wp off ulong n ulong to bool 2950 if or wp_eq_t off n tk_true wp_eq_t off n tk_false 2951 ret true 2952 end 2953 ret parse_lit_wp off n 2954 end 2955 2956 fn lit_conv_wp off ulong n ulong s ulong to ulong 2957 put g_st 47 0 2958 put g_st 48 0 2959 if eq s T_BOOL 2960 if wp_eq_t off n tk_true 2961 put g_st 48 1 2962 ret 0 2963 end 2964 if wp_eq_t off n tk_false 2965 put g_st 48 0 2966 ret 0 2967 end 2968 ret 1 2969 end 2970 if not parse_lit_wp off n 2971 ret 2 2972 end 2973 is_neg = get g_st 47 2974 mag = get g_st 48 2975 if and ne is_neg 0 and not is_signed s ne mag 0 2976 ret 3 2977 end 2978 b = scalar_bits s 2979 if is_signed s 2980 b = sub b 1 2981 end 2982 lim = sub ulong 0 1 2983 if lt b 64 2984 lim = sub shl ulong 1 b 1 2985 end 2986 if ne is_neg 0 2987 if gt mag add lim 1 2988 ret 4 2989 end 2990 else 2991 if gt mag lim 2992 ret 4 2993 end 2994 end 2995 if and ne is_neg 0 eq mag 0 2996 put g_st 47 0 2997 end 2998 ret 0 2999 end 3000 3001 fn lit_fits_wp off ulong n ulong m ulong to ulong 3002 r = ulong 0 3003 for s ulong T_NSCALAR bound 16 3004 if ne and shr m s 1 0 3005 if eq lit_conv_wp off n s 0 3006 r = or r shl ulong 1 s 3007 end 3008 end 3009 end 3010 ret r 3011 end 3012 3013 fn lit_reg_wp off ulong n ulong t ulong to long 3014 if ne ty_ref t R_NONE 3015 err_start 3016 err_c 39 3017 err_wp off n 3018 err_t te_num_arr 3019 ret neg long 1 3020 end 3021 s = ty_s t 3022 rc = lit_conv_wp off n s 3023 if eq rc 1 3024 err_start 3025 err_c 39 3026 err_wp off n 3027 err_t te_not_bool 3028 ret neg long 1 3029 end 3030 if eq rc 2 3031 err_start 3032 err_c 39 3033 err_wp off n 3034 err_t te_not_whole 3035 err_gw s 3036 ret neg long 1 3037 end 3038 if eq rc 3 3039 err_start 3040 err_gw s 3041 err_t te_cant_neg 3042 err_wp off n 3043 err_c 41 3044 ret neg long 1 3045 end 3046 if eq rc 4 3047 err_start 3048 err_wp off n 3049 err_t te_no_fit 3050 err_gw s 3051 ret neg long 1 3052 end 3053 is_neg = get g_st 47 3054 mag = get g_st 48 3055 nc = get g_st 11 3056 for i ulong nc bound 256 3057 if ne get g_ck_t i t 3058 continue 3059 end 3060 if ne get g_ck_neg i is_neg 3061 continue 3062 end 3063 if eq get g_ck_mag i mag 3064 ret long get g_ck_reg i 3065 end 3066 end 3067 if ge nc MAX_CONSTS 3068 err_start 3069 err_t te_max_consts 3070 ret neg long 1 3071 end 3072 r = new_reg t 3073 if lt r 0 3074 ret r 3075 end 3076 put g_ck_t nc t 3077 put g_ck_neg nc is_neg 3078 put g_ck_mag nc mag 3079 put g_ck_reg nc ulong r 3080 put g_st 11 add nc 1 3081 ret r 3082 end 3083 3084 fn lit_reg_t s view uchar * t ulong to long 3085 saved = get g_st 31 3086 off = wp_push_t s 3087 r = lit_reg_wp off len s t 3088 put g_st 31 saved 3089 ret r 3090 end 3091 3092 note ---- want & type binding ---- 3093 fn binds p ulong a ulong to bool 3094 pr = ty_ref p 3095 ar = ty_ref a 3096 if or eq pr R_NONE eq ar R_NONE 3097 ret eq p a 3098 end 3099 if or ne ty_s p ty_s a ne ty_len p ty_len a 3100 ret false 3101 end 3102 if eq pr R_SHARED 3103 ret true 3104 end 3105 if and eq pr R_MUT ne ar R_SHARED 3106 ret true 3107 end 3108 ret and eq pr R_OWN eq ar R_OWN 3109 end 3110 3111 fn ref_ok rf ulong a ulong to bool 3112 ar = ty_ref a 3113 if eq ar R_NONE 3114 ret false 3115 end 3116 if eq rf R_SHARED 3117 ret true 3118 end 3119 if and eq rf R_MUT ne ar R_SHARED 3120 ret true 3121 end 3122 ret eq ar R_OWN 3123 end 3124 3125 fn want_pack scal ulong arr ulong lit ulong top ulong p ulong lt_t ulong to ulong 3126 v = or scal or shl arr 9 or shl lit 11 shl top 13 3127 ret or v or shl p 16 shl lt_t 32 3128 end 3129 3130 fn want_scal w ulong to ulong 3131 ret and w 511 3132 end 3133 3134 fn want_arr w ulong to ulong 3135 ret and shr w 9 3 3136 end 3137 3138 fn want_lit w ulong to ulong 3139 ret and shr w 11 3 3140 end 3141 3142 fn want_top w ulong to ulong 3143 ret and shr w 13 1 3144 end 3145 3146 fn want_p w ulong to ulong 3147 ret and shr w 16 65535 3148 end 3149 3150 fn want_lt w ulong to ulong 3151 ret and shr w 32 65535 3152 end 3153 3154 fn want_set_top w ulong top ulong to ulong 3155 w = and w xor shl ulong 1 13 sub ulong 0 1 3156 ret or w shl top 13 3157 end 3158 3159 fn want_type t ulong to ulong 3160 if eq ty_ref t R_NONE 3161 ret want_pack shl ulong 1 ty_s t A_NONE L_TYPED 0 0 t 3162 end 3163 ret want_pack 0 A_EXACT L_NO 0 t 0 3164 end 3165 3166 fn want_param p ulong to ulong 3167 if eq ty_ref p R_NONE 3168 ret want_type p 3169 end 3170 ret want_pack 0 A_BIND L_NO 0 p 0 3171 end 3172 3173 fn want_ok w ulong t ulong to bool 3174 if eq ty_ref t R_NONE 3175 ret ne and shr want_scal w ty_s t 1 0 3176 end 3177 wa = want_arr w 3178 if eq wa A_ANY 3179 ret true 3180 end 3181 if eq wa A_EXACT 3182 ret eq want_p w t 3183 end 3184 if eq wa A_BIND 3185 ret binds want_p w t 3186 end 3187 ret false 3188 end 3189 3190 note ---- fill_word & fill_text ---- 3191 fn fill_word_wp off ulong n ulong to long 3192 ln = get g_st 20 3193 if ge ln MAX_FILL 3194 err_start 3195 err_t te_no_comp 3196 ret neg long 1 3197 end 3198 if eq get g_st 30 0 3199 put g_st 30 add ln 1 3200 end 3201 base = get g_st 23 3202 put g_lw_off add base ln off 3203 put g_lw_len add base ln n 3204 put g_st 20 add ln 1 3205 ret 0 3206 end 3207 3208 fn fill_word_t s view uchar * to long 3209 off = wp_push_t s 3210 ret fill_word_wp off len s 3211 end 3212 3213 fn fill_word_gw s ulong to long 3214 if eq s 0 3215 ret fill_word_t tg_bool 3216 end 3217 if eq s 1 3218 ret fill_word_t tg_uchar 3219 end 3220 if eq s 2 3221 ret fill_word_t tg_ushort 3222 end 3223 if eq s 3 3224 ret fill_word_t tg_uint 3225 end 3226 if eq s 4 3227 ret fill_word_t tg_ulong 3228 end 3229 if eq s 5 3230 ret fill_word_t tg_byte 3231 end 3232 if eq s 6 3233 ret fill_word_t tg_short 3234 end 3235 if eq s 7 3236 ret fill_word_t tg_int 3237 end 3238 ret fill_word_t tg_long 3239 end 3240 3241 fn fill_word_nm idx ulong to long 3242 off = get g_st 31 3243 src = mul idx 64 3244 nl = get g_nm_len idx 3245 for i ulong nl bound 64 3246 wp_push_c get g_nm_str add src i 3247 end 3248 ret fill_word_wp off nl 3249 end 3250 3251 fn fill_word_u64 v ulong to long 3252 tmp = new uchar 24 0 3253 off = get g_st 31 3254 if eq v 0 3255 wp_push_c 48 3256 ret fill_word_wp off 1 3257 end 3258 k = ulong 0 3259 while gt v 0 bound 32 3260 d = rem v 10 3261 put tmp k uchar add 48 d 3262 v = div v 10 3263 k = add k 1 3264 end 3265 n = k 3266 while gt k 0 bound 32 3267 k = sub k 1 3268 wp_push_c get tmp k 3269 end 3270 ret fill_word_wp off n 3271 end 3272 3273 fn fill_text_genb to long 3274 n = get g_genb_n 0 3275 i = ulong 0 3276 while lt i n bound 65536 3277 j = i 3278 while lt j n bound 65536 3279 if eq get g_genb j 32 3280 break 3281 end 3282 j = add j 1 3283 end 3284 k = sub j i 3285 if gt k NAME_MAX_LEN 3286 err_start 3287 err_t te_no_comp 3288 ret neg long 1 3289 end 3290 if gt k 0 3291 off = get g_st 31 3292 for p ulong k bound 64 3293 wp_push_c get g_genb add i p 3294 end 3295 rc = fill_word_wp off k 3296 if lt rc 0 3297 ret rc 3298 end 3299 end 3300 i = j 3301 if lt i n 3302 i = add i 1 3303 end 3304 end 3305 ret 0 3306 end 3307 3308 fn parse_type to long 3309 lp = get g_st 21 3310 ln = get g_st 20 3311 if ge lp ln 3312 if eq get g_st 24 0 3313 err_start 3314 err_t te_type_miss 3315 ret neg long 1 3316 end 3317 rc = fill_word_t tg_uint 3318 if lt rc 0 3319 ret rc 3320 end 3321 ln = get g_st 20 3322 end 3323 s = scalar_word_wp w_off lp w_len lp 3324 if ge s 0 3325 put g_st 21 add lp 1 3326 ret long ty_make R_NONE ulong s 0 3327 end 3328 rf = ref_word_wp w_off lp w_len lp 3329 if lt rf 0 3330 err_start 3331 err_c 39 3332 err_w lp 3333 err_t te_not_type 3334 ret neg long 1 3335 end 3336 if and ge add lp 2 ln eq get g_st 24 0 3337 err_start 3338 err_t te_arr_type1 3339 err_refw ulong rf 3340 err_t te_arr_type2 3341 ret neg long 1 3342 end 3343 if ge add lp 1 ln 3344 rc = fill_word_t tg_uint 3345 if lt rc 0 3346 ret rc 3347 end 3348 ln = get g_st 20 3349 end 3350 s = scalar_word_wp w_off add lp 1 w_len add lp 1 3351 if lt s 0 3352 err_start 3353 err_c 39 3354 err_w add lp 1 3355 err_t te_not_elem 3356 ret neg long 1 3357 end 3358 if ge add lp 2 ln 3359 rc = fill_word_t t_1 3360 if lt rc 0 3361 ret rc 3362 end 3363 ln = get g_st 20 3364 end 3365 ok = parse_lit_wp w_off add lp 2 w_len add lp 2 3366 alen = get g_st 48 3367 if or not ok or ne get g_st 47 0 or lt alen 1 gt alen 64 3368 err_start 3369 err_t te_arr_len1 3370 err_w add lp 2 3371 err_t te_arr_len2 3372 ret neg long 1 3373 end 3374 put g_st 21 add lp 3 3375 ret long ty_make ulong rf ulong s alen 3376 end 3377 3378 note ---- completion helpers ---- 3379 fn make_fresh_name to void 3380 tmp = new uchar 24 0 3381 k = ulong 0 3382 while lt k 100000 bound 100000 3383 put g_fresh 0 119 3384 fl = ulong 1 3385 if eq k 0 3386 put g_fresh 1 48 3387 fl = 2 3388 else 3389 v = k 3390 tk = ulong 0 3391 while gt v 0 bound 24 3392 put tmp tk uchar add 48 rem v 10 3393 v = div v 10 3394 tk = add tk 1 3395 end 3396 while gt tk 0 bound 24 3397 tk = sub tk 1 3398 put g_fresh fl get tmp tk 3399 fl = add fl 1 3400 end 3401 end 3402 saved = get g_st 31 3403 off = saved 3404 for i ulong fl bound 32 3405 wp_push_c get g_fresh i 3406 end 3407 used = or ge find_name_wp off fl 0 ge find_func_wp off fl 0 3408 ln = get g_st 20 3409 for i ulong ln bound 1024 3410 if used 3411 break 3412 end 3413 if wp_eq_wp w_off i w_len i off fl 3414 used = true 3415 end 3416 end 3417 put g_st 31 saved 3418 if not used 3419 put g_fresh_n 0 fl 3420 ret 3421 end 3422 k = add k 1 3423 end 3424 end 3425 3426 fn fill_fresh_name to long 3427 make_fresh_name 3428 off = get g_st 31 3429 fl = get g_fresh_n 0 3430 for i ulong fl bound 32 3431 wp_push_c get g_fresh i 3432 end 3433 ret fill_word_wp off fl 3434 end 3435 3436 fn in_r i ulong to bool 3437 if eq get g_st 26 0 3438 ret false 3439 end 3440 if ne get g_nm_fix i 0 3441 ret false 3442 end 3443 if ne get g_nm_rd i 0 3444 ret false 3445 end 3446 if lt get g_nm_dep i get g_st 27 3447 ret false 3448 end 3449 if ne get g_taken i 0 3450 ret false 3451 end 3452 ret true 3453 end 3454 3455 fn pick_array w ulong to long 3456 best = neg long 1 3457 nn = get g_st 9 3458 for i ulong nn bound 512 3459 reg = get g_nm_reg i 3460 t = get g_regs reg 3461 if or eq ty_ref t R_NONE or not want_ok w t own_dead reg 3462 continue 3463 end 3464 if in_r i 3465 ret long i 3466 end 3467 if lt best 0 3468 best = long i 3469 end 3470 end 3471 ret best 3472 end 3473 3474 fn args_exist fi ulong to bool 3475 np = get g_fn_np fi 3476 base = mul fi MAX_PARAMS 3477 for k ulong np bound 8 3478 pt = get g_fn_p add base k 3479 if eq ty_ref pt R_NONE 3480 continue 3481 end 3482 if lt pick_array want_param pt 0 3483 ret false 3484 end 3485 end 3486 ret true 3487 end 3488 3489 fn gives_int fi ulong to bool 3490 if and ne get g_st 6 0 eq fi sub get g_st 5 1 3491 ret false 3492 end 3493 if eq get g_fn_hret fi 0 3494 ret false 3495 end 3496 rt = get g_fn_ret fi 3497 if or ne ty_ref rt R_NONE eq ty_s rt T_BOOL 3498 ret false 3499 end 3500 ret args_exist fi 3501 end 3502 3503 fn call_text_tl use2 ulong fi ulong s ulong has_bx ulong to void 3504 rt = get g_fn_ret fi 3505 if ne ty_s rt s 3506 tl_gw use2 s 3507 tl_c use2 32 3508 end 3509 tl_fn use2 fi 3510 np = get g_fn_np fi 3511 base = mul fi MAX_PARAMS 3512 for k ulong np bound 8 3513 pt = get g_fn_p add base k 3514 if eq ty_ref pt R_NONE 3515 if and eq ty_s pt T_BOOL ne has_bx 0 3516 tl_c use2 32 3517 tl_bx use2 3518 has_bx = 0 3519 else 3520 tl_c use2 32 3521 if eq ty_s pt T_BOOL 3522 tl_t use2 tk_true 3523 else 3524 tl_c use2 48 3525 end 3526 end 3527 continue 3528 end 3529 ai = pick_array want_param pt 3530 au = ulong ai 3531 put g_taken au 1 3532 tl_c use2 32 3533 tl_nm use2 au 3534 end 3535 end 3536 3537 fn join_terms_to_genb n ulong s ulong is_typed ulong to void 3538 if eq n 0 3539 if eq is_typed 0 3540 genb_gw s 3541 genb_c 32 3542 end 3543 if eq s T_BOOL 3544 genb_t tk_true 3545 else 3546 genb_c 48 3547 end 3548 ret 3549 end 3550 p = ulong 0 3551 tlen = get g_tl_n 0 3552 for k ulong n bound 1024 3553 e = p 3554 while lt e tlen bound 65536 3555 if eq get g_tl e 10 3556 break 3557 end 3558 e = add e 1 3559 end 3560 if lt k sub n 1 3561 if eq s T_BOOL 3562 genb_t to_and 3563 else 3564 genb_t to_add 3565 end 3566 genb_c 32 3567 end 3568 for j ulong sub e p bound 4096 3569 genb_c get g_tl add p j 3570 end 3571 if lt k sub n 1 3572 genb_c 32 3573 end 3574 p = add e 1 3575 end 3576 end 3577 3578 fn join_terms_to_bx n ulong to void 3579 if eq n 0 3580 bx_t tk_true 3581 ret 3582 end 3583 p = ulong 0 3584 tlen = get g_tl2_n 0 3585 for k ulong n bound 1024 3586 e = p 3587 while lt e tlen bound 65536 3588 if eq get g_tl2 e 10 3589 break 3590 end 3591 e = add e 1 3592 end 3593 if lt k sub n 1 3594 bx_t to_and 3595 bx_c 32 3596 for j ulong sub e p bound 4096 3597 bx_c get g_tl2 add p j 3598 end 3599 bx_c 32 3600 else 3601 for j ulong sub e p bound 4096 3602 bx_c get g_tl2 add p j 3603 end 3604 end 3605 p = add e 1 3606 end 3607 end 3608 3609 fn gen_scalar_bool_to_bx to void 3610 put g_tl2_n 0 0 3611 put g_bx_n 0 0 3612 n = ulong 0 3613 nn = get g_st 9 3614 for i ulong nn bound 512 3615 if not in_r i 3616 continue 3617 end 3618 t = get g_regs get g_nm_reg i 3619 rf = ty_ref t 3620 ts = ty_s t 3621 if and eq rf R_NONE eq ts T_BOOL 3622 tl_nm 1 i 3623 tl_c 1 10 3624 else 3625 if eq rf R_NONE 3626 tl_t 1 to_eq 3627 tl_c 1 32 3628 tl_nm 1 i 3629 tl_c 1 32 3630 tl_nm 1 i 3631 tl_c 1 10 3632 else 3633 if eq ts T_BOOL 3634 tl_t 1 to_get 3635 tl_c 1 32 3636 tl_nm 1 i 3637 tl_c 1 32 3638 tl_c 1 48 3639 tl_c 1 10 3640 else 3641 tl_t 1 to_eq 3642 tl_c 1 32 3643 tl_t 1 to_get 3644 tl_c 1 32 3645 tl_nm 1 i 3646 tl_c 1 32 3647 tl_c 1 48 3648 tl_c 1 32 3649 tl_c 1 48 3650 tl_c 1 10 3651 end 3652 end 3653 end 3654 put g_taken i 1 3655 n = add n 1 3656 end 3657 join_terms_to_bx n 3658 end 3659 3660 fn find_bool_int_fn to long 3661 nf = get g_st 5 3662 for g ulong nf bound 32 3663 if gives_int g 3664 np = get g_fn_np g 3665 base = mul g MAX_PARAMS 3666 for k ulong np bound 8 3667 pt = get g_fn_p add base k 3668 if and eq ty_ref pt R_NONE eq ty_s pt T_BOOL 3669 ret long g 3670 end 3671 end 3672 end 3673 end 3674 ret neg long 1 3675 end 3676 3677 fn fn_binds_arr g ulong t ulong to bool 3678 if not gives_int g 3679 ret false 3680 end 3681 np = get g_fn_np g 3682 base = mul g MAX_PARAMS 3683 for k ulong np bound 8 3684 pt = get g_fn_p add base k 3685 if and ne ty_ref pt R_NONE binds pt t 3686 ret true 3687 end 3688 end 3689 ret false 3690 end 3691 3692 fn gen_scalar_needb s ulong to ulong 3693 h = find_bool_int_fn 3694 if ge h 0 3695 gen_scalar_bool_to_bx 3696 call_text_tl 0 ulong h s 1 3697 tl_c 0 10 3698 ret 1 3699 end 3700 added = ulong 0 3701 nn = get g_st 9 3702 nf = get g_st 5 3703 for i ulong nn bound 512 3704 if not in_r i 3705 continue 3706 end 3707 t = get g_regs get g_nm_reg i 3708 if eq ty_ref t R_NONE 3709 continue 3710 end 3711 g = ulong 0 3712 while and lt g nf in_r i bound 256 3713 if fn_binds_arr g t 3714 call_text_tl 0 g s 0 3715 tl_c 0 10 3716 added = add added 1 3717 else 3718 g = add g 1 3719 end 3720 end 3721 end 3722 ret added 3723 end 3724 3725 fn gen_scalar_to_genb s ulong is_typed ulong to void 3726 put g_tl_n 0 0 3727 n = ulong 0 3728 needb = ulong 0 3729 nn = get g_st 9 3730 for i ulong nn bound 512 3731 if not in_r i 3732 continue 3733 end 3734 t = get g_regs get g_nm_reg i 3735 rf = ty_ref t 3736 ts = ty_s t 3737 if eq s T_BOOL 3738 if and eq rf R_NONE eq ts T_BOOL 3739 tl_nm 0 i 3740 tl_c 0 10 3741 else 3742 if eq rf R_NONE 3743 tl_t 0 to_eq 3744 tl_c 0 32 3745 tl_nm 0 i 3746 tl_c 0 32 3747 tl_nm 0 i 3748 tl_c 0 10 3749 else 3750 if eq ts T_BOOL 3751 tl_t 0 to_get 3752 tl_c 0 32 3753 tl_nm 0 i 3754 tl_c 0 32 3755 tl_c 0 48 3756 tl_c 0 10 3757 else 3758 tl_t 0 to_eq 3759 tl_c 0 32 3760 tl_t 0 to_get 3761 tl_c 0 32 3762 tl_nm 0 i 3763 tl_c 0 32 3764 tl_c 0 48 3765 tl_c 0 32 3766 tl_c 0 48 3767 tl_c 0 10 3768 end 3769 end 3770 end 3771 put g_taken i 1 3772 n = add n 1 3773 else 3774 if eq ts T_BOOL 3775 needb = 1 3776 else 3777 if eq rf R_NONE 3778 if ne ts s 3779 tl_gw 0 s 3780 tl_c 0 32 3781 end 3782 tl_nm 0 i 3783 tl_c 0 10 3784 else 3785 if ne ts s 3786 tl_gw 0 s 3787 tl_c 0 32 3788 end 3789 tl_t 0 to_get 3790 tl_c 0 32 3791 tl_nm 0 i 3792 tl_c 0 32 3793 tl_c 0 48 3794 tl_c 0 10 3795 end 3796 put g_taken i 1 3797 n = add n 1 3798 end 3799 end 3800 end 3801 if ne needb 0 3802 n = add n gen_scalar_needb s 3803 end 3804 join_terms_to_genb n s is_typed 3805 end 3806 3807 fn gen_value_arr w ulong to long 3808 ai = pick_array w 3809 if ge ai 0 3810 genb_nm ulong ai 3811 ret fill_text_genb 3812 end 3813 nn = get g_st 9 3814 for rf ulong 3 bound 4 3815 rfv = add rf 1 3816 for k ulong nn bound 512 3817 reg = get g_nm_reg k 3818 t = get g_regs reg 3819 if ref_ok rfv t 3820 if and want_ok w ty_make rfv ty_s t ty_len t not own_dead reg 3821 genb_refw rfv 3822 genb_c 32 3823 genb_nm k 3824 ret fill_text_genb 3825 end 3826 end 3827 end 3828 end 3829 wp = want_p w 3830 if and ne want_top w 0 and eq want_arr w A_EXACT eq ty_ref wp R_OWN 3831 genb_t to_new 3832 genb_c 32 3833 genb_gw ty_s wp 3834 genb_c 32 3835 genb_u64 ty_len wp 3836 genb_c 32 3837 if eq ty_s wp T_BOOL 3838 genb_t tk_false 3839 else 3840 genb_c 48 3841 end 3842 ret fill_text_genb 3843 end 3844 err_start 3845 err_t te_no_arr 3846 ret neg long 1 3847 end 3848 3849 fn gen_value w ulong to long 3850 nn = get g_st 9 3851 for i ulong nn bound 512 3852 put g_taken i 0 3853 end 3854 put g_genb_n 0 0 3855 if eq want_scal w 0 3856 ret gen_value_arr w 3857 end 3858 m = want_scal w 3859 nr = ulong 0 3860 for i ulong nn bound 512 3861 if in_r i 3862 nr = add nr 1 3863 end 3864 end 3865 s = neg long 1 3866 if and gt nr 0 ne and m 1 0 3867 s = long T_BOOL 3868 else 3869 if and eq want_lit w L_TYPED ne and shr m ty_s want_lt w 1 0 3870 s = long ty_s want_lt w 3871 else 3872 if ne and shr m T_U32 1 0 3873 s = long T_U32 3874 else 3875 k = ulong 1 3876 while and lt k T_NSCALAR lt s 0 bound 16 3877 if ne and shr m k 1 0 3878 s = long k 3879 end 3880 k = add k 1 3881 end 3882 end 3883 end 3884 end 3885 if lt s 0 3886 s = long T_BOOL 3887 end 3888 su = ulong s 3889 is_t = ulong 0 3890 if and eq want_lit w L_TYPED eq ty_s want_lt w su 3891 is_t = 1 3892 end 3893 gen_scalar_to_genb su is_t 3894 ret fill_text_genb 3895 end 3896 3897 fn chain_floor to ulong 3898 k = sub get g_st 15 1 3899 while gt k 0 bound 64 3900 if ne get g_fr_kind k F_IF 3901 break 3902 end 3903 if eq get g_fr_hels k 0 3904 break 3905 end 3906 if ge get g_fr_join k 0 3907 break 3908 end 3909 k = sub k 1 3910 end 3911 ret get g_fr_dep k 3912 end 3913 3914 note ---- Val stack & expression helpers ---- 3915 fn val_alloc to ulong 3916 vi = get g_st 42 3917 put g_st 42 add vi 1 3918 put g_v_lit vi 0 3919 put g_v_word vi neg long 1 3920 put g_v_reg vi neg long 1 3921 put g_v_konst vi 0 3922 put g_v_head vi neg long 1 3923 put g_v_arity vi 0 3924 put g_v_paren vi 0 3925 put g_v_a vi get g_st 21 3926 put g_v_b vi 0 3927 put g_v_t vi 0 3928 ret vi 3929 end 3930 3931 fn to_dst dst long t ulong to long 3932 if ge dst 0 3933 dt = get g_regs ulong dst 3934 if ne dt t 3935 err_start 3936 err_t te_write_type1 3937 err_ty t 3938 err_t te_write_type2 3939 err_ty dt 3940 ret neg long 1 3941 end 3942 ret dst 3943 end 3944 ret new_reg t 3945 end 3946 3947 fn leaf vi ulong r ulong t ulong dst long to long 3948 put g_v_t vi t 3949 put g_v_b vi get g_st 21 3950 if eq dst neg long 2 3951 put g_v_reg vi long r 3952 ret 0 3953 end 3954 d = to_dst dst t 3955 if lt d 0 3956 ret d 3957 end 3958 rc = emit_mov ulong d r 3959 if lt rc 0 3960 ret rc 3961 end 3962 rc = own_mov ulong d r 3963 if lt rc 0 3964 ret rc 3965 end 3966 put g_v_reg vi d 3967 ret 0 3968 end 3969 3970 fn skip_value p ulong to long 3971 ln = get g_st 20 3972 if ge p ln 3973 ret neg long 1 3974 end 3975 wo = w_off p 3976 wl = w_len p 3977 if wp_eq_t wo wl t_lpar 3978 q = skip_value add p 1 3979 if lt q 0 3980 ret neg long 1 3981 end 3982 if ge ulong q ln 3983 ret neg long 1 3984 end 3985 if not w_eq_t ulong q t_rpar 3986 ret neg long 1 3987 end 3988 ret add q 1 3989 end 3990 if is_term_wp wo wl 3991 ret neg long 1 3992 end 3993 if or is_lit_wp wo wl ge find_name_wp wo wl 0 3994 ret long add p 1 3995 end 3996 g = find_callable_wp wo wl 3997 if ge g 0 3998 curp = long add p 1 3999 np = get g_fn_np ulong g 4000 for i ulong np bound 8 4001 if lt curp 0 4002 break 4003 end 4004 curp = skip_value ulong curp 4005 end 4006 ret curp 4007 end 4008 if ge scalar_word_wp wo wl 0 4009 ret skip_value add p 1 4010 end 4011 if ge ref_word_wp wo wl 0 4012 if le add p 2 ln 4013 ret long add p 2 4014 end 4015 ret neg long 1 4016 end 4017 o = op_word_wp wo wl 4018 if eq o long OP_GET 4019 if le add p 2 ln 4020 ret skip_value add p 2 4021 end 4022 ret neg long 1 4023 end 4024 if eq o long OP_NEW 4025 if le add p 3 ln 4026 ret skip_value add p 3 4027 end 4028 ret neg long 1 4029 end 4030 if or eq o long OP_NEG eq o long OP_NOT 4031 ret skip_value add p 1 4032 end 4033 if ge o 0 4034 q = skip_value add p 1 4035 if lt q 0 4036 ret neg long 1 4037 end 4038 ret skip_value ulong q 4039 end 4040 ret neg long 1 4041 end 4042 4043 fn extra_fail vi long in_paren ulong to long 4044 lp = get g_st 21 4045 ln = get g_st 20 4046 if and eq in_paren 0 w_eq_t lp t_rpar 4047 err_start 4048 err_t te_unmatched_rp 4049 ret neg long 1 4050 end 4051 m = ulong 0 4052 p = lp 4053 while and lt p ln not is_term_wp w_off p w_len p bound 1024 4054 q = skip_value p 4055 if lt q 0 4056 break 4057 end 4058 m = add m 1 4059 p = ulong q 4060 end 4061 e = lp 4062 while lt e ln bound 1024 4063 if and ne in_paren 0 w_eq_t e t_rpar 4064 break 4065 end 4066 e = add e 1 4067 end 4068 if and gt m 0 ge vi 0 4069 vu = ulong vi 4070 vh = get g_v_head vu 4071 if and ge vh 0 eq get g_v_paren vu 0 4072 ar = get g_v_arity vu 4073 err_start 4074 err_w ulong vh 4075 err_t te_has 4076 err_u64 add ar m 4077 err_t te_vals_after 4078 err_u64 ar 4079 ret neg long 1 4080 end 4081 end 4082 if ne in_paren 0 4083 err_start 4084 err_t te_paren_extra1 4085 err_span lp e 4086 err_t te_paren_extra2 4087 ret neg long 1 4088 end 4089 err_start 4090 err_t te_extra_end 4091 err_span lp ln 4092 err_c 39 4093 ret neg long 1 4094 end 4095 4096 fn array_fits a ulong kind ulong rf ulong want ulong to bool 4097 if eq ty_ref a R_NONE 4098 ret false 4099 end 4100 if eq kind AN_GET 4101 ret ne and shr want_scal want ty_s a 1 0 4102 end 4103 if eq kind AN_PUT 4104 ret ne ty_ref a R_SHARED 4105 end 4106 if eq kind AN_FREE 4107 ret eq ty_ref a R_OWN 4108 end 4109 ret and ref_ok rf a want_ok want ty_make rf ty_s a ty_len a 4110 end 4111 4112 fn array_name_fill kind ulong rf ulong want ulong to long 4113 cand = new ulong 512 0 4114 nc = ulong 0 4115 nd = ulong 0 4116 nn = get g_st 9 4117 for i ulong nn bound 512 4118 put g_taken i 0 4119 end 4120 for pass ulong 2 bound 2 4121 want_r = eq pass 0 4122 for i ulong nn bound 512 4123 reg = get g_nm_reg i 4124 if array_fits get g_regs reg kind rf want 4125 if own_dead reg 4126 if eq pass 0 4127 nd = add nd 1 4128 end 4129 else 4130 if eq in_r i want_r 4131 put cand nc i 4132 nc = add nc 1 4133 end 4134 end 4135 end 4136 end 4137 end 4138 if and eq nc 0 gt nd 0 4139 err_start 4140 err_t te_all_arr_dead 4141 ret neg long 1 4142 end 4143 if eq nc 0 4144 err_start 4145 err_t te_no_arr 4146 ret neg long 1 4147 end 4148 k = ulong 0 4149 if and gt nc 1 eq get g_st 29 0 4150 put g_st 29 nc 4151 k = rem get g_st 28 nc 4152 end 4153 ret fill_word_nm get cand k 4154 end 4155 4156 fn array_name head ulong arity ulong kind ulong rf ulong want ulong to long 4157 lp = get g_st 21 4158 if ge lp get g_st 20 4159 if eq get g_st 24 0 4160 err_start 4161 err_w head 4162 err_t te_has 4163 err_c 48 4164 err_t te_vals_after 4165 err_u64 arity 4166 ret neg long 1 4167 end 4168 rc = array_name_fill kind rf want 4169 if lt rc 0 4170 ret rc 4171 end 4172 end 4173 wo = w_off lp 4174 wl = w_len lp 4175 ni = find_name_wp wo wl 4176 if lt ni 0 4177 if or is_term_wp wo wl wp_eq_t wo wl t_lpar 4178 err_start 4179 err_w head 4180 err_t te_takes_arr 4181 err_wp wo wl 4182 err_c 39 4183 ret neg long 1 4184 end 4185 if is_lit_wp wo wl 4186 err_start 4187 err_c 39 4188 err_wp wo wl 4189 err_t te_not_arr 4190 ret neg long 1 4191 end 4192 err_start 4193 err_c 39 4194 err_wp wo wl 4195 err_t te_not_scope 4196 ret neg long 1 4197 end 4198 put g_st 21 add lp 1 4199 nu = ulong ni 4200 put g_nm_rd nu 1 4201 reg = get g_nm_reg nu 4202 if eq ty_ref get g_regs reg R_NONE 4203 err_start 4204 err_c 39 4205 err_wp wo wl 4206 err_t te_not_arr 4207 ret neg long 1 4208 end 4209 ret long reg 4210 end 4211 4212 fn slot want ulong dst long vi ulong head ulong k ulong arity ulong to long 4213 r = value want dst vi 4214 if eq r neg long 3 4215 err_start 4216 err_w head 4217 err_t te_has 4218 err_u64 k 4219 if eq k 1 4220 err_t te_val_after 4221 else 4222 err_t te_vals_after 4223 end 4224 err_u64 arity 4225 ret neg long 1 4226 end 4227 ret r 4228 end 4229 4230 fn call_args fi ulong head ulong args edit ulong 6 to long 4231 np = get g_fn_np fi 4232 base = mul fi MAX_PARAMS 4233 for i ulong np bound 8 4234 pt = get g_fn_p add base i 4235 sv = get g_st 42 4236 av = val_alloc 4237 rc = slot want_param pt neg long 2 av head i np 4238 if lt rc 0 4239 put g_st 42 sv 4240 ret rc 4241 end 4242 if ne get g_v_lit av 0 4243 err_start 4244 err_c 39 4245 err_w ulong get g_v_word av 4246 err_t te_arg_num 4247 err_fn fi 4248 err_t te_takes 4249 err_ty pt 4250 err_t te_there 4251 put g_st 42 sv 4252 ret neg long 1 4253 end 4254 avt = get g_v_t av 4255 if not binds pt avt 4256 err_start 4257 err_c 39 4258 err_span get g_v_a av get g_v_b av 4259 err_t te_is 4260 err_ty avt 4261 err_t te_ret_type2 4262 err_fn fi 4263 err_t te_takes 4264 err_ty pt 4265 err_t te_there 4266 put g_st 42 sv 4267 ret neg long 1 4268 end 4269 put args i ulong get g_v_reg av 4270 put g_st 42 sv 4271 end 4272 ret 0 4273 end 4274 4275 fn emit_call_op fi ulong args view ulong 6 has_dst ulong dst ulong to long 4276 r = op_begin 4277 if lt r 0 4278 ret r 4279 end 4280 if eq get g_st 25 0 4281 bops_t tj_call1 4282 bops_fn fi 4283 bops_t tj_call2 4284 np = get g_fn_np fi 4285 for i ulong np bound 8 4286 if gt i 0 4287 bops_t t_comma 4288 end 4289 bops_u64 get args i 4290 end 4291 if ne has_dst 0 4292 bops_t tj_call_dst 4293 bops_u64 dst 4294 else 4295 bops_c 93 4296 end 4297 op_finish 4298 end 4299 ret 0 4300 end 4301 4302 fn own_call fi ulong args view ulong 6 to long 4303 np = get g_fn_np fi 4304 base = mul fi MAX_PARAMS 4305 for k ulong np bound 8 4306 ar = get args k 4307 if eq ty_ref get g_regs ar R_NONE 4308 continue 4309 end 4310 rc = own_use ar 4311 if lt rc 0 4312 ret rc 4313 end 4314 if eq ty_ref get g_fn_p add base k R_OWN 4315 rc = own_kill ar 4316 if lt rc 0 4317 ret rc 4318 end 4319 end 4320 end 4321 ret 0 4322 end 4323 4324 fn value_call fi ulong dst long vi ulong to long 4325 if eq get g_fn_hret fi 0 4326 err_start 4327 err_fn fi 4328 err_t te_ret_void 4329 ret neg long 1 4330 end 4331 put g_v_arity vi get g_fn_np fi 4332 args = new ulong 6 0 4333 rc = call_args fi ulong get g_v_head vi edit args 4334 if lt rc 0 4335 ret rc 4336 end 4337 rt = get g_fn_ret fi 4338 d = to_dst dst rt 4339 if lt d 0 4340 ret d 4341 end 4342 rc = emit_call_op fi view args 1 ulong d 4343 if lt rc 0 4344 ret rc 4345 end 4346 rc = own_call fi view args 4347 if lt rc 0 4348 ret rc 4349 end 4350 put g_v_t vi rt 4351 put g_v_reg vi d 4352 put g_v_b vi get g_st 21 4353 ret 0 4354 end 4355 4356 fn value_conv s ulong dst long vi ulong to long 4357 ty = ty_make R_NONE s 0 4358 sc = S_INT 4359 if eq s T_BOOL 4360 sc = 1 4361 end 4362 sv = get g_st 42 4363 av = val_alloc 4364 if lt slot want_pack sc A_NONE L_TYPED 0 0 ty neg long 2 av ulong get g_v_head vi 0 1 0 4365 put g_st 42 sv 4366 ret neg long 1 4367 end 4368 aty = get g_v_t av 4369 if ne ty_ref aty R_NONE 4370 err_start 4371 err_c 39 4372 err_span get g_v_a av get g_v_b av 4373 err_t te_arr_conv 4374 put g_st 42 sv 4375 ret neg long 1 4376 end 4377 if ne eq s T_BOOL eq ty_s aty T_BOOL 4378 err_start 4379 err_t te_bool_conv 4380 put g_st 42 sv 4381 ret neg long 1 4382 end 4383 put g_v_t vi ty 4384 ar = ulong get g_v_reg av 4385 if ne get g_v_konst av 0 4386 if and eq dst neg long 2 eq ty_s aty s 4387 put g_v_reg vi long ar 4388 put g_v_konst vi 1 4389 put g_v_b vi get g_st 21 4390 put g_st 42 sv 4391 ret 0 4392 end 4393 end 4394 put g_st 42 sv 4395 d = to_dst dst ty 4396 if lt d 0 4397 ret d 4398 end 4399 sc = 0 4400 if eq s ty_s aty 4401 sc = 1 4402 end 4403 if lt emit_cast sc ulong d ar 0 4404 ret neg long 1 4405 end 4406 put g_v_reg vi d 4407 put g_v_b vi get g_st 21 4408 ret 0 4409 end 4410 4411 fn value_ref rf ulong want ulong dst long vi ulong to long 4412 ar = array_name ulong get g_v_head vi 1 AN_REF rf want 4413 if lt ar 0 4414 ret ar 4415 end 4416 au = ulong ar 4417 ta = get g_regs au 4418 if and eq rf R_OWN ne ty_ref ta R_OWN 4419 err_start 4420 err_t te_own_moves 4421 err_w sub get g_st 21 1 4422 err_t te_is 4423 err_ty ta 4424 ret neg long 1 4425 end 4426 if and eq rf R_MUT eq ty_ref ta R_SHARED 4427 err_start 4428 err_t te_edit_view 4429 err_w sub get g_st 21 1 4430 err_t te_is_view 4431 ret neg long 1 4432 end 4433 nt = ty_make rf ty_s ta ty_len ta 4434 put g_v_t vi nt 4435 d = to_dst dst nt 4436 if lt d 0 4437 ret d 4438 end 4439 rc = emit_mov ulong d au 4440 if lt rc 0 4441 ret rc 4442 end 4443 rc = own_mov ulong d au 4444 if lt rc 0 4445 ret rc 4446 end 4447 put g_v_reg vi d 4448 put g_v_b vi get g_st 21 4449 ret 0 4450 end 4451 4452 fn value_unop o ulong want ulong dst long vi ulong to long 4453 sc = want_scal want 4454 if eq o OP_NEG 4455 sc = and sc S_SIGNED 4456 else 4457 sc = and sc S_ALL 4458 end 4459 sv = get g_st 42 4460 av = val_alloc 4461 if lt slot want_pack sc A_NONE L_NO 0 0 0 neg long 2 av ulong get g_v_head vi 0 1 0 4462 put g_st 42 sv 4463 ret neg long 1 4464 end 4465 if ne get g_v_lit av 0 4466 err_start 4467 err_opw o 4468 err_c 32 4469 err_w ulong get g_v_word av 4470 err_t te_unk_num1 4471 err_w ulong get g_v_word av 4472 put g_st 42 sv 4473 ret neg long 1 4474 end 4475 aty = get g_v_t av 4476 if ne ty_ref aty R_NONE 4477 err_start 4478 err_opw o 4479 err_t te_needs_nb 4480 put g_st 42 sv 4481 ret neg long 1 4482 end 4483 if eq o OP_NEG 4484 if or eq ty_s aty T_BOOL not is_signed ty_s aty 4485 err_start 4486 err_t te_neg_signed 4487 err_span get g_v_a av get g_v_b av 4488 err_t te_is 4489 err_ty aty 4490 put g_st 42 sv 4491 ret neg long 1 4492 end 4493 end 4494 ar = ulong get g_v_reg av 4495 put g_st 42 sv 4496 put g_v_t vi aty 4497 d = to_dst dst aty 4498 if lt d 0 4499 ret d 4500 end 4501 sc = 0 4502 if eq o OP_NEG 4503 sc = 1 4504 end 4505 av = 0 4506 if eq ty_s aty T_BOOL 4507 av = 1 4508 end 4509 if lt emit_unop sc av ulong d ar 0 4510 ret neg long 1 4511 end 4512 put g_v_reg vi d 4513 put g_v_b vi get g_st 21 4514 ret 0 4515 end 4516 4517 fn value_get want ulong dst long vi ulong to long 4518 put g_v_arity vi 2 4519 ar = array_name ulong get g_v_head vi 2 AN_GET 0 want 4520 if lt ar 0 4521 ret ar 4522 end 4523 au = ulong ar 4524 sv = get g_st 42 4525 iv = val_alloc 4526 if lt slot want_pack S_INT A_NONE L_TYPED 0 0 ty_make R_NONE T_U32 0 neg long 2 iv ulong get g_v_head vi 1 2 0 4527 put g_st 42 sv 4528 ret neg long 1 4529 end 4530 if not ty_is_int get g_v_t iv 4531 err_start 4532 err_t te_idx_int1 4533 err_span get g_v_a iv get g_v_b iv 4534 err_t te_idx_int2 4535 put g_st 42 sv 4536 ret neg long 1 4537 end 4538 ir = ulong get g_v_reg iv 4539 put g_st 42 sv 4540 rt = ty_make R_NONE ty_s get g_regs au 0 4541 put g_v_t vi rt 4542 d = to_dst dst rt 4543 if lt d 0 4544 ret d 4545 end 4546 if lt emit_load ulong d au ir 0 4547 ret neg long 1 4548 end 4549 if lt own_use au 0 4550 ret neg long 1 4551 end 4552 put g_v_reg vi d 4553 put g_v_b vi get g_st 21 4554 ret 0 4555 end 4556 4557 fn value_new_head want ulong to long 4558 if ge get g_st 21 get g_st 20 4559 if eq get g_st 24 0 4560 err_start 4561 err_t to_new 4562 err_t te_has 4563 err_c 48 4564 err_t te_vals_after 4565 err_c 51 4566 ret neg long 1 4567 end 4568 es = T_U32 4569 if eq want_arr want A_EXACT 4570 es = ty_s want_p want 4571 end 4572 if lt fill_word_gw es 0 4573 ret neg long 1 4574 end 4575 end 4576 lp = get g_st 21 4577 s = scalar_word_wp w_off lp w_len lp 4578 if lt s 0 4579 err_start 4580 err_c 39 4581 err_w lp 4582 err_t te_not_elem 4583 ret neg long 1 4584 end 4585 put g_st 21 add lp 1 4586 if ge get g_st 21 get g_st 20 4587 if eq get g_st 24 0 4588 err_start 4589 err_t to_new 4590 err_t te_has 4591 err_c 49 4592 err_t te_val_after 4593 err_c 51 4594 ret neg long 1 4595 end 4596 el = ulong 1 4597 if eq want_arr want A_EXACT 4598 el = ty_len want_p want 4599 end 4600 if lt fill_word_u64 el 0 4601 ret neg long 1 4602 end 4603 end 4604 lp = get g_st 21 4605 ok = parse_lit_wp w_off lp w_len lp 4606 alen = get g_st 48 4607 if or not ok or ne get g_st 47 0 or lt alen 1 gt alen 64 4608 err_start 4609 err_t te_arr_len1 4610 err_w lp 4611 err_t te_arr_len2 4612 ret neg long 1 4613 end 4614 put g_st 21 add lp 1 4615 ret long ty_make R_OWN ulong s alen 4616 end 4617 4618 fn value_new want ulong dst long vi ulong to long 4619 put g_v_arity vi 3 4620 if eq want_top want 0 4621 err_start 4622 err_t te_new_top 4623 ret neg long 1 4624 end 4625 ntr = value_new_head want 4626 if lt ntr 0 4627 ret ntr 4628 end 4629 nt = ulong ntr 4630 et = ty_make R_NONE ty_s nt 0 4631 sv = get g_st 42 4632 iv = val_alloc 4633 if lt slot want_type et neg long 2 iv ulong get g_v_head vi 2 3 0 4634 put g_st 42 sv 4635 ret neg long 1 4636 end 4637 if ne get g_v_t iv et 4638 err_start 4639 err_t te_init_type1 4640 err_span get g_v_a iv get g_v_b iv 4641 err_t te_is 4642 err_ty get g_v_t iv 4643 err_t te_init_type2 4644 err_ty et 4645 put g_st 42 sv 4646 ret neg long 1 4647 end 4648 ir = ulong get g_v_reg iv 4649 put g_st 42 sv 4650 put g_v_t vi nt 4651 d = to_dst dst nt 4652 if lt d 0 4653 ret d 4654 end 4655 if lt emit_alloc ulong d ir 0 4656 ret neg long 1 4657 end 4658 if lt own_birth ulong d 0 4659 ret neg long 1 4660 end 4661 put g_v_reg vi d 4662 put g_v_b vi get g_st 21 4663 ret 0 4664 end 4665 4666 fn value_binop_finish o ulong dst long vi ulong av ulong bv ulong to long 4667 alit = ne get g_v_lit av 0 4668 if and alit ne get g_v_lit bv 0 4669 err_start 4670 err_opw o 4671 err_c 32 4672 err_w ulong get g_v_word av 4673 err_c 32 4674 err_w ulong get g_v_word bv 4675 err_t te_two_nums 4676 ret neg long 1 4677 end 4678 bt = get g_v_t bv 4679 if ne ty_ref bt R_NONE 4680 err_start 4681 err_opw o 4682 err_t te_not_arr_op 4683 ret neg long 1 4684 end 4685 ar = ulong 0 4686 aty = get g_v_t av 4687 if alit 4688 if and or is_arith o is_shift o eq ty_s bt T_BOOL 4689 err_start 4690 err_opw o 4691 err_t te_need_int_op 4692 ret neg long 1 4693 end 4694 aw = ulong get g_v_word av 4695 lr = lit_reg_wp w_off aw w_len aw bt 4696 if lt lr 0 4697 ret lr 4698 end 4699 ar = ulong lr 4700 aty = bt 4701 else 4702 ar = ulong get g_v_reg av 4703 end 4704 rt = aty 4705 if is_shift o 4706 if or not ty_is_int aty not ty_is_int bt 4707 err_start 4708 err_t te_shift_int 4709 ret neg long 1 4710 end 4711 else 4712 if ne aty bt 4713 err_start 4714 err_opw o 4715 err_t te_two_same 4716 err_span get g_v_a av get g_v_b av 4717 err_t te_is 4718 err_ty aty 4719 err_t t_comma 4720 err_c 39 4721 err_span get g_v_a bv get g_v_b bv 4722 err_t te_is 4723 err_ty bt 4724 ret neg long 1 4725 end 4726 if and is_arith o eq ty_s aty T_BOOL 4727 err_start 4728 err_opw o 4729 err_t te_need_int_op 4730 ret neg long 1 4731 end 4732 if is_cmp o 4733 rt = ty_make R_NONE T_BOOL 0 4734 end 4735 end 4736 put g_v_t vi rt 4737 d = to_dst dst rt 4738 if lt d 0 4739 ret d 4740 end 4741 if lt emit_binop o ulong d ar ulong get g_v_reg bv 0 4742 ret neg long 1 4743 end 4744 put g_v_reg vi d 4745 put g_v_b vi get g_st 21 4746 ret 0 4747 end 4748 4749 fn value_binop_w2 o ulong sc1 ulong av ulong to ulong 4750 if ne get g_v_lit av 0 4751 aw = ulong get g_v_word av 4752 ret want_pack lit_fits_wp w_off aw w_len aw sc1 A_NONE L_NO 0 0 0 4753 end 4754 aty = get g_v_t av 4755 sc2 = shl ulong 1 ty_s aty 4756 if is_shift o 4757 sc2 = S_INT 4758 end 4759 ret want_pack sc2 A_NONE L_TYPED 0 0 aty 4760 end 4761 4762 fn value_binop_check_a o ulong av ulong to long 4763 if ne get g_v_lit av 0 4764 ret 0 4765 end 4766 aty = get g_v_t av 4767 if ne ty_ref aty R_NONE 4768 err_start 4769 err_opw o 4770 err_t te_not_arr_op 4771 ret neg long 1 4772 end 4773 if or is_arith o is_shift o 4774 if eq ty_s aty T_BOOL 4775 err_start 4776 err_opw o 4777 err_t te_need_int_op 4778 ret neg long 1 4779 end 4780 end 4781 ret 0 4782 end 4783 4784 fn value_binop o ulong want ulong dst long vi ulong to long 4785 put g_v_arity vi 2 4786 sc1 = S_ALL 4787 if not is_cmp o 4788 if or is_arith o is_shift o 4789 sc1 = and want_scal want S_INT 4790 else 4791 sc1 = and want_scal want S_ALL 4792 end 4793 end 4794 sv = get g_st 42 4795 av = val_alloc 4796 bv = val_alloc 4797 if lt slot want_pack sc1 A_NONE L_OPEN 0 0 0 neg long 2 av ulong get g_v_head vi 0 2 0 4798 put g_st 42 sv 4799 ret neg long 1 4800 end 4801 if lt value_binop_check_a o av 0 4802 put g_st 42 sv 4803 ret neg long 1 4804 end 4805 if lt slot value_binop_w2 o sc1 av neg long 2 bv ulong get g_v_head vi 1 2 0 4806 put g_st 42 sv 4807 ret neg long 1 4808 end 4809 rc = value_binop_finish o dst vi av bv 4810 put g_st 42 sv 4811 ret rc 4812 end 4813 4814 fn value_paren want ulong dst long vi ulong to long 4815 start = get g_st 21 4816 put g_st 21 add start 1 4817 put g_st 22 add get g_st 22 1 4818 r = value want dst vi 4819 put g_st 22 sub get g_st 22 1 4820 if eq r neg long 3 4821 lp2 = get g_st 21 4822 if lt lp2 get g_st 20 4823 if w_eq_t lp2 t_rpar 4824 err_start 4825 err_t te_empty_par 4826 ret neg long 1 4827 end 4828 end 4829 err_start 4830 err_t te_miss_lp 4831 ret neg long 1 4832 end 4833 if lt r 0 4834 ret r 4835 end 4836 if ge get g_st 21 get g_st 20 4837 if eq get g_st 24 0 4838 err_start 4839 err_t te_unmatched_lp 4840 ret neg long 1 4841 end 4842 if lt fill_word_t t_rpar 0 4843 ret neg long 1 4844 end 4845 end 4846 if not w_eq_t get g_st 21 t_rpar 4847 ret extra_fail long vi 1 4848 end 4849 put g_st 21 add get g_st 21 1 4850 put g_v_paren vi 1 4851 put g_v_a vi start 4852 put g_v_b vi get g_st 21 4853 ret 0 4854 end 4855 4856 fn value_head wo ulong wl ulong want ulong dst long vi ulong to long 4857 s = scalar_word_wp wo wl 4858 if ge s 0 4859 ret value_conv ulong s dst vi 4860 end 4861 rf = ref_word_wp wo wl 4862 if ge rf 0 4863 ret value_ref ulong rf want dst vi 4864 end 4865 o = op_word_wp wo wl 4866 if lt o 0 4867 err_start 4868 err_c 39 4869 err_wp wo wl 4870 err_t te_unk_word 4871 ret neg long 1 4872 end 4873 ou = ulong o 4874 if or eq ou OP_NEG eq ou OP_NOT 4875 ret value_unop ou want dst vi 4876 end 4877 if eq ou OP_GET 4878 ret value_get want dst vi 4879 end 4880 if eq ou OP_NEW 4881 ret value_new want dst vi 4882 end 4883 ret value_binop ou want dst vi 4884 end 4885 4886 fn value want ulong dst long vi ulong to long 4887 put g_v_lit vi 0 4888 put g_v_word vi neg long 1 4889 put g_v_reg vi neg long 1 4890 put g_v_konst vi 0 4891 put g_v_head vi neg long 1 4892 put g_v_arity vi 0 4893 put g_v_paren vi 0 4894 put g_v_a vi get g_st 21 4895 put g_v_b vi 0 4896 put g_v_t vi 0 4897 if ge get g_st 21 get g_st 20 4898 if eq get g_st 24 0 4899 ret neg long 3 4900 end 4901 if lt gen_value want 0 4902 ret neg long 1 4903 end 4904 end 4905 lp = get g_st 21 4906 wo = w_off lp 4907 wl = w_len lp 4908 if wp_eq_t wo wl t_rpar 4909 if ne get g_st 22 0 4910 ret neg long 3 4911 end 4912 err_start 4913 err_t te_unmatched_rp 4914 ret neg long 1 4915 end 4916 if is_term_wp wo wl 4917 ret neg long 3 4918 end 4919 if wp_eq_t wo wl t_lpar 4920 ret value_paren want dst vi 4921 end 4922 if is_lit_wp wo wl 4923 put g_v_word vi long lp 4924 put g_st 21 add lp 1 4925 put g_v_b vi add lp 1 4926 if ne want_lit want L_TYPED 4927 put g_v_lit vi 1 4928 ret 0 4929 end 4930 lr = lit_reg_wp wo wl want_lt want 4931 if lt lr 0 4932 ret lr 4933 end 4934 put g_v_konst vi 1 4935 ret leaf vi ulong lr want_lt want dst 4936 end 4937 if or is_digit get g_wpool wo eq get g_wpool wo 45 4938 err_start 4939 err_c 39 4940 err_wp wo wl 4941 err_t te_bad_num 4942 ret neg long 1 4943 end 4944 ni = find_name_wp wo wl 4945 if ge ni 0 4946 put g_st 21 add lp 1 4947 put g_nm_rd ulong ni 1 4948 reg = get g_nm_reg ulong ni 4949 ret leaf vi reg get g_regs reg dst 4950 end 4951 g = find_callable_wp wo wl 4952 if and lt g 0 ge find_func_wp wo wl 0 4953 err_start 4954 err_wp wo wl 4955 err_t te_self_call 4956 ret neg long 1 4957 end 4958 put g_v_head vi long lp 4959 put g_st 21 add lp 1 4960 if ge g 0 4961 ret value_call ulong g dst vi 4962 end 4963 put g_v_arity vi 1 4964 ret value_head wo wl want dst vi 4965 end 4966 4967 note ---- statements & functions ---- 4968 fn line_end vi long to long 4969 if ge get g_st 21 get g_st 20 4970 ret 0 4971 end 4972 ret extra_fail vi 0 4973 end 4974 4975 fn alone s view uchar * to long 4976 if lt get g_st 21 get g_st 20 4977 err_start 4978 err_t s 4979 err_t te_stands_alone 4980 ret neg long 1 4981 end 4982 ret 0 4983 end 4984 4985 fn parse_cond vi ulong what view uchar * to long 4986 bw = want_type ty_make R_NONE T_BOOL 0 4987 r = value bw neg long 2 vi 4988 if eq r neg long 3 4989 err_start 4990 err_t what 4991 err_t te_needs_cond 4992 ret neg long 1 4993 end 4994 if lt r 0 4995 ret r 4996 end 4997 ct = get g_v_t vi 4998 if not and eq ty_ref ct R_NONE eq ty_s ct T_BOOL 4999 err_start 5000 err_t te_cond_bool 5001 err_ty ct 5002 ret neg long 1 5003 end 5004 ret 0 5005 end 5006 5007 fn push_frame kind ulong to long 5008 nf = get g_st 15 5009 if ge nf MAX_FRAMES 5010 err_start 5011 err_t te_max_frames 5012 ret neg long 1 5013 end 5014 put g_fr_kind nf kind 5015 dep = add get g_st 10 1 5016 put g_st 10 dep 5017 put g_fr_dep nf dep 5018 put g_fr_els nf 0 5019 put g_fr_join nf 0 5020 put g_fr_hels nf 0 5021 put g_fr_head nf 0 5022 put g_fr_exit nf 0 5023 put g_fr_ctr nf 0 5024 put g_fr_ohas nf 0 5025 put g_st 15 add nf 1 5026 ret long nf 5027 end 5028 5029 fn end_function_emit_one off ulong olen ulong to void 5030 p = ulong 0 5031 while lt p olen bound 4096 5032 c = get g_bops add off p 5033 if eq c 64 5034 p = add p 1 5035 id = ulong 0 5036 while lt p olen bound 32 5037 ch = get g_bops add off p 5038 if eq ch 64 5039 break 5040 end 5041 id = add mul id 10 ulong sub ch 48 5042 p = add p 1 5043 end 5044 out_u64 ulong get g_bmap id 5045 if lt p olen 5046 p = add p 1 5047 end 5048 else 5049 out_c c 5050 p = add p 1 5051 end 5052 end 5053 end 5054 5055 fn end_function_emit_ops b ulong first ulong to void 5056 idx = get g_blk_head b 5057 while ge idx 0 bound BIG 5058 iu = ulong idx 5059 if eq first 0 5060 out_t t_comma 5061 end 5062 first = 0 5063 out_c 123 5064 end_function_emit_one get g_op_off iu get g_op_len iu 5065 out_c 125 5066 idx = get g_op_next iu 5067 end 5068 end 5069 5070 fn end_function_emit_consts to ulong 5071 first = ulong 1 5072 nc = get g_st 11 5073 for c ulong nc bound 256 5074 if eq first 0 5075 out_t t_comma 5076 end 5077 first = 0 5078 out_t tj_const1 5079 out_u64 get g_ck_reg c 5080 out_t tj_const2 5081 if eq ty_s get g_ck_t c T_BOOL 5082 if ne get g_ck_mag c 0 5083 out_t tk_true 5084 else 5085 out_t tk_false 5086 end 5087 else 5088 if ne get g_ck_neg c 0 5089 out_c 45 5090 end 5091 out_u64 get g_ck_mag c 5092 end 5093 out_c 125 5094 end 5095 ret first 5096 end 5097 5098 fn end_function to void 5099 fi = sub get g_st 5 1 5100 nb = get g_st 12 5101 for i ulong nb bound 512 5102 o = get g_blk_ord i 5103 put g_bmap i o 5104 if ge o 0 5105 put g_bord ulong o i 5106 end 5107 end 5108 if gt get g_st 5 1 5109 out_c 44 5110 end 5111 out_t tj_fn1 5112 out_fn_name fi 5113 out_t tj_fn2 5114 np = get g_fn_np fi 5115 pbase = mul fi MAX_PARAMS 5116 for i ulong np bound 8 5117 if gt i 0 5118 out_t t_comma 5119 end 5120 out_c 34 5121 out_tir get g_fn_p add pbase i 5122 out_c 34 5123 end 5124 out_t tj_fn3 5125 if ne get g_fn_hret fi 0 5126 out_tir get g_fn_ret fi 5127 else 5128 out_t tk_void 5129 end 5130 out_t tj_fn4 5131 npar = get g_st 8 5132 nr = get g_st 7 5133 i = npar 5134 while lt i nr bound 512 5135 if gt i npar 5136 out_t t_comma 5137 end 5138 out_c 34 5139 out_tir get g_regs i 5140 out_c 34 5141 i = add i 1 5142 end 5143 out_t tj_fn5 5144 nord = get g_st 13 5145 for k ulong nord bound 512 5146 if gt k 0 5147 out_c 44 5148 end 5149 out_t tj_blk 5150 first = ulong 1 5151 if eq k 0 5152 first = end_function_emit_consts 5153 end 5154 end_function_emit_ops get g_bord k first 5155 out_c 93 5156 end 5157 out_t tj_fn6 5158 put g_st 40 0 5159 put g_st 41 0 5160 end 5161 5162 fn fn_line_params nf ulong to long 5163 while true bound 64 5164 if ge get g_st 21 get g_st 20 5165 if eq get g_st 24 0 5166 err_start 5167 err_t te_fn_to 5168 ret neg long 1 5169 end 5170 if lt fill_word_t tk_to 0 5171 ret neg long 1 5172 end 5173 end 5174 lp = get g_st 21 5175 if w_eq_t lp tk_to 5176 ret 0 5177 end 5178 np = get g_fn_np nf 5179 if ge np MAX_PARAMS 5180 err_start 5181 err_t te_max_params 5182 ret neg long 1 5183 end 5184 pno = w_off lp 5185 pnl = w_len lp 5186 put g_st 21 add lp 1 5187 tr = parse_type 5188 if lt tr 0 5189 ret tr 5190 end 5191 tu = ulong tr 5192 put g_fn_p add mul nf MAX_PARAMS np tu 5193 put g_fn_np nf add np 1 5194 r = new_reg tu 5195 if lt r 0 5196 ret r 5197 end 5198 if ge find_name_wp pno pnl 0 5199 err_start 5200 err_t te_dup_param1 5201 err_wp pno pnl 5202 err_t te_dup_param2 5203 ret neg long 1 5204 end 5205 if lt bind_name_wp pno pnl ulong r 2 0 5206 ret neg long 1 5207 end 5208 if eq ty_ref tu R_OWN 5209 os = own_slot ulong r 5210 if ge os 0 5211 put g_ost_b ulong os uchar OS_L 5212 put g_ost_m ulong os 0 5213 end 5214 end 5215 end 5216 ret 0 5217 end 5218 5219 fn fn_line to long 5220 if ne get g_st 6 0 5221 err_start 5222 err_t te_fn_in_fn 5223 ret neg long 1 5224 end 5225 nf = get g_st 5 5226 if ge nf MAX_FUNCS 5227 err_start 5228 err_t te_max_funcs 5229 ret neg long 1 5230 end 5231 if and lt get g_st 20 3 eq get g_st 24 0 5232 err_start 5233 err_t te_fn_syn 5234 ret neg long 1 5235 end 5236 if lt get g_st 20 2 5237 if lt fill_fresh_name 0 5238 ret neg long 1 5239 end 5240 end 5241 fo = w_off 1 5242 fl = w_len 1 5243 if or not valid_ident_wp fo fl reserved_wp fo fl 5244 err_start 5245 err_c 39 5246 err_wp fo fl 5247 err_t te_bad_fn 5248 ret neg long 1 5249 end 5250 if ge find_func_wp fo fl 0 5251 err_start 5252 err_t te_dup_fn1 5253 err_wp fo fl 5254 err_t te_dup_fn2 5255 ret neg long 1 5256 end 5257 dst = mul nf 64 5258 for i ulong fl bound 64 5259 put g_fn_name add dst i get g_wpool add fo i 5260 end 5261 put g_fn_nlen nf fl 5262 put g_fn_np nf 0 5263 put g_fn_hret nf 0 5264 put g_fn_ret nf 0 5265 put g_st 7 0 5266 put g_st 9 0 5267 put g_st 11 0 5268 put g_st 12 0 5269 put g_st 13 0 5270 put g_st 15 0 5271 put g_st 16 0 5272 put g_st 17 0 5273 put g_st 19 0 5274 put g_st 18 0 5275 put g_st 10 0 5276 put g_st 40 0 5277 put g_st 41 0 5278 if lt push_frame F_FN 0 5279 ret neg long 1 5280 end 5281 put g_st 21 2 5282 if lt fn_line_params nf 0 5283 ret neg long 1 5284 end 5285 put g_st 21 add get g_st 21 1 5286 if and ge get g_st 21 get g_st 20 ne get g_st 24 0 5287 if lt fill_word_t tk_void 0 5288 ret neg long 1 5289 end 5290 end 5291 is_void = false 5292 if lt get g_st 21 get g_st 20 5293 if w_eq_t get g_st 21 tk_void 5294 is_void = true 5295 end 5296 end 5297 if is_void 5298 put g_fn_hret nf 0 5299 put g_st 21 add get g_st 21 1 5300 else 5301 tr = parse_type 5302 if lt tr 0 5303 ret tr 5304 end 5305 tu = ulong tr 5306 if ne ty_ref tu R_NONE 5307 err_start 5308 err_t te_fn_ret_arr 5309 ret neg long 1 5310 end 5311 put g_fn_hret nf 1 5312 put g_fn_ret nf tu 5313 end 5314 if ne get g_st 21 get g_st 20 5315 err_start 5316 err_c 39 5317 err_w get g_st 21 5318 err_t te_after_ret 5319 ret neg long 1 5320 end 5321 put g_st 8 get g_st 7 5322 put g_st 5 add nf 1 5323 put g_st 6 1 5324 b = new_block 5325 if lt b 0 5326 ret b 5327 end 5328 start_block ulong b 5329 ret 0 5330 end 5331 5332 fn guarded_loop_tail is_for ulong to long 5333 fk = F_WHILE 5334 if ne is_for 0 5335 fk = F_FOR 5336 end 5337 fr = push_frame fk 5338 if lt fr 0 5339 ret fr 5340 end 5341 fu = ulong fr 5342 own_loop_pushed fu 5343 put g_fr_head fu long get g_st 57 5344 put g_fr_exit fu long get g_st 60 5345 ret fr 5346 end 5347 5348 fn guarded_loop_while_bound sv ulong to long 5349 if ge get g_st 21 get g_st 20 5350 if eq get g_st 24 0 5351 err_start 5352 err_t te_bound_miss 5353 put g_st 42 sv 5354 ret neg long 1 5355 end 5356 if lt fill_word_t t_1 0 5357 put g_st 42 sv 5358 ret neg long 1 5359 end 5360 end 5361 blp = get g_st 21 5362 put g_st 21 add blp 1 5363 bo = w_off blp 5364 bl = w_len blp 5365 bad = not parse_lit_wp bo bl 5366 if not bad 5367 if ne get g_st 47 0 5368 bad = true 5369 end 5370 end 5371 if not bad 5372 if or lt get g_st 48 1 gt get g_st 48 `1000000` 5373 bad = true 5374 end 5375 end 5376 if bad 5377 err_start 5378 err_t te_bound_rng1 5379 err_wp bo bl 5380 err_t te_bound_rng2 5381 put g_st 42 sv 5382 ret neg long 1 5383 end 5384 rc = line_end neg long 1 5385 put g_st 42 sv 5386 if lt rc 0 5387 ret rc 5388 end 5389 ret lit_reg_wp bo bl ty_make R_NONE T_U64 0 5390 end 5391 5392 fn guarded_loop_while_cond to long 5393 sv = get g_st 42 5394 cv = val_alloc 5395 if lt parse_cond cv tk_while 0 5396 put g_st 42 sv 5397 ret neg long 1 5398 end 5399 put g_st 51 ulong get g_v_reg cv 5400 if lt get g_st 21 get g_st 20 5401 if w_eq_t get g_st 21 tk_bound 5402 put g_st 21 add get g_st 21 1 5403 ret guarded_loop_while_bound sv 5404 end 5405 end 5406 rc = line_end long cv 5407 put g_st 42 sv 5408 if lt rc 0 5409 ret rc 5410 end 5411 ret lit_reg_t t_1m ty_make R_NONE T_U64 0 5412 end 5413 5414 fn guarded_loop_emit_guard cnt ulong lim ulong to long 5415 start_block get g_st 58 5416 ge_r = new_reg ty_make R_NONE T_BOOL 0 5417 if lt ge_r 0 5418 ret ge_r 5419 end 5420 if lt emit_binop OP_GE ulong ge_r cnt lim 0 5421 ret neg long 1 5422 end 5423 if lt emit_cbr ulong ge_r get g_st 59 get g_st 52 0 5424 ret neg long 1 5425 end 5426 start_block get g_st 59 5427 if lt emit_trap 4 0 5428 ret neg long 1 5429 end 5430 if lt emit_br get g_st 60 0 5431 ret neg long 1 5432 end 5433 start_block get g_st 52 5434 one = lit_reg_t t_1 ty_make R_NONE T_U64 0 5435 if lt one 0 5436 ret one 5437 end 5438 ret emit_binop OP_ADD cnt cnt ulong one 5439 end 5440 5441 fn guarded_loop_init_for s ulong to long 5442 t = ty_make R_NONE s 0 5443 z = lit_reg_t t_0 t 5444 if lt z 0 5445 ret z 5446 end 5447 if lt lit_reg_t t_1 t 0 5448 ret neg long 1 5449 end 5450 ctr = new_reg t 5451 if lt ctr 0 5452 ret ctr 5453 end 5454 if lt emit_mov ulong ctr ulong z 0 5455 ret neg long 1 5456 end 5457 ret ctr 5458 end 5459 5460 fn guarded_loop_alloc_blks to long 5461 b = new_block 5462 if lt b 0 5463 ret neg long 1 5464 end 5465 put g_st 57 ulong b 5466 b = new_block 5467 if lt b 0 5468 ret neg long 1 5469 end 5470 put g_st 58 ulong b 5471 b = new_block 5472 if lt b 0 5473 ret neg long 1 5474 end 5475 put g_st 59 ulong b 5476 b = new_block 5477 if lt b 0 5478 ret neg long 1 5479 end 5480 put g_st 52 ulong b 5481 b = new_block 5482 if lt b 0 5483 ret neg long 1 5484 end 5485 put g_st 60 ulong b 5486 ret 0 5487 end 5488 5489 fn guarded_loop is_for ulong s ulong count_reg ulong fn_off ulong fn_len ulong to long 5490 zero = lit_reg_t t_0 ty_make R_NONE T_U64 0 5491 if lt zero 0 5492 ret zero 5493 end 5494 if lt lit_reg_t t_1 ty_make R_NONE T_U64 0 0 5495 ret neg long 1 5496 end 5497 ctr = neg long 1 5498 cnt = new_reg ty_make R_NONE T_U64 0 5499 if lt cnt 0 5500 ret cnt 5501 end 5502 if ne is_for 0 5503 ctr = guarded_loop_init_for s 5504 if lt ctr 0 5505 ret ctr 5506 end 5507 end 5508 if lt emit_mov ulong cnt ulong zero 0 5509 ret neg long 1 5510 end 5511 if lt guarded_loop_alloc_blks 0 5512 ret neg long 1 5513 end 5514 if lt emit_br get g_st 57 0 5515 ret neg long 1 5516 end 5517 if lt own_loop_open 0 5518 ret neg long 1 5519 end 5520 start_block get g_st 57 5521 lim = neg long 1 5522 if ne is_for 0 5523 lim = new_reg ty_make R_NONE T_BOOL 0 5524 if lt lim 0 5525 ret lim 5526 end 5527 put g_st 51 ulong lim 5528 if lt emit_binop OP_LT ulong lim ulong ctr count_reg 0 5529 ret neg long 1 5530 end 5531 lim = lit_reg_t t_1m ty_make R_NONE T_U64 0 5532 else 5533 lim = guarded_loop_while_cond 5534 end 5535 if lt lim 0 5536 ret lim 5537 end 5538 if lt emit_cbr get g_st 51 get g_st 58 get g_st 60 0 5539 ret neg long 1 5540 end 5541 if lt guarded_loop_emit_guard ulong cnt ulong lim 0 5542 ret neg long 1 5543 end 5544 lim = guarded_loop_tail is_for 5545 if lt lim 0 5546 ret lim 5547 end 5548 put g_fr_ctr ulong lim ctr 5549 if ne is_for 0 5550 ret bind_name_wp fn_off fn_len ulong ctr 1 5551 end 5552 ret 0 5553 end 5554 5555 fn count_number to long 5556 i = get g_st 21 5557 ln = get g_st 20 5558 k = ulong 0 5559 while lt i ln bound 1024 5560 if not w_eq_t i t_lpar 5561 break 5562 end 5563 i = add i 1 5564 k = add k 1 5565 end 5566 if ge i ln 5567 ret neg long 1 5568 end 5569 if not is_lit_wp w_off i w_len i 5570 ret neg long 1 5571 end 5572 j = add i 1 5573 c = ulong 0 5574 while and lt j ln lt c k bound 1024 5575 if not w_eq_t j t_rpar 5576 break 5577 end 5578 j = add j 1 5579 c = add c 1 5580 end 5581 if and eq j ln ne get g_st 24 0 5582 while lt c k bound 1024 5583 if lt fill_word_t t_rpar 0 5584 ret neg long 1 5585 end 5586 c = add c 1 5587 j = add j 1 5588 end 5589 ln = get g_st 20 5590 end 5591 if or ne j ln lt c k 5592 ret neg long 1 5593 end 5594 ret long i 5595 end 5596 5597 fn for_line_const_emit nmo ulong nml ulong ctr ulong k ulong to long 5598 h = new_block 5599 if lt h 0 5600 ret neg long 1 5601 end 5602 body = new_block 5603 if lt body 0 5604 ret neg long 1 5605 end 5606 ex = new_block 5607 if lt ex 0 5608 ret neg long 1 5609 end 5610 if lt emit_br ulong h 0 5611 ret neg long 1 5612 end 5613 if lt own_loop_open 0 5614 ret neg long 1 5615 end 5616 start_block ulong h 5617 c = new_reg ty_make R_NONE T_BOOL 0 5618 if lt c 0 5619 ret c 5620 end 5621 if lt emit_binop OP_LT ulong c ctr k 0 5622 ret neg long 1 5623 end 5624 if lt emit_cbr ulong c ulong body ulong ex 0 5625 ret neg long 1 5626 end 5627 c = push_frame F_FOR 5628 if lt c 0 5629 ret c 5630 end 5631 own_loop_pushed ulong c 5632 put g_fr_head ulong c h 5633 put g_fr_exit ulong c ex 5634 put g_fr_ctr ulong c long ctr 5635 if lt bind_name_wp nmo nml ctr 1 0 5636 ret neg long 1 5637 end 5638 start_block ulong body 5639 ret 0 5640 end 5641 5642 fn for_line_const nmo ulong nml ulong t ulong ki ulong to long 5643 ko = w_off ki 5644 kl = w_len ki 5645 if not parse_lit_wp ko kl 5646 err_start 5647 err_t te_cnt_rng1 5648 err_wp ko kl 5649 err_t te_cnt_rng2 5650 ret neg long 1 5651 end 5652 if or ne get g_st 47 0 gt get g_st 48 `1000000` 5653 err_start 5654 err_t te_cnt_rng1 5655 err_wp ko kl 5656 err_t te_cnt_rng2 5657 ret neg long 1 5658 end 5659 put g_st 21 get g_st 20 5660 if lt line_end neg long 1 0 5661 ret neg long 1 5662 end 5663 zero = lit_reg_t t_0 t 5664 if lt zero 0 5665 ret zero 5666 end 5667 k = lit_reg_wp ko kl t 5668 if lt k 0 5669 ret k 5670 end 5671 if lt lit_reg_t t_1 t 0 5672 ret neg long 1 5673 end 5674 ctr = new_reg t 5675 if lt ctr 0 5676 ret ctr 5677 end 5678 if lt emit_mov ulong ctr ulong zero 0 5679 ret neg long 1 5680 end 5681 ret for_line_const_emit nmo nml ulong ctr ulong k 5682 end 5683 5684 fn for_line to long 5685 if ge get g_st 21 get g_st 20 5686 if eq get g_st 24 0 5687 err_start 5688 err_t te_for_syn 5689 ret neg long 1 5690 end 5691 rc = fill_fresh_name 5692 if lt rc 0 5693 ret rc 5694 end 5695 end 5696 lp = get g_st 21 5697 nmo = w_off lp 5698 nml = w_len lp 5699 put g_st 21 add lp 1 5700 rc = check_new_name_wp nmo nml 5701 if lt rc 0 5702 ret rc 5703 end 5704 if ge get g_st 21 get g_st 20 5705 if eq get g_st 24 0 5706 err_start 5707 err_t te_for_syn 5708 ret neg long 1 5709 end 5710 rc = fill_word_t tg_uint 5711 if lt rc 0 5712 ret rc 5713 end 5714 end 5715 lp = get g_st 21 5716 s = scalar_word_wp w_off lp w_len lp 5717 if or lt s 0 eq s long T_BOOL 5718 err_start 5719 err_c 39 5720 err_w lp 5721 err_t te_not_int_ty 5722 ret neg long 1 5723 end 5724 put g_st 21 add lp 1 5725 t = ty_make R_NONE ulong s 0 5726 if eq get g_st 14 0 5727 err_start 5728 err_t te_dead_line 5729 ret neg long 1 5730 end 5731 ki = count_number 5732 if ge ki 0 5733 ret for_line_const nmo nml t ulong ki 5734 end 5735 sv = get g_st 42 5736 cv = val_alloc 5737 r = value want_type t neg long 2 cv 5738 if eq r neg long 3 5739 err_start 5740 err_t te_for_syn 5741 put g_st 42 sv 5742 ret neg long 1 5743 end 5744 if lt r 0 5745 put g_st 42 sv 5746 ret r 5747 end 5748 if ne get g_v_t cv t 5749 err_start 5750 err_t te_cnt_rng1 5751 err_span get g_v_a cv get g_v_b cv 5752 err_t te_is 5753 err_ty get g_v_t cv 5754 err_t te_init_type2 5755 err_ty t 5756 put g_st 42 sv 5757 ret neg long 1 5758 end 5759 rc = line_end long cv 5760 creg = ulong get g_v_reg cv 5761 put g_st 42 sv 5762 if lt rc 0 5763 ret rc 5764 end 5765 ret guarded_loop 1 ulong s creg nmo nml 5766 end 5767 5768 fn stmt_end fi ulong to long 5769 fk_idx = sub get g_st 15 1 5770 fk = get g_fr_kind fk_idx 5771 if and eq fk F_FN and gt get g_st 14 0 ne get g_fn_hret fi 0 5772 err_start 5773 err_fn fi 5774 err_t te_no_ret 5775 ret neg long 1 5776 end 5777 rc = alone tk_end 5778 if lt rc 0 5779 ret rc 5780 end 5781 if eq fk F_IF 5782 own_if_end fk_idx 5783 if eq get g_fr_hels fk_idx 0 5784 els = ulong get g_fr_els fk_idx 5785 if gt get g_st 14 0 5786 rc = emit_br els 5787 if lt rc 0 5788 ret rc 5789 end 5790 end 5791 start_block els 5792 else 5793 if gt get g_st 14 0 5794 if lt get g_fr_join fk_idx 0 5795 jb = new_block 5796 if lt jb 0 5797 ret jb 5798 end 5799 put g_fr_join fk_idx jb 5800 end 5801 rc = emit_br ulong get g_fr_join fk_idx 5802 if lt rc 0 5803 ret rc 5804 end 5805 end 5806 if ge get g_fr_join fk_idx 0 5807 start_block ulong get g_fr_join fk_idx 5808 else 5809 put g_st 14 0 5810 end 5811 end 5812 else 5813 if eq fk F_WHILE 5814 rc = own_loop_close fk_idx 5815 if lt rc 0 5816 ret rc 5817 end 5818 if gt get g_st 14 0 5819 rc = emit_br ulong get g_fr_head fk_idx 5820 if lt rc 0 5821 ret rc 5822 end 5823 end 5824 start_block ulong get g_fr_exit fk_idx 5825 else 5826 if eq fk F_FOR 5827 rc = own_loop_close fk_idx 5828 if lt rc 0 5829 ret rc 5830 end 5831 if gt get g_st 14 0 5832 ctr = ulong get g_fr_ctr fk_idx 5833 one = lit_reg_t t_1 get g_regs ctr 5834 if lt one 0 5835 ret one 5836 end 5837 rc = emit_binop OP_ADD ctr ctr ulong one 5838 if lt rc 0 5839 ret rc 5840 end 5841 rc = emit_br ulong get g_fr_head fk_idx 5842 if lt rc 0 5843 ret rc 5844 end 5845 end 5846 start_block ulong get g_fr_exit fk_idx 5847 else 5848 if gt get g_st 14 0 5849 if ne get g_fn_hret fi 0 5850 err_start 5851 err_fn fi 5852 err_t te_no_ret 5853 ret neg long 1 5854 end 5855 rc = emit_ret_void 5856 if lt rc 0 5857 ret rc 5858 end 5859 rc = own_ret 5860 if lt rc 0 5861 ret rc 5862 end 5863 put g_st 14 0 5864 end 5865 if eq get g_st 25 0 5866 end_function 5867 end 5868 put g_st 6 0 5869 end 5870 end 5871 end 5872 put g_st 15 fk_idx 5873 ret pop_scope 5874 end 5875 5876 fn stmt_else to long 5877 fk_idx = sub get g_st 15 1 5878 if or ne get g_fr_kind fk_idx F_IF ne get g_fr_hels fk_idx 0 5879 err_start 5880 err_t te_else_no_if 5881 ret neg long 1 5882 end 5883 rc = alone tk_else 5884 if lt rc 0 5885 ret rc 5886 end 5887 if gt get g_st 14 0 5888 own_save_oacc fk_idx 5889 put g_fr_ohas fk_idx 1 5890 jb = new_block 5891 if lt jb 0 5892 ret jb 5893 end 5894 put g_fr_join fk_idx jb 5895 rc = emit_br ulong jb 5896 if lt rc 0 5897 ret rc 5898 end 5899 else 5900 put g_fr_join fk_idx neg long 1 5901 end 5902 put g_fr_hels fk_idx 1 5903 rc = pop_scope 5904 if lt rc 0 5905 ret rc 5906 end 5907 put g_st 10 add get g_st 10 1 5908 start_block ulong get g_fr_els fk_idx 5909 nown = get g_st 16 5910 base = mul fk_idx MAX_OWN 5911 for s ulong nown bound 64 5912 put g_ost_b s get g_fr_oin_b add base s 5913 put g_ost_m s get g_fr_oin_m add base s 5914 end 5915 ret 0 5916 end 5917 5918 fn stmt_if to long 5919 sv = get g_st 42 5920 cv = val_alloc 5921 rc = parse_cond cv tk_if 5922 if lt rc 0 5923 put g_st 42 sv 5924 ret rc 5925 end 5926 rc = line_end long cv 5927 creg = ulong get g_v_reg cv 5928 put g_st 42 sv 5929 if lt rc 0 5930 ret rc 5931 end 5932 th = new_block 5933 el = new_block 5934 if or lt th 0 lt el 0 5935 ret neg long 1 5936 end 5937 put g_blk_refd ulong th 1 5938 put g_blk_refd ulong el 1 5939 rc = emit_cbr creg ulong th ulong el 5940 if lt rc 0 5941 ret rc 5942 end 5943 fr = push_frame F_IF 5944 if lt fr 0 5945 ret fr 5946 end 5947 fu = ulong fr 5948 own_save_oin fu 5949 put g_fr_ohas fu 0 5950 put g_fr_els fu el 5951 put g_fr_join fu neg long 1 5952 start_block ulong th 5953 ret 0 5954 end 5955 5956 fn stmt_break to long 5957 k = get g_st 15 5958 while gt k 0 bound 64 5959 k = sub k 1 5960 fk = get g_fr_kind k 5961 if or eq fk F_WHILE eq fk F_FOR 5962 rc = alone tk_break 5963 if lt rc 0 5964 ret rc 5965 end 5966 if gt get g_st 14 0 5967 own_join_oacc k get g_fr_ohas k 5968 put g_fr_ohas k 1 5969 end 5970 ret emit_br ulong get g_fr_exit k 5971 end 5972 end 5973 err_start 5974 err_t te_brk_no_loop 5975 ret neg long 1 5976 end 5977 5978 fn stmt_ret fi ulong to long 5979 if eq get g_fn_hret fi 0 5980 if lt get g_st 21 get g_st 20 5981 err_start 5982 err_fn fi 5983 err_t te_ret_alone 5984 ret neg long 1 5985 end 5986 rc = emit_ret_void 5987 if lt rc 0 5988 ret rc 5989 end 5990 rc = own_ret 5991 if lt rc 0 5992 ret rc 5993 end 5994 put g_st 14 0 5995 ret 0 5996 end 5997 if ne get g_st 24 0 5998 put g_st 26 1 5999 put g_st 27 chain_floor 6000 end 6001 rt = get g_fn_ret fi 6002 sv = get g_st 42 6003 vv = val_alloc 6004 r = value want_type rt neg long 2 vv 6005 if eq r neg long 3 6006 err_start 6007 err_fn fi 6008 err_t te_ret_need1 6009 err_ty rt 6010 err_t te_ret_need2 6011 put g_st 42 sv 6012 ret neg long 1 6013 end 6014 if lt r 0 6015 put g_st 42 sv 6016 ret r 6017 end 6018 vt = get g_v_t vv 6019 if ne vt rt 6020 err_start 6021 err_t te_ret_type1 6022 err_ty vt 6023 err_t te_ret_type2 6024 err_fn fi 6025 err_t te_ret_need1 6026 err_ty rt 6027 put g_st 42 sv 6028 ret neg long 1 6029 end 6030 rc = line_end long vv 6031 vreg = ulong get g_v_reg vv 6032 put g_st 42 sv 6033 if lt rc 0 6034 ret rc 6035 end 6036 rc = emit_ret_val vreg 6037 if lt rc 0 6038 ret rc 6039 end 6040 rc = own_ret 6041 if lt rc 0 6042 ret rc 6043 end 6044 put g_st 14 0 6045 ret 0 6046 end 6047 6048 fn stmt_trap fi ulong to long 6049 if ge get g_st 21 get g_st 20 6050 if eq get g_st 24 0 6051 err_start 6052 err_t te_trap_syn 6053 ret neg long 1 6054 end 6055 rc = fill_word_t t_1 6056 if lt rc 0 6057 ret rc 6058 end 6059 end 6060 lp = get g_st 21 6061 ok = parse_lit_wp w_off lp w_len lp 6062 c = get g_st 48 6063 if or not ok or ne get g_st 47 0 or lt c 1 gt c 14 6064 err_start 6065 err_t te_trap_syn 6066 ret neg long 1 6067 end 6068 put g_st 21 add lp 1 6069 if lt get g_st 21 get g_st 20 6070 err_start 6071 err_t te_trap_syn 6072 ret neg long 1 6073 end 6074 rc = emit_trap c 6075 if lt rc 0 6076 ret rc 6077 end 6078 if ne get g_fn_hret fi 0 6079 rt = get g_fn_ret fi 6080 z = neg long 1 6081 if eq ty_s rt T_BOOL 6082 z = lit_reg_t tk_false rt 6083 else 6084 z = lit_reg_t t_0 rt 6085 end 6086 if lt z 0 6087 ret z 6088 end 6089 rc = emit_ret_val ulong z 6090 if lt rc 0 6091 ret rc 6092 end 6093 else 6094 rc = emit_ret_void 6095 if lt rc 0 6096 ret rc 6097 end 6098 end 6099 put g_st 14 0 6100 ret 0 6101 end 6102 6103 fn stmt_put to long 6104 ar = array_name 0 3 AN_PUT 0 0 6105 if lt ar 0 6106 ret ar 6107 end 6108 au = ulong ar 6109 ta = get g_regs au 6110 if eq ty_ref ta R_SHARED 6111 err_start 6112 err_c 39 6113 err_w sub get g_st 21 1 6114 err_t te_put_view 6115 ret neg long 1 6116 end 6117 iw = want_pack S_INT A_NONE L_TYPED 0 0 ty_make R_NONE T_U32 0 6118 et = ty_make R_NONE ty_s ta 0 6119 vw = want_type et 6120 sv = get g_st 42 6121 iv = val_alloc 6122 vv = val_alloc 6123 rc = slot iw neg long 2 iv 0 1 3 6124 if lt rc 0 6125 put g_st 42 sv 6126 ret rc 6127 end 6128 if not ty_is_int get g_v_t iv 6129 err_start 6130 err_t te_idx_int1 6131 err_span get g_v_a iv get g_v_b iv 6132 err_t te_idx_int2 6133 put g_st 42 sv 6134 ret neg long 1 6135 end 6136 rc = slot vw neg long 2 vv 0 2 3 6137 if lt rc 0 6138 put g_st 42 sv 6139 ret rc 6140 end 6141 if ne get g_v_t vv et 6142 err_start 6143 err_c 39 6144 err_span get g_v_a vv get g_v_b vv 6145 err_t te_is 6146 err_ty get g_v_t vv 6147 err_t te_put_ty 6148 err_ty et 6149 put g_st 42 sv 6150 ret neg long 1 6151 end 6152 wh = val_alloc 6153 put g_v_head wh 0 6154 put g_v_arity wh 3 6155 rc = line_end long wh 6156 ir = ulong get g_v_reg iv 6157 vr = ulong get g_v_reg vv 6158 put g_st 42 sv 6159 if lt rc 0 6160 ret rc 6161 end 6162 rc = emit_store au ir vr 6163 if lt rc 0 6164 ret rc 6165 end 6166 ret own_use au 6167 end 6168 6169 fn stmt_free to long 6170 ar = array_name 0 1 AN_FREE 0 0 6171 if lt ar 0 6172 ret ar 6173 end 6174 au = ulong ar 6175 if ne ty_ref get g_regs au R_OWN 6176 err_start 6177 err_c 39 6178 err_w sub get g_st 21 1 6179 err_t te_free_own 6180 ret neg long 1 6181 end 6182 sv = get g_st 42 6183 wh = val_alloc 6184 put g_v_head wh 0 6185 put g_v_arity wh 1 6186 rc = line_end long wh 6187 put g_st 42 sv 6188 if lt rc 0 6189 ret rc 6190 end 6191 rc = emit_release au 6192 if lt rc 0 6193 ret rc 6194 end 6195 ret own_release au 6196 end 6197 6198 fn stmt_call g ulong to long 6199 if ne get g_fn_hret g 0 6200 err_start 6201 err_fn g 6202 err_t te_ret_need1 6203 err_ty get g_fn_ret g 6204 err_t te_call_keep1 6205 err_fn g 6206 err_t te_call_keep2 6207 ret neg long 1 6208 end 6209 args = new ulong 6 0 6210 rc = call_args g 0 edit args 6211 if lt rc 0 6212 ret rc 6213 end 6214 sv = get g_st 42 6215 wh = val_alloc 6216 put g_v_head wh 0 6217 put g_v_arity wh get g_fn_np g 6218 rc = line_end long wh 6219 put g_st 42 sv 6220 if lt rc 0 6221 ret rc 6222 end 6223 rc = emit_call_op g view args 0 0 6224 if lt rc 0 6225 ret rc 6226 end 6227 ret own_call g view args 6228 end 6229 6230 fn stmt_assign w0o ulong w0l ulong to long 6231 ni = find_name_wp w0o w0l 6232 if and eq get g_st 20 1 eq get g_st 24 0 6233 err_start 6234 err_c 39 6235 err_wp w0o w0l 6236 err_t te_no_start 6237 ret neg long 1 6238 end 6239 if ge ni 0 6240 if eq get g_nm_fix ulong ni 1 6241 err_start 6242 err_c 39 6243 err_wp w0o w0l 6244 err_t te_loop_ctr 6245 ret neg long 1 6246 end 6247 end 6248 if lt ni 0 6249 if or ge find_func_wp w0o w0l 0 or reserved_wp w0o w0l not valid_ident_wp w0o w0l 6250 err_start 6251 err_c 39 6252 err_wp w0o w0l 6253 err_t te_cant_name 6254 ret neg long 1 6255 end 6256 end 6257 w = want_pack S_ALL A_ANY L_NO 1 0 0 6258 dst = neg long 1 6259 if ge ni 0 6260 reg = get g_nm_reg ulong ni 6261 w = want_set_top want_type get g_regs reg 1 6262 dst = long reg 6263 end 6264 if lt get g_st 21 get g_st 20 6265 if w_eq_t get g_st 21 t_eqs 6266 put g_st 21 add get g_st 21 1 6267 end 6268 end 6269 sv = get g_st 42 6270 vv = val_alloc 6271 r = value w dst vv 6272 if eq r neg long 3 6273 err_start 6274 err_t te_val_miss 6275 err_span 0 get g_st 21 6276 err_c 39 6277 put g_st 42 sv 6278 ret neg long 1 6279 end 6280 if lt r 0 6281 put g_st 42 sv 6282 ret r 6283 end 6284 if ne get g_v_lit vv 0 6285 vw = ulong get g_v_word vv 6286 err_start 6287 err_c 39 6288 err_w vw 6289 err_t te_num_unk 6290 err_w vw 6291 put g_st 42 sv 6292 ret neg long 1 6293 end 6294 rc = line_end long vv 6295 vreg = ulong get g_v_reg vv 6296 put g_st 42 sv 6297 if lt rc 0 6298 ret rc 6299 end 6300 if lt ni 0 6301 ret bind_name_wp w0o w0l vreg 0 6302 end 6303 ret 0 6304 end 6305 6306 fn stmt to long 6307 w0o = w_off 0 6308 w0l = w_len 0 6309 if wp_eq_t w0o w0l tk_fn 6310 ret fn_line 6311 end 6312 if eq get g_st 6 0 6313 err_start 6314 err_c 39 6315 err_wp w0o w0l 6316 err_t te_eof_in_fn2 6317 put g_st 3 0 6318 err_start 6319 err_c 39 6320 err_wp w0o w0l 6321 err_c 39 6322 err_c 32 6323 err_c 111 6324 err_c 117 6325 err_c 116 6326 err_c 115 6327 err_c 105 6328 err_c 100 6329 err_c 101 6330 err_c 32 6331 err_c 97 6332 err_c 32 6333 err_c 102 6334 err_c 117 6335 err_c 110 6336 err_c 99 6337 err_c 116 6338 err_c 105 6339 err_c 111 6340 err_c 110 6341 err_c 32 6342 err_c 40 6343 err_c 115 6344 err_c 116 6345 err_c 97 6346 err_c 114 6347 err_c 116 6348 err_c 32 6349 err_c 111 6350 err_c 110 6351 err_c 101 6352 err_c 32 6353 err_c 119 6354 err_c 105 6355 err_c 116 6356 err_c 104 6357 err_c 32 6358 err_c 102 6359 err_c 110 6360 err_c 41 6361 ret neg long 1 6362 end 6363 fi = sub get g_st 5 1 6364 put g_st 21 1 6365 if wp_eq_t w0o w0l tk_end 6366 ret stmt_end fi 6367 end 6368 if wp_eq_t w0o w0l tk_else 6369 ret stmt_else 6370 end 6371 if wp_eq_t w0o w0l tk_if 6372 ret stmt_if 6373 end 6374 if wp_eq_t w0o w0l tk_while 6375 if eq get g_st 14 0 6376 err_start 6377 err_t te_dead_line 6378 ret neg long 1 6379 end 6380 ret guarded_loop 0 0 0 0 0 6381 end 6382 if wp_eq_t w0o w0l tk_for 6383 ret for_line 6384 end 6385 if wp_eq_t w0o w0l tk_break 6386 ret stmt_break 6387 end 6388 if wp_eq_t w0o w0l tk_ret 6389 ret stmt_ret fi 6390 end 6391 if wp_eq_t w0o w0l tk_trap 6392 ret stmt_trap fi 6393 end 6394 if wp_eq_t w0o w0l tk_put 6395 ret stmt_put 6396 end 6397 if wp_eq_t w0o w0l tk_free 6398 ret stmt_free 6399 end 6400 if and ge find_func_wp w0o w0l 0 lt find_callable_wp w0o w0l 0 6401 err_start 6402 err_wp w0o w0l 6403 err_t te_self_call 6404 ret neg long 1 6405 end 6406 g = find_callable_wp w0o w0l 6407 if ge g 0 6408 ret stmt_call ulong g 6409 end 6410 ret stmt_assign w0o w0l 6411 end 6412 6413 note ---- split_line & run_src ---- 6414 fn is_sep c uchar to bool 6415 if or eq c 32 eq c 9 6416 ret true 6417 end 6418 if or eq c 13 or eq c 40 eq c 41 6419 ret true 6420 end 6421 ret false 6422 end 6423 6424 fn is_word_ch c uchar to bool 6425 if is_alnum c 6426 ret true 6427 end 6428 if or eq c 95 or eq c 45 eq c 61 6429 ret true 6430 end 6431 ret false 6432 end 6433 6434 fn split_src start ulong endp ulong base ulong to long 6435 n = ulong 0 6436 p = start 6437 while lt p endp bound BIG 6438 c = get g_src p 6439 if or eq c 32 or eq c 9 eq c 13 6440 p = add p 1 6441 continue 6442 end 6443 if ge n MAX_WORDS 6444 err_start 6445 err_t te_max_words 6446 ret neg long 1 6447 end 6448 if or eq c 40 eq c 41 6449 off = get g_st 31 6450 wp_push_c c 6451 put g_lw_off add base n off 6452 put g_lw_len add base n 1 6453 n = add n 1 6454 p = add p 1 6455 continue 6456 end 6457 off = get g_st 31 6458 wl = ulong 0 6459 while lt p endp bound BIG 6460 ch = get g_src p 6461 if is_sep ch 6462 break 6463 end 6464 if not is_word_ch ch 6465 err_start 6466 err_t te_bad_char1 6467 err_c ch 6468 err_t te_bad_char2 6469 ret neg long 1 6470 end 6471 wp_push_c ch 6472 wl = add wl 1 6473 p = add p 1 6474 end 6475 put g_lw_off add base n off 6476 put g_lw_len add base n wl 6477 n = add n 1 6478 end 6479 ret long n 6480 end 6481 6482 fn split_lineb base ulong to long 6483 n = ulong 0 6484 p = ulong 0 6485 endp = get g_lineb_n 0 6486 while lt p endp bound 256 6487 c = get g_lineb p 6488 if or eq c 32 or eq c 9 eq c 13 6489 p = add p 1 6490 continue 6491 end 6492 if ge n MAX_WORDS 6493 err_start 6494 err_t te_max_words 6495 ret neg long 1 6496 end 6497 if or eq c 40 eq c 41 6498 off = get g_st 31 6499 wp_push_c c 6500 put g_lw_off add base n off 6501 put g_lw_len add base n 1 6502 n = add n 1 6503 p = add p 1 6504 continue 6505 end 6506 off = get g_st 31 6507 wl = ulong 0 6508 while lt p endp bound 256 6509 ch = get g_lineb p 6510 if is_sep ch 6511 break 6512 end 6513 if not is_word_ch ch 6514 err_start 6515 err_t te_bad_char1 6516 err_c ch 6517 err_t te_bad_char2 6518 ret neg long 1 6519 end 6520 wp_push_c ch 6521 wl = add wl 1 6522 p = add p 1 6523 end 6524 put g_lw_off add base n off 6525 put g_lw_len add base n wl 6526 n = add n 1 6527 end 6528 ret long n 6529 end 6530 6531 fn run_src slen ulong keep_tail ulong to long 6532 p = ulong 0 6533 put g_st 4 0 6534 put g_st 1 0 6535 if eq get g_st 25 0 6536 out_t tj_head 6537 end 6538 while true bound BIG 6539 nl = p 6540 found_nl = false 6541 while lt nl slen bound BIG 6542 if eq get g_src nl 10 6543 found_nl = true 6544 break 6545 end 6546 nl = add nl 1 6547 end 6548 if and not found_nl ne keep_tail 0 6549 ret 0 6550 end 6551 put g_st 4 add get g_st 4 1 6552 put g_st 31 0 6553 put g_st 23 0 6554 n = split_src p nl 0 6555 if lt n 0 6556 ret n 6557 end 6558 if gt n 0 6559 put g_st 20 ulong n 6560 put g_st 21 0 6561 put g_st 22 0 6562 put g_st 42 0 6563 rc = stmt 6564 if lt rc 0 6565 ret rc 6566 end 6567 end 6568 if not found_nl 6569 break 6570 end 6571 p = add nl 1 6572 end 6573 put g_st 4 add get g_st 4 1 6574 if ne get g_st 6 0 6575 err_start 6576 err_t te_eof_in_fn1 6577 err_fn sub get g_st 5 1 6578 err_t te_eof_in_fn2 6579 ret neg long 1 6580 end 6581 if eq get g_st 5 0 6582 err_start 6583 err_t te_no_fn 6584 ret neg long 1 6585 end 6586 if eq get g_st 25 0 6587 out_t tj_tail 6588 end 6589 ret 0 6590 end 6591 6592 note ---- oracle state save / restore ---- 6593 fn save_state_rest to void 6594 nfr = get g_st 15 6595 nown = get g_st 16 6596 for i ulong nfr bound 64 6597 put s0_fr_kind i get g_fr_kind i 6598 put s0_fr_dep i get g_fr_dep i 6599 put s0_fr_els i get g_fr_els i 6600 put s0_fr_join i get g_fr_join i 6601 put s0_fr_hels i get g_fr_hels i 6602 put s0_fr_head i get g_fr_head i 6603 put s0_fr_exit i get g_fr_exit i 6604 put s0_fr_ctr i get g_fr_ctr i 6605 put s0_fr_ohas i get g_fr_ohas i 6606 base = mul i MAX_OWN 6607 for s ulong nown bound 64 6608 idx = add base s 6609 put s0_fr_oin_b idx get g_fr_oin_b idx 6610 put s0_fr_oin_m idx get g_fr_oin_m idx 6611 put s0_fr_oacc_b idx get g_fr_oacc_b idx 6612 put s0_fr_oacc_m idx get g_fr_oacc_m idx 6613 put s0_fr_opost_b idx get g_fr_opost_b idx 6614 put s0_fr_opost_m idx get g_fr_opost_m idx 6615 end 6616 end 6617 for s ulong nown bound 64 6618 put s0_own_reg s get g_own_reg s 6619 put s0_ost_b s get g_ost_b s 6620 put s0_ost_m s get g_ost_m s 6621 end 6622 nq = get g_st 17 6623 for i ulong nq bound 256 6624 put s0_owq_k i get g_owq_k i 6625 put s0_owq_kind i get g_owq_kind i 6626 put s0_owq_s i get g_owq_s i 6627 put s0_owq_line i get g_owq_line i 6628 put s0_owq_ob i get g_owq_ob i 6629 put s0_owq_om i get g_owq_om i 6630 nl = get g_owq_nlen i 6631 put s0_owq_nlen i nl 6632 off = mul i 64 6633 for j ulong nl bound 64 6634 put s0_owq_nm add off j get g_owq_nm add off j 6635 end 6636 end 6637 end 6638 6639 fn restore_state_rest to void 6640 nfr = get g_st 15 6641 nown = get g_st 16 6642 for i ulong nfr bound 64 6643 put g_fr_kind i get s0_fr_kind i 6644 put g_fr_dep i get s0_fr_dep i 6645 put g_fr_els i get s0_fr_els i 6646 put g_fr_join i get s0_fr_join i 6647 put g_fr_hels i get s0_fr_hels i 6648 put g_fr_head i get s0_fr_head i 6649 put g_fr_exit i get s0_fr_exit i 6650 put g_fr_ctr i get s0_fr_ctr i 6651 put g_fr_ohas i get s0_fr_ohas i 6652 base = mul i MAX_OWN 6653 for s ulong nown bound 64 6654 idx = add base s 6655 put g_fr_oin_b idx get s0_fr_oin_b idx 6656 put g_fr_oin_m idx get s0_fr_oin_m idx 6657 put g_fr_oacc_b idx get s0_fr_oacc_b idx 6658 put g_fr_oacc_m idx get s0_fr_oacc_m idx 6659 put g_fr_opost_b idx get s0_fr_opost_b idx 6660 put g_fr_opost_m idx get s0_fr_opost_m idx 6661 end 6662 end 6663 for s ulong nown bound 64 6664 put g_own_reg s get s0_own_reg s 6665 put g_ost_b s get s0_ost_b s 6666 put g_ost_m s get s0_ost_m s 6667 end 6668 nq = get g_st 17 6669 for i ulong nq bound 256 6670 put g_owq_k i get s0_owq_k i 6671 put g_owq_kind i get s0_owq_kind i 6672 put g_owq_s i get s0_owq_s i 6673 put g_owq_line i get s0_owq_line i 6674 put g_owq_ob i get s0_owq_ob i 6675 put g_owq_om i get s0_owq_om i 6676 nl = get s0_owq_nlen i 6677 put g_owq_nlen i nl 6678 off = mul i 64 6679 for j ulong nl bound 64 6680 put g_owq_nm add off j get s0_owq_nm add off j 6681 end 6682 end 6683 end 6684 6685 fn save_state to void 6686 put s0_st 0 get g_st 5 6687 put s0_st 1 get g_st 6 6688 put s0_st 2 get g_st 7 6689 put s0_st 3 get g_st 8 6690 put s0_st 4 get g_st 9 6691 put s0_st 5 get g_st 10 6692 put s0_st 6 get g_st 11 6693 put s0_st 7 get g_st 12 6694 put s0_st 8 get g_st 13 6695 put s0_st 9 get g_st 14 6696 put s0_st 10 get g_st 15 6697 put s0_st 11 get g_st 16 6698 put s0_st 12 get g_st 17 6699 put s0_st 13 get g_st 19 6700 nf = get g_st 5 6701 for i ulong nf bound 32 6702 nl = get g_fn_nlen i 6703 put s0_fn_nlen i nl 6704 off = mul i 64 6705 for j ulong nl bound 64 6706 put s0_fn_name add off j get g_fn_name add off j 6707 end 6708 np = get g_fn_np i 6709 put s0_fn_np i np 6710 pbase = mul i MAX_PARAMS 6711 for j ulong np bound 8 6712 put s0_fn_p add pbase j get g_fn_p add pbase j 6713 end 6714 put s0_fn_hret i get g_fn_hret i 6715 put s0_fn_ret i get g_fn_ret i 6716 end 6717 nr = get g_st 7 6718 for i ulong nr bound 512 6719 put s0_regs i get g_regs i 6720 end 6721 nn = get g_st 9 6722 for i ulong nn bound 512 6723 nl = get g_nm_len i 6724 put s0_nm_len i nl 6725 off = mul i 64 6726 for j ulong nl bound 64 6727 put s0_nm_str add off j get g_nm_str add off j 6728 end 6729 put s0_nm_reg i get g_nm_reg i 6730 put s0_nm_dep i get g_nm_dep i 6731 put s0_nm_fix i get g_nm_fix i 6732 put s0_nm_rd i get g_nm_rd i 6733 end 6734 nc = get g_st 11 6735 for i ulong nc bound 256 6736 put s0_ck_t i get g_ck_t i 6737 put s0_ck_neg i get g_ck_neg i 6738 put s0_ck_mag i get g_ck_mag i 6739 put s0_ck_reg i get g_ck_reg i 6740 end 6741 for i ulong get g_st 12 bound 512 6742 put s0_blk_nops i get g_blk_nops i 6743 put s0_blk_ord i get g_blk_ord i 6744 put s0_blk_refd i get g_blk_refd i 6745 end 6746 save_state_rest 6747 end 6748 6749 fn restore_state to void 6750 put g_st 5 get s0_st 0 6751 put g_st 6 get s0_st 1 6752 put g_st 7 get s0_st 2 6753 put g_st 8 get s0_st 3 6754 put g_st 9 get s0_st 4 6755 put g_st 10 get s0_st 5 6756 put g_st 11 get s0_st 6 6757 put g_st 12 get s0_st 7 6758 put g_st 13 get s0_st 8 6759 put g_st 14 get s0_st 9 6760 put g_st 15 get s0_st 10 6761 put g_st 16 get s0_st 11 6762 put g_st 17 get s0_st 12 6763 put g_st 19 get s0_st 13 6764 put g_st 18 0 6765 nf = get g_st 5 6766 for i ulong nf bound 32 6767 nl = get s0_fn_nlen i 6768 put g_fn_nlen i nl 6769 off = mul i 64 6770 for j ulong nl bound 64 6771 put g_fn_name add off j get s0_fn_name add off j 6772 end 6773 np = get s0_fn_np i 6774 put g_fn_np i np 6775 pbase = mul i MAX_PARAMS 6776 for j ulong np bound 8 6777 put g_fn_p add pbase j get s0_fn_p add pbase j 6778 end 6779 put g_fn_hret i get s0_fn_hret i 6780 put g_fn_ret i get s0_fn_ret i 6781 end 6782 nr = get g_st 7 6783 for i ulong nr bound 512 6784 put g_regs i get s0_regs i 6785 end 6786 nn = get g_st 9 6787 for i ulong nn bound 512 6788 nl = get s0_nm_len i 6789 put g_nm_len i nl 6790 off = mul i 64 6791 for j ulong nl bound 64 6792 put g_nm_str add off j get s0_nm_str add off j 6793 end 6794 put g_nm_reg i get s0_nm_reg i 6795 put g_nm_dep i get s0_nm_dep i 6796 put g_nm_fix i get s0_nm_fix i 6797 put g_nm_rd i get s0_nm_rd i 6798 end 6799 nc = get g_st 11 6800 for i ulong nc bound 256 6801 put g_ck_t i get s0_ck_t i 6802 put g_ck_neg i get s0_ck_neg i 6803 put g_ck_mag i get s0_ck_mag i 6804 put g_ck_reg i get s0_ck_reg i 6805 end 6806 for i ulong get g_st 12 bound 512 6807 put g_blk_nops i get s0_blk_nops i 6808 put g_blk_ord i get s0_blk_ord i 6809 put g_blk_refd i get s0_blk_refd i 6810 end 6811 restore_state_rest 6812 end 6813 6814 note ---- run_line, own_repair, close_all, judge, witness ---- 6815 fn run_line_lineb to long 6816 put g_st 4 add get g_st 4 1 6817 put g_st 31 get g_st 33 6818 put g_st 23 RL_BASE 6819 n = split_lineb RL_BASE 6820 if le n 0 6821 ret n 6822 end 6823 put g_st 20 ulong n 6824 put g_st 21 0 6825 put g_st 22 0 6826 put g_st 42 0 6827 ret stmt 6828 end 6829 6830 fn own_repair_check_name nu ulong r ulong to bool 6831 saved = get g_st 31 6832 off = saved 6833 nl = get g_nm_len nu 6834 nsrc = mul nu 64 6835 for j ulong nl bound 64 6836 wp_push_c get g_nm_str add nsrc j 6837 end 6838 fn_i = find_name_wp off nl 6839 put g_st 31 saved 6840 if lt fn_i 0 6841 ret false 6842 end 6843 ret eq get g_nm_reg ulong fn_i r 6844 end 6845 6846 fn own_repair_emit ek ulong ob uchar s ulong nu ulong r ulong to bool 6847 osb = get g_ost_b s 6848 osm = get g_ost_m s 6849 has_l = ne and ulong ob OS_L 0 6850 if or eq ek OW_USE eq ek OW_FREE 6851 if and not has_l not os_only osb osm 6852 put g_lineb_n 0 0 6853 if or ne osm 0 ne and ulong osb OS_L 0 6854 lb_t tk_free 6855 lb_c 32 6856 lb_nm nu 6857 else 6858 rt = get g_regs r 6859 lb_nm nu 6860 lb_c 32 6861 lb_c 61 6862 lb_c 32 6863 lb_t to_new 6864 lb_c 32 6865 lb_gw ty_s rt 6866 lb_c 32 6867 lb_u64 ty_len rt 6868 lb_c 32 6869 if eq ty_s rt T_BOOL 6870 lb_t tk_false 6871 else 6872 lb_c 48 6873 end 6874 end 6875 ret true 6876 end 6877 end 6878 if or eq ek OW_BIRTH eq ek OW_RET 6879 if and has_l not os_none osb osm 6880 put g_lineb_n 0 0 6881 lb_t tk_free 6882 lb_c 32 6883 lb_nm nu 6884 ret true 6885 end 6886 end 6887 ret false 6888 end 6889 6890 fn own_repair_one i ulong k ulong to bool 6891 kb = shl ulong 1 k 6892 nkb = xor kb sub ulong 0 1 6893 s = get g_owq_s i 6894 idx = add mul k MAX_OWN s 6895 ob = get g_owq_ob i 6896 om = get g_owq_om i 6897 if ne and om kb 0 6898 hb = uchar or ulong get g_fr_oin_b idx ulong get g_ost_b s 6899 hm = or get g_fr_oin_m idx and get g_ost_m s nkb 6900 ob = uchar or ulong ob ulong hb 6901 om = or and om nkb hm 6902 end 6903 if ne om 0 6904 ret false 6905 end 6906 r = get g_own_reg s 6907 ni = own_label r 6908 if lt ni 0 6909 ret false 6910 end 6911 if not own_repair_check_name ulong ni r 6912 ret false 6913 end 6914 ret own_repair_emit get g_owq_kind i ob s ulong ni r 6915 end 6916 6917 fn own_repair to bool 6918 k = sub get g_st 15 1 6919 nq = get g_st 17 6920 for i ulong nq bound 256 6921 if eq get g_owq_k i k 6922 if own_repair_one i k 6923 ret true 6924 end 6925 end 6926 end 6927 ret false 6928 end 6929 6930 fn close_find_unread to long 6931 nn = get g_st 9 6932 dep = get g_st 10 6933 for i ulong nn bound 512 6934 if ne get g_nm_fix i 0 6935 continue 6936 end 6937 if ne get g_nm_rd i 0 6938 continue 6939 end 6940 if ge get g_nm_dep i dep 6941 ret long i 6942 end 6943 end 6944 ret neg long 1 6945 end 6946 6947 fn close_all_cur to void 6948 u = close_find_unread 6949 if ge u 0 6950 lb_nm ulong u 6951 lb_c 32 6952 lb_c 61 6953 lb_c 32 6954 lb_nm ulong u 6955 ret 6956 end 6957 top_fk = get g_fr_kind sub get g_st 15 1 6958 if eq top_fk F_FN 6959 hidden = false 6960 nown = get g_st 16 6961 for s ulong nown bound 64 6962 if ne and ulong get g_ost_b s OS_L 0 6963 ni = own_label get g_own_reg s 6964 if ge ni 0 6965 lb_t tk_free 6966 lb_c 32 6967 lb_nm ulong ni 6968 ret 6969 else 6970 hidden = true 6971 end 6972 end 6973 end 6974 if hidden 6975 lb_t tk_trap 6976 lb_c 32 6977 lb_c 49 6978 ret 6979 end 6980 fi = sub get g_st 5 1 6981 if ne get g_fn_hret fi 0 6982 lb_t tk_ret 6983 lb_c 32 6984 if eq ty_s get g_fn_ret fi T_BOOL 6985 lb_t tk_false 6986 else 6987 lb_c 48 6988 end 6989 ret 6990 end 6991 lb_t tk_end 6992 ret 6993 end 6994 if or eq top_fk F_WHILE eq top_fk F_FOR 6995 if own_repair 6996 ret 6997 end 6998 end 6999 lb_t tk_end 7000 end 7001 7002 fn close_all to long 7003 for guard ulong 1500 bound 1600 7004 put g_lineb_n 0 0 7005 if eq get g_st 6 0 7006 if gt get g_st 5 0 7007 break 7008 end 7009 make_fresh_name 7010 lb_t tk_fn 7011 lb_c 32 7012 lb_fresh 7013 lb_c 32 7014 lb_t tk_to 7015 lb_c 32 7016 lb_t tk_void 7017 else 7018 if gt get g_st 14 0 7019 close_all_cur 7020 else 7021 lb_t tk_end 7022 end 7023 end 7024 rc = run_line_lineb 7025 if lt rc 0 7026 ret rc 7027 end 7028 close_lineb 7029 end 7030 ret 0 7031 end 7032 7033 fn judge nw ulong to long 7034 restore_state 7035 put g_st 23 0 7036 put g_st 20 nw 7037 put g_st 21 0 7038 put g_st 22 0 7039 put g_st 24 0 7040 put g_st 4 get g_st 35 7041 put g_st 42 0 7042 if gt nw MAX_WORDS 7043 err_start 7044 err_t te_max_words 7045 ret neg long 1 7046 end 7047 if gt nw 0 7048 rc = stmt 7049 if lt rc 0 7050 ret rc 7051 end 7052 end 7053 clen = get g_st 44 7054 p = ulong 0 7055 while lt p clen bound BIG 7056 e = p 7057 while lt e clen bound BIG 7058 if eq get g_close e 10 7059 break 7060 end 7061 e = add e 1 7062 end 7063 put g_lineb_n 0 0 7064 for j ulong sub e p bound 256 7065 lb_c get g_close add p j 7066 end 7067 rc = run_line_lineb 7068 if lt rc 0 7069 ret rc 7070 end 7071 p = add e 1 7072 end 7073 put g_st 4 add get g_st 4 1 7074 if ne get g_st 6 0 7075 err_start 7076 err_t te_eof_in_fn1 7077 err_fn sub get g_st 5 1 7078 err_t te_eof_in_fn2 7079 ret neg long 1 7080 end 7081 if eq get g_st 5 0 7082 err_start 7083 err_t te_no_fn 7084 ret neg long 1 7085 end 7086 ret 0 7087 end 7088 7089 fn witness nw ulong fill ulong wsave ulong to long 7090 r = neg long 1 7091 for pk ulong 64 bound 64 7092 put g_st 28 pk 7093 restore_state 7094 put g_st 31 wsave 7095 put g_st 30 0 7096 put g_st 29 0 7097 put g_st 26 0 7098 put g_st 23 0 7099 put g_st 20 nw 7100 put g_st 21 0 7101 put g_st 22 0 7102 put g_st 24 fill 7103 put g_st 4 get g_st 35 7104 put g_st 42 0 7105 if gt nw 0 7106 r = stmt 7107 else 7108 r = 0 7109 end 7110 put g_st 24 0 7111 put g_st 26 0 7112 if gt get g_st 30 0 7113 put g_st 39 1 7114 else 7115 put g_st 39 0 7116 end 7117 put g_st 38 get g_st 20 7118 put g_st 33 get g_st 31 7119 put g_st 44 0 7120 if eq r 0 7121 put g_st 39 1 7122 r = close_all 7123 end 7124 if eq r 0 7125 r = judge get g_st 38 7126 end 7127 if or eq r 0 ge add pk 1 get g_st 29 7128 break 7129 end 7130 end 7131 ret r 7132 end 7133 7134 fn legal_wp has_a ulong ao ulong al ulong fill ulong to bool 7135 nw = get g_st 34 7136 for i ulong nw bound 128 7137 put g_lw_off i get g_W_off i 7138 put g_lw_len i get g_W_len i 7139 end 7140 n = nw 7141 if ne has_a 0 7142 put g_lw_off n ao 7143 put g_lw_len n al 7144 n = add n 1 7145 end 7146 ret eq witness n fill get g_st 31 0 7147 end 7148 7149 fn legal_t s view uchar * fill ulong to bool 7150 put g_st 31 get g_st 32 7151 off = wp_push_t s 7152 ret legal_wp 1 off len s fill 7153 end 7154 7155 fn legal_u_t s view uchar * fill ulong to bool 7156 put g_st 31 get g_st 32 7157 off = wp_push_t s 7158 nw = get g_st 34 7159 for i ulong nw bound 128 7160 put g_lw_off i get g_W_off i 7161 put g_lw_len i get g_W_len i 7162 end 7163 put g_lw_off nw get g_st 36 7164 put g_lw_len nw get g_st 37 7165 put g_lw_off add nw 1 off 7166 put g_lw_len add nw 1 len s 7167 ret eq witness add nw 2 fill get g_st 31 0 7168 end 7169 7170 fn legal_eof to bool 7171 restore_state 7172 nw = get g_st 34 7173 for i ulong nw bound 128 7174 put g_lw_off i get g_W_off i 7175 put g_lw_len i get g_W_len i 7176 end 7177 n = nw 7178 if gt get g_st 37 0 7179 put g_lw_off n get g_st 36 7180 put g_lw_len n get g_st 37 7181 n = add n 1 7182 end 7183 put g_st 23 0 7184 put g_st 20 n 7185 put g_st 21 0 7186 put g_st 22 0 7187 put g_st 24 0 7188 put g_st 4 get g_st 35 7189 put g_st 42 0 7190 if gt n 0 7191 if lt stmt 0 7192 ret false 7193 end 7194 end 7195 ret and eq get g_st 6 0 gt get g_st 5 0 7196 end 7197 7198 note ---- fixed words table (order = KWORDER + OPW + GW + IRN[1..] + REFW[1..]) ---- 7199 fn fw_push_wp k ulong to ulong 7200 if eq k 0 7201 ret wp_push_t tk_fn 7202 end 7203 if eq k 1 7204 ret wp_push_t tk_if 7205 end 7206 if eq k 2 7207 ret wp_push_t tk_while 7208 end 7209 if eq k 3 7210 ret wp_push_t tk_for 7211 end 7212 if eq k 4 7213 ret wp_push_t tk_ret 7214 end 7215 if eq k 5 7216 ret wp_push_t tk_put 7217 end 7218 if eq k 6 7219 ret wp_push_t tk_free 7220 end 7221 if eq k 7 7222 ret wp_push_t tk_trap 7223 end 7224 if eq k 8 7225 ret wp_push_t tk_break 7226 end 7227 if eq k 9 7228 ret wp_push_t tk_else 7229 end 7230 if eq k 10 7231 ret wp_push_t tk_end 7232 end 7233 if eq k 11 7234 ret wp_push_t tk_to 7235 end 7236 if eq k 12 7237 ret wp_push_t tk_void 7238 end 7239 if eq k 13 7240 ret wp_push_t tk_bound 7241 end 7242 if eq k 14 7243 ret wp_push_t t_eqs 7244 end 7245 if eq k 15 7246 ret wp_push_t tk_true 7247 end 7248 if eq k 16 7249 ret wp_push_t tk_false 7250 end 7251 if eq k 17 7252 ret wp_push_t to_add 7253 end 7254 if eq k 18 7255 ret wp_push_t to_sub 7256 end 7257 if eq k 19 7258 ret wp_push_t to_mul 7259 end 7260 if eq k 20 7261 ret wp_push_t to_div 7262 end 7263 if eq k 21 7264 ret wp_push_t to_rem 7265 end 7266 if eq k 22 7267 ret wp_push_t to_and 7268 end 7269 if eq k 23 7270 ret wp_push_t to_or 7271 end 7272 if eq k 24 7273 ret wp_push_t to_xor 7274 end 7275 if eq k 25 7276 ret wp_push_t to_shl 7277 end 7278 if eq k 26 7279 ret wp_push_t to_shr 7280 end 7281 if eq k 27 7282 ret wp_push_t to_eq 7283 end 7284 if eq k 28 7285 ret wp_push_t to_ne 7286 end 7287 if eq k 29 7288 ret wp_push_t to_lt 7289 end 7290 if eq k 30 7291 ret wp_push_t to_le 7292 end 7293 if eq k 31 7294 ret wp_push_t to_gt 7295 end 7296 if eq k 32 7297 ret wp_push_t to_ge 7298 end 7299 if eq k 33 7300 ret wp_push_t to_neg 7301 end 7302 if eq k 34 7303 ret wp_push_t to_not 7304 end 7305 if eq k 35 7306 ret wp_push_t to_get 7307 end 7308 if eq k 36 7309 ret wp_push_t to_new 7310 end 7311 if eq k 37 7312 ret wp_push_t tg_bool 7313 end 7314 if eq k 38 7315 ret wp_push_t tg_uchar 7316 end 7317 if eq k 39 7318 ret wp_push_t tg_ushort 7319 end 7320 if eq k 40 7321 ret wp_push_t tg_uint 7322 end 7323 if eq k 41 7324 ret wp_push_t tg_ulong 7325 end 7326 if eq k 42 7327 ret wp_push_t tg_byte 7328 end 7329 if eq k 43 7330 ret wp_push_t tg_short 7331 end 7332 if eq k 44 7333 ret wp_push_t tg_int 7334 end 7335 if eq k 45 7336 ret wp_push_t tg_long 7337 end 7338 if eq k 46 7339 ret wp_push_t ti_u8 7340 end 7341 if eq k 47 7342 ret wp_push_t ti_u16 7343 end 7344 if eq k 48 7345 ret wp_push_t ti_u32 7346 end 7347 if eq k 49 7348 ret wp_push_t ti_u64 7349 end 7350 if eq k 50 7351 ret wp_push_t ti_i8 7352 end 7353 if eq k 51 7354 ret wp_push_t ti_i16 7355 end 7356 if eq k 52 7357 ret wp_push_t ti_i32 7358 end 7359 if eq k 53 7360 ret wp_push_t ti_i64 7361 end 7362 if eq k 54 7363 ret wp_push_t tr_own 7364 end 7365 if eq k 55 7366 ret wp_push_t tr_edit 7367 end 7368 ret wp_push_t tr_view 7369 end 7370 7371 note ---- ids table & extends ---- 7372 fn wp_extends_u wo ulong wl ulong to bool 7373 ul = get g_st 37 7374 if lt wl ul 7375 ret false 7376 end 7377 uo = get g_st 36 7378 for i ulong ul bound 64 7379 if ne get g_wpool add wo i get g_wpool add uo i 7380 ret false 7381 end 7382 end 7383 ret true 7384 end 7385 7386 fn id_extends_u idx ulong to bool 7387 ul = get g_st 37 7388 if lt get g_ids_len idx ul 7389 ret false 7390 end 7391 io = mul idx 64 7392 uo = get g_st 36 7393 for i ulong ul bound 64 7394 if ne get g_ids_str add io i get g_wpool add uo i 7395 ret false 7396 end 7397 end 7398 ret true 7399 end 7400 7401 fn id_eq_wp idx ulong off ulong n ulong to bool 7402 if ne get g_ids_len idx n 7403 ret false 7404 end 7405 io = mul idx 64 7406 for j ulong n bound 64 7407 if ne get g_ids_str add io j get g_wpool add off j 7408 ret false 7409 end 7410 end 7411 ret true 7412 end 7413 7414 fn find_id_wp off ulong n ulong to long 7415 ni = get g_st 43 7416 for i ulong ni bound 4096 7417 if id_eq_wp i off n 7418 ret long i 7419 end 7420 end 7421 ret neg long 1 7422 end 7423 7424 fn add_id_wp off ulong n ulong kind ulong to void 7425 if or not valid_ident_wp off n or reserved_wp off n ge find_id_wp off n 0 7426 ret 7427 end 7428 ni = get g_st 43 7429 if ge ni len g_ids_len 7430 nc = mul ni 2 7431 if lt nc 128 7432 nc = 128 7433 end 7434 r1 = enlarge g_ids_str mul nc 64 7435 r2 = enlarge g_ids_len nc 7436 r3 = enlarge g_ids_kind nc 7437 r4 = enlarge g_ids_leg nc 7438 if or lt r1 0 or lt r2 0 or lt r3 0 lt r4 0 7439 exit 2 7440 end 7441 end 7442 dst = mul ni 64 7443 for j ulong n bound 64 7444 put g_ids_str add dst j get g_wpool add off j 7445 end 7446 put g_ids_len ni n 7447 put g_ids_kind ni kind 7448 put g_ids_leg ni 0 7449 put g_st 43 add ni 1 7450 end 7451 7452 fn representative to bool 7453 uo = get g_st 36 7454 ul = get g_st 37 7455 if and gt ul 0 not valid_ident_wp uo ul 7456 ret false 7457 end 7458 tmp = new uchar 24 0 7459 for step ulong 1002 bound 1005 7460 rn = ulong 0 7461 if eq step 0 7462 if eq ul 0 7463 continue 7464 end 7465 for i ulong ul bound 64 7466 put g_rep i get g_wpool add uo i 7467 end 7468 rn = ul 7469 else 7470 if gt ul 0 7471 for i ulong ul bound 64 7472 put g_rep i get g_wpool add uo i 7473 end 7474 rn = ul 7475 else 7476 put g_rep 0 110 7477 rn = 1 7478 end 7479 if lt rn 70 7480 put g_rep rn 95 7481 rn = add rn 1 7482 end 7483 if gt step 1 7484 k = sub step 2 7485 if eq k 0 7486 put g_rep rn 48 7487 rn = add rn 1 7488 else 7489 tk = ulong 0 7490 while gt k 0 bound 16 7491 put tmp tk uchar add 48 rem k 10 7492 k = div k 10 7493 tk = add tk 1 7494 end 7495 while gt tk 0 bound 16 7496 tk = sub tk 1 7497 if lt rn 70 7498 put g_rep rn get tmp tk 7499 rn = add rn 1 7500 end 7501 end 7502 end 7503 end 7504 end 7505 if gt rn NAME_MAX_LEN 7506 ret false 7507 end 7508 put g_st 31 get g_st 32 7509 off = get g_st 31 7510 for i ulong rn bound 64 7511 wp_push_c get g_rep i 7512 end 7513 if and not reserved_wp off rn lt find_id_wp off rn 0 7514 put g_rep_n 0 rn 7515 ret true 7516 end 7517 end 7518 ret false 7519 end 7520 7521 note ---- 128-bit signed integer arithmetic (hi long, lo ulong) ---- 7522 fn i128_lt ah long al ulong bh long bl ulong to bool 7523 if ne ah bh 7524 ret lt ah bh 7525 end 7526 ret lt al bl 7527 end 7528 7529 fn i128_eq ah long al ulong bh long bl ulong to bool 7530 ret and eq ah bh eq al bl 7531 end 7532 7533 fn i128_add ah long al ulong bh long bl ulong to void 7534 lo = add al bl 7535 c = long 0 7536 if lt lo al 7537 c = 1 7538 end 7539 put g_i128_hi 0 add add ah bh c 7540 put g_st 50 lo 7541 end 7542 7543 fn i128_neg ah long al ulong to void 7544 lo = sub ulong 0 al 7545 hi = neg ah 7546 if ne al 0 7547 hi = sub hi 1 7548 end 7549 put g_i128_hi 0 hi 7550 put g_st 50 lo 7551 end 7552 7553 fn u128_div10 uhi ulong ulo ulong to ulong 7554 rhi = rem uhi 10 7555 put g_st 49 div uhi 10 7556 t1 = add shl rhi 32 shr ulo 32 7557 q1 = div t1 10 7558 t0 = add shl rem t1 10 32 and ulo `4294967295` 7559 put g_st 50 or shl q1 32 div t0 10 7560 ret rem t0 10 7561 end 7562 7563 fn i128_to_num which ulong hi long lo ulong to void 7564 is_neg = lt hi 0 7565 uhi = ulong 0 7566 ulo = lo 7567 if is_neg 7568 i128_neg hi lo 7569 uhi = ulong get g_i128_hi 0 7570 ulo = get g_st 50 7571 else 7572 uhi = ulong hi 7573 end 7574 tmp = new uchar 48 0 7575 k = ulong 0 7576 while true bound 48 7577 put tmp k uchar add 48 u128_div10 uhi ulo 7578 k = add k 1 7579 uhi = get g_st 49 7580 ulo = get g_st 50 7581 if and eq uhi 0 eq ulo 0 7582 break 7583 end 7584 end 7585 j = ulong 0 7586 if eq which 1 7587 if is_neg 7588 put g_num1 j 45 7589 j = add j 1 7590 end 7591 while gt k 0 bound 48 7592 k = sub k 1 7593 put g_num1 j get tmp k 7594 j = add j 1 7595 end 7596 put g_num1_n 0 j 7597 else 7598 if is_neg 7599 put g_num2 j 45 7600 j = add j 1 7601 end 7602 while gt k 0 bound 48 7603 k = sub k 1 7604 put g_num2 j get tmp k 7605 j = add j 1 7606 end 7607 put g_num2_n 0 j 7608 end 7609 end 7610 7611 fn i128_lt_st a ulong b ulong to bool 7612 ret i128_lt get g_i128_hi a get g_st add 50 a get g_i128_hi b get g_st add 50 b 7613 end 7614 7615 fn number_extends_try is_neg ulong dval ulong p ulong to bool 7616 a_lo = mul dval p 7617 i128_add 0 a_lo 0 sub p 1 7618 if ne is_neg 0 7619 i128_neg get g_i128_hi 0 get g_st 50 7620 put g_i128_hi 3 get g_i128_hi 0 7621 put g_st 53 get g_st 50 7622 i128_neg 0 a_lo 7623 put g_i128_hi 4 get g_i128_hi 0 7624 put g_st 54 get g_st 50 7625 else 7626 put g_i128_hi 3 0 7627 put g_st 53 a_lo 7628 put g_i128_hi 4 get g_i128_hi 0 7629 put g_st 54 get g_st 50 7630 end 7631 if i128_lt_st 3 1 7632 put g_i128_hi 3 get g_i128_hi 1 7633 put g_st 53 get g_st 51 7634 end 7635 if i128_lt_st 2 4 7636 put g_i128_hi 4 get g_i128_hi 2 7637 put g_st 54 get g_st 52 7638 end 7639 if not i128_lt_st 4 3 7640 if ne is_neg 0 7641 put g_i128_hi 0 get g_i128_hi 4 7642 put g_st 50 get g_st 54 7643 else 7644 put g_i128_hi 0 get g_i128_hi 3 7645 put g_st 50 get g_st 53 7646 end 7647 ret true 7648 end 7649 ret false 7650 end 7651 7652 fn number_extends_loop is_neg ulong doff ulong dlen ulong to bool 7653 if gt dlen 20 7654 ret false 7655 end 7656 for i ulong dlen bound 24 7657 if not is_digit get g_wpool add doff i 7658 ret false 7659 end 7660 end 7661 if eq get g_wpool doff 48 7662 if or gt dlen 1 ne is_neg 0 7663 ret false 7664 end 7665 if or i128_lt 0 0 get g_i128_hi 1 get g_st 51 i128_lt get g_i128_hi 2 get g_st 52 0 0 7666 ret false 7667 end 7668 put g_i128_hi 0 0 7669 put g_st 50 0 7670 ret true 7671 end 7672 dval = ulong 0 7673 umax = sub ulong 0 1 7674 for i ulong dlen bound 24 7675 dig = ulong sub get g_wpool add doff i 48 7676 if gt dval div sub umax dig 10 7677 ret false 7678 end 7679 dval = add mul dval 10 dig 7680 end 7681 p = ulong 1 7682 for k ulong 20 bound 24 7683 if gt dval div umax p 7684 break 7685 end 7686 if number_extends_try is_neg dval p 7687 ret true 7688 end 7689 if eq k 19 7690 break 7691 end 7692 p = mul p 10 7693 end 7694 ret false 7695 end 7696 7697 fn number_extends loh long lol ulong hih long hil ulong to bool 7698 if i128_lt hih hil loh lol 7699 ret false 7700 end 7701 uo = get g_st 36 7702 ul = get g_st 37 7703 if eq ul 0 7704 if i128_lt 0 0 loh lol 7705 put g_i128_hi 0 loh 7706 put g_st 50 lol 7707 else 7708 if i128_lt hih hil 0 0 7709 put g_i128_hi 0 hih 7710 put g_st 50 hil 7711 else 7712 put g_i128_hi 0 0 7713 put g_st 50 0 7714 end 7715 end 7716 ret true 7717 end 7718 is_neg = ulong 0 7719 doff = uo 7720 dlen = ul 7721 if eq get g_wpool uo 45 7722 is_neg = 1 7723 doff = add uo 1 7724 dlen = sub ul 1 7725 end 7726 if eq dlen 0 7727 m1h = neg long 1 7728 m1l = sub ulong 0 1 7729 if i128_lt m1h m1l loh lol 7730 ret false 7731 end 7732 if i128_lt hih hil m1h m1l 7733 put g_i128_hi 0 hih 7734 put g_st 50 hil 7735 else 7736 put g_i128_hi 0 m1h 7737 put g_st 50 m1l 7738 end 7739 ret true 7740 end 7741 put g_i128_hi 1 loh 7742 put g_st 51 lol 7743 put g_i128_hi 2 hih 7744 put g_st 52 hil 7745 ret number_extends_loop is_neg doff dlen 7746 end 7747 7748 fn init_breaks to ulong 7749 put g_bp_hi 0 neg long 1 7750 put g_bp_lo 0 1 7751 put g_bp_hi 1 neg long 1 7752 put g_bp_lo 1 `9223372036854775808` 7753 put g_bp_hi 2 neg long 1 7754 put g_bp_lo 2 sub ulong 0 `2147483648` 7755 put g_bp_hi 3 neg long 1 7756 put g_bp_lo 3 sub ulong 0 32768 7757 put g_bp_hi 4 neg long 1 7758 put g_bp_lo 4 sub ulong 0 128 7759 put g_bp_hi 5 0 7760 put g_bp_lo 5 0 7761 put g_bp_hi 6 0 7762 put g_bp_lo 6 1 7763 put g_bp_hi 7 0 7764 put g_bp_lo 7 14 7765 put g_bp_hi 8 0 7766 put g_bp_lo 8 64 7767 put g_bp_hi 9 0 7768 put g_bp_lo 9 127 7769 put g_bp_hi 10 0 7770 put g_bp_lo 10 255 7771 put g_bp_hi 11 0 7772 put g_bp_lo 11 32767 7773 put g_bp_hi 12 0 7774 put g_bp_lo 12 65535 7775 put g_bp_hi 13 0 7776 put g_bp_lo 13 `1000000` 7777 put g_bp_hi 14 0 7778 put g_bp_lo 14 `2147483647` 7779 put g_bp_hi 15 0 7780 put g_bp_lo 15 `4294967295` 7781 put g_bp_hi 16 0 7782 put g_bp_lo 16 `9223372036854775807` 7783 put g_bp_hi 17 0 7784 put g_bp_lo 17 `18446744073709551615` 7785 ret 18 7786 end 7787 7788 fn sort_dedup_bp nb ulong to ulong 7789 i = ulong 1 7790 while lt i nb bound 128 7791 kh = get g_bp_hi i 7792 kl = get g_bp_lo i 7793 j = i 7794 while gt j 0 bound 128 7795 jm = sub j 1 7796 if not i128_lt kh kl get g_bp_hi jm get g_bp_lo jm 7797 break 7798 end 7799 put g_bp_hi j get g_bp_hi jm 7800 put g_bp_lo j get g_bp_lo jm 7801 j = jm 7802 end 7803 put g_bp_hi j kh 7804 put g_bp_lo j kl 7805 i = add i 1 7806 end 7807 m = ulong 0 7808 for k ulong nb bound 128 7809 keep = eq m 0 7810 if not keep 7811 keep = not i128_eq get g_bp_hi k get g_bp_lo k get g_bp_hi sub m 1 get g_bp_lo sub m 1 7812 end 7813 if keep 7814 put g_bp_hi m get g_bp_hi k 7815 put g_bp_lo m get g_bp_lo k 7816 m = add m 1 7817 end 7818 end 7819 ret m 7820 end 7821 7822 note ---- oracle ---- 7823 fn refuse_out to int 7824 en = get g_st 3 7825 if eq get g_st 39 0 7826 so_t tc_refused 7827 so_err_buf 0 en 7828 so_c 10 7829 so_flush 7830 ret 1 7831 end 7832 m = ulong 0 7833 if ge en 5 7834 has_lp = and eq get g_err 0 108 eq get g_err 1 105 7835 if and has_lp and eq get g_err 2 110 and eq get g_err 3 101 eq get g_err 4 32 7836 p = ulong 5 7837 while lt add p 1 en bound 512 7838 if and eq get g_err p 58 eq get g_err add p 1 32 7839 m = add p 2 7840 break 7841 end 7842 p = add p 1 7843 end 7844 end 7845 end 7846 so_t tc_ref_pfx 7847 so_u64 get g_st 35 7848 so_t tc_ref_mid 7849 so_err_buf m sub en m 7850 so_t tc_ref_end 7851 so_flush 7852 ret 1 7853 end 7854 7855 fn human_line lbl view uchar * to void 7856 n = get g_hbuf_n 0 7857 if gt n 0 7858 so_t lbl 7859 so_c 58 7860 for i ulong n bound 65536 7861 so_c get g_hbuf i 7862 end 7863 so_c 10 7864 put g_hbuf_n 0 0 7865 end 7866 end 7867 7868 fn oracle_collect_bp to ulong 7869 nb = init_breaks 7870 lens = ulong 0 7871 snn = get s0_st 4 7872 for i ulong snn bound 512 7873 t = get s0_regs get s0_nm_reg i 7874 if ne ty_ref t R_NONE 7875 lens = or lens shl ulong 1 sub ty_len t 1 7876 end 7877 end 7878 for l0 ulong 64 bound 64 7879 if ne and shr lens l0 1 0 7880 put g_bp_hi nb 0 7881 put g_bp_lo nb add l0 1 7882 nb = add nb 1 7883 end 7884 end 7885 ret sort_dedup_bp nb 7886 end 7887 7888 fn oracle_test_num ah long al ulong to bool 7889 i128_to_num 1 ah al 7890 put g_st 31 get g_st 32 7891 off = get g_st 31 7892 nl = get g_num1_n 0 7893 for j ulong nl bound 64 7894 wp_push_c get g_num1 j 7895 end 7896 ret legal_wp 1 off nl 1 7897 end 7898 7899 fn oracle_num_step k ulong gap ulong nb ulong to void 7900 ah = get g_bp_hi k 7901 al = get g_bp_lo k 7902 bh = ah 7903 bl = al 7904 if ne gap 0 7905 if ge add k 1 nb 7906 ret 7907 end 7908 i128_add ah al 0 1 7909 ah = get g_i128_hi 0 7910 al = get g_st 50 7911 nk = add k 1 7912 i128_add get g_bp_hi nk get g_bp_lo nk neg long 1 sub ulong 0 1 7913 bh = get g_i128_hi 0 7914 bl = get g_st 50 7915 if i128_lt bh bl ah al 7916 ret 7917 end 7918 end 7919 if oracle_test_num ah al 7920 niv = get g_st 61 7921 if ne get g_st 62 0 7922 put g_hi_hi sub niv 1 bh 7923 put g_hi_lo sub niv 1 bl 7924 else 7925 put g_lo_hi niv ah 7926 put g_lo_lo niv al 7927 put g_hi_hi niv bh 7928 put g_hi_lo niv bl 7929 put g_st 61 add niv 1 7930 put g_st 62 1 7931 end 7932 else 7933 put g_st 62 0 7934 end 7935 end 7936 7937 fn oracle_compute_nums to ulong 7938 ul = get g_st 37 7939 if gt ul 0 7940 c0 = get g_wpool get g_st 36 7941 if not or eq c0 45 is_digit c0 7942 ret 0 7943 end 7944 end 7945 nb = oracle_collect_bp 7946 put g_st 61 0 7947 put g_st 62 0 7948 for k ulong nb bound 128 7949 oracle_num_step k 0 nb 7950 oracle_num_step k 1 nb 7951 end 7952 niv = get g_st 61 7953 m = ulong 0 7954 for k ulong niv bound 256 7955 if number_extends get g_lo_hi k get g_lo_lo k get g_hi_hi k get g_hi_lo k 7956 put g_lo_hi m get g_lo_hi k 7957 put g_lo_lo m get g_lo_lo k 7958 put g_hi_hi m get g_hi_hi k 7959 put g_hi_lo m get g_hi_lo k 7960 m = add m 1 7961 end 7962 end 7963 ret m 7964 end 7965 7966 fn oracle_print_machine nn ulong niv ulong flags ulong to void 7967 for k ulong NFIXED bound 64 7968 if ne get g_fx k 0 7969 so_t tm_word 7970 put g_st 31 get g_st 32 7971 off = fw_push_wp k 7972 so_wpool off sub get g_st 31 off 7973 so_c 10 7974 end 7975 end 7976 nids = get g_st 43 7977 for i ulong nids bound 4096 7978 if ne get g_ids_leg i 0 7979 so_t tm_word 7980 so_ids_name i 7981 so_c 10 7982 end 7983 end 7984 if ne nn 0 7985 so_t tm_newname 7986 for i ulong nids bound 4096 7987 if id_extends_u i 7988 so_c 32 7989 so_ids_name i 7990 end 7991 end 7992 so_c 10 7993 end 7994 for k ulong niv bound 256 7995 i128_to_num 1 get g_lo_hi k get g_lo_lo k 7996 i128_to_num 2 get g_hi_hi k get g_hi_lo k 7997 so_t tm_number 7998 so_num1 7999 so_c 32 8000 so_num2 8001 so_c 10 8002 end 8003 if ne and flags 1 0 8004 so_t tm_lpar 8005 end 8006 if ne and flags 2 0 8007 so_t tm_rpar 8008 end 8009 if ne and flags 4 0 8010 so_t tm_space 8011 end 8012 if ne and flags 8 0 8013 so_t tm_newline 8014 end 8015 if ne and flags 16 0 8016 so_t tm_eof 8017 end 8018 so_flush 8019 end 8020 8021 fn oracle_print_human nn ulong niv ulong flags ulong to void 8022 put g_hbuf_n 0 0 8023 is_start = and eq get g_st 34 0 eq get g_st 37 0 8024 nids = get g_st 43 8025 for i ulong nids bound 4096 8026 if and ne get g_ids_leg i 0 ne get g_ids_kind i 1 8027 hbuf_c 32 8028 hbuf_ids i 8029 end 8030 end 8031 if is_start 8032 human_line th_assign 8033 else 8034 human_line th_names 8035 end 8036 for k ulong niv bound 256 8037 if gt k 0 8038 hbuf_c 44 8039 end 8040 hbuf_c 32 8041 i128_to_num 1 get g_lo_hi k get g_lo_lo k 8042 i128_to_num 2 get g_hi_hi k get g_hi_lo k 8043 hbuf_num1 8044 hbuf_t t_dotdot 8045 hbuf_num2 8046 end 8047 human_line th_number 8048 if ne nn 0 8049 hbuf_t th_anyname 8050 end 8051 human_line th_newname 8052 for k ulong NFIXED bound 64 8053 if ne get g_fx k 0 8054 hbuf_c 32 8055 put g_st 31 get g_st 32 8056 off = fw_push_wp k 8057 n = sub get g_st 31 off 8058 for j ulong n bound 64 8059 hbuf_c get g_wpool add off j 8060 end 8061 end 8062 end 8063 for i ulong nids bound 4096 8064 if and ne get g_ids_leg i 0 eq get g_ids_kind i 1 8065 hbuf_c 32 8066 hbuf_ids i 8067 end 8068 end 8069 if ne and flags 1 0 8070 hbuf_t th_lpar 8071 end 8072 if ne and flags 2 0 8073 hbuf_t th_rpar 8074 end 8075 if and ne and flags 4 0 gt get g_st 37 0 8076 hbuf_t th_space 8077 end 8078 if and ne and flags 8 0 not is_start 8079 hbuf_t th_newline 8080 end 8081 if ne and flags 16 0 8082 hbuf_t th_eof 8083 end 8084 human_line th_words 8085 so_flush 8086 end 8087 8088 fn oracle_pick_first nn ulong niv ulong flags ulong to ulong 8089 ul = get g_st 37 8090 if ne and flags 4 0 8091 put g_st 57 get g_st 36 8092 put g_st 58 ul 8093 ret 1 8094 end 8095 for k ulong NFIXED bound 64 8096 if ne get g_fx k 0 8097 put g_st 31 get g_st 32 8098 fo = fw_push_wp k 8099 put g_st 57 fo 8100 put g_st 58 sub get g_st 31 fo 8101 ret 1 8102 end 8103 end 8104 nids = get g_st 43 8105 for i ulong nids bound 4096 8106 if ne get g_ids_leg i 0 8107 put g_st 31 get g_st 32 8108 put g_st 57 get g_st 31 8109 fl = get g_ids_len i 8110 put g_st 58 fl 8111 io = mul i 64 8112 for j ulong fl bound 64 8113 wp_push_c get g_ids_str add io j 8114 end 8115 ret 1 8116 end 8117 end 8118 if ne nn 0 8119 put g_st 31 get g_st 32 8120 put g_st 57 get g_st 31 8121 fl = get g_rep_n 0 8122 put g_st 58 fl 8123 for j ulong fl bound 64 8124 wp_push_c get g_rep j 8125 end 8126 ret 1 8127 end 8128 for k ulong niv bound 256 8129 if number_extends get g_lo_hi k get g_lo_lo k get g_hi_hi k get g_hi_lo k 8130 i128_to_num 1 get g_i128_hi 0 get g_st 50 8131 put g_st 31 get g_st 32 8132 put g_st 57 get g_st 31 8133 fl = get g_num1_n 0 8134 put g_st 58 fl 8135 for j ulong fl bound 64 8136 wp_push_c get g_num1 j 8137 end 8138 ret 1 8139 end 8140 end 8141 ret 0 8142 end 8143 8144 fn oracle_complete nn ulong niv ulong flags ulong to int 8145 if ne and flags 16 0 8146 ret 0 8147 end 8148 ul = get g_st 37 8149 has_first = ulong 0 8150 fo = ulong 0 8151 fl = ulong 0 8152 if gt ul 0 8153 has_first = oracle_pick_first nn niv flags 8154 if eq has_first 0 8155 ok = legal_wp 1 get g_st 36 ul 1 8156 ret refuse_out 8157 end 8158 fo = get g_st 57 8159 fl = get g_st 58 8160 else 8161 put g_st 31 get g_st 32 8162 end 8163 if not legal_wp has_first fo fl 1 8164 ret refuse_out 8165 end 8166 if ne has_first 0 8167 if gt fl ul 8168 so_wpool add fo ul sub fl ul 8169 end 8170 end 8171 k = add get g_st 34 has_first 8172 gfl = get g_st 38 8173 while lt k gfl bound 1024 8174 so_c 32 8175 so_wpool get g_lw_off k get g_lw_len k 8176 k = add k 1 8177 end 8178 if gt gfl 0 8179 so_c 10 8180 end 8181 so_close 8182 so_flush 8183 ret 0 8184 end 8185 8186 fn oracle_collect_ids nwu ulong to void 8187 nn0 = get g_st 9 8188 for j ulong nn0 bound 512 8189 put g_st 31 get g_st 32 8190 off = get g_st 31 8191 nl = get g_nm_len j 8192 nsrc = mul j 64 8193 for p ulong nl bound 64 8194 wp_push_c get g_nm_str add nsrc p 8195 end 8196 add_id_wp off nl 0 8197 end 8198 nf0 = get g_st 5 8199 for j ulong nf0 bound 32 8200 put g_st 31 get g_st 32 8201 off = get g_st 31 8202 nl = get g_fn_nlen j 8203 fsrc = mul j 64 8204 for p ulong nl bound 64 8205 wp_push_c get g_fn_name add fsrc p 8206 end 8207 add_id_wp off nl 1 8208 end 8209 for j ulong nwu bound 128 8210 add_id_wp get g_W_off j get g_W_len j 2 8211 end 8212 end 8213 8214 fn oracle_eval_words to ulong 8215 any = ulong 0 8216 for k ulong NFIXED bound 64 8217 put g_fx k 0 8218 put g_st 31 get g_st 32 8219 off = fw_push_wp k 8220 wl = sub get g_st 31 off 8221 if wp_extends_u off wl 8222 if legal_wp 1 off wl 1 8223 put g_fx k 1 8224 any = 1 8225 end 8226 end 8227 end 8228 nids = get g_st 43 8229 for j ulong nids bound 4096 8230 put g_ids_leg j 0 8231 if id_extends_u j 8232 put g_st 31 get g_st 32 8233 off = get g_st 31 8234 nl = get g_ids_len j 8235 io = mul j 64 8236 for p ulong nl bound 64 8237 wp_push_c get g_ids_str add io p 8238 end 8239 if legal_wp 1 off nl 1 8240 put g_ids_leg j 1 8241 any = 1 8242 end 8243 end 8244 end 8245 nn_leg = ulong 0 8246 if representative 8247 put g_st 31 get g_st 32 8248 off = get g_st 31 8249 rl = get g_rep_n 0 8250 for p ulong rl bound 64 8251 wp_push_c get g_rep p 8252 end 8253 if legal_wp 1 off rl 1 8254 nn_leg = 1 8255 any = 1 8256 end 8257 end 8258 ret or any shl nn_leg 1 8259 end 8260 8261 fn oracle_check_punct any ulong to ulong 8262 ul = get g_st 37 8263 flags = ulong 0 8264 if gt ul 0 8265 if legal_u_t t_lpar 1 8266 flags = or flags 1 8267 end 8268 if legal_u_t t_rpar 1 8269 flags = or flags 2 8270 end 8271 put g_st 31 get g_st 32 8272 if legal_wp 1 get g_st 36 ul 0 8273 flags = or flags 8 8274 end 8275 else 8276 if legal_t t_lpar 1 8277 flags = or flags 1 8278 end 8279 if legal_t t_rpar 1 8280 flags = or flags 2 8281 end 8282 put g_st 31 get g_st 32 8283 if legal_wp 0 0 0 0 8284 flags = or flags 8 8285 end 8286 end 8287 if legal_eof 8288 flags = or flags 16 8289 end 8290 if ne flags 0 8291 any = 1 8292 end 8293 if gt ul 0 8294 put g_st 31 get g_st 32 8295 if legal_wp 1 get g_st 36 ul 1 8296 flags = or flags 4 8297 any = 1 8298 end 8299 else 8300 if ne any 0 8301 flags = or flags 4 8302 end 8303 end 8304 ret or flags shl any 8 8305 end 8306 8307 fn oracle_prep slen ulong to long 8308 put g_st 25 1 8309 put g_st 43 0 8310 tail = ulong 0 8311 i = slen 8312 while gt i 0 bound BIG 8313 i = sub i 1 8314 if eq get g_src i 10 8315 tail = add i 1 8316 break 8317 end 8318 end 8319 mid = false 8320 if gt sub slen tail 0 8321 if not is_sep get g_src sub slen 1 8322 mid = true 8323 end 8324 end 8325 put g_st 39 0 8326 if lt run_src tail 1 0 8327 ret neg long 1 8328 end 8329 tline = add get g_st 4 1 8330 put g_st 35 tline 8331 put g_st 4 tline 8332 put g_st 31 0 8333 put g_st 23 0 8334 nw = split_src tail slen 0 8335 if lt nw 0 8336 ret neg long 1 8337 end 8338 nwu = ulong nw 8339 for j ulong nwu bound 128 8340 put g_W_off j get g_lw_off j 8341 put g_W_len j get g_lw_len j 8342 end 8343 if mid 8344 nwu = sub nwu 1 8345 put g_st 36 get g_W_off nwu 8346 put g_st 37 get g_W_len nwu 8347 else 8348 put g_st 36 0 8349 put g_st 37 0 8350 end 8351 put g_st 34 nwu 8352 put g_st 32 get g_st 31 8353 save_state 8354 oracle_collect_ids nwu 8355 ret 0 8356 end 8357 8358 fn oracle slen ulong mode ulong to int 8359 if lt oracle_prep slen 0 8360 ret refuse_out 8361 end 8362 ew = oracle_eval_words 8363 any = and ew 1 8364 nn_leg = shr ew 1 8365 niv = oracle_compute_nums 8366 if gt niv 0 8367 any = 1 8368 end 8369 pf = oracle_check_punct any 8370 flags = and pf 255 8371 any = shr pf 8 8372 if eq any 0 8373 ul = get g_st 37 8374 put g_st 31 get g_st 32 8375 if gt ul 0 8376 ok1 = legal_wp 0 0 0 1 8377 if or ok1 ne get g_st 39 0 8378 put g_st 31 get g_st 32 8379 ok2 = legal_wp 1 get g_st 36 ul 1 8380 put g_st 39 1 8381 end 8382 else 8383 ok3 = legal_wp 0 0 0 1 8384 end 8385 ret refuse_out 8386 end 8387 if eq mode M_MACHINE 8388 oracle_print_machine nn_leg niv flags 8389 ret 0 8390 end 8391 if eq mode M_HUMAN 8392 oracle_print_human nn_leg niv flags 8393 ret 0 8394 end 8395 ret oracle_complete nn_leg niv flags 8396 end 8397 8398 note ---- CLI & file I/O ---- 8399 fn arg1_eq s view uchar * n ulong to bool 8400 if ne n len s 8401 ret false 8402 end 8403 for i ulong n bound 256 8404 if ne get g_arg1 i get s i 8405 ret false 8406 end 8407 end 8408 ret true 8409 end 8410 8411 fn arg2_eq s view uchar * n ulong to bool 8412 if ne n len s 8413 ret false 8414 end 8415 for i ulong n bound 256 8416 if ne get g_arg2 i get s i 8417 ret false 8418 end 8419 end 8420 ret true 8421 end 8422 8423 fn slurp_arg3 plen ulong to long 8424 fd = fopen g_arg3 0 plen 0 0 8425 if lt fd 0 8426 k = write 2 g_arg3 0 plen 8427 k2 = write 2 tc_open_err 0 len tc_open_err 8428 exit 2 8429 end 8430 r = enlarge g_src add MAX_IN 2 8431 if lt r 0 8432 cl = fclose int fd 8433 exit 2 8434 end 8435 tot = ulong 0 8436 lim = add MAX_IN 1 8437 while lt tot lim bound BIG 8438 k = read int fd g_src tot sub lim tot 8439 if eq k neg long 4 8440 continue 8441 end 8442 if lt k 0 8443 cl = fclose int fd 8444 exit 2 8445 end 8446 if eq k 0 8447 break 8448 end 8449 tot = add tot ulong k 8450 end 8451 cl = fclose int fd 8452 if gt tot MAX_IN 8453 k = write 2 g_arg3 0 plen 8454 k2 = write 2 tc_large_err 0 len tc_large_err 8455 exit 2 8456 end 8457 for i ulong tot bound BIG 8458 if eq get g_src i 0 8459 so_t tc_zero_err 8460 so_flush 8461 exit 1 8462 end 8463 end 8464 put g_st 0 tot 8465 ret long tot 8466 end 8467 8468 fn write_out_arg2 plen ulong to int 8469 fd = fopen g_arg2 0 plen 577 420 8470 if lt fd 0 8471 k = write 2 g_arg2 0 plen 8472 k2 = write 2 tc_open_err 0 len tc_open_err 8473 ret 2 8474 end 8475 n = get g_st 1 8476 off = ulong 0 8477 while lt off n bound BIG 8478 k = write int fd g_out off sub n off 8479 if eq k neg long 4 8480 continue 8481 end 8482 if le k 0 8483 cl = fclose int fd 8484 k2 = write 2 g_arg2 0 plen 8485 k3 = write 2 tc_write_err 0 len tc_write_err 8486 ret 2 8487 end 8488 off = add off ulong k 8489 end 8490 cl = fclose int fd 8491 if lt cl 0 8492 k2 = write 2 g_arg2 0 plen 8493 k3 = write 2 tc_write_err 0 len tc_write_err 8494 ret 2 8495 end 8496 ret 0 8497 end 8498 8499 fn cmd_words to int 8500 so_t tk_fn 8501 so_c 10 8502 so_t tk_to 8503 so_c 10 8504 so_t tk_void 8505 so_c 10 8506 so_t tk_end 8507 so_c 10 8508 so_t tk_else 8509 so_c 10 8510 so_t tk_if 8511 so_c 10 8512 so_t tk_while 8513 so_c 10 8514 so_t tk_for 8515 so_c 10 8516 so_t tk_break 8517 so_c 10 8518 so_t tk_ret 8519 so_c 10 8520 so_t tk_trap 8521 so_c 10 8522 so_t tk_put 8523 so_c 10 8524 so_t tk_free 8525 so_c 10 8526 so_t tk_true 8527 so_c 10 8528 so_t tk_false 8529 so_c 10 8530 so_t tk_bound 8531 so_c 10 8532 so_t to_add 8533 so_c 10 8534 so_t to_sub 8535 so_c 10 8536 so_t to_mul 8537 so_c 10 8538 so_t to_div 8539 so_c 10 8540 so_t to_rem 8541 so_c 10 8542 so_t to_and 8543 so_c 10 8544 so_t to_or 8545 so_c 10 8546 so_t to_xor 8547 so_c 10 8548 so_t to_shl 8549 so_c 10 8550 so_t to_shr 8551 so_c 10 8552 so_t to_eq 8553 so_c 10 8554 so_t to_ne 8555 so_c 10 8556 so_t to_lt 8557 so_c 10 8558 so_t to_le 8559 so_c 10 8560 so_t to_gt 8561 so_c 10 8562 so_t to_ge 8563 so_c 10 8564 so_t to_neg 8565 so_c 10 8566 so_t to_not 8567 so_c 10 8568 so_t to_get 8569 so_c 10 8570 so_t to_new 8571 so_c 10 8572 so_t tg_bool 8573 so_c 10 8574 so_t tg_uchar 8575 so_c 10 8576 so_t tg_ushort 8577 so_c 10 8578 so_t tg_uint 8579 so_c 10 8580 so_t tg_ulong 8581 so_c 10 8582 so_t tg_byte 8583 so_c 10 8584 so_t tg_short 8585 so_c 10 8586 so_t tg_int 8587 so_c 10 8588 so_t tg_long 8589 so_c 10 8590 so_t tr_own 8591 so_c 10 8592 so_t tr_edit 8593 so_c 10 8594 so_t tr_view 8595 so_c 10 8596 so_flush 8597 ret 0 8598 end 8599 8600 fn main to int 8601 ac = argcnt 8602 if eq ac 2 8603 n1 = argread 1 g_arg1 0 4095 8604 if ge n1 0 8605 if arg1_eq tc_words ulong n1 8606 ret cmd_words 8607 end 8608 end 8609 end 8610 if ge ac 3 8611 n1 = argread 1 g_arg1 0 4095 8612 if ge n1 0 8613 is_mach = false 8614 if and eq ac 4 arg1_eq tc_next ulong n1 8615 n2 = argread 2 g_arg2 0 4095 8616 if ge n2 0 8617 if arg2_eq tc_machine ulong n2 8618 is_mach = true 8619 end 8620 end 8621 end 8622 if or is_mach and eq ac 3 or arg1_eq tc_next ulong n1 arg1_eq tc_complete ulong n1 8623 pidx = sub ulong ac 1 8624 plen = argread pidx g_arg3 0 4095 8625 if lt plen 0 8626 k = write 2 tc_usage 0 len tc_usage 8627 ret 2 8628 end 8629 slen = slurp_arg3 ulong plen 8630 mode = M_COMPLETE 8631 if is_mach 8632 mode = M_MACHINE 8633 else 8634 if arg1_eq tc_next ulong n1 8635 mode = M_HUMAN 8636 end 8637 end 8638 ret oracle ulong slen mode 8639 end 8640 if and eq ac 4 arg1_eq tc_emit ulong n1 8641 in_len = argread 2 g_arg3 0 4095 8642 out_len = argread 3 g_arg2 0 4095 8643 if or lt in_len 0 lt out_len 0 8644 k = write 2 tc_usage 0 len tc_usage 8645 ret 2 8646 end 8647 slen = slurp_arg3 ulong in_len 8648 if lt run_src ulong slen 0 0 8649 so_t tc_refused 8650 so_err_buf 0 get g_st 3 8651 so_c 10 8652 so_flush 8653 ret 1 8654 end 8655 ret write_out_arg2 ulong out_len 8656 end 8657 end 8658 end 8659 k = write 2 tc_usage 0 len tc_usage 8660 ret 2 8661 end