From 8f1be31ba27e1a473b7ad3ebab222cbba4b35676 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 2 Sep 2016 18:59:04 +0100 Subject: [PATCH] remove io library (not general enough) --- cubescript.cc | 22 ---------------------- cubescript.hh | 9 ++++----- tools/repl.cc | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/cubescript.cc b/cubescript.cc index 546d650b..5bf3b640 100644 --- a/cubescript.cc +++ b/cubescript.cc @@ -1246,25 +1246,6 @@ CsCommand *CsState::new_command( ); } -void cs_init_lib_io(CsState &cs) { - cs.new_command("exec", "sb", [&cs](CsValueRange args, CsValue &res) { - auto file = args[0].get_strr(); - bool ret = cs.run_file(file); - if (!ret) { - if (args[1].get_int()) { - ostd::err.writefln("could not run file \"%s\"", file); - } - res.set_int(0); - } else { - res.set_int(1); - } - }); - - cs.new_command("echo", "C", [](CsValueRange args, CsValue &) { - ostd::writeln(args[0].get_strr()); - }); -} - static inline void cs_do_loop( CsState &cs, CsIdent &id, CsInt offset, CsInt n, CsInt step, CsBytecode *cond, CsBytecode *body @@ -1551,9 +1532,6 @@ void cs_init_lib_string(CsState &cs); void cs_init_lib_list(CsState &cs); OSTD_EXPORT void CsState::init_libs(int libs) { - if (libs & CS_LIB_IO) { - cs_init_lib_io(*this); - } if (libs & CS_LIB_MATH) { cs_init_lib_math(*this); } diff --git a/cubescript.hh b/cubescript.hh index 39c05357..e20a4d7d 100644 --- a/cubescript.hh +++ b/cubescript.hh @@ -323,11 +323,10 @@ struct CsIdentLink { }; enum { - CS_LIB_IO = 1 << 0, - CS_LIB_MATH = 1 << 1, - CS_LIB_STRING = 1 << 2, - CS_LIB_LIST = 1 << 3, - CS_LIB_ALL = 0b1111 + CS_LIB_MATH = 1 << 0, + CS_LIB_STRING = 1 << 1, + CS_LIB_LIST = 1 << 2, + CS_LIB_ALL = 0b111 }; struct OSTD_EXPORT CsState { diff --git a/tools/repl.cc b/tools/repl.cc index c388994d..512356bf 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -171,6 +171,23 @@ static void do_tty(CsState &cs) { do_exit = true; }); + cs.new_command("exec", "sb", [&cs](CsValueRange args, CsValue &res) { + auto file = args[0].get_strr(); + bool ret = cs.run_file(file); + if (!ret) { + if (args[1].get_int()) { + ostd::err.writefln("could not run file \"%s\"", file); + } + res.set_int(0); + } else { + res.set_int(1); + } + }); + + cs.new_command("echo", "C", [](CsValueRange args, CsValue &) { + ostd::writeln(args[0].get_strr()); + }); + ostd::writeln(version); for (;;) { auto line = read_line(prompt);