Repl+Env+Example: Load global outer environment in Repl::init
This commit is contained in:
Vendored
+3
@@ -79,6 +79,9 @@ EnvironmentPtr Environment::create(const ValuePtr lambda, ValueVector&& argument
|
||||
|
||||
void Environment::loadFunctions()
|
||||
{
|
||||
s_function_parts.clear();
|
||||
s_lambdas.clear();
|
||||
|
||||
loadCollectionAccess();
|
||||
loadCollectionConstructor();
|
||||
loadCollectionModify();
|
||||
|
||||
+10
-4
@@ -25,12 +25,18 @@
|
||||
namespace blaze {
|
||||
|
||||
Readline g_readline;
|
||||
EnvironmentPtr g_outer_env = Environment::create();
|
||||
EnvironmentPtr g_outer_env;
|
||||
|
||||
auto Repl::cleanup(int signal) -> void
|
||||
auto Repl::init() -> void
|
||||
{
|
||||
::print("\033[0m\n");
|
||||
std::exit(signal);
|
||||
g_outer_env = Environment::create();
|
||||
Environment::loadFunctions();
|
||||
Environment::installFunctions(g_outer_env);
|
||||
}
|
||||
|
||||
auto Repl::cleanup() -> void
|
||||
{
|
||||
g_outer_env = nullptr;
|
||||
}
|
||||
|
||||
auto Repl::readline(const std::string& prompt) -> ValuePtr
|
||||
|
||||
+3
-1
@@ -17,7 +17,9 @@ namespace blaze {
|
||||
|
||||
class Repl {
|
||||
public:
|
||||
static auto cleanup(int signal) -> void;
|
||||
static auto init() -> void;
|
||||
static auto cleanup() -> void;
|
||||
|
||||
static auto eval(ValuePtr ast, EnvironmentPtr env) -> ValuePtr;
|
||||
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void;
|
||||
static auto print(ValuePtr value) -> std::string;
|
||||
|
||||
Reference in New Issue
Block a user