# HG changeset patch # User Mike Pavone # Date 1281073357 14400 # Node ID e09c2d1d6d5bae3edeb300e41da3d81923842ca7 # Parent a34a982ecd320a44b9f4365ee86cbe96d88d1dbd Got dataflow graph code working in compiler (nworker_c.rhope) diff -r a34a982ecd32 -r e09c2d1d6d5b backendutils_c.rhope --- a/backendutils_c.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/backendutils_c.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -39,6 +39,26 @@ out <- op } +Make Op@String Cat[string,func:out] +{ + out <- [func]Resolve[string] +} + +Strip Addref@String Cat[op:out] +{ + out <- op +} + +Make Op@String Slice[string,func:out] +{ + out <- [func]Resolve[string] +} + +Strip Addref@String Slice[op:out] +{ + out <- op +} + Make Op@Whole Number[num,func:out] { out <- num diff -r a34a982ecd32 -r e09c2d1d6d5b cbackend.rhope --- a/cbackend.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/cbackend.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -333,14 +333,14 @@ ]Set["Boolean", "TYPE_BOOLEAN"] //9 ]Set["Float32", "TYPE_FLOAT32"] //10 ]Set["Float64", "TYPE_FLOAT64"] //11 - ]Set["Real Number", "TYPE_FLOAT64"] //12 - ]Set["Blueprint", "TYPE_BLUEPRINT"] //13 - ]Set["Array", "TYPE_ARRAY"] //14 - ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//15 - ]Set["Worker", "TYPE_WORKER"] //16 - ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //17 - ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //18 - ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //19 + ]Set["Real Number", "TYPE_FLOAT64"] + ]Set["Blueprint", "TYPE_BLUEPRINT"] //12 + ]Set["Array", "TYPE_ARRAY"] //13 + ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//14 + ]Set["Worker", "TYPE_WORKER"] //15 + ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //16 + ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //17 + ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //18 ]Definitions << [Dictionary[]] ]Next ID <<[0] } @@ -1175,6 +1175,15 @@ out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ] } +_List Literal El[text,val,index,type reg:out] +{ + out <- [[[[text + ]Append[", "] + ]Append[index] + ]Append[", "] + ]Append[Const Construct C[val, type reg]] +} + Const Construct C[value,type reg:out] { valtype <- Type Of[value] @@ -1230,7 +1239,12 @@ ]Append[Fold[["+"]Set Input[0, 1], 0, [value]Args >>]] ]Append[")"] }{ - out <- "UnhandledLiteralType" + If[[valtype]=["List"]] + { + out <- [Fold[["_List Literal El"]Set Input[3, type reg], ["make_List("]Append[[value]Length], value]]Append[")"] + }{ + out <- "UnhandledLiteralType" + } } } } @@ -1273,6 +1287,7 @@ [[";\n\tinout[2] = " ]Append[Const Construct C[el, type reg]] ]Append[";\n"] + ]]]Append["\trhope(FUNC_Set, inout, 3, 3);\n"] } diff -r a34a982ecd32 -r e09c2d1d6d5b dict.rhope --- a/dict.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/dict.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -46,7 +46,12 @@ _Set@Empty Dictionary[dict,index,val,bits,bitindex:out] { - out <- _Set New[index,val,bits,bitindex] + If[[bits]=[0u32]] + { + out <- _Terminal Node[val] + }{ + out <- _Set New[index,val,bits,bitindex] + } } Set@Empty Dictionary[dict,index,val:out] @@ -67,13 +72,14 @@ Index@Dictionary[dict,index:out,not found] { + out,not found <- [dict]_Index[index,[Dict Type ID[index]]+[1u32], -1] } _Index@Dictionary[dict,index,bits,bitindex:out,not found] { If[[bits]=[[dict]Bits >>]] - { + { If[[bits]=[0u32]] { out <- Straight >>[dict] @@ -238,6 +244,21 @@ } } +_String Seq[str,val,key:out] +{ + out <- [[[[str + ]Append["\n\t"] + ]Append[String[key]] + ]Append[":\t"] + ]Append[String[val]] +} + + +String@Dictionary[dict:out] +{ + out <- Fold[_String Seq[?], "Dictionary", dict] +} + _Print Seq[dict,key:out] { val <- String[[dict]Index[key]] diff -r a34a982ecd32 -r e09c2d1d6d5b kernel.rhope --- a/kernel.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/kernel.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -16,6 +16,13 @@ Val(Int32,Naked) } +String@Boolean[b:out] +{ + If[b] + { out <- "Yes" } + { out <- "No" } +} + /* Blueprint Blueprint { @@ -208,9 +215,12 @@ Get Input@Worker[worker(Worker),bindex(Int32):val,not populated] { index <- [bindex]Trunc Int16 - ,not populated <- If[_internal_worker_hasinput[worker,index]] + ,not populated <- If[[index]<[[worker]Size >>]] { - val <- _internal_worker_getinput[worker,index] + ,not populated <- If[_internal_worker_hasinput[worker,index]] + { + val <- _internal_worker_getinput[worker,index] + } } } @@ -233,6 +243,9 @@ Set Input@Worker[worker(Worker),bindex(Int32),val:out(Worker)] { index <- [bindex]Trunc Int16 + [worker]Get Input[bindex] + { newcount <- Count >>[worker] } + { newcount <- [Count >>[worker]]+[1i16] } If[[index] < [[worker]Size >>]] { set <- _internal_worker_setinput[worker, index, val] @@ -243,7 +256,7 @@ , 0i16] , index, val] } - out <- [set]Count <<[ [[set]Count >>]+[1i16] ] + out <- [set]Count <<[newcount] } =@Blueprint[left,right:out] diff -r a34a982ecd32 -r e09c2d1d6d5b parser_old.rhope --- a/parser_old.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/parser_old.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -1029,7 +1029,7 @@ If[[before] = [""]] { Print[[["Found "]Append[delim]]Append[" where a named pipe or literal was expected"]] - { Print[["Near: "]Append[ [afterdelim]Slice[40]]] } + { Print[["Near: "]Append[ [afterdelim]Slice[80]]] } }{ If[[before]Contains[[params]Global Separator >>]] { @@ -1322,6 +1322,7 @@ { ,after arglist <- Worker Declaration[string, params] { + Print[worker name] worker name <- [~]Name >> body text, modifiers <- [after arglist]Get Comment DString[[params]Block Begin >>, params] modified <- Process Modifiers[~, params, modifiers] @@ -1509,6 +1510,7 @@ Do Import[tree,file name,unused,params:out] { + Print[["Parsing: "]Append[file name]] file <- #include #include +#include +#include void register_builtin_type(uint32_t type) { @@ -115,13 +117,32 @@ t_Boolean * b = (t_Boolean *)new_object(TYPE_BOOLEAN); b->Val = val != 0; return (object*)b; -} - -object * make_Worker(int32_t index, int16_t initialsize, int16_t initialcount) -{ - t_Worker * worker = (t_Worker *)_internal_worker_alloc(initialsize); - worker->payload.Index = index; - worker->payload.Count = initialcount; - return (object *)worker; +} + +object * make_Worker(int32_t index, int16_t initialsize, int16_t initialcount) +{ + t_Worker * worker = (t_Worker *)_internal_worker_alloc(initialsize); + worker->payload.Index = index; + worker->payload.Count = initialcount; + return (object *)worker; } +object * make_List(int32_t numels,...) +{ + int32_t idx, elidx; + object * inout[3]; + va_list args; + + va_start(args, numels); + rhope(FUNC_List, inout, 0, 1); + + for (idx = 0; idx < numels; ++idx) + { + elidx = va_arg(args, int32_t); + inout[1] = make_Int32(elidx); + inout[2] = va_arg(args, object *); + } + return inout[0]; +} + + diff -r a34a982ecd32 -r e09c2d1d6d5b string.rhope --- a/string.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/string.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -647,3 +647,35 @@ out <- [compare] = [ends with] } +If@String[str:yes,no] +{ + yes,no <- If[[str]Length] +} + +If@String Cat[str:yes,no] +{ + yes,no <- If[[str]Length] +} + +If@String Slice[str:yes,no] +{ + yes,no <- If[[str]Length] +} + +_Split[list,string,delim:out] +{ + ,,rest <- [string]Partition[delim] + { + out <- _Split[[list]Append[~], rest, delim] + } {} {} { + out <- [list]Append[string] + } +} + +Split[string,delim:out] +{ + If[string] + { out <- _Split[(),string,delim] } + { out <- () } +} + diff -r a34a982ecd32 -r e09c2d1d6d5b testdictsetget.rhope --- a/testdictsetget.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/testdictsetget.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -11,6 +11,12 @@ Print[[dict]Index["food"]] { Print[[dict]Index["bovine"]] { Print[[dict]Index["foo"]] - { Print[[dict]Index["fool"]] }}} + { Print[[dict]Index["fool"]] + { + Print[[[[Dictionary[] + ]Set["+@Foo", "bar"] + ]Set["+", "add"] + ]Index["+"]] + }}}} } diff -r a34a982ecd32 -r e09c2d1d6d5b testnworker.rhope --- a/testnworker.rhope Tue Aug 03 23:51:39 2010 -0400 +++ b/testnworker.rhope Fri Aug 06 01:42:37 2010 -0400 @@ -2,8 +2,8 @@ Test NWorker[:out] { - ref+ <- Worker Ref["+","rhope",2,1] - ref* <- Worker Ref["*","rhope",2,1] + ref+ <- Worker Ref["+","rhope",2,1,Yes] + ref* <- Worker Ref["*","rhope",2,1,Yes] ,a <- [NWorker["rhope"] ]Add Input["a", 0] { ,b <- [~]Add Input["b", 1] { @@ -22,7 +22,7 @@ Main[] { Print[ - [[[[NProgram]Register Builtins + [[[[NProgram[]]Register Builtins ]Bind Worker["Test", Test NWorker[]] ]Compile Program[C Program[]] ]Text