issue #163 fix bugs - wrong type associated with the LLVM definition of raviV_op_defer()

defer
Dibyendu Majumdar 5 years ago
parent aaee69bfd2
commit 12eda8ca0d

@ -121,6 +121,7 @@ opcodes_coverage.TOTYPE = 0
opcodes_coverage.TOSTRING = 0
opcodes_coverage.TOCLOSURE = 0
opcodes_coverage.SELF_SK = 0
opcodes_coverage.DEFER = 0
local compile = function(f)
if ravi.jit() then
@ -1727,6 +1728,49 @@ compile(x)
assert(x(2,3) == 2^3)
print 'Test 77 OK'
-- Test defer statement
y = 0
function x()
defer y = y + 1 end
defer y = y + 1 end
end
check(x, 'DEFER', 'CLOSURE', 'DEFER', 'CLOSURE', 'RETURN')
x()
assert(y == 2)
compile(x)
x()
assert(y == 4)
print 'Test 78 OK'
-- Test defer statement
y = 0
function x()
defer y = y + 1 end
error('raise error')
defer y = y + 2 end -- will not be called
end
pcall(x)
assert(y == 1)
compile(x)
pcall(x)
assert(y == 2)
print 'Test 79 OK'
-- Test defer statement
y = 0
function x()
defer y = y + 1 end
defer y = y + 2; error('err') end
defer y = y + 3 end
end
pcall(x)
assert(y == 6)
compile(x)
pcall(x)
assert(y == 12)
print 'Test 80 OK'
for k,v in pairs(opcodes_coverage)
do
print(k, v)

@ -122,6 +122,7 @@ opcodes_coverage.TABLE_SELF_SK = 0
opcodes_coverage.TOTYPE = 0
opcodes_coverage.TOSTRING = 0
opcodes_coverage.TOCLOSURE = 0
opcodes_coverage.DEFER = 0
--ravi.verbosity(1)

@ -1203,7 +1203,7 @@ void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
def->types->raviV_op_totypeT, reinterpret_cast<void *>(&raviV_op_totype),
"raviV_op_totype");
def->raviV_op_deferF = def->raviF->addExternFunction(
def->types->raviV_op_totypeT, reinterpret_cast<void *>(&raviV_op_defer),
def->types->raviV_op_deferT, reinterpret_cast<void *>(&raviV_op_defer),
"raviV_op_defer");
def->ravi_dump_valueF = def->raviF->addExternFunction(

Loading…
Cancel
Save