WebAssembly in LuaLaTeX (SotonHack 2026 project)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

initial commit

arthomnix e3409536

+43
+43
wasmtex.sty
··· 1 + \ProvidesPackage{wasmtex}[2026-03-15 v0.1a WebAssembly for LuaLaTeX] 2 + 3 + \directlua{wasmlib = require("wasmlib")} 4 + 5 + \NewDocumentCommand\WASMTracingOn{}{\directlua{wasmlib.TRACING = true}} 6 + 7 + \NewDocumentCommand\WASMInstantiateFile{v m}{ 8 + \directlua{ 9 + __wasmtex_#2 = wasmlib.VM:new() 10 + __wasmtex_#2.outBuf = "" 11 + __wasmtex_#2:instantiateFile( 12 + "\luaescapestring{#1}", 13 + { 14 + tex = { 15 + tex_putchar = function(x) 16 + __wasmtex_#2.outBuf = __wasmtex_#2.outBuf .. string.char(x) 17 + end, 18 + tex_flush = function() 19 + tex.sprint(__wasmtex_#2.outBuf) 20 + __wasmtex_#2.outBuf = "" 21 + end, 22 + }, 23 + env = { 24 + putchar = function(x) io.write(string.char(x)) end, 25 + putint = function(x) print("DEBUG",x) end, 26 + }, 27 + } 28 + ) 29 + } 30 + } 31 + 32 + \NewDocumentCommand\WASMCallExportedFunction{m v v}{ 33 + \directlua{ 34 + __wasmtex_#1.exports.#2(#3) 35 + } 36 + } 37 + 38 + \NewDocumentCommand\WASMCallFunctionByIndex{m m}{ 39 + \directlua{ 40 + __wasmtex_#1:invoke(#2) 41 + while \string##__wasmtex_#1.stackFrames > 0 do __wasmtex_#1:step() end 42 + } 43 + }