parsav  Diff

Differences From Artifact [11ad9b3025]:

To Artifact [579976ae23]:


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