1 require 'metalua.dollar'
5 function dollar.log(...)
7 local ti = table.insert
13 if args[i].tag=='String' then
14 ti(code, +{print(" [LOG] "..-{args[1]})})
18 local xtra_args, names, vals = { }, { }, { }
21 | +{ 'nohash' } -> nohash = true
22 | `Number{ w } -> width = w
23 --| `String{...} | `Number{...} -> ti (xtra_args, args[i])
24 | `Id{n} -> ti (names, n); ti (vals, args[i])
25 | x -> ti (names, table.tostring(x, 'nohash')); ti (vals, x)
30 local msg = string.format(" [LOG] %s = ", names[i])
31 local printer = `Call{ +{table.tostring},
35 if nohash then ti(printer, +{'nohash'}) end
36 ti (code, `Call{ +{printf}, +{"%s%s"}, `String{ msg }, printer })