changeset 83:27bb051d631c

Initial implementation of Dictionary
author Mike Pavone <pavone@retrodev.com>
date Tue, 27 Jul 2010 23:33:31 -0400
parents 2e2e55fc12f9
children 6d41b71f1b77 3c4325e6298f
files cbackend.rhope dict.rhope kernel.rhope nworker.rhope parser_old.rhope runtime/blueprint.h string.rhope testdictsetget.rhope todo.txt
diffstat 9 files changed, 375 insertions(+), 193 deletions(-) [+]
line wrap: on
line diff
--- a/cbackend.rhope	Tue Jul 27 15:23:32 2010 -0400
+++ b/cbackend.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -236,19 +236,19 @@
 {
 	If[[[[ctype]Fields >>]Length] = [1]]
 	{
-		out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0]]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>]]]Append[";"]
-					]Append[ 
-						[[[["typedef "
-							]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1] ]]
-							]Append[" nt_"]
-							]Append[Escape Rhope Name[[ctype]Name >>]]
+		out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0]]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>]]]Append[";"]
+					]Append[ 
+						[[[["typedef "
+							]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1] ]]
+							]Append[" nt_"]
+							]Append[Escape Rhope Name[[ctype]Name >>]]
 							]Append[";"] ]
 	}{
 		//HACK!!!
 		If[[[ctype]Name >>]=["Blueprint"]]
 		{
 			out <- ""	
-		}{
+		}{
 			[("Array","Worker")]Find[[ctype]Name >>]
 			{ oend <- "\nMObject(" }
 			{ oend <- "\nObject(" } 
@@ -270,7 +270,7 @@
 }
 
 Type Init@C Type[ctype,id,method reg,field reg:out]
-{
+{
 	[("Array","Worker")]Find[[ctype]Name >>]
 	{ size <- "-1" }
 	{ 
@@ -335,7 +335,7 @@
 			]Set["Float64", "TYPE_FLOAT64"]		//11
 			]Set["Real Number", "TYPE_FLOAT64"]	//12
 			]Set["Blueprint", "TYPE_BLUEPRINT"]	//13
-			]Set["Array", "TYPE_ARRAY"]			//14
+			]Set["Array", "TYPE_ARRAY"]			//14
 			]Set["Worker", "TYPE_WORKER"]		//15
 			]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"]	//16
 			]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"]	//17
@@ -573,12 +573,12 @@
 
 Lookup Constant@C Function[func,const,doaddref:out]
 {
-	var <- ["_const_"]Append[Escape Rhope Name[const]]
-	If[doaddref]
-	{
-		out <- [["add_ref("]Append[var]]Append[")"]
-	}{
-		out <- Val[var]
+	var <- ["_const_"]Append[Escape Rhope Name[const]]
+	If[doaddref]
+	{
+		out <- [["add_ref("]Append[var]]Append[")"]
+	}{
+		out <- Val[var]
 	}
 }
 
@@ -694,13 +694,13 @@
 		]Append[val]
 		]Append[")"]
 	]
