Differences From
Artifact [41c6f93980]:
197 197 end)
198 198 lib.enum = function(tbl)
199 199 local ty = uint8
200 200 if #tbl >= 2^32 then ty = uint64 -- hey, can't be too safe
201 201 elseif #tbl >= 2^16 then ty = uint32
202 202 elseif #tbl >= 2^8 then ty = uint16 end
203 203 local o = { t = ty }
204 + local strings = {}
204 205 for i, name in ipairs(tbl) do
205 - o[name] = i
206 + o[name] = i - 1
207 + strings[i] = `[lib.mem.ref(int8)]{ptr=[name], ct=[#name]}
208 + end
209 + o._str = terra(val: ty)
210 + var l = array([strings])
211 + return l[val]
206 212 end
207 213 return o
208 214 end
209 215 lib.set = function(tbl)
210 216 local bytes = math.ceil(#tbl / 8)
211 217 local o = {}
212 218 for i, name in ipairs(tbl) do o[name] = i end
................................................................................
214 220 local struct bit { _v: intptr _set: &set}
215 221 terra set:clear() for i=0,bytes do self._store[i] = 0 end end
216 222 terra set:fill() for i=0,bytes do self._store[i] = 0xFF end end
217 223 set.members = tbl
218 224 set.name = string.format('set<%s>', table.concat(tbl, '|'))
219 225 set.metamethods.__entrymissing = macro(function(val, obj)
220 226 if o[val] == nil then error('value ' .. val .. ' not in set') end
221 - return `bit { _v=[o[val] - 1], _set = &obj }
227 + return `bit { _v=[o[val] - 1], _set = &(obj) }
222 228 end)
229 + terra set:sz()
230 + var ct: intptr = 0
231 + for i = 0, [#tbl] do
232 + if (self._store[i/8] and (1 << i % 8)) ~= 0 then ct = ct + 1 end
233 + end
234 + return ct
235 + end
223 236 set.methods.dump = macro(function(self)
224 237 local q = quote lib.io.say('dumping set:\n') end
225 238 for i,v in ipairs(tbl) do
226 239 q = quote
227 240 [q]
228 241 if [bool](self.[v])
229 242 then lib.io.say([' - ' .. v .. ': true\n'])
................................................................................
306 319 for k,v in pairs(data.view) do
307 320 local t = lib.tpl.mk { body = v, id = 'view/'..k }
308 321 data.view[k] = t
309 322 end
310 323
311 324 lib.load {
312 325 'srv';
326 + 'render:nav';
327 + 'render:login';
313 328 'render:profile';
314 329 'render:userpage';
330 + 'render:compose';
315 331 'route';
316 332 }
317 333
318 334 do
319 335 local p = string.format('parsav: %s\nbuilt on %s\n', config.build.str, config.build.when)
320 336 terra version() lib.io.send(1, p, [#p]) end
321 337 end
................................................................................
427 443
428 444 if bflag('dump-config','C') then
429 445 print(util.dump(config))
430 446 os.exit(0)
431 447 end
432 448
433 449 local holler = print
434 -local out = config.exe and 'parsav' or 'parsav.o'
435 -local linkargs = {}
450 +local out = config.exe and 'parsav' or ('parsav.' .. config.outform)
451 +local linkargs = {'-O4'}
436 452
437 453 if bflag('quiet','q') then holler = function() end end
438 454 if bflag('asan','s') then linkargs[#linkargs+1] = '-fsanitize=address' end
439 455 if bflag('lsan','S') then linkargs[#linkargs+1] = '-fsanitize=leak' end
440 456
441 457 if config.posix then
442 458 linkargs[#linkargs+1] = '-pthread'