feat(shell): provide the default environment when parsing Lua files

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-01-12 18:21:14 -08:00
parent 7f818ecd92
commit 35bacf95fc
3 changed files with 8 additions and 2 deletions

View file

@ -94,6 +94,7 @@ static void parse_lean_cmds_core(lua_State * L, rw_shared_environment const & en
set_global_options(L, s.get_options());
} else {
parse_lean_cmds_core(L, env, *io);
set_global_options(L, io->get_options());
}
}

View file

@ -227,7 +227,13 @@ int main(int argc, char ** argv) {
}
} else if (k == input_kind::Lua) {
try {
S.dofile(argv[i]);
S.apply([&](lua_State * L) {
lean::set_io_state set1(L, ios);
lean::set_environment set2(L, env);
S.exec_unprotected([&]() {
S.dofile(argv[i]);
});
});
} catch (lean::exception & ex) {
std::cerr << ex.what() << std::endl;
ok = false;

View file

@ -1,4 +1,3 @@
assert(not pcall(function() get_environment() end))
local env = environment()
env:import("Int")
env:add_uvar_cnstr("M", level(level(), 1))