summaryrefslogtreecommitdiff
path: root/libstd/varargs.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/varargs.myr
parent3de952510eb2a23350d24ed926f19c0cf72a12f2 (diff)
downloadmc-2bc852bda98762d3bc01548bf972e3f1b137fbfb.tar.gz
Move Myrddin libs to lib/ subdirectory.
Diffstat (limited to 'libstd/varargs.myr')
-rw-r--r--libstd/varargs.myr105
1 files changed, 0 insertions, 105 deletions
diff --git a/libstd/varargs.myr b/libstd/varargs.myr
deleted file mode 100644
index c2ed1b2..0000000
--- a/libstd/varargs.myr
+++ /dev/null
@@ -1,105 +0,0 @@
-use "types.use"
-use "introspect.use"
-use "sleq.use"
-use "die.use"
-
-pkg std =
- type valist
-
- const vastart : (args : ...# -> valist)
- const vatype : (ap : valist# -> byte[:])
- const vabytes : (ap : valist# -> byte[:])
- generic vanext : (ap : valist# -> @a)
-;;
-
-type valist = struct
- args : byte#
- tc : typecursor
-;;
-
-/*
- * a valist is really just a pointer to the varargs.
- * we assume that these sit on the stack nicely,
- * and don't need special handling to get to.
- *
- * This will be a problem when we switch to a
- * register based convention. We might want to
- * force varargs onto the stack regardless.
- */
-const vastart = {args
- var tc, a, ip
-
- /*
- pull out the args. These are on the stacks like so:
-
- [ required ]
- [ args ]
- ---variadic---
- [ typeinfo ] --> type description
- ------------
- [ variadic ]
- [ args ]
- [ here ]
-
- &args points to the typeinfo, &args + sizeof(void#)
- points to the rest argument.
- */
-
- tc = typeenc(args)
- ip = (args castto(intptr)) + sizeof(byte#)
- a = ip castto(byte#)
- -> [.args = a, .tc = tc]
-}
-
-const vatype = {ap
- -> tcpeek(&ap.tc)
-}
-
-const vabytes = {ap
- var sl
- var ti, align, sz
- var p
-
- ti = typeinfo(tcpeek(&ap.tc))
-
- /* apply the alignment to the arg pointer */
- align = ti.align castto(intptr)
- p = ap.args castto(intptr)
- p = (p + align - 1) & ~(align - 1)
- ap.args = p castto(byte#)
-
- sl = ap.args[:ti.size]
- tcnext(&ap.tc)
-
- sz = ti.size castto(intptr)
- ap.args = ((p castto(intptr)) + sz) castto(byte#)
-
- -> sl
-}
-
-const inspectarg = {x
-}
-
-generic vanext = {ap -> @a
- var v : @a
- var ti
- var align
- var p
-
- ti = typeinfo(tcpeek(&ap.tc))
-
- /* apply the alignment to the arg pointer */
- align = ti.align castto(intptr)
- inspectarg(align)
- p = ap.args castto(intptr)
- p = (p + align - 1) & ~(align - 1)
- ap.args = p castto(byte#)
-
- v = (ap.args castto(@a#))#
- /* TODO: check for type mismatch */
- tcnext(&ap.tc)
-
- /* only move on after we read through the value */
- ap.args = ((p castto(intptr)) + sizeof(@a)) castto(byte#)
- -> v
-}