Skip to content

Commit

Permalink
Add coverage opcode (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatSageEqualToHeaven authored and SnorlaxAssist committed Apr 4, 2024
1 parent 1b788cf commit efce698
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ FIU_TESTCASES {
"Conformance/utf8",
"Conformance/vararg",

// Emulated Tests
"Conformance/Emulated/Coverage",

// Instruction Specific Tests
"Conformance/Instructions/Calls",
"Conformance/Instructions/Constants",
Expand Down
23 changes: 23 additions & 0 deletions tests/Conformance/Emulated/Coverage.lua
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit efce698

Please sign in to comment.