Mercurial > repos > rhope
changeset 88:f69987c58fa8
Merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 30 Jul 2010 19:52:54 -0400 |
parents | 3c4325e6298f (diff) a163250b8885 (current diff) |
children | 5a195ee08eac |
files | cbackend.rhope |
diffstat | 7 files changed, 110 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/cbackend.rhope Fri Jul 30 23:49:39 2010 +0000 +++ b/cbackend.rhope Fri Jul 30 19:52:54 2010 -0400 @@ -1339,12 +1339,12 @@ { out <- [[[[["typedef enum {\n" ]Append[Fold["_Dispatch Enum", - [Fold["_Dispatch Enum Methods", "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n"], + [Fold["_Dispatch Enum Methods", "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n"], [program]Functions >>]] ]Append["\tEND\n} funcids;\n\n"] ]Append["#define DispatchEntries \\\n"] ]Append[Fold["_Dispatch Switch", - [Fold["_Dispatch Switch Methods", "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n"], + [Fold["_Dispatch Switch Methods", "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n"], [program]Functions >>]] ]Append["\tEndEntry\n\n"] } @@ -1442,7 +1442,8 @@ DispatchVar FuncDef(Build) FuncDef(BlueprintSP_Of) - FuncDef(ID)\n"] + FuncDef(ID) + FuncDef(BlueprintSP_FromSP_ID)\n"] ]Append[Fold["Local Pointers", "", [program]Functions >>]] ]Append[" ct = new_context(); @@ -1486,6 +1487,24 @@ release_ref(cdata->params[0]); Ret(0, lv_ID->id) EndFunc(ID) +DISPATCH + +Func(BlueprintSP_FromSP_ID, NumParams 1) + + Param(0, TYPE_UINT32) + + lv_BlueprintSP_FromSP_ID->type = ((t_UInt32 *)cdata->params[0])->Num; + if (lv_BlueprintSP_FromSP_ID->type >= max_registered_type || !registered_types[lv_BlueprintSP_FromSP_ID->type]) { + Ret(1, cdata->params[0]) + Ret(0, NULL) + } else { + release_ref(cdata->params[0]); + Ret(0, new_object(TYPE_BLUEPRINT)) + ((t_Blueprint *)cdata->params[0])->bp = registered_types[lv_BlueprintSP_FromSP_ID->type]; + Ret(1, NULL) + } + +EndFunc(BlueprintSP_FromSP_ID) DISPATCH\n"] ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Native"]]] ]Append["
--- a/dict.rhope Fri Jul 30 23:49:39 2010 +0000 +++ b/dict.rhope Fri Jul 30 19:52:54 2010 -0400 @@ -86,10 +86,9 @@ }{ If[[bits]<[[dict]Bits >>]] { + go <- Left >>[dict] + }{ go <- Right >>[dict] - - }{ - go <- Left >>[dict] } out,not found <- [go]_Index[index,bits,bitindex] } @@ -116,14 +115,56 @@ }{ If[[bits]<[[dict]Bits >>]] { + go <- Left >>[dict] + out <- [dict]Left <<[new] + }{ go <- Right >>[dict] out <- [dict]Right <<[new] - - }{ - go <- Left >>[dict] - out <- [dict]Left <<[new] } new <- [go]_Set[index,val,bits,bitindex] } } +_First Type ID@Empty Dictionary[dict:typeid,node,none] +{ + none <- dict +} + +_First Type ID@Dictionary[dict:typeid,node] +{ + typeid,node <- [[dict]Left >>]_First Type ID {} {} + { + typeid <- [dict]Bits >> + node <- dict + } +} + +_First@Empty Dictionary[dict,keylist:keyout,none] +{ + none <- dict +} + +_First@Dictionary[dict,keylist:keyout] +{ + keyout <- [[dict]Left >>]_First[keylist] {} + { + If[[[dict]Bits >>] = [4294967295u32]] + { + keyout <- keylist + }{ + keyout <- [[dict]Straight >>]_First[[keylist]Append[[dict]Bits >>]] + } + } +} + +First@Dictionary[dict:out,none] +{ + typeid, node <- [dict]_First Type ID + l <- List[] + rawkey <- [[node]Left >>]_First[l] {} + { + rawkey <- [[node]Straight >>]_First[l] + } + out <- [Build[Blueprint From ID[typeid]]]From Dict Key[rawkey] +} +
--- a/nworker.rhope Fri Jul 30 23:49:39 2010 +0000 +++ b/nworker.rhope Fri Jul 30 19:52:54 2010 -0400 @@ -1451,15 +1451,16 @@ 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 Worker["Blueprint From ID", "rhope", 1, 2] ]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"]] ] @@ -1501,6 +1502,13 @@ ]Outputs <<[("id")] ]Output Types <<[ [()]Append[Type Instance["UInt32"]]] ]Builtin? << [Yes]] + ]Bind Worker["Blueprint From ID", + [[[[[NWorker["rhope"] + ]Inputs <<[("id")] + ]Input Types <<[ [()]Append[Type Instance["UInt32"]]] + ]Outputs <<[("bp","none")] + ]Output Types <<[ [[()]Append[Type Instance["Blueprint"]]]Append[Type Instance["Any Type"]]] + ]Builtin? << [Yes]] } Find Worker@NProgram[prog, name:out,notfound]
--- a/runtime/blueprint.h Fri Jul 30 23:49:39 2010 +0000 +++ b/runtime/blueprint.h Fri Jul 30 19:52:54 2010 -0400 @@ -22,4 +22,8 @@ object * id; } lt_ID; +typedef struct { + uint32_t type; +} lt_BlueprintSP_FromSP_ID; + #endif //BLUEPRINT_H_
--- a/runtime/object.h Fri Jul 30 23:49:39 2010 +0000 +++ b/runtime/object.h Fri Jul 30 19:52:54 2010 -0400 @@ -83,6 +83,9 @@ returntype coerce_value(uint32_t type, calldata * params); blueprint * get_blueprint_byid(uint32_t type); +extern blueprint ** registered_types; +extern uint32_t max_registered_type; + #define INITIAL_TYPE_STORAGE 32 #define INITIAL_METHOD_LOOKUP 8 #define BELOW_INITIAL_METHOD 3
--- a/string.rhope Fri Jul 30 23:49:39 2010 +0000 +++ b/string.rhope Fri Jul 30 19:52:54 2010 -0400 @@ -559,3 +559,13 @@ { out <- UInt32[~] } } +_From Dict String[arr,el:out] +{ + out <- [arr]Append[Trunc UInt8[el]] +} + +From Dict Key@String[string,data:out] +{ + out <- String[Fold[_From Dict String[?], Array[], data]] +} +