8 #ifndef LLUVIA_CORE_INTERPRETER_H_
9 #define LLUVIA_CORE_INTERPRETER_H_
16 #include <type_traits>
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wunused-lambda-capture"
20 #pragma clang diagnostic ignored "-Wunused-parameter"
21 #pragma clang diagnostic ignored "-Wshadow"
23 #define SOL_ALL_SAFETIES_ON 1
24 #include "sol/sol.hpp"
26 #pragma clang diagnostic pop
46 void run(
const std::string& code);
47 void runFile(
const std::string& filename);
49 sol::load_result
load(
const std::string& code);
53 template <
typename T,
typename... Args>
57 auto loadCode =
load(std::forward<const std::string>(code));
59 auto scriptFunction =
static_cast<sol::protected_function
>(loadCode);
60 sol::protected_function_result scriptResult = scriptFunction(std::forward<Args>(args)...);
62 if (!scriptResult.valid()) {
63 const sol::error err = scriptResult;
66 "error running code: " + sol::to_string(loadCode.status()) +
"\n\t" + err.what());
70 return scriptResult.get<T>();
73 template <
typename... Args>
77 auto loadCode =
load(std::forward<const std::string>(code));
79 auto scriptFunction =
static_cast<sol::protected_function
>(loadCode);
80 sol::protected_function_result scriptResult = scriptFunction(std::forward<Args>(args)...);
82 if (!scriptResult.valid()) {
83 const sol::error err = scriptResult;
86 "error running code: " + sol::to_string(loadCode.status()) +
"\n\t" + err.what());
91 std::unique_ptr<sol::state> m_lua;
Definition: Interpreter.h:34
Interpreter & operator=(Interpreter &&interpreter)=default
void setActiveSession(ll::Session *session)
Interpreter & operator=(const Interpreter &interpreter)=delete
Interpreter(const Interpreter &interpreter)=delete
void loadAndRunNoReturn(const std::string &&code, Args &&... args)
Definition: Interpreter.h:74
sol::load_result load(const std::string &code)
T loadAndRun(const std::string &&code, Args &&... args)
Definition: Interpreter.h:54
void run(const std::string &code)
void runFile(const std::string &filename)
Interpreter(Interpreter &&interpreter)=default
Class that contains all the state required to run compute operations on a compute device.
Definition: Session.h:51
error related classes and methods.
void throwSystemError(ll::ErrorCode errorCode, T &&msg)
Throws a std::system_error exception with error code and message.
Definition: error.h:173