diff 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
line wrap: on
line diff
--- a/kernel.rhope	Sat Jul 10 18:02:04 2010 -0400
+++ b/kernel.rhope	Wed Jul 21 00:45:13 2010 -0400
@@ -1,6 +1,7 @@
 Import string.rhope
 Import list.rhope
 Import functional.rhope
+Import file.rhope
 
 Val[in:out]
 {
@@ -40,11 +41,8 @@
 
 Foreign C:libc
 {
-	open[name(Array,Raw Pointer),flags(Int32,Naked):filedes(Int32,Naked)]
 	write[filedes(Int32,Naked),buf(Array,Raw Pointer),nbyte(Int64,Naked):written(Int32,Naked)]
 	read[filedes(Int32,Naked),buf(Array,Raw Pointer,Mutable),nbyte(Int64,Naked):read(Int64,Naked),buf]
-	close[filedes(Int32,Naked):status(Int32,Naked)]
-	fsync[filedes(Int32,Naked):status(Int32,Naked)]
 }
 
 _Print Int32[n,buf:out]
@@ -361,6 +359,55 @@
 	out <- [arr]Index[index]
 }
 
+_Copy Part Naked[source,dest,srcindex,destindex:out]
+{
+	ndest <- _internal_array_copyin[dest, destindex, [source]Index[srcindex]]
+	
+	[source]Next[srcindex]
+	{
+		out <- _Copy Part Naked[source, ndest, ~, [destindex]+[1]]
+	}{
+		out <- Val[ndest]
+	}
+}
+
+_Copy Part Boxed[source,dest,srcindex,destindex:out]
+{
+	ndest <- _internal_array_setboxed[dest, destindex, [source]Index[srcindex]]
+	
+	[source]Next[srcindex]
+	{
+		out <- _Copy Part Boxed[source, ndest, ~, [destindex]+[1]]
+	}{
+		out <- Val[ndest]
+	}
+}
+
+Slice@Array[arr,slicepoint(Int32):left,right]
+{
+	If[[slicepoint]<[[arr]Length]]
+	{
+		If[[slicepoint]>[0i32]]
+		{
+			eltype <- [arr]Eltype >>
+			If[[eltype] = [Any Type()]]
+			{
+				_Copy Part Boxed[arr, _internal_array_allocboxed[[[arr]Length]-[slicepoint]], slicepoint, 0]
+			}{
+				_Copy Part Naked[arr, _internal_array_allocnaked[[[arr]Length]-[slicepoint], eltype], slicepoint, 0]
+			}
+			left <- [arr]Length <<[slicepoint]
+		}{
+			right <- arr
+			left <- Array[]
+		}
+	}{
+		left <- arr
+		right <- Array[]
+	}
+	
+}
+
 And[left,right:out]
 {
 	,out <- If[left]