annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
517
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
1 -- !does not generates sigs with aggregates!
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
2
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
3 -- following knobs control generation:
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
4
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
5 -- required to be defined by who is using this:
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
6 -- ncases
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
7 -- types
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
8
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
9 -- optional:
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
10 -- rtypes (if not set, it'll be 'v'..types)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
11
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
12
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
13 --------------------------------
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
14
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
15 if rtypes == nil then
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
16 rtypes = "v"..types
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
17 end
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
18
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
19 local i
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
20 for i = 0, ncases-1 do
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
21 local s = ""
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
22 local typeindex
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
23 local ntypes = #types
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
24 local nrtypes = #rtypes
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
25 local x = offset+i*step
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
26 if x >= nrtypes then
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
27 local y = math.floor(x / nrtypes) - 1
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
28 while y >= ntypes do
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
29 typeindex = 1 + (y % ntypes)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
30 s = s .. string.sub(types, typeindex, typeindex)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
31 y = math.floor(y / ntypes) - 1
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
32 end
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
33 typeindex = 1 + (y % ntypes)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
34 s = s .. string.sub(types, typeindex, typeindex)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
35 end
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
36 typeindex = 1 + (x % nrtypes)
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
37 io.write(s .. ")" .. string.sub(rtypes, typeindex, typeindex) .. "\n")
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
38 end
f8856e29b512 - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void')
Tassilo Philipp
parents:
diff changeset
39