Further namespace reorganization and cleanup to limit to the user the

most important aspect of the API and make documenation easier.
This commit is contained in:
Jason Turner
2011-03-24 09:23:05 -06:00
parent 637164e457
commit cd8bead54a
10 changed files with 2156 additions and 2136 deletions

View File

@@ -49,7 +49,7 @@ namespace chaiscript
try {
// We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it
// either way, we are not responsible if it doesn't work
return detail::Cast_Helper<Type>::cast(boxed_dynamic_cast<Type>(bv));
return detail::Cast_Helper<Type>::cast(detail::boxed_dynamic_cast<Type>(bv));
} catch (const boost::bad_any_cast &) {
throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type));
}

View File

@@ -201,7 +201,7 @@ namespace chaiscript
protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params) const
{
return dispatch(m_funcs.begin(), m_funcs.end(), params);
return detail::dispatch(m_funcs.begin(), m_funcs.end(), params);
}
private:
@@ -647,7 +647,7 @@ namespace chaiscript
{
std::vector<Proxy_Function> functions = get_function(t_name);
return dispatch(functions.begin(), functions.end(), params);
return detail::dispatch(functions.begin(), functions.end(), params);
}
Boxed_Value call_function(const std::string &t_name) const

View File

@@ -254,29 +254,31 @@ namespace chaiscript
return detail::Dynamic_Conversions::create<Base, Derived>();
}
template<typename Base, typename Derived>
bool dynamic_cast_converts()
namespace detail
{
return dynamic_cast_converts(user_type<Base>(), user_type<Derived>());
}
template<typename Base, typename Derived>
bool dynamic_cast_converts()
{
return dynamic_cast_converts(user_type<Base>(), user_type<Derived>());
}
static bool dynamic_cast_converts(const Type_Info &base, const Type_Info &derived)
{
return detail::Dynamic_Conversions::get().has_conversion(base, derived);
}
template<typename Base>
Boxed_Value boxed_dynamic_cast(const Boxed_Value &derived)
{
try {
return detail::Dynamic_Conversions::get().get_conversion(user_type<Base>(), derived.get_type_info())->convert(derived);
} catch (const std::out_of_range &) {
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "No known conversion");
} catch (const std::bad_cast &) {
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unable to perform dynamic_cast operation");
static bool dynamic_cast_converts(const Type_Info &base, const Type_Info &derived)
{
return detail::Dynamic_Conversions::get().has_conversion(base, derived);
}
}
template<typename Base>
Boxed_Value boxed_dynamic_cast(const Boxed_Value &derived)
{
try {
return detail::Dynamic_Conversions::get().get_conversion(user_type<Base>(), derived.get_type_info())->convert(derived);
} catch (const std::out_of_range &) {
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "No known conversion");
} catch (const std::bad_cast &) {
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unable to perform dynamic_cast operation");
}
}
}
}

View File

@@ -139,7 +139,7 @@ namespace chaiscript
|| (!bv.get_type_info().is_undef()
&& (ti.bare_equal(user_type<Boxed_POD_Value>())
|| ti.bare_equal(bv.get_type_info())
|| dynamic_cast_converts(ti, bv.get_type_info())
|| detail::dynamic_cast_converts(ti, bv.get_type_info())
|| bv.get_type_info().bare_equal(user_type<boost::shared_ptr<const Proxy_Function_Base> >())
)
)
@@ -594,46 +594,49 @@ namespace chaiscript
};
}
/**
* Take a vector of functions and a vector of parameters. Attempt to execute
* each function against the set of parameters, in order, until a matching
* function is found or throw dispatch_error if no matching function is found
*/
template<typename InItr>
Boxed_Value dispatch(InItr begin, InItr end,
const std::vector<Boxed_Value> &plist)
namespace detail
{
while (begin != end)
{
try {
if ((*begin)->filter(plist))
/**
* Take a vector of functions and a vector of parameters. Attempt to execute
* each function against the set of parameters, in order, until a matching
* function is found or throw dispatch_error if no matching function is found
*/
template<typename InItr>
Boxed_Value dispatch(InItr begin, InItr end,
const std::vector<Boxed_Value> &plist)
{
while (begin != end)
{
return (*(*begin))(plist);
try {
if ((*begin)->filter(plist))
{
return (*(*begin))(plist);
}
} catch (const exception::bad_boxed_cast &) {
//parameter failed to cast, try again
} catch (const exception::arity_error &) {
//invalid num params, try again
} catch (const exception::guard_error &) {
//guard failed to allow the function to execute,
//try again
}
++begin;
}
} catch (const exception::bad_boxed_cast &) {
//parameter failed to cast, try again
} catch (const exception::arity_error &) {
//invalid num params, try again
} catch (const exception::guard_error &) {
//guard failed to allow the function to execute,
//try again
throw exception::dispatch_error(plist.empty()?false:plist[0].is_const());
}
++begin;
}
throw exception::dispatch_error(plist.empty()?false:plist[0].is_const());
}
/**
* Take a vector of functions and a vector of parameters. Attempt to execute
* each function against the set of parameters, in order, until a matching
* function is found or throw dispatch_error if no matching function is found
*/
template<typename Funcs>
Boxed_Value dispatch(const Funcs &funcs,
const std::vector<Boxed_Value> &plist)
{
return dispatch(funcs.begin(), funcs.end(), plist);
/**
* Take a vector of functions and a vector of parameters. Attempt to execute
* each function against the set of parameters, in order, until a matching
* function is found or throw dispatch_error if no matching function is found
*/
template<typename Funcs>
Boxed_Value dispatch(const Funcs &funcs,
const std::vector<Boxed_Value> &plist)
{
return dispatch(funcs.begin(), funcs.end(), plist);
}
}
}

