Assembly *LSLuaState::loadExecutableAssembly(const utString& assemblyName, bool absPath) { // executables always in bin utString filePath; if (!absPath) { filePath = "./bin/"; } filePath += assemblyName; if (!strstr(filePath.c_str(), ".loom")) { filePath += ".loom"; } const char *buffer = NULL; long bufferSize; LSMapFile(filePath.c_str(), (void **)&buffer, &bufferSize); lmAssert(buffer && bufferSize, "Error loading executable: %s, unable to map file", assemblyName.c_str()); Assembly* assembly = loadExecutableAssemblyBinary(buffer, bufferSize); LSUnmapFile(filePath.c_str()); lmAssert(assembly, "Error loading executable: %s", assemblyName.c_str()); assembly->freeByteCode(); return assembly; }
int Assembly::loadBytes(lua_State *L) { utByteArray *bytes = static_cast<utByteArray*>(lualoom_getnativepointer(L, 1, false, "system.ByteArray")); Assembly *assembly = LSLuaState::getExecutingVM(L)->loadExecutableAssemblyBinary(static_cast<const char*>(bytes->getDataPtr()), bytes->getSize()); lmAssert(assembly, "Error loading assembly bytes"); lualoom_pushnative(L, assembly); assembly->freeByteCode(); return 1; }