6#include <simplesquirrel/simplesquirrel.hpp>
13#include <unordered_map>
39 const std::string& message);
51 const std::string&
source() const noexcept {
return source_; }
52 uint64_t
scriptId() const noexcept {
return script_id_; }
56 int line() const noexcept {
return line_; }
58 int column() const noexcept {
return column_; }
60 const std::string&
function() const noexcept {
return function_; }
62 const std::string&
stackTrace() const noexcept {
return stack_trace_; }
64 bool reported() const noexcept {
return reported_; }
72 std::string function_;
73 std::string stack_trace_;
74 bool reported_ =
false;
79 ssq::Type
type = ssq::Type::NULLPTR;
85 ssq::Type
type = ssq::Type::NULLPTR;
121 int top() const noexcept {
return top_; }
148 explicit Runtime(
size_t stackSize = 2048, ssq::Libs::Flag libraries = ssq::Libs::ALL);
158 void shutdown() noexcept;
160 bool initialized() const noexcept;
163 ssq::VM&
vm() noexcept;
164 const
ssq::VM&
vm() const noexcept;
168 ssq::Table root() const;
173 ssq::Table table(const
char*
name) const;
180 static Runtime* current() noexcept;
182 static
size_t stackDepth() noexcept;
191 ScriptId compileSource(std::
string source, std::
string sourceName = "buffer");
198 ScriptId compileFile(const std::
string& path);
202 ScriptId runSource(std::
string source, std::
string sourceName = "buffer");
204 ScriptId runFile(const std::
string& path);
206 ScriptId reflectFile(const std::
string& path) {
return runFile(path); }
213 const std::string& source = {});
215 ScriptId reload(ScriptId
id);
217 bool unload(ScriptId
id);
219 void unloadAll() noexcept;
222 bool contains(ScriptId
id) const noexcept;
224 const ScriptInfo* script(ScriptId
id) const noexcept;
226 std::vector<ScriptInfo> scripts() const;
228 const ReflectedClass* reflectedClass(const std::
string&
name) const noexcept;
230 std::vector<ReflectedClass> reflectedClasses() const;
232 ssq::Class findClass(const std::
string&
name) const;
235 void setErrorHandler(
ErrorHandler handler) { error_handler_ = std::move(handler); }
243 void installErrorHandler();
245 std::unique_ptr<ssq::VM> vm_;
246 std::unordered_map<ScriptId, std::unique_ptr<ScriptRecord>> scripts_;
247 std::unordered_map<std::string, ReflectedClass> classes_;
248 std::unordered_map<std::string, ScriptId> class_owners_;
249 ScriptId next_script_id_ = 1;
250 bool initialized_ =
false;
251 bool shutting_down_ =
false;
252 bool stopped_ =
false;
253 ErrorHandler error_handler_;
254 LifecycleHandler lifecycle_handler_;
256 void notifyLifecycle(
const ScriptInfo& info)
noexcept;
258 const std::string& sourceText);
259 [[noreturn]]
void fail(
ScriptStage stage,
const std::string& source, ScriptId
id,
260 const std::exception&
error);
261 [[noreturn]]
void fail(
ScriptStage stage,
const std::string& source, ScriptId
id,
263 void discoverClasses(ScriptRecord& record,
264 const std::unordered_map<std::string, SQUserPointer>& before);
265 std::unordered_map<std::string, SQUserPointer> rootClasses()
const;
267 const std::string& source)
const;
struct SQVM * HSQUIRRELVM
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
JobSystemThreadPool::State * state
Pushes this Runtime on the current thread's runtime stack.
Scope(const Scope &)=delete
Scope & operator=(Scope &&other)=delete
Scope & operator=(const Scope &)=delete
Restores the native Squirrel stack when a binding operation leaves scope.
StackGuard & operator=(const StackGuard &)=delete
StackGuard(const StackGuard &)=delete
std::function< void(const ScriptInfo &)> LifecycleHandler
Runtime(Runtime &&)=delete
std::function< void(const ScriptException &)> ErrorHandler
Runtime & operator=(Runtime &&)=delete
Runtime(const Runtime &)=delete
Runtime & operator=(const Runtime &)=delete
Scope enter()
Pushes this runtime on the thread-local runtime stack (RAII pop).
void setLifecycleHandler(LifecycleHandler handler)
Replaces the handler notified on every script lifecycle change.
Exception raised at the public Runtime boundary.
bool reported() const noexcept
True when a reporter (e.g. DevTool hook) already handled it.
const std::string & stackTrace() const noexcept
Multi-line call stack captured at the throw site.
bool hasLocation() const noexcept
True when the exception carries a script source line.
int column() const noexcept
1-based compile column; -1 when unknown.
ScriptStage stage() const noexcept
const std::string & function() const noexcept
Function name at the throw site; empty when unknown.
const std::string & source() const noexcept
uint64_t scriptId() const noexcept
int line() const noexcept
1-based throw/compile site line; -1 when unknown.
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
std::vector< ReflectedMember > members
std::vector< ReflectedAttribute > attributes
std::vector< std::string > classes
Structured snapshot of a script error: message, throw site and stack.