View File

@@ -108,59 +108,65 @@ namespace chaiscript
/**
* Errors generated during parsing or evaluation
*/
struct Eval_Error : public std::runtime_error {
std::string reason;
File_Position start_position;
File_Position end_position;
std::string filename;
std::vector<AST_NodePtr> call_stack;
namespace exception
{
/**
* Errors generated during parsing or evaluation
*/
struct eval_error : public std::runtime_error {
std::string reason;
File_Position start_position;
File_Position end_position;
std::string filename;
std::vector<AST_NodePtr> call_stack;
Eval_Error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) :
std::runtime_error("Error: \"" + t_why + "\" " +
(t_fname != "__EVAL__" ? ("in '" + t_fname + "' ") : "during evaluation ") +
+ "at (" + boost::lexical_cast<std::string>(t_where.line) + ", " +
boost::lexical_cast<std::string>(t_where.column) + ")"),
reason(t_why), start_position(t_where), end_position(t_where), filename(t_fname)
{ }
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) throw() :
std::runtime_error("Error: \"" + t_why + "\" " +
(t_fname != "__EVAL__" ? ("in '" + t_fname + "' ") : "during evaluation ") +
+ "at (" + boost::lexical_cast<std::string>(t_where.line) + ", " +
boost::lexical_cast<std::string>(t_where.column) + ")"),
reason(t_why), start_position(t_where), end_position(t_where), filename(t_fname)
{ }
Eval_Error(const std::string &t_why)
: std::runtime_error("Error: \"" + t_why + "\" "),
eval_error(const std::string &t_why) throw()
: std::runtime_error("Error: \"" + t_why + "\" "),
reason(t_why)
{}
{}
virtual ~Eval_Error() throw() {}
};
virtual ~eval_error() throw() {}
};
/**
* Errors generated when loading a file
*/
struct File_Not_Found_Error : public std::runtime_error {
File_Not_Found_Error(const std::string &t_filename)
: std::runtime_error("File Not Found: " + t_filename)
{ }
/**
* Errors generated when loading a file
*/
struct file_not_found_error : public std::runtime_error {
file_not_found_error(const std::string &t_filename) throw()
: std::runtime_error("File Not Found: " + t_filename)
{ }
virtual ~File_Not_Found_Error() throw() {}
};
virtual ~file_not_found_error() throw() {}
};
}
/**
* Special type for returned values
*/
struct Return_Value {
Boxed_Value retval;
namespace detail
{
/**
* Special type for returned values
*/
struct Return_Value {
Boxed_Value retval;
Return_Value(const Boxed_Value &t_return_value) : retval(t_return_value) { }
};
Return_Value(const Boxed_Value &t_return_value) : retval(t_return_value) { }
};
/**
* Special type indicating a call to 'break'
*/
struct Break_Loop {
Break_Loop() { }
};
/**
* Special type indicating a call to 'break'
*/
struct Break_Loop {
Break_Loop() { }
};
}
}
#endif /* _CHAISCRIPT_COMMON_HPP */

View File

