ktye / i

interpret
100 stars 16 forks source link

wb.k jump with label #42

Closed ktye closed 1 year ago

ktye commented 1 year ago

break/continue with labels needs to calculate nesting level

ktye commented 1 year ago

compare diff k.wasm vs j.wasm tee.awk:

$1~/local.tee/{
 gsub("tee","set")
 print $0
 gsub("set","get")
 print $0
 next
}
{print}
ktye commented 1 year ago
wbjmp:{y;0x0c,_$[`~S x;1+I x;wbtrg x]}

wbtrg:{l:S x;c:-~I x   /calculate target for labeled break/continue
 x:1_{$[(`for;l)~(T x;S x);x;P x]}\:x   /scan parents til for-with-label
 x:x@&~`stm=T x                         /dont nest statements
 c+-1+(#x)+/(`for=T x)&~I x}            /simple loops add 1 level, others 2