Mercurial > hg > CbC > old > device
diff test/device.d @ 0:d35df41eac69
Initial revision
author | kono |
---|---|
date | Thu, 13 Jan 2000 02:41:41 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/device.d Thu Jan 13 02:41:41 2000 +0900 @@ -0,0 +1,41 @@ +struct env_segment1 { + void *fp; + void *sp; +} + +struct cont_segment1 { + int value; + *return(); +} + +segment1(env_segment1 e, + cont_segment1 c) { + cont_segment1 c1 = + new_continuation(c,e); + c.return = segment2; + call_segment(e,c1); +} + +call_segment(env_segment1 e, + cont_segment1 c) { + c.value = 1; + c.return(); +} + +segment2(env_segment2 e, + cont_segment1 c) { + cont_segment1 c1 = + old_continuation(e); + halt(e,c); +} + +inline type new_continuation(c,e) { + e.fp -= sizeof(type); + return (type)e.fp; +} + +inline type old_continuation(c,e) { + e.fp += sizeof(c); + return (type)e.fp; +} +