parsav  Diff

Differences From Artifact [60110bc615]:

To Artifact [12858be43d]:


1
2
3



4
5
6
7
8
9
10
..
52
53
54
55
56
57
58






59
60
61
62
63
64
65
-- vim: ft=terra
local m = {
	shorthand = {maxlen = 14}



}

local pstring = lib.mem.ptr(int8)

-- swap in place -- faster on little endian
m.netswap_ip = macro(function(ty, src, dest)
	if ty:astype().type ~= 'integer' then error('bad type') end
................................................................................
	elseif ch == 0x3a then ch = 37
	elseif ch >= 0x61 and ch <= 0x7a then
		ch = 38 + (ch - 0x61)
	else return 0, false end

	return ch, true 
end







terra m.shorthand.gen(val: uint64, dest: rawstring): ptrdiff
	var lst = "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ:abcdefghijklmnopqrstuvwxyz"
	var buf: int8[m.shorthand.maxlen]
	var ptr = [&int8](buf)
	while val ~= 0 do
		var v = val % 64


|
>
>
>







 







>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- vim: ft=terra
local m = {
	shorthand = {maxlen = 14};
	ll = {
		ctpop_u8 = terralib.intrinsic('llvm.ctpop.i8', uint8 -> uint8);
	};
}

local pstring = lib.mem.ptr(int8)

-- swap in place -- faster on little endian
m.netswap_ip = macro(function(ty, src, dest)
	if ty:astype().type ~= 'integer' then error('bad type') end
................................................................................
	elseif ch == 0x3a then ch = 37
	elseif ch >= 0x61 and ch <= 0x7a then
		ch = 38 + (ch - 0x61)
	else return 0, false end

	return ch, true 
end

terra m.pow(n: intptr, fac: intptr): intptr
	var o = n
	for i=0,fac do n = n * o end
	return n
end

terra m.shorthand.gen(val: uint64, dest: rawstring): ptrdiff
	var lst = "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ:abcdefghijklmnopqrstuvwxyz"
	var buf: int8[m.shorthand.maxlen]
	var ptr = [&int8](buf)
	while val ~= 0 do
		var v = val % 64