comparison 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
comparison
equal deleted inserted replaced
51:7d6a6906b648 52:079200bc3e75
31 } 31 }
32 32
33 If@Int32[num:yes,no] 33 If@Int32[num:yes,no]
34 { 34 {
35 yes,no <- If[[num]!=[0i32]] 35 yes,no <- If[[num]!=[0i32]]
36 }
37
38 Foreign C:libc
39 {
40 write[filedes(Int32,Naked),buf(Array,Raw Pointer),nbyte(Int64,Naked):written(Int32,Naked)]
41 }
42
43 _Print Int32[n,buf:out]
44 {
45 If[[n] < [10i32]]
46 {
47 byte <- [[n]Trunc Int8] + [48i8]
48 out <- [buf]Append[byte]
49 }{
50 next <- [n]/[10i32]
51
52 byte <- [[[n]-[[next]*[10i32]]]Trunc Int8] + [48i8]
53 out <- [_Print Int32[next, buf]]Append[byte]
54 }
55 }
56
57 Print@Int32[n:out]
58 {
59 If[[n] < [0i32]]
60 {
61 val <- [0i32]-[n]
62 buf <- [Array[1]]Append[45i8]
63 }{
64 val <- Val[n]
65 buf <- Array[1]
66 }
67 fbuf <- [_Print Int32[val, buf]]Append[10i8]
68 out <- write[1i32, fbuf, Int64[[fbuf]Length >>]]
36 } 69 }
37 70
38 Blueprint Int16 71 Blueprint Int16
39 { 72 {
40 Num(Int16,Naked) 73 Num(Int16,Naked)