90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
...
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
if c == true then r = i else r = e end
in r end
end);
coalesce = macro(function(...)
local args = {...}
local ty = args[1].tree.type
local val = symbol(ty)
local empty if ty.type == 'integer'
then empty = `0
else empty = `nil
end
local exp = quote val = [empty] end
for i=#args, 1, -1 do
local v = args[i]
exp = quote
if [v] ~= [empty]
then val = v
else [exp]
end
end
end
local q = quote
var [val]
[exp]
................................................................................
lib.b64 = lib.loadlib('mbedtls','mbedtls/base64.h')
lib.net = lib.loadlib('mongoose','mongoose.h')
lib.pq = lib.loadlib('libpq','libpq-fe.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt';
'http', 'session', 'tpl', 'store';
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile('backend/' .. b .. '.t')()
end
lib.store.backends = global(`array([be]))
................................................................................
lib.load {
'srv';
'render:nav';
'render:login';
'render:profile';
'render:userpage';
'render:compose';
'route';
}
do
local p = string.format('parsav: %s\nbuilt on %s\n', config.build.str, config.build.when)
terra version() lib.io.send(1, p, [#p]) end
end
................................................................................
if bflag('dump-config','C') then
print(util.dump(config))
os.exit(0)
end
local holler = print
local out = config.exe and 'parsav' or ('parsav.' .. config.outform)
local linkargs = {'-O4'}
if bflag('quiet','q') then holler = function() end end
if bflag('asan','s') then linkargs[#linkargs+1] = '-fsanitize=address' end
if bflag('lsan','S') then linkargs[#linkargs+1] = '-fsanitize=leak' end
if config.posix then
linkargs[#linkargs+1] = '-pthread'
|
|
>
|
|
<
>
|
>
>
>
>
>
>
>
|
|
|
>
>
>
>
>
|
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
...
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
if c == true then r = i else r = e end
in r end
end);
coalesce = macro(function(...)
local args = {...}
local ty = args[1].tree.type
local val = symbol(ty)
local empty
if ty.ptr_basetype then empty = `[ty]{ptr=nil,ct=0}
elseif ty.type == 'integer' then empty = `0
else empty = `nil end
local exp = quote val = [empty] end
for i=#args, 1, -1 do
local v = args[i]
if ty.ptr_basetype then
exp = quote
if [v].ptr ~= nil
then val = v
else [exp]
end
end
else
exp = quote
if [v] ~= [empty]
then val = v
else [exp]
end
end
end
end
local q = quote
var [val]
[exp]
................................................................................
lib.b64 = lib.loadlib('mbedtls','mbedtls/base64.h')
lib.net = lib.loadlib('mongoose','mongoose.h')
lib.pq = lib.loadlib('libpq','libpq-fe.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt';
'http', 'session', 'tpl', 'store';
'smackdown'; -- md-alike parser
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile('backend/' .. b .. '.t')()
end
lib.store.backends = global(`array([be]))
................................................................................
lib.load {
'srv';
'render:nav';
'render:login';
'render:profile';
'render:userpage';
'render:compose';
'render:tweet';
'render:timeline';
'route';
}
do
local p = string.format('parsav: %s\nbuilt on %s\n', config.build.str, config.build.when)
terra version() lib.io.send(1, p, [#p]) end
end
................................................................................
if bflag('dump-config','C') then
print(util.dump(config))
os.exit(0)
end
local holler = print
local out = config.exe and 'parsav' or ('parsav.' .. config.outform)
local linkargs = {}
if bflag('quiet','q') then holler = function() end end
if bflag('asan','s') then linkargs[#linkargs+1] = '-fsanitize=address' end
if bflag('lsan','S') then linkargs[#linkargs+1] = '-fsanitize=leak' end
if config.posix then
linkargs[#linkargs+1] = '-pthread'
|