From b04e01cda7b53ccebac4a1294c2a25269d2b33d2 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 22 Sep 2009 21:06:02 +0000 Subject: [PATCH] Ensure that __EVAL__ is in the list of loaded files and be smarter about accessing it --- include/chaiscript/language/chaiscript_engine.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 78ddfdb..453a51a 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -236,7 +236,15 @@ namespace chaiscript } } else { try { - if (parser.parse(input, loaded_files.find(filename)->c_str())) { +#ifndef CHAISCRIPT_NO_THREADS + boost::shared_lock l(mutex); +#endif + const char *fname = loaded_files.find("__EVAL__")->c_str(); +#ifndef CHAISCRIPT_NO_THREADS + l.unlock(); +#endif + + if (parser.parse(input, fname)) { //parser.show_match_stack(); value = eval_token(engine, parser.ast()); } @@ -283,6 +291,7 @@ namespace chaiscript public: ChaiScript_System() { + loaded_files.insert("__EVAL__"); // Make sure the default name is already registered build_eval_system(); }