-}
-
+}
+
 _Val Function Arg C[func,val,inputnum,worker:out]
 {
 	out <- [func]Add Raw Line[
-		[[[[[["VCSetParam("
-		]Append[worker]
+		[[[[[["VCSetParam("
+		]Append[worker]
 		]Append[", "]
 		]Append[inputnum]
 		]Append[", "]
@@ -712,25 +712,25 @@
 Method Call@C Function[func,method,args:out]
 {
 	out <- [func]Call[method,args]
-}
-
-Val Call@C Function[func,to call,args:out]
-{
-	worker <- Make Op[Strip Addref[to call], func]
-	rargs <- Map[args, ["Make Op"]Set Input[1, func]]
-
+}
+
+Val Call@C Function[func,to call,args:out]
+{
+	worker <- Make Op[Strip Addref[to call], func]
+	rargs <- Map[args, ["Make Op"]Set Input[1, func]]
+
 	If[[[func]Last NumParams >>] = [-1]]
 	{
 		freed <- Val[func]
 	}{
 		freed <- [func]Add Raw Line["FreeCall"]
-	}
-	prepped <- [[freed]Add Raw Line[ 
-			[[[["VCPrepCall("
-				]Append[worker]
-				]Append[", "]
-				]Append[[rargs]Length]
-				]Append[")"] ]
+	}
+	prepped <- [[freed]Add Raw Line[ 
+			[[[["VCPrepCall("
+				]Append[worker]
+				]Append[", "]
+				]Append[[rargs]Length]
+				]Append[")"] ]
 		]Last NumParams <<[[rargs]Length]
 	
 	
@@ -744,41 +744,41 @@
 		]Append[[func]Resume Index >>]
 		]Append[", "]
 		]Append[Escape Rhope Name[[func]Name >>]]
-		]Append[")"]]
-	]Add Raw Line["DISPATCH"]
-	]Add Raw Line[
-		[[[["ValCallPostlude("
+		]Append[")"]]
+	]Add Raw Line["DISPATCH"]
+	]Add Raw Line[
+		[[[["ValCallPostlude("
 		]Append[[func]Resume Index >>]
 		]Append[", "]
 		]Append[Escape Rhope Name[[func]Name >>]]
 		]Append[")"]]
-	]Resume Index <<[ [[func]Resume Index >>]+[1] ]
+	]Resume Index <<[ [[func]Resume Index >>]+[1] ]
 }
 
 Call@C Function[func,name,args:out]
-{
-	If[[name]=["Call@Worker"]]
-	{
-		//TODO: Handle case when user explicitly calls the fully qualified version, but the type of the first arg isn't Worker
-		out <- [func]Val Call[[args]Index[0], Tail[args,1]]
-	}{
-		If[[name]=["Call"]]
-		{
-			to call <- [args]Index[0]
-			out <- [[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]]
-			]Val Call[to call, Tail[args,1]]
-			]Add Raw Line["} else {"]
-			]Func Base["Call",args, "Call"]
-			]Add Raw Line["}"]
+{
+	If[[name]=["Call@Worker"]]
+	{
+		//TODO: Handle case when user explicitly calls the fully qualified version, but the type of the first arg isn't Worker
+		out <- [func]Val Call[[args]Index[0], Tail[args,1]]
+	}{
+		If[[name]=["Call"]]
+		{
+			to call <- [args]Index[0]
+			out <- [[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]]
+			]Val Call[to call, Tail[args,1]]
+			]Add Raw Line["} else {"]
+			]Func Base["Call",args, "Call"]
+			]Add Raw Line["}"]
 		}{
-			out <- [func]Func Base[Escape Rhope Name[name],args, "Call"]
-		}
+			out <- [func]Func Base[Escape Rhope Name[name],args, "Call"]
+		}
 	}
 }
 
 Func Base@C Function[func,tocall,args,type:out]
 {
-	Print[ [[func]Name >>]Append[ [": Func Base("]Append[tocall] ] ]
+	Print[ [[func]Name >>]Append[ [": Func Base("]Append[tocall] ] ]
 	rargs <- Map[args, ["Make Op"]Set Input[1, func]]
 
 	If[[[rargs]Length] > [[func]Last NumParams >>]]
@@ -890,27 +890,27 @@
 		]Add Raw Line["}"]
 		]Resume Index <<[[stream]Resume Index >>]
 
