comparison test/common/ordered-sig.lua @ 517:f8856e29b512

- tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
author Tassilo Philipp
date Mon, 11 Apr 2022 14:50:35 +0200
parents
children
comparison
equal deleted inserted replaced
516:1a813b706de4 517:f8856e29b512
1 -- !does not generates sigs with aggregates!
2
3 -- following knobs control generation:
4
5 -- required to be defined by who is using this:
6 -- ncases
7 -- types
8
9 -- optional:
10 -- rtypes (if not set, it'll be 'v'..types)
11
12
13 --------------------------------
14
15 if rtypes == nil then
16 rtypes = "v"..types
17 end
18
19 local i
20 for i = 0, ncases-1 do
21 local s = ""
22 local typeindex
23 local ntypes = #types
24 local nrtypes = #rtypes
25 local x = offset+i*step
26 if x >= nrtypes then
27 local y = math.floor(x / nrtypes) - 1
28 while y >= ntypes do
29 typeindex = 1 + (y % ntypes)
30 s = s .. string.sub(types, typeindex, typeindex)
31 y = math.floor(y / ntypes) - 1
32 end
33 typeindex = 1 + (y % ntypes)
34 s = s .. string.sub(types, typeindex, typeindex)
35 end
36 typeindex = 1 + (x % nrtypes)
37 io.write(s .. ")" .. string.sub(rtypes, typeindex, typeindex) .. "\n")
38 end
39