Mercurial > repos > rhope
diff kernel.rhope @ 52:079200bc3e75
String literals almost working. Print moved out of C runtime.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 28 Apr 2010 01:23:30 -0400 |
parents | 689fb73e7612 |
children | d0ce696786cc |
line wrap: on
line diff
--- a/kernel.rhope Thu Apr 22 02:18:26 2010 -0400 +++ b/kernel.rhope Wed Apr 28 01:23:30 2010 -0400 @@ -35,6 +35,39 @@ yes,no <- If[[num]!=[0i32]] } +Foreign C:libc +{ + write[filedes(Int32,Naked),buf(Array,Raw Pointer),nbyte(Int64,Naked):written(Int32,Naked)] +} + +_Print Int32[n,buf:out] +{ + If[[n] < [10i32]] + { + byte <- [[n]Trunc Int8] + [48i8] + out <- [buf]Append[byte] + }{ + next <- [n]/[10i32] + + byte <- [[[n]-[[next]*[10i32]]]Trunc Int8] + [48i8] + out <- [_Print Int32[next, buf]]Append[byte] + } +} + +Print@Int32[n:out] +{ + If[[n] < [0i32]] + { + val <- [0i32]-[n] + buf <- [Array[1]]Append[45i8] + }{ + val <- Val[n] + buf <- Array[1] + } + fbuf <- [_Print Int32[val, buf]]Append[10i8] + out <- write[1i32, fbuf, Int64[[fbuf]Length >>]] +} + Blueprint Int16 { Num(Int16,Naked)