changeset 115:04148770c229

Merge
author Mike Pavone <pavone@retrodev.com>
date Wed, 13 Oct 2010 01:18:53 +0000
parents 25a205094f9b (diff) 7ca80654c9bb (current diff)
children 60906f8803ef
files nworker_c.rhope parser_old.rhope parser_old_c.rhope
diffstat 7 files changed, 94 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/compile	Mon Oct 11 21:53:49 2010 -0400
+++ b/compile	Wed Oct 13 01:18:53 2010 +0000
@@ -4,7 +4,7 @@
 	rm "$1.c"
 fi
 
-./rhope -t 1 parser_old.rhope $1
+./rhope -t 1 compile_old.rhope $1
 
 if test ! -f "$1.c"; then
 	echo "Compilation to C failed"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compile_old.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -0,0 +1,29 @@
+Import parser_old.rhope
+
+Main[args]
+{
+	fname <- [args]Index[1]
+	{
+		file <- <String@File[~]
+		,text <- [file]Get FString[[file]Length]
+		params <- New@Parser[]
+		Print[["Parsing "]Append[fname]]
+		Null[text, params, New@Parse Program[], 0]
+		{
+			Print["Parsing imports"]
+			Process Imports[~, params]
+			{
+				tree <- [~]Workers << [ Map[[~]Workers >>, ["Check Worker Literals"]Set Input[1, ~]] ]
+				{ Print["Compiling"] }
+			}
+			compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
+			{ Print["Compiled program to backend"] }
+			outfile <- <String@File[ [fname]Append[".c"] ]
+			[outfile]Put String[ [compiled]Text ]
+			{ Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
+		}
+	}{
+		REPL[New@Parser[]]
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compile_old_c.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -0,0 +1,30 @@
+
+Import parser_old_c.rhope
+
+Main[args]
+{
+        fname <- [args]Index[1]
+        {
+                file <- [File[~]]Open["r"]
+                text <- String[[file]Read[[file]Length]]
+                params <- Parser[]
+                Print[["Parsing "]Append[fname]]
+                Null[text, params, Parse Program[], 0]
+                {
+                        Print["Parsing imports"]
+                        Process Imports[~, params]
+                        {
+                                tree <- [~]Workers << [ Map[[~]Workers >>, Check Worker Literals[?, ~]] ]
+                                { Print["Compiling"] }
+                        }
+                        compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
+                        { Print["Compiled program to backend"] }
+                        outfile <- [File[ [fname]Append[".c"] ]]Truncate
+                        [[compiled]Text]Write to File[outfile] 
+                        { Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
+                }
+        }{
+                Print["You must provide a file name to compile"]
+        }
+}
+
--- a/file.rhope	Mon Oct 11 21:53:49 2010 -0400
+++ b/file.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -219,12 +219,28 @@
 
 Write@File Write[file,data(Array):out,err]
 {
-	err <- If[write[[file]Descriptor >>, data, Int64[[data]Length >>]]] {}
+	err <- If[[write[[file]Descriptor >>, data, Int64[[data]Length >>]]]<[0i32]] {}
 	{
 		out <- file
 	}
 }
 
+Write to File@String[str,file:out,err]
+{
+	out,err <- [file]Write[[str]Buffer >>]
+}
+
+Write to File@String Slice[str,file:out,err]
+{
+	out,err <- [[str]Flatten]Write to File[file]
+}
+
+Write to File@String Cat[str,file:out,err]
+{
+	,err <- [[str]Left >>]Write to File[file]
+	{ out,err <- [[str]Right >>]Write to File[~] }
+}
+
 Close@File Write[file:out]
 {
 	fsync[[file]Descriptor >>]
--- a/nworker_c.rhope	Mon Oct 11 21:53:49 2010 -0400
+++ b/nworker_c.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -32,7 +32,18 @@
 {
 	If[[Blueprint Of[cond]] = [Condition Set()]]
 	{
-		out <- [set]Subsets <<[ [[set]Subsets>>]Set[[cond]To String, cond] ]
+		If[[[set]Condition Type >>]=[[cond]Condition Type >>]]
+		{
+			out <- [[set]Variables <<[ Combine[[set]Variables >>, [cond]Variables >>] ]
+				]Subsets <<[ Combine[[set]Subsets >>, [cond]Subsets >>] ]
+		}{
+			[cond]Empty?
+			{
+				out <- [set]Subsets <<[ [[set]Subsets>>]Set[[cond]To String, cond] ]
+			}{
+				out <- set
+			}
+		}
 	}{
 		out <- [set]Variables <<[ [[set]Variables >>]Set[cond, Yes] ]
 	}
@@ -72,47 +83,17 @@
 
 Empty?@Condition Set[set:not empty,empty]
 {
-	Print["Empty?@Condition Set"]
 	[[set]Variables >>]First
 	{
 		not empty <- Yes
 	}{
-		,empty <- [[set]Subsets >>]First Non-empty Set
+		,empty <- [[set]Subsets >>]First
 		{
 			not empty <- Yes
 		}
 	}
 }
 
-_First Non-empty Set[setlist,index:out,none]
-{
-	current <- [setlist]Index[index]
-	[[current]Variables >>]First
-	{
-		out <- index
-	}{
-		,trynext <- [[current]Subsets >>]First Non-empty Set
-		{
-			out <- index
-		}
-	}
-	Val[trynext]
-	{
-		,none <- [setlist]Next[index]
-		{
-			out,none <- _First Non-empty Set[setlist, ~]
-		}
-	}
-}
-
-First Non-empty Set[setlist:index,none]
-{
-	,none <- [setlist]First
-	{
-		index,none <- _First Non-empty Set[setlist,~]
-	}
-}
-
 For Backend@Condition Set[set:out,none]
 {
 	firstvar <- [[set]Variables >>]First
@@ -125,7 +106,7 @@
 		}
 		out <- Fold[_For Backend Subset[?, ?, [set]Condition Type >>], vars, [set]Subsets >>]
 	}{
-		[[set]Subsets >>]First Non-empty Set
+		[[set]Subsets >>]First
 		{
 			firstsub <- [[[set]Subsets >>]Index[~]]For Backend
 			[[set]Subsets >>]Next[~]
@@ -714,7 +695,7 @@
 		If[[[node]Type >>] = ["input"]]
 		{
 			input name <- [[worker]Inputs >>]Index[ [node]Data >> ]
-			[conditions]For Backend
+			[conditions]Empty?
 			{
 				out <- AddRef[Result Var Name[[noderef]IO Num >>, [noderef]Index >>]]
 			}{
@@ -723,7 +704,7 @@
 		}{
 			If[[[node]Type >>] = ["const"]]
 			{
-				[conditions]For Backend
+				[conditions]Empty?
 				{
 					out <- AddRef[Result Var Name[[noderef]IO Num >>, [noderef]Index >>]]
 				}{
@@ -1031,7 +1012,7 @@
 {
 	[("const","input")]Find[=[[node]Type >>, ?]]
 	{
-		[[node]Conditions >>]For Backend
+		[[node]Conditions >>]Empty?
 		{
 			out <- Result Var[vars, 0, index]
 		}{	
--- a/parser_old.rhope	Mon Oct 11 21:53:49 2010 -0400
+++ b/parser_old.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -1651,30 +1651,3 @@
 	out <- Fold[["Add If Store"]Set Input[2, params], stores, [node]Assignments >>]
 }
 
-
-Main[args]
-{
-	fname <- [args]Index[1]
-	{
-		file <- <String@File[~]
-		,text <- [file]Get FString[[file]Length]
-		params <- New@Parser[]
-		Print[["Parsing "]Append[fname]]
-		Null[text, params, New@Parse Program[], 0]
-		{
-			Print["Parsing imports"]
-			Process Imports[~, params]
-			{
-				tree <- [~]Workers << [ Map[[~]Workers >>, ["Check Worker Literals"]Set Input[1, ~]] ]
-				{ Print["Compiling"] }
-			}
-			compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
-			{ Print["Compiled program to backend"] }
-			outfile <- <String@File[ [fname]Append[".c"] ]
-			[outfile]Put String[ [compiled]Text ]
-			{ Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
-		}
-	}{
-		REPL[New@Parser[]]
-	}
-}
--- a/parser_old_c.rhope	Mon Oct 11 21:53:49 2010 -0400
+++ b/parser_old_c.rhope	Wed Oct 13 01:18:53 2010 +0000
@@ -1579,30 +1579,3 @@
 }
 
 
-/* Main[args]
-{
-	fname <- [args]Index[1]
-	{
-		file <- [File[~]]Open["r"]
-		text <- String[[file]Read[[file]Length]]
-		params <- Parser[]
-		Print[["Parsing "]Append[fname]]
-		Null[text, params, Parse Program[], 0]
-		{
-			Print["Parsing imports"]
-			Process Imports[~, params]
-			{
-				tree <- [~]Workers << [ Map[[~]Workers >>, Check Worker Literals[?, ~]] ]
-				{ Print["Compiling"] }
-			}
-			compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
-			{ Print["Compiled program to backend"] }
-			outfile <- [File[ [fname]Append[".c"] ]]Truncate
-			[outfile]Write[ [Flatten[[compiled]Text]]Buffer >> ]
-			{ Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
-		}
-	}{
-		Print["You must provide a file name to compile"]
-	}
-} */
-