diff dict.rhope @ 92:e73a93fb5de1

Beginning of port of compiler to itself, some bugfixes and a refcount optimization
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Aug 2010 00:58:55 -0400
parents c25d75c2440b
children fa437d23bb24
line wrap: on
line diff
--- a/dict.rhope	Sat Jul 31 17:17:23 2010 -0400
+++ b/dict.rhope	Mon Aug 02 00:58:55 2010 -0400
@@ -238,14 +238,14 @@
 	}
 }
 
-_Print Dict[dict,key]
+_Print Seq[dict,key]
 {
 	val <- String[[dict]Index[key]]
-	Print[ [[["\t"]Append[String[key]]]Append[": "]]Append[val] ]
+	Print[ [[["\t"]Append[String[key]]]Append[":\t"]]Append[val] ]
 	{
 		[dict]Next[key]
 		{
-			_Print Dict[dict, ~]
+			_Print Seq[dict, ~]
 		}
 	}
 }
@@ -253,7 +253,7 @@
 Print@Dictionary[dict:out]
 {
 	Print["Dictionary"]
-	{ _Print Dict[dict, [dict]First] }
+	{ _Print Seq[dict, [dict]First] }
 }
 
 Print@Empty Dictionary[dict:out]
@@ -261,3 +261,39 @@
 	Print["Dictionary\n\t{Empty}"]
 }
 
+Length@Empty Dictionary[dict:out]
+{
+	out <- 0
+}
+
+Length@Dictionary[dict:out]
+{
+	If[[dict]Bits >>]
+	{
+		out <- [Length[[dict]Straight >>]]+[[Length[[dict]Left >>]] + [Length[[dict]Right >>]]]
+	}{
+		out <- [1]+[[Length[[dict]Left >>]] + [Length[[dict]Right >>]]]
+	}
+}
+
+_Combine[source,dest,key:out]
+{
+	new dest <- [dest]Set[key, [source]Index[key]]
+	[source]Next[key]
+	{
+		out <- _Combine[source, new dest, ~]
+	}{
+		out <- Val[new dest]
+	}
+}
+
+Combine[source,dest:out]
+{
+	[source]First
+	{
+		out <- _Combine[source, dest, ~]
+	}{
+		out <- dest
+	}
+}
+