MikeInnes / WebAssembly.jl

Other
83 stars 11 forks source link

WIP: add import and export sections #4

Closed tshort closed 6 years ago

tshort commented 6 years ago

This is a start at adding import and export sections to a wasm module. Imports could look something like the following on the Charlotte side:

@import env.sin(Float64)::Float64

This would become:

function sin(::Float64)
    Expr(:meta, (:env, :sin, Float64, Tuple{Float64}))
    nothing
end

Then, that would be transformed into a call in wasm when sin is parsed. Instead of Julia types given above, those could be wasm types.

Exports could be picked up as follows:

function mathfun(x)
    x + sin(x)
end

m = @wasm begin
    mathfun(Float64)
    # Enter more functions here...
end
write("test.wat", m)
tshort commented 6 years ago

Closing in favor of #6.