Compare commits

...

2 Commits

  1. 1
      compile_commands.json
  2. 21
      example/src/main.cpp
  3. 3
      src/blaze/env/environment.cpp
  4. 14
      src/blaze/repl.cpp
  5. 4
      src/blaze/repl.h

1
compile_commands.json

@ -0,0 +1 @@
build/compile_commands.json

21
example/src/main.cpp

@ -21,6 +21,13 @@
namespace blaze {
static auto cleanup(int signal) -> void
{
print("\033[0m\n");
Repl::cleanup();
std::exit(signal);
}
auto main(int argc, char* argv[]) -> int
{
bool dump_lexer = false;
@ -39,17 +46,17 @@ auto main(int argc, char* argv[]) -> int
arg_parser.addArgument(arguments, "arguments", nullptr, nullptr, ruc::ArgParser::Required::No);
arg_parser.parse(argc, argv);
Repl::init();
// Signal callbacks
std::signal(SIGINT, cleanup);
std::signal(SIGTERM, cleanup);
// Set settings
g_outer_env->set("*DUMP-LEXER*", makePtr<Constant>(dump_lexer));
g_outer_env->set("*DUMP-READER*", makePtr<Constant>(dump_reader));
g_outer_env->set("*PRETTY-PRINT*", makePtr<Constant>(pretty_print));
// Signal callbacks
std::signal(SIGINT, Repl::cleanup);
std::signal(SIGTERM, Repl::cleanup);
Environment::loadFunctions();
Environment::installFunctions(g_outer_env);
Repl::makeArgv(g_outer_env, arguments);
if (arguments.size() > 0) {
@ -73,6 +80,8 @@ auto main(int argc, char* argv[]) -> int
print("\033[0m");
}
Repl::cleanup();
return 0;
}

3
src/blaze/env/environment.cpp vendored

@ -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();

14
src/blaze/repl.cpp

@ -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

4
src/blaze/repl.h

@ -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;

Loading…
Cancel
Save