comparison test/call_suite_aggrs/mk-cases.lua @ 510:f0080b53635d

test/call_suite_aggrs: - less confusing and simpler generated code (with first arg in V_?[0] output) - avoid using same test reference value for retval and last arg
author Tassilo Philipp
date Sat, 09 Apr 2022 23:45:44 +0200
parents ed7d1f5e7973
children 4d0541bf9b38
comparison
equal deleted inserted replaced
509:f3d44195dbdf 510:f0080b53635d
24 function mkcase(id,sig) 24 function mkcase(id,sig)
25 local sig = trim(sig) 25 local sig = trim(sig)
26 local fsig = put_sig_rtype_first(sig) 26 local fsig = put_sig_rtype_first(sig)
27 local h = { "/* ",id,":",sig," */ " } 27 local h = { "/* ",id,":",sig," */ " }
28 local t = { "" } 28 local t = { "" }
29 local pos = 0 29 local pos = -1
30 local n_nest = 0 30 local n_nest = 0
31 local aggr = { } 31 local aggr = { }
32 local aggr_sig = { } 32 local aggr_sig = { }
33 aggr[0] = { } -- non-sequential [0] collects all non-aggr types 33 aggr[0] = { } -- non-sequential [0] collects all non-aggr types
34 aggr_sig[0] = '' 34 aggr_sig[0] = ''
85 else 85 else
86 t[#t+1] = "V_"..ch.."["..pos.."]="..name..";" 86 t[#t+1] = "V_"..ch.."["..pos.."]="..name..";"
87 end 87 end
88 88
89 -- is return type or func arg? 89 -- is return type or func arg?
90 if pos == 0 then 90 if pos == -1 then
91 h[#h+1] = " f"..id.."(" 91 h[#h+1] = " f"..id.."("
92 h[#h+1] = '' 92 h[#h+1] = ''
93 t[#t] = '' -- clear; aggr return type handled explicitly 93 t[#t] = '' -- clear; aggr return type handled explicitly
94 else 94 else
95 h[#h+1] = ' '..name 95 h[#h+1] = ' '..name
98 98
99 pos = pos + 1 99 pos = pos + 1
100 end 100 end
101 end 101 end
102 end 102 end
103 max_numargs = math.max(max_numargs, pos-1) 103 max_numargs = math.max(max_numargs, pos)
104 h[#h] = "){" 104 h[#h] = "){"
105 if #h[6] == 1 then 105 if #h[6] == 1 then
106 t[#t+1] = "ret_"..h[6].."("..(pos-1)..")}\n" 106 t[#t+1] = "ret_"..h[6].."("..pos..")}\n"
107 else 107 else
108 t[#t+1] = "ret_a("..(pos-1)..","..h[6]..")}\n" 108 t[#t+1] = "ret_a("..pos..","..h[6]..")}\n"
109 end 109 end
110 return table.concat(h,"")..table.concat(t,"") 110 return table.concat(h,"")..table.concat(t,"")
111 end 111 end
112 112
113 function mkfuntab(n) 113 function mkfuntab(n)