From efce698798e27149e767f7dc2d88f0a29e58f8e4 Mon Sep 17 00:00:00 2001 From: James <85808999+TheGreatSageEqualToHeaven@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:11:10 +0100 Subject: [PATCH] Add coverage opcode (#30) --- Source.lua | 2 ++ tests/Config.h | 3 +++ tests/Conformance/Emulated/Coverage.lua | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/Conformance/Emulated/Coverage.lua diff --git a/Source.lua b/Source.lua index 90cd04f..b81fa82 100644 --- a/Source.lua +++ b/Source.lua @@ -1109,6 +1109,8 @@ local function luau_load(module, env, luau_settings) pc += inst.E elseif op == 68 then --[[ FASTCALL ]] --[[ Skipped ]] + elseif op == 69 then --[[ COVERAGE ]] + inst.E += 1 elseif op == 70 then --[[ CAPTURE ]] --[[ Handled by CLOSURE ]] error("encountered unhandled CAPTURE") diff --git a/tests/Config.h b/tests/Config.h index 6a0d47b..83f8e9b 100644 --- a/tests/Config.h +++ b/tests/Config.h @@ -68,6 +68,9 @@ FIU_TESTCASES { "Conformance/utf8", "Conformance/vararg", + // Emulated Tests + "Conformance/Emulated/Coverage", + // Instruction Specific Tests "Conformance/Instructions/Calls", "Conformance/Instructions/Constants", diff --git a/tests/Conformance/Emulated/Coverage.lua b/tests/Conformance/Emulated/Coverage.lua new file mode 100644 index 0000000..fcfbd9a --- /dev/null +++ b/tests/Conformance/Emulated/Coverage.lua @@ -0,0 +1,23 @@ +--!ctx Luau + +local ok, compileResult = Luau.compile([[ +print("Hello World!") +]]) + +if not ok then + error(`Failed to compile, error: {compileResult}`) +end + +local module = Fiu.luau_deserialize(compileResult) + +table.insert(module.mainProto.code, 1, { + opcode = 69, + opname = "COVERAGE", + E = 0, +}) + +local func, _ = Fiu.luau_load(module, {print = print}) + +func() + +OK()