changeset 101:f4fc0a98088a

Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
author Mike Pavone <pavone@retrodev.com>
date Mon, 09 Aug 2010 23:53:20 -0400
parents f51c4c17457c
children 2f6f0867fd68
files cbackend_c.rhope functional.rhope kernel.rhope list.rhope parser_old_c.rhope runtime/func.h
diffstat 6 files changed, 96 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/cbackend_c.rhope	Mon Aug 09 02:03:57 2010 -0400
+++ b/cbackend_c.rhope	Mon Aug 09 23:53:20 2010 -0400
@@ -904,7 +904,7 @@
 
 Checked Result Reference@C Function[func,output:out]
 {
-	out <- [[[["("]Append[output]]Append[" < cdata->num_params ? cdata->params["]]Append[output]]Append["] : NULL)"]
+	out <- [[[["("]Append[String[output]]]Append[" < cdata->num_params ? cdata->params["]]Append[String[output]]]Append["] : NULL)"]
 }
 
 
--- a/functional.rhope	Mon Aug 09 02:03:57 2010 -0400
+++ b/functional.rhope	Mon Aug 09 23:53:20 2010 -0400
@@ -47,7 +47,7 @@
 _Find[list,pred,cur:loc,not found]
 {
 	val <- [list]Index[cur]
-	If[[pred]Call[val]]
+	If[[pred]Call[val,cur]]
 	{
 		loc <- cur
 	}{
--- a/kernel.rhope	Mon Aug 09 02:03:57 2010 -0400
+++ b/kernel.rhope	Mon Aug 09 23:53:20 2010 -0400
@@ -55,51 +55,86 @@
 	read[filedes(Int32,Naked),buf(Array,Raw Pointer,Mutable),nbyte(Int64,Naked):read(Int64,Naked),buf]
 }
 
-_String 32[n,buf:out]
+Trunc UInt8@UInt8[in:out]
 {
-	If[[n] < [10u32]]
+	out <- in
+}
+
+__String Int[n,buf,ten:out]
+{
+	If[[n] < [ten]]
 	{
 		byte <- [[n]Trunc UInt8] + [48u8]
 		out <- [buf]Append[byte]
 	}{
-		next <- [n]/[10u32]
+		next <- [n]/[ten]
 		
-		byte <- [[[n]-[[next]*[10u32]]]Trunc UInt8] + [48u8]
-		out <- [_String 32[next, buf]]Append[byte]
+		byte <- [[[n]-[[next]*[ten]]]Trunc UInt8] + [48u8]
+		out <- [__String Int[next, buf, ten]]Append[byte]
 	}
 }
 
-_String Int32[n:out]
+_String Int[n,zero,ten:out]
 {
-	If[[n] < [0i32]]
+	If[[n] < [zero]]
 	{
 		buf <- [Array[]]Append[45u8]
 	}{
 		buf <- Array[]
 	}
 	val <- Abs UInt[n]
-	out <- _String 32[val, buf]
+	out <- __String Int[val, buf, ten]
+}
+
+String@Int64[n:out]
+{
+	out <- String[_String Int[n, 0i64, 10u64]]
+}
+
+String@UInt64[n:out]
+{
+	out <- String[__String Int[n, Array[], 10u64]]
 }
 
 String@Int32[n:out]
 {
-	out <- String[_String Int32[n]]
+	out <- String[_String Int[n, 0i32, 10u32]]
+}
+
+String@UInt32[n:out]
+{
+	out <- String[__String Int[n, Array[], 10u32]]
+}
+
+String@Int16[n:out]
+{
+	out <- String[_String Int[n, 0i16, 10u16]]
+}
+
+String@UInt16[n:out]
+{
+	out <- String[__String Int[n, Array[], 10u16]]
+}
+
+String@Int8[n:out]
+{
+	out <- String[_String Int[n, 0i8, 10u8]]
+}
+
+String@UInt8[n:out]
+{
+	out <- String[__String Int[n, Array[], 10u8]]
 }
 
 Print@Int32[n:out]
 {
-	fbuf <- [_String Int32[n]]Append[10u8]
+	fbuf <- [_String Int[n, 0i32, 10u32]]Append[10u8]
 	out <- write[1i32, fbuf, Int64[[fbuf]Length >>]]
 }
 
-String@UInt32[n:out]
-{
-	out <- String[_String 32[n, Array[]]]
-}
-
 Print@UInt32[n:out]
 {
-	fbuf <- [_String 32[n, Array[]]]Append[10u8]
+	fbuf <- [__String Int[n, Array[], 10u32]]Append[10u8]
 	out <- write[1i32, fbuf, Int64[[fbuf]Length >>]]
 }
 
--- a/list.rhope	Mon Aug 09 02:03:57 2010 -0400
+++ b/list.rhope	Mon Aug 09 23:53:20 2010 -0400
@@ -224,7 +224,8 @@
 	{
 		out <- [list]Set[index, val]
 	}{
-		out,didn't set <- [[list]Right >>]_Right Set[[index]-[[list]Right Offset >>], val]
+		,didn't set <- [[list]Right >>]_Right Set[[index]-[[list]Right Offset >>], val]
+		{ out <- [list]Right <<[~] }
 	}
 }
 
