MCPcopy Create free account
hub / github.com/OpenMW/openmw / loadScriptAndCache

Method loadScriptAndCache

components/lua/luastate.cpp:404–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402 }
403
404 sol::function LuaState::loadScriptAndCache(const VFS::Path::Normalized& path)
405 {
406 auto iter = mCompiledScripts.find(path);
407 if (iter != mCompiledScripts.end())
408 {
409 sol::load_result res = mSol.load(iter->second.as_string_view(), path.value(), sol::load_mode::binary);
410 // Unless we have memory corruption issues, the bytecode is valid at this point, but loading might still
411 // fail because we've hit our Lua memory cap
412 if (!res.valid())
413 throw std::runtime_error("Lua error: " + res.get<std::string>());
414 return res;
415 }
416 sol::function res = loadFromVFS(path);
417 mCompiledScripts[path] = res.dump();
418 return res;
419 }
420
421 sol::function LuaState::loadFromVFS(const VFS::Path::Normalized& path)
422 {

Callers

nothing calls this directly

Calls 7

as_string_viewMethod · 0.80
findMethod · 0.45
endMethod · 0.45
loadMethod · 0.45
valueMethod · 0.45
validMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected