Mercurial > repos > rhope
comparison kernel.rhope @ 80:d78613686a38
Some progress on File
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 21 Jul 2010 00:45:13 -0400 |
parents | 80d8c9248f85 |
children | 27bb051d631c |
comparison
equal
deleted
inserted
replaced
79:80d8c9248f85 | 80:d78613686a38 |
---|---|
1 Import string.rhope | 1 Import string.rhope |
2 Import list.rhope | 2 Import list.rhope |
3 Import functional.rhope | 3 Import functional.rhope |
4 Import file.rhope | |
4 | 5 |
5 Val[in:out] | 6 Val[in:out] |
6 { | 7 { |
7 out <- in | 8 out <- in |
8 } | 9 } |
38 yes,no <- If[[num]!=[0i32]] | 39 yes,no <- If[[num]!=[0i32]] |
39 } | 40 } |
40 | 41 |
41 Foreign C:libc | 42 Foreign C:libc |
42 { | 43 { |
43 open[name(Array,Raw Pointer),flags(Int32,Naked):filedes(Int32,Naked)] | |
44 write[filedes(Int32,Naked),buf(Array,Raw Pointer),nbyte(Int64,Naked):written(Int32,Naked)] | 44 write[filedes(Int32,Naked),buf(Array,Raw Pointer),nbyte(Int64,Naked):written(Int32,Naked)] |
45 read[filedes(Int32,Naked),buf(Array,Raw Pointer,Mutable),nbyte(Int64,Naked):read(Int64,Naked),buf] | 45 read[filedes(Int32,Naked),buf(Array,Raw Pointer,Mutable),nbyte(Int64,Naked):read(Int64,Naked),buf] |
46 close[filedes(Int32,Naked):status(Int32,Naked)] | |
47 fsync[filedes(Int32,Naked):status(Int32,Naked)] | |
48 } | 46 } |
49 | 47 |
50 _Print Int32[n,buf:out] | 48 _Print Int32[n,buf:out] |
51 { | 49 { |
52 If[[n] < [10i32]] | 50 If[[n] < [10i32]] |
359 Call@Array[arr(Array),index(Int32):out] | 357 Call@Array[arr(Array),index(Int32):out] |
360 { | 358 { |
361 out <- [arr]Index[index] | 359 out <- [arr]Index[index] |
362 } | 360 } |
363 | 361 |
362 _Copy Part Naked[source,dest,srcindex,destindex:out] | |
363 { | |
364 ndest <- _internal_array_copyin[dest, destindex, [source]Index[srcindex]] | |
365 | |
366 [source]Next[srcindex] | |
367 { | |
368 out <- _Copy Part Naked[source, ndest, ~, [destindex]+[1]] | |
369 }{ | |
370 out <- Val[ndest] | |
371 } | |
372 } | |
373 | |
374 _Copy Part Boxed[source,dest,srcindex,destindex:out] | |
375 { | |
376 ndest <- _internal_array_setboxed[dest, destindex, [source]Index[srcindex]] | |
377 | |
378 [source]Next[srcindex] | |
379 { | |
380 out <- _Copy Part Boxed[source, ndest, ~, [destindex]+[1]] | |
381 }{ | |
382 out <- Val[ndest] | |
383 } | |
384 } | |
385 | |
386 Slice@Array[arr,slicepoint(Int32):left,right] | |
387 { | |
388 If[[slicepoint]<[[arr]Length]] | |
389 { | |
390 If[[slicepoint]>[0i32]] | |
391 { | |
392 eltype <- [arr]Eltype >> | |
393 If[[eltype] = [Any Type()]] | |
394 { | |
395 _Copy Part Boxed[arr, _internal_array_allocboxed[[[arr]Length]-[slicepoint]], slicepoint, 0] | |
396 }{ | |
397 _Copy Part Naked[arr, _internal_array_allocnaked[[[arr]Length]-[slicepoint], eltype], slicepoint, 0] | |
398 } | |
399 left <- [arr]Length <<[slicepoint] | |
400 }{ | |
401 right <- arr | |
402 left <- Array[] | |
403 } | |
404 }{ | |
405 left <- arr | |
406 right <- Array[] | |
407 } | |
408 | |
409 } | |
410 | |
364 And[left,right:out] | 411 And[left,right:out] |
365 { | 412 { |
366 ,out <- If[left] | 413 ,out <- If[left] |
367 { | 414 { |
368 out,out <- If[right] | 415 out,out <- If[right] |