parsav  Diff

Differences From Artifact [2bbe093dad]:

To Artifact [5b9672ebb4]:


   183    183   	var now = lib.osclock.time(nil)
   184    184   	var diff = now - lib.noise.lasttime
   185    185   	if diff > 30 then -- print cur time
   186    186   		lib.noise.lasttime = now
   187    187   		var curtime: int8[26]
   188    188   		lib.osclock.ctime_r(&now, &curtime[0])
   189    189   		for i=0,26 do if curtime[i] == @'\n' then curtime[i] = 0 break end end -- :/
   190         -		[ lib.emit(false, 2, '\27[1m[', `&curtime[0], ']\27[;36m\n +00 ') ]
          190  +		[ lib.emit(false, 2, '\27[1m', `&curtime[0], '\27[;36m\n +00 ') ]
   191    191   	else -- print time since last msg
   192    192   		var dfs = arrayof(int8, 0x30 + diff/10, 0x30 + diff%10, 0x20, 0)
   193    193   		[ lib.emit(false, 2, ' \27[36m+', `&dfs[0]) ]
   194    194   	end
   195    195   end
   196    196   
   197    197   local defrep = function(level,n,code)
................................................................................
   235    235   	return n
   236    236   end)
   237    237   lib.enum = function(tbl)
   238    238   	local ty = uint8
   239    239   	if #tbl >= 2^32 then ty = uint64 -- hey, can't be too safe
   240    240   	elseif #tbl >= 2^16 then ty = uint32
   241    241   	elseif #tbl >= 2^8 then ty = uint16 end
   242         -	local o = { t = ty }
          242  +	local o = { t = ty, members = tbl }
   243    243   	local strings = {}
   244    244   	for i, name in ipairs(tbl) do
   245    245   		o[name] = i - 1
   246    246   		strings[i] = `[lib.mem.ref(int8)]{ptr=[name], ct=[#name]}
   247    247   	end
   248    248   	o._str = terra(val: ty)
   249    249   		var l = array([strings])
................................................................................
   271    271   			if (self._store[i/8] and (1 << i % 8)) ~= 0 then ct = ct + 1 end
   272    272   		end
   273    273   		return ct
   274    274   	end
   275    275   	set.methods.dump = macro(function(self)
   276    276   		local q = quote lib.io.say('dumping set:\n') end
   277    277   		for i,v in ipairs(tbl) do
   278         -			q = quote
   279         -				[q]
          278  +			q = quote [q]
   280    279   				if [bool](self.[v])
   281    280   					then lib.io.say([' - ' .. v .. ': true\n'])
   282    281   					else lib.io.say([' - ' .. v .. ': false\n'])
   283    282   				end
   284    283   			end
   285    284   		end
   286    285   		return q