-}
-
-Discard Outputs@C Function[func,first to discard:out]
-{
-	out <- [[[[[func
-		]Add Raw Line[[["for(idx = "]Append[first to discard]]Append["; idx < cdata->num_params; ++idx)"]]
-		]Add Raw Line["{"]
-		]Add Raw Line["	if (cdata->params[idx])"]
-		]Add Raw Line["		release_ref(cdata->params[idx]);"]
-		]Add Raw Line["}"]
+}
+
+Discard Outputs@C Function[func,first to discard:out]
+{
+	out <- [[[[[func
+		]Add Raw Line[[["for(idx = "]Append[first to discard]]Append["; idx < cdata->num_params; ++idx)"]]
+		]Add Raw Line["{"]
+		]Add Raw Line["	if (cdata->params[idx])"]
+		]Add Raw Line["		release_ref(cdata->params[idx]);"]
+		]Add Raw Line["}"]
 }
 
 Result Reference@C Function[func,output:out]
 {
 	out <- [["cdata->params["]Append[output]]Append["]"]
-}
-
-Checked Result Reference@C Function[func,output:out]
+}
+
+Checked Result Reference@C Function[func,output:out]
 {
 	out <- [[[["("]Append[output]]Append[" < cdata->num_params ? cdata->params["]]Append[output]]Append["] : NULL)"]
-}
+}
 
 
 If Null Else@C Function[func,left,right:out]
@@ -1170,21 +1170,21 @@
 _Consts C Program[text,value,name:out]
 {
 	out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ]
-}
-
-Const Construct C[value,type reg:out]
-{
-	valtype <- Type Of[value]
+}
+
+Const Construct C[value,type reg:out]
+{
+	valtype <- Type Of[value]
 	[("Int32","Whole Number")]Find[valtype]
-	{
-		out <- [["make_Int32("]Append[value]]Append[")"]
-	}{
+	{
+		out <- [["make_Int32("]Append[value]]Append[")"]
+	}{
 		If[[valtype] = ["Type Instance"]]
 		{
 			//TODO: Support parametric types
-			typeid <- [type reg]Type ID[[value]Name >>]
-			out <- [["make_Blueprint("]Append[typeid]]Append[")"]
-		}{
+			typeid <- [type reg]Type ID[[value]Name >>]
+			out <- [["make_Blueprint("]Append[typeid]]Append[")"]
+		}{
 			If[[valtype] = ["Yes No"]]
 			{
 				If[value]
@@ -1200,64 +1200,64 @@
 					{ s <- "I" }
 					{ s <- "UI" }
 					
-					out <- [[[[[["make_"
-						]Append[s]
-						]Append["nt"]
-						]Append[[value]Size >>]
-						]Append["("]
-						]Append[[value]Value >>]
+					out <- [[[[[["make_"
+						]Append[s]
+						]Append["nt"]
+						]Append[[value]Size >>]
+						]Append["("]
+						]Append[[value]Value >>]
 						]Append[")"]
-				}{
+				}{
 					If[[valtype] = ["String"]]
 					{
 						out <- [["make_String(\""]Append[ [[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""] ]]Append["\")"]
-					}{
-						If[[valtype]=["Worker Literal"]]
-						{
-							//TODO: Figure out how to fully support these in nested cases
-							//or workaround the problem higher up in the food chain
-							[[value]Args >>]Last
-							{ size <- [~]+[1] }
-							{ size <- "0" }
-							out <- [[[[[["make_Worker(FUNC_"
-									]Append[Escape Rhope Name[[value]Name >>]]
-									]Append[", "]
-									]Append[size]
-									]Append[", "]
-									]Append[[[value]Args >>]Length]
-									]Append[")"]
-						}{
-							out <- "UnhandledLiteralType"
-						}
-					}
-				}
-			}
-		}
-			
-	}
-}
+					}{
+						If[[valtype]=["Worker Literal"]]
+						{
+							//TODO: Figure out how to fully support these in nested cases
+							//or workaround the problem higher up in the food chain
+							[[value]Args >>]Last
+							{ size <- [~]+[1] }
+							{ size <- "0" }
+							out <- [[[[[["make_Worker(FUNC_"
+									]Append[Escape Rhope Name[[value]Name >>]]
+									]Append[", "]
+									]Append[size]
+									]Append[", "]
+									]Append[[[value]Args >>]Length]
+									]Append[")"]
+						}{
+							out <- "UnhandledLiteralType"
+						}
+					}
+				}
+			}
+		}
+			
+	}
+}
 
