summaryrefslogtreecommitdiff
path: root/libstd/fmtfuncs.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-08-26 12:20:58 -0700
committerOri Bernstein <ori@eigenstate.org>2015-08-26 12:20:58 -0700
commit2bc852bda98762d3bc01548bf972e3f1b137fbfb (patch)
tree74831deed3c9057c5fe0cbb8790d220e855bc792 /libstd/fmtfuncs.myr
parent3de952510eb2a23350d24ed926f19c0cf72a12f2 (diff)
downloadmc-2bc852bda98762d3bc01548bf972e3f1b137fbfb.tar.gz
Move Myrddin libs to lib/ subdirectory.
Diffstat (limited to 'libstd/fmtfuncs.myr')
-rw-r--r--libstd/fmtfuncs.myr54
1 files changed, 0 insertions, 54 deletions
diff --git a/libstd/fmtfuncs.myr b/libstd/fmtfuncs.myr
deleted file mode 100644
index abe5e75..0000000
--- a/libstd/fmtfuncs.myr
+++ /dev/null
@@ -1,54 +0,0 @@
-use "alloc.use"
-use "bigint.use"
-use "bitset.use"
-use "fmt.use"
-use "introspect.use"
-use "strbuf.use"
-use "varargs.use"
-
-pkg std =
-;;
-
-const __init__ = {
- var bigint : bigint#
- var bitset : bitset#
-
- fmtinstall(typeof(bigint), bigfmt, [][:])
- fmtinstall(typeof(bitset), bsfmt, [][:])
-}
-
-const bigfmt = {sb, ap, opts
- var a, n, buf
-
- a = vanext(ap)
- /*
- allocate a buffer guaranteed to be big enough.
- that's
- 2 + floor(nbits/(log_2(10)))
- or
- 2 + a.dig.len * 32/3.32...
- or
- 2 + a.dig.len * 10
- plus one for the - sign.
- */
- buf = slalloc(3 + a.dig.len * 10)
- n = bigbfmt(buf, a, 10)
- sbputs(sb, buf[:n])
- slfree(buf)
-}
-
-const bsfmt = {sb, ap, opts
- var i, bs, sep
-
- bs = vanext(ap)
- sep = ""
- sbputs(sb, "bitset{")
- for i = 0; i < bsmax(bs); i++
- if bshas(bs, i)
- sbfmt(sb, sep)
- sbfmt(sb, "{}", i)
- sep = ", "
- ;;
- ;;
- sbputs(sb, "}")
-}