@@ -352,4 +353,37 @@
 	}
 }
 
+_Check Present[check in,val,index:out]
+{
+	[check in]Index[index]
+	{
+		If[[~]=[val]]
+		{ out <- No }
+		{ out <- Yes }
+	}{ 
+		out <- Yes
+	}
+}
 
+_=List[a,b:out]
+{
+	,out <- If[[[a]Length]=[[b]Length]]
+	{
+		[a]Find[_Check Present[b,?]]
+		{
+			out <- No
+		}{
+			out <- Yes
+		}
+	}
+}
+
+=@List Leaf[a,b:out]
+{
+	out <- _=List[a,b]
+}
+
+=@List[a,b:out]
+{
+	out <- _=List[a,b]
+}
--- a/parser_old_c.rhope	Mon Aug 09 02:03:57 2010 -0400
+++ b/parser_old_c.rhope	Mon Aug 09 23:53:20 2010 -0400
@@ -856,11 +856,11 @@
 			fields <- Fold[Process Blueprint Field[?, ?, params], (), Filter[Map[body lines, Trim[?,"\n\r\t "]], Not Empty[?]]]
 			new tree <- [tree]Blueprints << [ [[tree]Blueprints >>]Set[name, New Blueprint Definition[name, fields]] ]
 			out <- Null[~, params, new tree, [lines] + [more lines]]
-		} {} {
+		} {} {} {
 			out <- [tree]Errors <<[ [[tree]Errors >>]Append[Parse Error["Error",[["Blueprint is missing an block close symbol \""]Append[[params]Block End >>]]Append["\""], lines]] ]
 		}
 		
-	} {} {
+	} {} {} {
 		out <- [tree]Errors <<[ [[tree]Errors >>]Append[Parse Error["Error",[["Blueprint is missing an block open symbol \""]Append[[params]Block Begin >>]]Append["\""], lines]] ]
 	}
 }
--- a/runtime/func.h	Mon Aug 09 02:03:57 2010 -0400
+++ b/runtime/func.h	Mon Aug 09 23:53:20 2010 -0400
@@ -126,7 +126,12 @@
 
 #define CopiedParam(num,convtypeid) Param(num,convtypeid) cdata->params[num] = copy_object(cdata->params[num]);
 #define Ret(num,val) cdata->params[num] = (object *)(val);
-#define NumRet(num) cdata->num_params = num;
+#define NumRet(num) cdata->num_params = num;\
+	if (num == 1 && !cdata->params[0])\
+	{\
+		puts("Worker with only one output failed to produce data for that output!");\
+		goto _exception;\
+	}
 #define Exception
 #define FuncDef(name) lt_ ## name * lv_ ## name;
 #define MethodDef(name) lt_ ## name ## AT_ ## type_name * lv_ ## name ## AT_ ## type_name;