-_Set Worker Params C[text,param,num,type reg,name:out]
-{
-	out <- [text]Append[
-		[[[[[["\t((object **)(((t_Worker *)_const_"
-			]Append[name]
-			]Append[")+1))["]
-			]Append[num]
-			]Append["] = "]
-			]Append[Const Construct C[param, type reg]]
-			]Append[";\n"] ]
-}
+_Set Worker Params C[text,param,num,type reg,name:out]
+{
+	out <- [text]Append[
+		[[[[[["\t((object **)(((t_Worker *)_const_"
+			]Append[name]
+			]Append[")+1))["]
+			]Append[num]
+			]Append["] = "]
+			]Append[Const Construct C[param, type reg]]
+			]Append[";\n"] ]
+}
 
 _Set Consts C Program[text,value,name,type reg:out]
 {
-	valtype <- Type Of[value]
-	[("String","Worker Literal")]Find[valtype]
-	{
-		out <- text
-	}{
-		Const Construct C[value,type reg]
-		{ out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
+	valtype <- Type Of[value]
+	[("String","Worker Literal")]Find[valtype]
+	{
+		out <- text
+	}{
+		Const Construct C[value,type reg]
+		{ out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
 	}
 }
 
@@ -1265,18 +1265,18 @@
 {
 	valtype <- Type Of[value]
 	[("String","Worker Literal")]Find[valtype]
-	{
-		Const Construct C[value,type reg]
-		{ init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
-		
-		If[[valtype]=["Worker Literal"]]
-		{
-			out <- Fold[[["_Set Worker Params C"]Set Input[3, type reg]]Set Input[4, Escape Rhope Name[name]], init, [value]Args >>]
+	{
+		Const Construct C[value,type reg]
+		{ init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
+		
+		If[[valtype]=["Worker Literal"]]
+		{
+			out <- Fold[[["_Set Worker Params C"]Set Input[3, type reg]]Set Input[4, Escape Rhope Name[name]], init, [value]Args >>]
 		}{
-			out <- Val[init]
+			out <- Val[init]
 		}
-	}{
-		out <- text
+	}{
+		out <- text
 	}
 }
 
@@ -1343,12 +1343,12 @@
 {
 	out <- [[[[["typedef enum {\n"
 		]Append[Fold["_Dispatch Enum", 
-			[Fold["_Dispatch Enum Methods", "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n"], 
+			[Fold["_Dispatch Enum Methods", "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n"], 
 			[program]Functions >>]]
 		]Append["\tEND\n} funcids;\n\n"]
 		]Append["#define DISPATCH switch(func) { \\\n"]
 		]Append[Fold["_Dispatch Switch", 
-			[Fold["_Dispatch Switch Methods", "", all methods]]Append["\tcase FUNC_Build: goto f_Build;\\\n\tcase FUNC_BlueprintSP_Of: goto f_BlueprintSP_Of;\\\n"], 
+			[Fold["_Dispatch Switch Methods", "", all methods]]Append["\tcase FUNC_Build: goto f_Build;\\\n\tcase FUNC_BlueprintSP_Of: goto f_BlueprintSP_Of;\\\n\tcase FUNC_ID: goto f_ID;\\\n"], 
 			[program]Functions >>]]
 		]Append["\tcase END: goto DO_END;\\\n}\n\n"]
 }
@@ -1427,7 +1427,7 @@
 #include \"func.h\"
 #include \"integer.h\"
 #include \"blueprint.h\"
-#include \"array.h\"
+#include \"array.h\"
 #include \"worker.h\"
 #include \"bool.h\"\n\n"
 	out <- [[[[[[[[[[[[[[[headers
@@ -1442,7 +1442,7 @@
 {
 	uint16_t resume,idx, vcparam_offset, last_vcparam;
 	context * ct;
-	calldata * cdata, *temp_cdata, *my_cdata;\n\nFuncDef(Build)\nFuncDef(BlueprintSP_Of)\n"]
+	calldata * cdata, *temp_cdata, *my_cdata;\n\nFuncDef(Build)\nFuncDef(BlueprintSP_Of)\nFuncDef(ID)\n"]
 		]Append[Fold["Local Pointers", "", [program]Functions >>]]
 		]Append["
 	ct = new_context();
@@ -1475,6 +1475,17 @@
 	Ret(0, new_object(TYPE_BLUEPRINT))
 	((t_Blueprint *)cdata->params[0])->bp = lv_BlueprintSP_Of->bp;
 EndFunc(BlueprintSP_Of)
+DISPATCH
+
+Func(ID, NumParams 1)
+
+	Param(0, TYPE_BLUEPRINT)
+
+	lv_ID->id = new_object(TYPE_UINT32);
+	((t_UInt32 *)lv_ID->id)->Num = ((t_Blueprint *)cdata->params[0])->bp->type_id;
+	release_ref(cdata->params[0]);
+	Ret(0, lv_ID->id)
+EndFunc(ID)
 DISPATCH\n"]
 		]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Native"]]]
 		]Append["
@@ -1495,37 +1506,37 @@
 }
 
 #include \"builtin.c\"
-#include \"array.c\"
+#include \"array.c\"
 #include \"worker.c\"
 
 int main(int argc, char **argv)
 {
-	blueprint * bp;
-	int numret;
-	int idx;
+	blueprint * bp;
+	int numret;
+	int idx;
 	object * inout[2];
 	register_builtin_types();\n\n"]
 		]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ]
 		]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]]
 		]Append[Fold[["_Set Late Consts C"]Set Input[3, [program]Type Registry >>], "", constants]]
-		]Append["
-	rhope(FUNC_List, inout, 0, 1);
-	for (idx = 0; idx < argc; ++idx)
-	{
-		inout[1] = make_String(argv[idx]);
-		rhope(FUNC_Append, inout, 2, 2);
+		]Append["
+	rhope(FUNC_List, inout, 0, 1);
+	for (idx = 0; idx < argc; ++idx)
+	{
+		inout[1] = make_String(argv[idx]);
+		rhope(FUNC_Append, inout, 2, 2);
 	}
-	numret = rhope(FUNC_Main, inout, 1, 1);
-	if (!numret)
-		return 0;
-	if (numret < 0)
-		return numret;
-	if (get_blueprint(inout[0])->type_id == TYPE_INT32)
-		return ((t_Int32 *)inout[0])->Num;
+	numret = rhope(FUNC_Main, inout, 1, 1);
+	if (!numret)
+		return 0;
+	if (numret < 0)
+		return numret;
+	if (get_blueprint(inout[0])->type_id == TYPE_INT32)
+		return ((t_Int32 *)inout[0])->Num;
 
-	rhope(FUNC_If, inout, 1, 2);
-	if (inout[0])
-		return 0;
+	rhope(FUNC_If, inout, 1, 2);
+	if (inout[0])
+		return 0;
 	return 1;
 }\n\n"]
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dict.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -0,0 +1,129 @@
+
+Blueprint Empty Dictionary
+{
+}
+
+Blueprint Dictionary
+{
+	Left
+	Right
+	Straight
+	Bits(UInt32,Naked)
+}
+
+Dictionary[:out]
+{
+	out <- Build[Empty Dictionary()]
+}
+
+_Index@Empty Dictionary[dict,index,bits,bitindex:out,not found]
+{
+	not found <- dict
+}
+
+Index@Empty Dictionary[dict,index:out,not found]
+{
+	not found <- dict
+}
+
+_Terminal Node[val:out]
+{
+	out <- [[[[Build[Dictionary()]
+		]Left <<[Dictionary[]]
+		]Right <<[Dictionary[]]
+		]Straight <<[val]
+		]Bits <<[4294967295u32] //Maximum 32-bit unsigned int value
+}
+
+_Set New[index,val,bits,bitindex:out]
+{
+	nbitindex <- [bitindex]+[1]
+	[index]Dict Bits[nbitindex]
+	{ straight <- _Set New[index,val,~,nbitindex] }
+	{ straight <- _Terminal Node[val] }
+	out <- [[[[Build[Dictionary()]]Left <<[Dictionary[]]]Right <<[Dictionary[]]]Straight <<[straight]]Bits <<[bits]
+}
+
+_Set@Empty Dictionary[dict,index,val,bits,bitindex:out]
+{
+	out <- _Set New[index,val,bits,bitindex]
+}
+
+Set@Empty Dictionary[dict,index,val:out]
+{
+	out <- _Set New[index,val, Dict Type ID[index], -1]
+}
+
+First@Empty Dictionary[dict:first,not found]
+{
+	not found <- dict
+}
+
+Next@Empty Dictionary[dict,index:next,not found]
+{
+	not found <- dict
+}
+
+
+Index@Dictionary[dict,index:out,not found]
+{
+	out,not found <- [dict]_Index[index,Dict Type ID[index], -1]
+}
+
+_Index@Dictionary[dict,index,bits,bitindex:out,not found]
+{
+	If[[bits]=[[dict]Bits >>]]
+	{
+		If[[bits]=[4294967295u32]]
+		{
+			out <- Straight >>[dict]
+		}{
+			nbitindex <- [bitindex]+[1]
+			nbits <- [index]Dict Bits[nbitindex] {}
+			{ nbits <- 4294967295u32 }
+			out,not found <- [[dict]Straight >>]_Index[index,nbits,nbitindex]
+		}
+	}{
+		If[[bits]<[[dict]Bits >>]]
+		{
+			go <- Right >>[dict]
+			
+		}{
+			go <- Left >>[dict]
+		}
+		out,not found <- [go]_Index[index,bits,bitindex]
+	}
+}
+
+Set@Dictionary[dict,index,val:out]
+{
+	out <- [dict]_Set[index,val,Dict Type ID[index], -1]
+}
+
+_Set@Dictionary[dict,index,val,bits,bitindex:out]
+{
+	If[[bits]=[[dict]Bits >>]]
+	{
+		If[[bits]=[4294967295u32]]
+		{
+			out <- [dict]Straight <<[val]
+		}{
+			nbitindex <- [bitindex]+[1]
+			nbits <- [index]Dict Bits[nbitindex] {}
+			{ nbits <- 4294967295u32 }
+			out <- [dict]Straight <<[[[dict]Straight >>]_Set[index,val,nbits,nbitindex]]
+		}
+	}{
+		If[[bits]<[[dict]Bits >>]]
+		{
+			go <- Right >>[dict]
+			out <- [dict]Right <<[new]
+			
+		}{
+			go <- Left >>[dict]
+			out <- [dict]Left <<[new]
+		}
+		new <- [go]_Set[index,val,bits,bitindex]
+	}
+}
+
--- a/kernel.rhope	Tue Jul 27 15:23:32 2010 -0400
+++ b/kernel.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -2,6 +2,7 @@
 Import list.rhope
 Import functional.rhope
 Import file.rhope
+Import dict.rhope
 
 Val[in:out]
 {
--- a/nworker.rhope	Tue Jul 27 15:23:32 2010 -0400
+++ b/nworker.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -806,7 +806,6 @@
 
 Compile Node@NWorker[worker,program,func,nodes,current:out,out worker]
 {
-	Print[[[["Compile node: "]Append[[node]Type >>]]Append[", "]]Append[node index]]
 	node index <- [nodes]Index[current]
 	node <- [[worker]Nodes >>]Index[node index]
 	conditions <- [node]Conditions >>
@@ -987,19 +986,15 @@
 
 _No Release[vars,node,index,worker:out]
 {
-	Print[["_No Release"]Append[[node]Type >>]]
 	[("const","input")]Find[[node]Type >>]
 	{
 		[[node]Conditions >>]For Backend
 		{
-			Print[["Const or input with conditions: "]Append[index]]
 			out <- Result Var[vars, 0, index]
 		}{	
-			Print[["Const or input with no conditions: "]Append[index]]
 			out <- vars
 		}
 	}{
-		Print[["Other node type: "]Append[index]]
 		out <- vars
 	}
 }
@@ -1140,8 +1135,7 @@
 }		
 
 Compile Worker@NWorker[worker,program,name:out]
-{	
-	Print[["Compile Worker: "]Append[[worker]Name >>]]
+{
 	If[[worker]Builtin? >>]
 	{
 		out <- program
@@ -1457,14 +1451,15 @@
 
 Register Builtins@NProgram[prog:out]
 {
-	registered <- [[[[[[prog]Register Worker["Print", "rhope", 1, 1]
+	registered <- [[[[[[[prog]Register Worker["Print", "rhope", 1, 1]
 	]Register Worker["If@Boolean", "rhope", 1, 2]
 	]Register Worker["Build", "rhope", 1, 1]
 	]Register Worker["Blueprint Of", "rhope", 1, 1]
 	]Register Worker["Call@Worker", "rhope", 1, 2] //We're using 2 because we need to assume that the outputs are conditional
+	]Register Worker["ID", "rhope", 1, 1]
 	]Register Number Methods
 	
-	out <- [[[[[registered]Bind Worker["If@Boolean",
+	out <- [[[[[[registered]Bind Worker["If@Boolean",
 		[[[[[NWorker["rhope"]
 		]Inputs <<[("condition")]
 		]Input Types <<[ [()]Append[Type Instance["Boolean"]] ]
@@ -1499,6 +1494,13 @@
 		]Outputs <<[("ret1","ret2")]
 		]Output Types <<[ [[()]Append[Type Instance["Any Type"]]]Append[Type Instance["Any Type"]] ]
 		]Builtin? << [Yes]]
+	]Bind Worker["ID",
+		[[[[[NWorker["rhope"]
+		]Inputs <<[("bp")]
+		]Input Types <<[ [()]Append[Type Instance["Blueprint"]]]
+		]Outputs <<[("id")]
+		]Output Types <<[ [()]Append[Type Instance["UInt32"]]]
+		]Builtin? << [Yes]]
 }
 
 Find Worker@NProgram[prog, name:out,notfound]
--- a/parser_old.rhope	Tue Jul 27 15:23:32 2010 -0400
+++ b/parser_old.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -318,7 +318,7 @@
 
 Add Param Wire[worker,param,input num,end index,blocks,parse worker,assignments:out]
 {
-	param worker, start index, output num <- [param]Add Wires[worker, blocks, parse worker, assignments] { Print["got param worker"] }
+	param worker, start index, output num <- [param]Add Wires[worker, blocks, parse worker, assignments] {}
 	{
 		out <- [param worker]Add Wire[start index, output num, end index, input num]
 	}{}{
@@ -634,11 +634,7 @@
 
 Add Wires@Literal Node[node,worker,blocks,parse worker,assignments:worker,index,num,unused]
 {
-	Print[["Add Wires@Literal Node, Literal Type: "]Append[Type Of[[node]Value >>]]]
 	worker,index,num <- Add Wires Literal or Global[node, worker, blocks, parse worker, assignments]
-	{ Print["Got worker"] }
-	{ Print["got index"] }
-	{ Print["got num"] }
 }
 
 Check Worker Literals@Literal Node[node,program:out]
@@ -1414,7 +1410,7 @@
 
 Register Workers Compile[prog, worker, name:out]
 {
-	Print[["Registering "]Append[name]]
+	//Print[["Registering "]Append[name]]
 	If[[ Type Of[[worker]Trees >>] ] = ["Foreign Lib"]]
 	{ convention <- Val[[[worker]Trees >>]Language >>] }
 	{ convention <- "rhope" }
@@ -1423,6 +1419,7 @@
 
 Add Workers Compile[prog, worker, name:out]
 {
+	Print[["Transforming "]Append[name]]
 		If[[Type Of[[worker]Trees >>]] = ["Foreign Lib"]]
 		{
 			//TODO: Handle foreign func
@@ -1434,20 +1431,9 @@
 			]Library <<[ [[worker]Trees >>]Name >> ]
 			
 		}{
-			Print[["Transforming "]Append[name]]
 			trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [[NWorker["rhope"]]Uses[[worker]Uses Stores >>]]Outputs <<[ [worker]Outputs >> ], prog, worker, Dictionary[]]
 			{
-				,proceed <- If[[name] = ["Main"]]
-				{ Print["Added Trees to worker"]
-				{ proceed <- Pretty Print[trees, ""] }}
-				Val[proceed]
-				{
 				final nworker <- Fold[[["Add Wires Helper"]Set Input[3, worker]]Set Input[4, refs], nworker, trees]
-				{
-					If[[name] = ["Main"]]
-					{ Print["Added wires to worker"] }
-				}
-				}
 			}
 			
 		}
--- a/runtime/blueprint.h	Tue Jul 27 15:23:32 2010 -0400
+++ b/runtime/blueprint.h	Tue Jul 27 23:33:31 2010 -0400
@@ -18,4 +18,8 @@
 	blueprint * bp;
 } lt_BlueprintSP_Of;
 
+typedef struct {
+	object * id;
+} lt_ID;
+
 #endif //BLUEPRINT_H_
--- a/string.rhope	Tue Jul 27 15:23:32 2010 -0400
+++ b/string.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -526,3 +526,36 @@
 }
 
 
+Dict Type ID@String[string:out]
+{
+	out <- ID[String()]
+}
+
+Dict Type ID@String Cat[string:out]
+{
+	out <- ID[String()]
+}
+
+Dict Type ID@String Slice[string:out]
+{
+	out <- ID[String()]
+}
+
+Dict Bits@String[string,index:out,invalid]
+{
+	,invalid <- [string]Byte[index]
+	{ out <- UInt32[~] }
+}
+
+Dict Bits@String Cat[string,index:out,invalid]
+{
+	,invalid <- [string]Byte[index]
+	{ out <- UInt32[~] }
+}
+
+Dict Bits@String Slice[string,index:out,invalid]
+{
+	,invalid <- [string]Byte[index]
+	{ out <- UInt32[~] }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdictsetget.rhope	Tue Jul 27 23:33:31 2010 -0400
@@ -0,0 +1,16 @@
+
+
+Main[]
+{
+	dict <- [[[[Dictionary[]
+	]Set["foo", "bar"]
+	]Set["bovine","moo"]
+	]Set["food", "fight"]
+	]Set["fool", "wise"]
+
+	Print[[dict]Index["food"]]
+	{ Print[[dict]Index["bovine"]]
+	{ Print[[dict]Index["foo"]]
+	{ Print[[dict]Index["fool"]] }}}
+}
+
--- a/todo.txt	Tue Jul 27 15:23:32 2010 -0400
+++ b/todo.txt	Tue Jul 27 23:33:31 2010 -0400
@@ -5,14 +5,13 @@
 
 Needed for compiler to be self-hosting:
 	Add support for List literals in compiler
-	Implement Dictionary
-	Implement File	
-	Add support for implicit conversions
+	Implement iteration support in Dictionary
 	Tweak extendlib to work with language changes introduced with compiler
 	Tweak compiler to work with language changes introduced with compiler
 
 Needed for web site to work in compiler:
 	Pretty much everything needed for the compiler to be self-hosting
+	Add support for implicit conversions
 	Implement Net Connection (or whatever the TCP connection type gets called)
 	Add support for multi-threaded execution in runtime (not strictly needed)
 	Add support for global stores to compiler/runtime
@@ -31,6 +30,7 @@
 	Support construction of new workers at runtime
 	Get a REPL working on the new stack
 	Flesh out ideas for having limited I/O within transactions
+	Proper implementation of File (fits in with the above)
 	Add module system
 	Exception support