@@ -28,193 +28,199 @@
namespace chaiscript
{
struct load_module_error : std::runtime_error
namespace exception
{
load_module_error(const std::string &t_reason) throw()
: std::runtime_error(t_reason)
struct load_module_error : std::runtime_error
{
}
load_module_error(const std::string &t_reason) throw()
: std::runtime_error(t_reason)
{
}
virtual ~load_module_error() throw()
{
}
};
virtual ~load_module_error() throw()
{
}
};
}
namespace detail
{
#ifdef _POSIX_VERSION
struct Loadable_Module
{
struct DLModule
struct Loadable_Module
{
DLModule(const std::string &t_filename)
: m_data(dlopen(t_filename.c_str(), RTLD_NOW))
struct DLModule
{
if (!m_data)
DLModule(const std::string &t_filename)
: m_data(dlopen(t_filename.c_str(), RTLD_NOW))
{
if (!m_data)
{
throw load_module_error(dlerror());
throw exception::load_module_error(dlerror());
}
}
}
DLModule(const DLModule &); // Explicitly unimplemented copy constructor
DLModule &operator=(const DLModule &); // Explicitly unimplemented assignment operator
DLModule(const DLModule &); // Explicitly unimplemented copy constructor
DLModule &operator=(const DLModule &); // Explicitly unimplemented assignment operator
~DLModule()
{
dlclose(m_data);
}
~DLModule()
{
dlclose(m_data);
}
void *m_data;
};
void *m_data;
};
template<typename T>
struct DLSym
{
DLSym(DLModule &t_mod, const std::string &t_symbol)
: m_symbol(reinterpret_cast<T>(dlsym(t_mod.m_data, t_symbol.c_str())))
{
if (!m_symbol)
template<typename T>
struct DLSym
{
DLSym(DLModule &t_mod, const std::string &t_symbol)
: m_symbol(reinterpret_cast<T>(dlsym(t_mod.m_data, t_symbol.c_str())))
{
throw load_module_error(dlerror());
if (!m_symbol)
{
throw exception::load_module_error(dlerror());
}
}
}
T m_symbol;
};
T m_symbol;
};
Loadable_Module(const std::string &t_module_name, const std::string &t_filename)
: m_dlmodule(t_filename), m_func(m_dlmodule, "create_chaiscript_module_" + t_module_name),
Loadable_Module(const std::string &t_module_name, const std::string &t_filename)
: m_dlmodule(t_filename), m_func(m_dlmodule, "create_chaiscript_module_" + t_module_name),
m_moduleptr(m_func.m_symbol())
{
}
{
}
DLModule m_dlmodule;
DLSym<Create_Module_Func> m_func;
ModulePtr m_moduleptr;
};
DLModule m_dlmodule;
DLSym<Create_Module_Func> m_func;
ModulePtr m_moduleptr;
};
#else
#ifdef WIN32
struct Loadable_Module
{
template<typename T>
static std::wstring towstring(const T &t_str)
struct Loadable_Module
{
return std::wstring(t_str.begin(), t_str.end());
}
template<typename T>
static std::wstring towstring(const T &t_str)
{
return std::wstring(t_str.begin(), t_str.end());
}
template<typename T>
static std::string tostring(const T &t_str)
{
return std::string(t_str.begin(), t_str.end());
}
template<typename T>
static std::string tostring(const T &t_str)
{
return std::string(t_str.begin(), t_str.end());
}
#ifdef _UNICODE
template<typename T>
static std::wstring toproperstring(const T &t_str)
{
return towstring(t_str);
}
template<typename T>
static std::wstring toproperstring(const T &t_str)
{
return towstring(t_str);
}
#else
template<typename T>
static std::string toproperstring(const T &t_str)
{
return tostring(t_str);
}
template<typename T>
static std::string toproperstring(const T &t_str)
{
return tostring(t_str);
}
#endif
static std::string GetErrorMessage(DWORD t_err)
{
static std::string GetErrorMessage(DWORD t_err)
{
#ifdef _UNICODE
typedef LPWSTR StringType;
std::wstring retval = L"Unknown Error";
typedef LPWSTR StringType;
std::wstring retval = L"Unknown Error";
#else
typedef LPSTR StringType;
std::string retval = "Unknown Error";
typedef LPSTR StringType;
std::string retval = "Unknown Error";
#endif
StringType lpMsgBuf = 0;
StringType lpMsgBuf = 0;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t_err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(StringType)&lpMsgBuf,
0, NULL );
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t_err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(StringType)&lpMsgBuf,
0, NULL );
if (lpMsgBuf)
{
retval = lpMsgBuf;
if (lpMsgBuf)
{
retval = lpMsgBuf;
}
LocalFree(lpMsgBuf);
return tostring(retval);
}
LocalFree(lpMsgBuf);
return tostring(retval);
}
struct DLModule
{
DLModule(const std::string &t_filename)
: m_data(LoadLibrary(toproperstring(t_filename).c_str()))
struct DLModule
{
if (!m_data)
DLModule(const std::string &t_filename)
: m_data(LoadLibrary(toproperstring(t_filename).c_str()))
{
if (!m_data)
{
throw load_module_error(GetErrorMessage(GetLastError()));
throw exception::load_module_error(GetErrorMessage(GetLastError()));
}
}
}
~DLModule()
{
FreeLibrary(m_data);
}
~DLModule()
{
FreeLibrary(m_data);
}
HMODULE m_data;
};
HMODULE m_data;
};
template<typename T>
struct DLSym
{
DLSym(DLModule &t_mod, const std::string &t_symbol)
: m_symbol(reinterpret_cast<T>(GetProcAddress(t_mod.m_data, t_symbol.c_str())))
{
if (!m_symbol)
template<typename T>
struct DLSym
{
DLSym(DLModule &t_mod, const std::string &t_symbol)
: m_symbol(reinterpret_cast<T>(GetProcAddress(t_mod.m_data, t_symbol.c_str())))
{
throw load_module_error(GetErrorMessage(GetLastError()));
if (!m_symbol)
{
throw exception::load_module_error(GetErrorMessage(GetLastError()));
}
}
}
T m_symbol;
};
T m_symbol;
};
Loadable_Module(const std::string &t_module_name, const std::string &t_filename)
: m_dlmodule(t_filename), m_func(m_dlmodule, "create_chaiscript_module_" + t_module_name),
Loadable_Module(const std::string &t_module_name, const std::string &t_filename)
: m_dlmodule(t_filename), m_func(m_dlmodule, "create_chaiscript_module_" + t_module_name),
m_moduleptr(m_func.m_symbol())
{
}
{
}
DLModule m_dlmodule;
DLSym<Create_Module_Func> m_func;
ModulePtr m_moduleptr;
};
DLModule m_dlmodule;
DLSym<Create_Module_Func> m_func;
ModulePtr m_moduleptr;
};
#else
struct Loadable_Module
{
Loadable_Module(const std::string &, const std::string &)
struct Loadable_Module
{
throw load_module_error("Loadable module support not available for your platform");
}
Loadable_Module(const std::string &, const std::string &)
{
throw exception::load_module_error("Loadable module support not available for your platform");
}
ModulePtr get()
{
throw load_module_error("Loadable module support not available for your platform");
}
};
ModulePtr get()
{
throw exception::load_module_error("Loadable module support not available for your platform");
}
};
#endif
#endif
typedef boost::shared_ptr<Loadable_Module> Loadable_Module_Ptr;
typedef boost::shared_ptr<Loadable_Module> Loadable_Module_Ptr;
}
class ChaiScript {
#ifndef CHAISCRIPT_NO_THREADS
@@ -223,7 +229,7 @@ namespace chaiscript
#endif
std::set<std::string> m_used_files;
std::map<std::string, Loadable_Module_Ptr> m_loaded_modules;
std::map<std::string, detail::Loadable_Module_Ptr> m_loaded_modules;
std::set<std::string> m_active_loaded_modules;
std::vector<std::string> m_modulepaths;
@@ -238,7 +244,7 @@ namespace chaiscript
Boxed_Value do_eval(const std::string &t_input, const std::string &t_filename = "__EVAL__", bool /* t_internal*/ = false)
{
try {
ChaiScript_Parser parser;
parser::ChaiScript_Parser parser;
if (parser.parse(t_input, t_filename)) {
//parser.show_match_stack();
return parser.ast()->eval(m_engine);
@@ -246,7 +252,7 @@ namespace chaiscript
return Boxed_Value();
}
}
catch (const Return_Value &rv) {
catch (const detail::Return_Value &rv) {
return rv.retval;
}
}
@@ -287,10 +293,10 @@ namespace chaiscript
#endif
eval_file(appendedpath);
}
} catch (const File_Not_Found_Error &) {
} catch (const exception::file_not_found_error &) {
if (i == m_usepaths.size() - 1)
{
throw File_Not_Found_Error(t_filename);
throw exception::file_not_found_error(t_filename);
}
// failed to load, try the next path
@@ -305,6 +311,56 @@ namespace chaiscript
return m_engine;
}
/**
* Builds all the requirements for ChaiScript, including its evaluator and a run of its prelude.
*/
void build_eval_system() {
using namespace bootstrap;
m_engine.add_reserved_word("def");
m_engine.add_reserved_word("fun");
m_engine.add_reserved_word("while");
m_engine.add_reserved_word("for");
m_engine.add_reserved_word("if");
m_engine.add_reserved_word("else");
m_engine.add_reserved_word("&&");
m_engine.add_reserved_word("||");
m_engine.add_reserved_word(",");
m_engine.add_reserved_word(":=");
m_engine.add_reserved_word("var");
m_engine.add_reserved_word("return");
m_engine.add_reserved_word("break");
m_engine.add_reserved_word("true");
m_engine.add_reserved_word("false");
m_engine.add_reserved_word("_");
add(Bootstrap::bootstrap());
m_engine.add(fun(&Dispatch_Engine::dump_system, boost::ref(m_engine)), "dump_system");
m_engine.add(fun(&Dispatch_Engine::dump_object, boost::ref(m_engine)), "dump_object");
m_engine.add(fun(&Dispatch_Engine::is_type, boost::ref(m_engine)), "is_type");
m_engine.add(fun(&Dispatch_Engine::type_name, boost::ref(m_engine)), "type_name");
m_engine.add(fun(&Dispatch_Engine::function_exists, boost::ref(m_engine)), "function_exists");
m_engine.add(fun(&Dispatch_Engine::get_type_name, boost::ref(m_engine)), "name");
typedef void (ChaiScript::*load_mod_1)(const std::string&);
typedef void (ChaiScript::*load_mod_2)(const std::string&, const std::string&);
m_engine.add(fun(static_cast<load_mod_1>(&ChaiScript::load_module), this), "load_module");
m_engine.add(fun(static_cast<load_mod_2>(&ChaiScript::load_module), this), "load_module");
add(standard_library::vector_type<std::vector<Boxed_Value> >("Vector"));
add(standard_library::string_type<std::string>("string"));
add(standard_library::map_type<std::map<std::string, Boxed_Value> >("Map"));
add(standard_library::pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair"));
m_engine.add(fun(&ChaiScript::use, this), "use");
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
m_engine.add(fun(&ChaiScript::internal_eval_ast, this), "eval");
do_eval(chaiscript_prelude, "standard prelude");
}
public:
ChaiScript(const std::vector<std::string> &t_modulepaths = std::vector<std::string>(),
@@ -398,7 +454,7 @@ namespace chaiscript
*/
void load_module(const std::string &t_module_name)
{
std::vector<load_module_error> errors;
std::vector<exception::load_module_error> errors;
std::vector<std::string> prefixes;
prefixes.push_back("lib");
@@ -419,7 +475,7 @@ namespace chaiscript
std::string name = m_modulepaths[i] + prefixes[j] + t_module_name + postfixes[k];
load_module(t_module_name, name);
return;
} catch (const load_module_error &e) {
} catch (const exception::load_module_error &e) {
errors.push_back(e);
// Try next set
}
@@ -429,7 +485,7 @@ namespace chaiscript
std::string errstring;
for (std::vector<load_module_error>::const_iterator itr = errors.begin();
for (std::vector<exception::load_module_error>::const_iterator itr = errors.begin();
itr != errors.end();
++itr)
{
@@ -441,7 +497,7 @@ namespace chaiscript
errstring += itr->what();
}
throw load_module_error("Unable to find module: " + t_module_name + " Errors: " + errstring);
throw exception::load_module_error("Unable to find module: " + t_module_name + " Errors: " + errstring);
}
/**
@@ -455,7 +511,7 @@ namespace chaiscript
if (m_loaded_modules.count(t_module_name) == 0)
{
Loadable_Module_Ptr lm(new Loadable_Module(t_module_name, t_filename));
detail::Loadable_Module_Ptr lm(new detail::Loadable_Module(t_module_name, t_filename));
m_loaded_modules[t_module_name] = lm;
m_active_loaded_modules.insert(t_module_name);
add(lm->m_moduleptr);
@@ -495,7 +551,7 @@ namespace chaiscript
std::ifstream infile(t_filename.c_str(), std::ios::in | std::ios::ate | std::ios::binary );
if (!infile.is_open()) {
throw File_Not_Found_Error(t_filename);
throw exception::file_not_found_error(t_filename);
}
std::streampos size = infile.tellg();
@@ -513,56 +569,6 @@ namespace chaiscript
}
}
/**
* Builds all the requirements for ChaiScript, including its evaluator and a run of its prelude.
*/
void build_eval_system() {
using namespace bootstrap;
m_engine.add_reserved_word("def");
m_engine.add_reserved_word("fun");
m_engine.add_reserved_word("while");
m_engine.add_reserved_word("for");
m_engine.add_reserved_word("if");
m_engine.add_reserved_word("else");
m_engine.add_reserved_word("&&");
m_engine.add_reserved_word("||");
m_engine.add_reserved_word(",");
m_engine.add_reserved_word(":=");
m_engine.add_reserved_word("var");
m_engine.add_reserved_word("return");
m_engine.add_reserved_word("break");
m_engine.add_reserved_word("true");
m_engine.add_reserved_word("false");
m_engine.add_reserved_word("_");
add(Bootstrap::bootstrap());
m_engine.add(fun(&Dispatch_Engine::dump_system, boost::ref(m_engine)), "dump_system");
m_engine.add(fun(&Dispatch_Engine::dump_object, boost::ref(m_engine)), "dump_object");
m_engine.add(fun(&Dispatch_Engine::is_type, boost::ref(m_engine)), "is_type");
m_engine.add(fun(&Dispatch_Engine::type_name, boost::ref(m_engine)), "type_name");
m_engine.add(fun(&Dispatch_Engine::function_exists, boost::ref(m_engine)), "function_exists");
m_engine.add(fun(&Dispatch_Engine::get_type_name, boost::ref(m_engine)), "name");
typedef void (ChaiScript::*load_mod_1)(const std::string&);
typedef void (ChaiScript::*load_mod_2)(const std::string&, const std::string&);
m_engine.add(fun(static_cast<load_mod_1>(&ChaiScript::load_module), this), "load_module");
m_engine.add(fun(static_cast<load_mod_2>(&ChaiScript::load_module), this), "load_module");
add(standard_library::vector_type<std::vector<Boxed_Value> >("Vector"));
add(standard_library::string_type<std::string>("string"));
add(standard_library::map_type<std::map<std::string, Boxed_Value> >("Map"));
add(standard_library::pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair"));
m_engine.add(fun(&ChaiScript::use, this), "use");
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
m_engine.add(fun(&ChaiScript::internal_eval_ast, this), "eval");
do_eval(chaiscript_prelude, "standard prelude");
}
template<typename T>
T eval(const std::string &t_input)

View File

@@ -28,10 +28,10 @@ namespace chaiscript
Boxed_Value retval(t_node->eval(t_ss));
t_ss.pop_scope();
return retval;
} catch (const Return_Value &rv) {
} catch (const detail::Return_Value &rv) {
t_ss.pop_scope();
return rv.retval;
} catch (Eval_Error &ee) {
} catch (exception::eval_error &ee) {
ee.call_stack.push_back(t_node);
t_ss.pop_scope();
throw;
@@ -55,7 +55,7 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -65,9 +65,9 @@ namespace chaiscript
retval = t_ss.call_function(this->children[i]->text, retval, this->children[i+1]->eval(t_ss));
}
catch(const exception::dispatch_error &){
throw Eval_Error("Can not find appropriate '" + this->children[i]->text + "'");
throw exception::eval_error("Can not find appropriate '" + this->children[i]->text + "'");
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+1]);
throw;
}
@@ -131,7 +131,7 @@ namespace chaiscript
return t_ss.get_object(this->text);
}
catch (std::exception &) {
throw Eval_Error("Can not find object: " + this->text);
throw exception::eval_error("Can not find object: " + this->text);
}
}
}
@@ -171,7 +171,7 @@ namespace chaiscript
try {
plb << this->children[1]->children[i]->eval(t_ss);
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]->children[i]);
throw;
}
@@ -192,9 +192,9 @@ namespace chaiscript
}
catch(const exception::dispatch_error &e){
t_ss.set_stack(prev_stack);
throw Eval_Error(std::string(e.what()) + " with function '" + this->children[0]->text + "'");
throw exception::eval_error(std::string(e.what()) + " with function '" + this->children[0]->text + "'");
}
catch(Return_Value &rv) {
catch(detail::Return_Value &rv) {
t_ss.set_stack(prev_stack);
return rv.retval;
}
@@ -203,10 +203,10 @@ namespace chaiscript
throw;
}
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
t_ss.set_stack(prev_stack);
throw Eval_Error(ee.reason);
throw exception::eval_error(ee.reason);
}
}
@@ -226,7 +226,7 @@ namespace chaiscript
try {
plb << this->children[1]->children[i]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]->children[i]);
throw;
}
@@ -240,18 +240,18 @@ namespace chaiscript
return (*boxed_cast<Const_Proxy_Function >(fn))(plb);
}
catch(const exception::dispatch_error &e){
throw Eval_Error(std::string(e.what()) + " with function '" + this->children[0]->text + "'");
throw exception::eval_error(std::string(e.what()) + " with function '" + this->children[0]->text + "'");
}
catch(Return_Value &rv) {
catch(detail::Return_Value &rv) {
return rv.retval;
}
catch(...) {
throw;
}
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw Eval_Error(ee.reason);
throw exception::eval_error(ee.reason);
}
}
@@ -282,7 +282,7 @@ namespace chaiscript
try {
retval = this->children.back()->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back());
throw;
}
@@ -303,14 +303,14 @@ namespace chaiscript
retval = t_ss.call_function(this->children[i+1]->text, lhs, retval);
}
catch(const exception::dispatch_error &){
throw Eval_Error(std::string("Mismatched types in equation") + (lhs.is_const()?", lhs is const.":"."));
throw exception::eval_error(std::string("Mismatched types in equation") + (lhs.is_const()?", lhs is const.":"."));
}
}
catch(const exception::dispatch_error &){
throw Eval_Error("Can not clone right hand side of equation");
throw exception::eval_error("Can not clone right hand side of equation");
}
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
throw;
}
@@ -322,10 +322,10 @@ namespace chaiscript
lhs.assign(retval);
}
else {
throw Eval_Error("Mismatched types in equation");
throw exception::eval_error("Mismatched types in equation");
}
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
throw;
}
@@ -335,9 +335,9 @@ namespace chaiscript
retval = t_ss.call_function(this->children[i+1]->text, this->children[i]->eval(t_ss), retval);
}
catch(const exception::dispatch_error &){
throw Eval_Error("Can not find appropriate '" + this->children[i+1]->text + "'");
throw exception::eval_error("Can not find appropriate '" + this->children[i+1]->text + "'");
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
throw;
}
@@ -358,7 +358,7 @@ namespace chaiscript
t_ss.add_object(this->children[0]->text, Boxed_Value());
}
catch (const exception::reserved_word_error &) {
throw Eval_Error("Reserved word used as variable '" + this->children[0]->text + "'");
throw exception::eval_error("Reserved word used as variable '" + this->children[0]->text + "'");
}
return t_ss.get_object(this->children[0]->text);
}
@@ -397,7 +397,7 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -407,12 +407,12 @@ namespace chaiscript
retval = t_ss.call_function("[]", retval, this->children[i]->eval(t_ss));
}
catch(std::out_of_range &) {
throw Eval_Error("Out of bounds exception");
throw exception::eval_error("Out of bounds exception");
}
catch(const exception::dispatch_error &){
throw Eval_Error("Can not find appropriate array lookup '[]' ");
throw exception::eval_error("Can not find appropriate array lookup '[]' ");
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
throw;
}
@@ -432,7 +432,7 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -447,7 +447,7 @@ namespace chaiscript
try {
plb << this->children[i]->children[1]->children[j]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]->children[1]->children[j]);
throw;
}
@@ -472,9 +472,9 @@ namespace chaiscript
}
catch(const exception::dispatch_error &e){
t_ss.set_stack(prev_stack);
throw Eval_Error(std::string(e.what()));
throw exception::eval_error(std::string(e.what()));
}
catch(Return_Value &rv) {
catch(detail::Return_Value &rv) {
t_ss.set_stack(prev_stack);
retval = rv.retval;
}
@@ -488,12 +488,12 @@ namespace chaiscript
retval = t_ss.call_function("[]", retval, this->children[i]->children[j]->eval(t_ss));
}
catch(std::out_of_range &) {
throw Eval_Error("Out of bounds exception");
throw exception::eval_error("Out of bounds exception");
}
catch(const exception::dispatch_error &){
throw Eval_Error("Can not find appropriate array lookup '[]' ");
throw exception::eval_error("Can not find appropriate array lookup '[]' ");
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]->children[j]);
throw;
}
@@ -576,11 +576,11 @@ namespace chaiscript
return retval;
}
}
catch (const chaiscript::Return_Value &) {
catch (const chaiscript::detail::Return_Value &) {
t_ss.pop_scope();
throw;
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
t_ss.pop_scope();
throw;
@@ -644,7 +644,7 @@ namespace chaiscript
l_annotation, guard)), l_function_name);
}
catch (const exception::reserved_word_error &e) {
throw Eval_Error("Reserved word used as function name '" + e.word() + "'");
throw exception::eval_error("Reserved word used as function name '" + e.word() + "'");
}
return Boxed_Value();
}
@@ -666,9 +666,9 @@ namespace chaiscript
}
catch (const exception::bad_boxed_cast &) {
t_ss.pop_scope();
throw Eval_Error("While condition not boolean");
throw exception::eval_error("While condition not boolean");
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
t_ss.pop_scope();
throw;
@@ -678,7 +678,7 @@ namespace chaiscript
try {
this->children[1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]);
throw;
}
@@ -688,15 +688,15 @@ namespace chaiscript
}
catch (const exception::bad_boxed_cast &) {
t_ss.pop_scope();
throw Eval_Error("While condition not boolean");
throw exception::eval_error("While condition not boolean");
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
t_ss.pop_scope();
throw;
}
}
catch (Break_Loop &) {
catch (detail::Break_Loop &) {
cond = false;
}
}
@@ -717,9 +717,9 @@ namespace chaiscript
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
}
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("If condition not boolean");
throw exception::eval_error("If condition not boolean");
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -728,7 +728,7 @@ namespace chaiscript
try {
return this->children[1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]);
throw;
}
@@ -741,7 +741,7 @@ namespace chaiscript
try {
return this->children[i+1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+1]);
throw;
}
@@ -751,9 +751,9 @@ namespace chaiscript
cond = boxed_cast<bool>(this->children[i+1]->eval(t_ss));
}
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("'else if' condition not boolean");
throw exception::eval_error("'else if' condition not boolean");
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+1]);
throw;
}
@@ -761,7 +761,7 @@ namespace chaiscript
try {
return this->children[i+2]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+2]);
throw;
}
@@ -792,7 +792,7 @@ namespace chaiscript
try {
this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -800,7 +800,7 @@ namespace chaiscript
try {
cond = boxed_cast<bool>(this->children[1]->eval(t_ss));
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]);
throw;
}
@@ -809,7 +809,7 @@ namespace chaiscript
try {
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
t_ss.pop_scope();
throw;
@@ -818,7 +818,7 @@ namespace chaiscript
}
catch (const exception::bad_boxed_cast &) {
t_ss.pop_scope();
throw Eval_Error("For condition not boolean");
throw exception::eval_error("For condition not boolean");
}
while (cond) {
try {
@@ -826,7 +826,7 @@ namespace chaiscript
try {
this->children[3]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[3]);
throw;
}
@@ -834,7 +834,7 @@ namespace chaiscript
try {
this->children[2]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[2]);
throw;
}
@@ -842,7 +842,7 @@ namespace chaiscript
try {
cond = boxed_cast<bool>(this->children[1]->eval(t_ss));
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]);
throw;
}
@@ -851,7 +851,7 @@ namespace chaiscript
try {
this->children[2]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[2]);
throw;
}
@@ -859,7 +859,7 @@ namespace chaiscript
try {
this->children[1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[1]);
throw;
}
@@ -867,7 +867,7 @@ namespace chaiscript
try {
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
t_ss.pop_scope();
throw;
@@ -876,9 +876,9 @@ namespace chaiscript
}
catch (const exception::bad_boxed_cast &) {
t_ss.pop_scope();
throw Eval_Error("For condition not boolean");
throw exception::eval_error("For condition not boolean");
}
catch (Break_Loop &) {
catch (detail::Break_Loop &) {
cond = false;
}
}
@@ -900,7 +900,7 @@ namespace chaiscript
try {
vec.push_back(this->children[0]->children[i]->eval(t_ss));
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]->children[i]);
throw;
}
@@ -925,7 +925,7 @@ namespace chaiscript
retval[boxed_cast<std::string>(this->children[0]->children[i]->children[0]->eval(t_ss))]
= t_ss.call_function("clone", this->children[0]->children[i]->children[1]->eval(t_ss));
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]->children[i]);
throw;
}
@@ -933,7 +933,7 @@ namespace chaiscript
return const_var(retval);
}
catch (const exception::dispatch_error &) {
throw Eval_Error("Can not find appropriate 'Map()'");
throw exception::eval_error("Can not find appropriate 'Map()'");
}
}
@@ -947,15 +947,15 @@ namespace chaiscript
virtual Boxed_Value eval(Dispatch_Engine &t_ss){
if (this->children.size() > 0) {
try {
throw Return_Value(this->children[0]->eval(t_ss));
throw detail::Return_Value(this->children[0]->eval(t_ss));
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
}
else {
throw Return_Value(Boxed_Value());
throw detail::Return_Value(Boxed_Value());
}
}
@@ -975,7 +975,7 @@ namespace chaiscript
return retval;
}
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i]);
throw;
}
@@ -994,7 +994,7 @@ namespace chaiscript
return t_ss.call_function(this->children[0]->text, this->children[1]->eval(t_ss));
}
catch(std::exception &){
throw Eval_Error("Can not find appropriate unary '" + this->children[0]->text + "'");
throw exception::eval_error("Can not find appropriate unary '" + this->children[0]->text + "'");
}
}
@@ -1006,7 +1006,7 @@ namespace chaiscript
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Break_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){
throw Break_Loop();
throw detail::Break_Loop();
}
};
@@ -1036,9 +1036,9 @@ namespace chaiscript
this->children[0]->children[0]->children[1]->eval(t_ss));
}
catch (const exception::dispatch_error &) {
throw Eval_Error("Unable to generate range vector");
throw exception::eval_error("Unable to generate range vector");
}
catch(Eval_Error &ee) {
catch(exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]->children[0]);
throw;
}
@@ -1065,13 +1065,13 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
if (this->children.back()->identifier == AST_Node_Type::Finally) {
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee2) {
catch (exception::eval_error &ee2) {
ee2.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
@@ -1096,7 +1096,7 @@ namespace chaiscript
try {
retval = catch_block->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[0]);
throw;
}
@@ -1108,7 +1108,7 @@ namespace chaiscript
try {
retval = catch_block->children[1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[1]);
throw;
}
@@ -1127,20 +1127,20 @@ namespace chaiscript
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
}
}
t_ss.pop_scope();
throw Eval_Error("Guard condition not boolean");
throw exception::eval_error("Guard condition not boolean");
}
if (guard) {
try {
retval = catch_block->children[2]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[2]);
throw;
}
@@ -1153,14 +1153,14 @@ namespace chaiscript
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
}
}
t_ss.pop_scope();
throw Eval_Error("Internal error: catch block size unrecognized");
throw exception::eval_error("Internal error: catch block size unrecognized");
}
}
}
@@ -1174,7 +1174,7 @@ namespace chaiscript
try {
retval = catch_block->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[0]);
throw;
}
@@ -1187,7 +1187,7 @@ namespace chaiscript
try {
retval = catch_block->children[1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[1]);
throw;
}
@@ -1207,7 +1207,7 @@ namespace chaiscript
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
@@ -1215,9 +1215,9 @@ namespace chaiscript
}
t_ss.pop_scope();
throw Eval_Error("Guard condition not boolean");
throw exception::eval_error("Guard condition not boolean");
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[1]);
throw;
}
@@ -1225,7 +1225,7 @@ namespace chaiscript
try {
retval = catch_block->children[2]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(catch_block->children[2]);
throw;
}
@@ -1237,14 +1237,14 @@ namespace chaiscript
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
}
}
t_ss.pop_scope();
throw Eval_Error("Internal error: catch block size unrecognized");
throw exception::eval_error("Internal error: catch block size unrecognized");
}
}
}
@@ -1253,7 +1253,7 @@ namespace chaiscript
try {
this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
@@ -1267,7 +1267,7 @@ namespace chaiscript
try {
retval = this->children.back()->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope();
throw;
@@ -1365,7 +1365,7 @@ namespace chaiscript
}
}
catch (const exception::reserved_word_error &e) {
throw Eval_Error("Reserved word used as method name '" + e.word() + "'");
throw exception::eval_error("Reserved word used as method name '" + e.word() + "'");
}
return Boxed_Value();
}
@@ -1384,7 +1384,7 @@ namespace chaiscript
}
catch (const exception::reserved_word_error &) {
throw Eval_Error("Reserved word used as attribute '" + this->children[1]->text + "'");
throw exception::eval_error("Reserved word used as attribute '" + this->children[1]->text + "'");
}
return Boxed_Value();
}
@@ -1436,7 +1436,7 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -1448,13 +1448,13 @@ namespace chaiscript
lhs = boxed_cast<bool>(retval);
}
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("Condition not boolean");
throw exception::eval_error("Condition not boolean");
}
if (lhs) {
try {
retval = this->children[i+1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+1]);
throw;
}
@@ -1479,7 +1479,7 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[0]);
throw;
}
@@ -1491,7 +1491,7 @@ namespace chaiscript
lhs = boxed_cast<bool>(retval);
}
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("Condition not boolean");
throw exception::eval_error("Condition not boolean");
}
if (lhs) {
retval = Boxed_Value(true);
@@ -1500,7 +1500,7 @@ namespace chaiscript
try {
retval = this->children[i+1]->eval(t_ss);
}
catch (Eval_Error &ee) {
catch (exception::eval_error &ee) {
ee.call_stack.push_back(this->children[i+1]);
throw;
}

File diff suppressed because it is too large Load Diff

View File

@@ -107,14 +107,14 @@ void interactive(chaiscript::ChaiScript& chai)
catch (...) {} //If we can't, do nothing
}
}
catch (chaiscript::Eval_Error &ee) {
catch (const chaiscript::exception::eval_error &ee) {
std::cout << ee.what();
if (ee.call_stack.size() > 0) {
std::cout << "during evaluation at (" << ee.call_stack[0]->start.line << ", " << ee.call_stack[0]->start.column << ")";
}
std::cout << std::endl;
}
catch (std::exception &e) {
catch (const std::exception &e) {
std::cout << e.what();
std::cout << std::endl;
}
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
case eFile : val = chai.eval_file(arg); break;
}
}
catch (chaiscript::Eval_Error &ee) {
catch (const chaiscript::exception::eval_error &ee) {
std::cout << ee.what();
if (ee.call_stack.size() > 0) {
std::cout << "during evaluation at (" << *(ee.call_stack[0]->filename) << " " << ee.call_stack[0]->start.line << ", " << ee.call_stack[0]->start.column << ")";

View File

@@ -71,8 +71,8 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflect
);
CHAISCRIPT_CLASS( m,
chaiscript::ChaiScript_Parser,
(chaiscript::ChaiScript_Parser ()),
chaiscript::parser::ChaiScript_Parser,
(chaiscript::parser::ChaiScript_Parser ()),
((parse))
((ast))
);