# HG changeset patch # User Mike Pavone # Date 1308125908 25200 # Node ID ed322ae647383f6144ba9ae2ac94b03efd19fdff # Parent e57c151f351ebab8dfa44d02507c1c485b181ba8 Detect duplicates in conditions diff -r e57c151f351e -r ed322ae64738 backendutils_c.rhope --- a/backendutils_c.rhope Sun Jun 12 03:49:51 2011 -0700 +++ b/backendutils_c.rhope Wed Jun 15 01:18:28 2011 -0700 @@ -13,6 +13,30 @@ } } +Blueprint Make Op Res +{ + Func + Val +} + +Make Op Res[func,val:out] +{ + out <- [[Build[Make Op Res()]]Func <<[func]]Val <<[val] +} + +Make Op Mod[func,val:out func,out val] +{ + nval <- [val]Make Op[func] + If[[Blueprint Of[nval]]=[Make Op Res()]] + { + out func <- Func >>[nval] + out val <- Val >>[nval] + }{ + out func <- func + out val <- Val[nval] + } +} + Blueprint AddRef { Value @@ -33,6 +57,11 @@ out <- [[op]Value >>]Strip Addref } +=@AddRef[a,b(AddRef):out] +{ + out <- [[a]Value >>]==[[b]Value >>] +} + Make Op@String[string,func:out] { out <- [func]Resolve[string] @@ -78,26 +107,6 @@ out <- [func]Get Var Type[op] } -Make Op@Whole Number[num,func:out] -{ - out <- num -} - -Strip Addref@Whole Number[op:out] -{ - out <- op -} - -Make Op@Real Number[num,func:out] -{ - out <- num -} - -Strip Addref@Real Number[op:out] -{ - out <- op -} - Blueprint Output { Name @@ -118,6 +127,12 @@ out <- op } +=@Output[a,b(Output):out] +{ + out <- [[a]Name >>]=[[b]Name >>] +} + + Blueprint Constant { Value @@ -144,6 +159,11 @@ out <- [op]Need Addref <<[No] } +=@Constant[a,b(Constant):out] +{ + out <- [[a]Value >>]=[[b]Value >>] +} + Blueprint Result { Output Num @@ -164,6 +184,11 @@ out <- op } +=@Result[a,b(Result):out] +{ + out <- [[a]Output Num >>]=[[b]Output Num >>] +} + Blueprint Global Get { Store @@ -185,6 +210,14 @@ out <- get } +=@Global Get[a,b(Global Get):out] +{ + ,out <- If[[[a]Store >>]=[[b]Store >>]] + { + out <- [[a]Var >>]=[[b]Var >>] + } +} + Blueprint Check Result { Output Num @@ -215,6 +248,11 @@ } } +=@Check Result[a,b(Check Result):out] +{ + out <- [[a]Output Num >>]=[[b]Output Num >>] +} + Blueprint OrValue { Left @@ -223,7 +261,12 @@ OrValue[left,right:out] { - out <- [[Build[OrValue()]]Left <<[left]]Right <<[right] + If[[left]==[right]] + { + out <- left + }{ + out <- [[Build[OrValue()]]Left <<[left]]Right <<[right] + } } Make Op@OrValue[orval,func:out] @@ -236,6 +279,14 @@ out <- [[op]Left <<[ [[op]Left >>]Strip Addref ]]Right <<[ [[op]Right >>]Strip Addref ] } +=@OrValue[a,b(OrValue):out] +{ + ,out <- If[[[a]Left >>]==[[b]Left >>]] + { + out <- [[a]Right >>]==[[b]Right >>] + } +} + Blueprint Cast { Value @@ -257,6 +308,14 @@ out <- [op]Value <<[[[op]Value >>]Strip Addref] } +=@Cast[a,b(Cast):out] +{ + ,out <- If[[[a]Value >>] == [[b]Value >>]] + { + out <- [[a]Type >>]=[[b]Type >>] + } +} + Blueprint NotCond { Condition @@ -264,7 +323,12 @@ NotCond[cond:out] { - out <- [Build[NotCond()]]Condition <<[[cond]Strip Addref] + If[[Blueprint Of[cond]]=[NotCond()]] + { + out <- [cond]Condition >> + }{ + out <- [Build[NotCond()]]Condition <<[[cond]Strip Addref] + } } Make Op@NotCond[cond,func:out] @@ -277,6 +341,11 @@ out <- op } +=@NotCond[a,b(NotCond):out] +{ + out <- [[a]Condition >>]==[[b]Condition >>] +} + Blueprint OrCond { Condition1 @@ -285,7 +354,12 @@ OrCond[cond1,cond2:out] { - out <- [[Build[OrCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] + If[[cond1]==[cond2]] + { + out <- cond1 + }{ + out <- [[Build[OrCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] + } } Make Op@OrCond[cond,func:out] @@ -298,6 +372,14 @@ out <- op } +=@OrCond[a,b(OrCond):out] +{ + ,out <- If[[[a]Condition1 >>] == [[b]Condition1 >>]] + { + out <- [[a]Condition2 >>] == [[b]Condition2 >>] + } +} + Blueprint AndCond { Condition1 @@ -306,7 +388,12 @@ AndCond[cond1,cond2:out] { - out <- [[Build[AndCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] + If[[cond1]==[cond2]] + { + out <- cond1 + }{ + out <- [[Build[AndCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] + } } Make Op@AndCond[cond,func:out] @@ -319,6 +406,14 @@ out <- op } +=@AndCond[a,b(AndCond):out] +{ + ,out <- If[[[a]Condition1 >>] == [[b]Condition1 >>]] + { + out <- [[a]Condition2 >>] == [[b]Condition2 >>] + } +} + Blueprint Field Ref { Variable @@ -345,6 +440,14 @@ out <- op } +=@Field Ref[a,b(Field Ref):out] +{ + ,out <- If[[[a]Variable >>]==[[b]Variable >>]] + { + out <- [[a]Field >>]=[[b]Field >>] + } +} + Blueprint Type Instance { Name