From 99da90d0e3ff79a1d9b2462e6de429763f7e09b4 Mon Sep 17 00:00:00 2001 From: DerelictDrone Date: Sat, 25 May 2024 07:39:52 -0500 Subject: [PATCH] Lua instructions w/ flag can now break precompile --- lua/wire/cpulib.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/wire/cpulib.lua b/lua/wire/cpulib.lua index d9a4a0f..4579f02 100644 --- a/lua/wire/cpulib.lua +++ b/lua/wire/cpulib.lua @@ -930,6 +930,18 @@ function CPULib:RegisterExtension(name, extension) self:Dyn_EmitOperand(2,"interOp[2]") self:Dyn_Emit("end") ]] + local precompileBreakApplied = false + for _,i in ipairs(flags) do + -- force a break if this is a branching function + if (i == "CB" or i == "UB") and not precompileBreakApplied then + -- Without this, a CB(conditional branch) or UB(unconditional branch) flagged function will not have VM:Jump take effect. + opfunc = opfunc .. [[ + self:Dyn_EmitBreak() + self.PrecompileBreak = true + ]] + precompileBreakApplied = true + end + end local instruction = self:RegisterInstruction(name, opcount, opfunc, flags, docs) instruction.InterOpFunc = luafunc end