view boolean.rhope @ 189:d0e3a13c1bd9 default tip

Remove old calculator example
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2011 00:24:04 -0700
parents ac5c2d78663f
children
line wrap: on
line source


Generate Boolean Methods[backend:out]
{
	func,inval <- [[[[[backend]Create Function["If@Boolean",("in"),("yes","no"),"rhope"]
		]Set Input Type[Type Instance["Boolean"], 0]
		]Set Output Type[Type Instance["Boolean"], 0]
		]Set Output Type[Type Instance["Boolean"], 1]
		]Read Field["in", "Val"]

	ifyes <- [[[func]Instruction Stream
		]Move["in","yes"]
		]Set Null["no"]

	ifno <- [[[func]Instruction Stream
		]Move["in","no"]
		]Set Null["yes"]

	ffunc <- [[func]Do If[inval, ifyes]
		]Do If[NotCond[inval], ifno]

	out <- [backend]Store Function[ffunc]
}

Compile Boolean Inline Check[func,op,type,in,outyes,outno:out,no inline]
{
	,no inline <- If[[op]=["If"]]
	{
		,no inline <- If[[[type]Name >>]=["Boolean"]]
		{
			ifyes <- [[func]Instruction Stream
			]Move[in, outyes]
			
			ifno <- [[func]Instruction Stream
			]Move[in, outno]
			
			,inval <- [func]Read Field[Cast[in, type] "Val"]
			{ 
				out <- [[~]Do If[inval, ifyes]
					]Do If[NotCond[inval], ifno]
			}
			
		}
	}
}