view boolean.rhope @ 179:64be565a40c6

Implement If method on List, fix Get Char to handle end of file, fix nested list pretty printing
author Mike Pavone <pavone@retrodev.com>
date Sat, 18 Jun 2011 11:11:58 -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]
			}
			
		}
	}
}