1 -- WARNING, this is undertested, especially in cases where mutliple
2 -- modules have their own fenvs. Use at your own risks.
6 local function decl_builder(x)
7 local ids, vals = unpack(x)
8 local ids_as_strings = table.imap(|x| `String{x[1]}, ids)
9 local decl = `Call{ +{getmetatable(getfenv()).__newglobal},
10 unpack(ids_as_strings) }
11 if vals then return { decl, `Set{ ids, vals } }
15 mlp.lexer:add 'global'
17 'global', mlp.id_list, gg.onkeyword{ '=', mlp.expr_list },
18 builder = decl_builder }
20 return +{ require (-{ `String{ package.metalua_extension_prefix .. 'xglobal-runtime' } }) }