mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
wasm: add support for [export]ed functions (#18055)
This commit is contained in:
parent
c4b34c9482
commit
4bfe270c41
@ -309,11 +309,17 @@ fn (mut g Gen) fn_decl(node ast.FnDecl) {
|
||||
for idx := paraml.len; idx < g.local_temporaries.len; idx++ {
|
||||
temporaries << g.local_temporaries[idx].typ
|
||||
}
|
||||
|
||||
function := binaryen.addfunction(g.mod, name.str, params_type, return_type, temporaries.data,
|
||||
temporaries.len, wasm_expr)
|
||||
|
||||
mut export_name := name.str
|
||||
if cattr := node.attrs.find_first('export') {
|
||||
export_name = cattr.arg.str
|
||||
}
|
||||
//&& g.pref.os == .browser
|
||||
if node.is_pub && node.mod == 'main' {
|
||||
binaryen.addfunctionexport(g.mod, name.str, name.str)
|
||||
binaryen.addfunctionexport(g.mod, name.str, export_name)
|
||||
}
|
||||
if g.pref.is_debug {
|
||||
binaryen.functionsetdebuglocation(function, wasm_expr, g.file_path_idx, node.pos.line_nr,
|
||||
|
Loading…
Reference in New Issue
Block a user