Mercurial > repos > rhope
view testc_c.rhope @ 121:1af91ceaaf49
Fixed memory leak when an output is only attached to a single null input
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:04:12 -0400 |
parents | 5a08705f7610 |
children |
line wrap: on
line source
Import cbackend_c.rhope Import number_c.rhope Import boolean.rhope //Dummy versions of nworker methods so the code in number_c.rhope will compile Register Worker[prog,name,convention,inputs,outputs:out] { out <- prog } Bind Worker[prog,name,worker:out] { out <- prog } Blueprint NWorker { Inputs Input Types Outputs Output Types Builtin? } NWorker[convention:out] { out <- convention } Main[] { prog <- [[C Program[]]Generate Number Methods]Generate Boolean Methods base <- [[[[[[[[[prog]Create Function["Fib",("n"),("out"),"rhope"] ]Allocate Var["work1", Type Instance["Any Type"]] ]Allocate Var["work2", Type Instance["Any Type"]] ]Register Constant["const_1", 1] ]Register Constant["const_2", 2] ]Set Null["out"] ]Method Call["<", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] ]Move[Result[0], "work1"] ]Method Call["If", [()]Append["work1"]] {Print["base done"] } stream1 <- [[[base]Instruction Stream ]Release[Result[0]] ]Move[AddRef[Constant["const_1"]], "out"] {Print["stream1 done"]} [[[[[[[[[[base]Instruction Stream ]Release[Result[0]] ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_1"]]]] ]Move[Result[0], "work1"] ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] ]Move[Result[0], "work2"] ]Call["Fib", ("work1")] ]Move[Result[0], "work1"] ]Call["Fib", ("work2")] ]Move[Result[0], "work2"] { stream3 <- [[[~]Instruction Stream ]Release["n"] ]Method Call["+", ("work1","work2")] stream2 <- [~]Do If[NotCond["out"], stream3] {Print["stream2 done"]} } func <- [[[base ]Do If[Result[0], stream1] ]Do If[Result[1], stream2] ]Release["n"] {Print["func done"] } main <- [[[[prog]Create Function["Main", (), ("out"), "rhope"] ]Register Constant["const_30", 30] ]Call["Fib", [()]Append[Constant["const_30"]]] ]Move[Result[0], "out"] text <- [[[prog]Store Function[func] ]Store Function[main] ]Text Print[[text]Length] { Print[text] } }