view testc.rhope @ 13:23dd9c766699

C backend close to being useable
author mpavone@
date Tue, 26 May 2009 23:49:46 +0000
parents 69dfca29565f
children ea991f95ae1f
line wrap: on
line source

Import cbackend.rhope

Main[]
{
	base <- [[[[[[C Function["Fib",("n"),("out"),""]
		]Allocate Var["work1", "Any Type"]
		]Allocate Var["work2", "Any Type"]
		]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"]}

	stream2 <- [[[[[[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"]
	{Print["stream2 done"]}

	func <- [[base
		]Do If[Result[0], stream1]
		]Do If[Result[1], stream2]
	{Print["func done"] }
		
	Print[[func]Definitions]
	{
	Print[[func]Text] }
}

Foo[]
{
}