| ------------------------------------------------------------------------------- |
| -- Copyright (c) 2006-2013 Fabien Fleutot and others. |
| -- |
| -- All rights reserved. |
| -- |
| -- This program and the accompanying materials are made available |
| -- under the terms of the Eclipse Public License v1.0 which |
| -- accompanies this distribution, and is available at |
| -- http://www.eclipse.org/legal/epl-v10.html |
| -- |
| -- This program and the accompanying materials are also made available |
| -- under the terms of the MIT public license which accompanies this |
| -- distribution, and is available at http://www.lua.org/license.html |
| -- |
| -- Contributors: |
| -- Fabien Fleutot - API and implementation |
| -- |
| ------------------------------------------------------------------------------- |
| |
| -- WARNING, this is undertested, especially in cases where mutliple |
| -- modules have their own fenvs. Use at your own risks. |
| |
| require 'strict' |
| |
| local function decl_builder(x) |
| local ids, vals = unpack(x) |
| local ids_as_strings = table.imap(|x| `String{x[1]}, ids) |
| local decl = `Call{ +{getmetatable(getfenv()).__newglobal}, |
| unpack(ids_as_strings) } |
| if vals then return { decl, `Set{ ids, vals } } |
| else return decl end |
| end |
| |
| mlp.lexer:add 'global' |
| mlp.stat:add{ |
| 'global', mlp.id_list, gg.onkeyword{ '=', mlp.expr_list }, |
| builder = decl_builder } |
| |
| return +{ require (-{ `String{ package.metalua_extension_prefix .. 'xglobal-runtime' } }) } |