Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869;; Instructions zena has no intrinsic for, as functions engine/*.zena imports from "rt". scripts/build.sh;; wasm-merges this module into every build, then drops its exports again, so the import becomes a direct;; call that wasm-opt inlines.(module (import "engine" "memory" (memory 1)) ;; memmove: the ranges may overlap. (func (export "move") (param $dst i32) (param $src i32) (param $len i32) (memory.copy (local.get $dst) (local.get $src) (local.get $len))) ;; The first address in [a, b) holding byte x, y or z, else b; 16 bytes per step. Reads up to 15 bytes ;; past b (the input buffer's slack), and clamps a match found there to b. (func (export "find3") (param $a i32) (param $b i32) (param $x i32) (param $y i32) (param $z i32) (result i32) (local $vx v128) (local $vy v128) (local $vz v128) (local $v v128) (local $m i32) (local.set $vx (i8x16.splat (local.get $x))) (local.set $vy (i8x16.splat (local.get $y))) (local.set $vz (i8x16.splat (local.get $z))) (block $done (loop $l (br_if $done (i32.ge_u (local.get $a) (local.get $b))) (local.set $v (v128.load align=1 (local.get $a))) (local.set $m (i8x16.bitmask (v128.or (v128.or (i8x16.eq (local.get $v) (local.get $vx)) (i8x16.eq (local.get $v) (local.get $vy))) (i8x16.eq (local.get $v) (local.get $vz))))) (if (local.get $m) (then (local.set $a (i32.add (local.get $a) (i32.ctz (local.get $m)))) (return (select (local.get $a) (local.get $b) (i32.lt_u (local.get $a) (local.get $b)))))) (local.set $a (i32.add (local.get $a) (i32.const 16))) (br $l))) (local.get $b)) ;; The first address p in [a, b) with `*/` at p, else b; 16 bytes per step. A lone `*` doesn't stop the ;; scan, unlike find3, which matters for JSDoc's `*` on every line. Reads up to 16 bytes past b (the input ;; buffer's slack), and clamps a match found there to b. (func (export "findClose") (param $a i32) (param $b i32) (result i32) (local $m i32) (block $done (loop $l (br_if $done (i32.ge_u (local.get $a) (local.get $b))) (local.set $m (i8x16.bitmask (v128.and (i8x16.eq (v128.load align=1 (local.get $a)) (v128.const i8x16 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42)) (i8x16.eq (v128.load offset=1 align=1 (local.get $a)) (v128.const i8x16 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47))))) (if (local.get $m) (then (local.set $a (i32.add (local.get $a) (i32.ctz (local.get $m)))) (return (select (local.get $a) (local.get $b) (i32.lt_u (local.get $a) (local.get $b)))))) (local.set $a (i32.add (local.get $a) (i32.const 16))) (br $l))) (local.get $b)) ;; Blanks the leading run of [s, s + n) that holds no byte >= 0x80, \n or \r: writes spaces to d onward, 16 ;; at a time while at least 16 bytes remain, and returns the run's length (a multiple of 16 when it reaches ;; past the last whole chunk). May write up to 15 spaces past the run, never past d + n. (func (export "blank16") (param $s i32) (param $d i32) (param $n i32) (result i32) (local $k i32) (local $v v128) (local $m i32) (block $done (loop $l (br_if $done (i32.lt_s (i32.sub (local.get $n) (local.get $k)) (i32.const 16))) (local.set $v (v128.load align=1 (i32.add (local.get $s) (local.get $k)))) (v128.store align=1 (i32.add (local.get $d) (local.get $k)) (v128.const i8x16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32)) (local.set $m (i8x16.bitmask (v128.or (local.get $v) (v128.or (i8x16.eq (local.get $v) (v128.const i8x16 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10)) (i8x16.eq (local.get $v) (v128.const i8x16 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13)))))) (if (local.get $m) (then (return (i32.add (local.get $k) (i32.ctz (local.get $m)))))) (local.set $k (i32.add (local.get $k) (i32.const 16))) (br $l))) (local.get $k)))