view backendutils.rhope @ 18:ea991f95ae1f

C backend working well enough to generate Fib test
author Mike Pavone <pavone@retrodev.com>
date Wed, 27 May 2009 04:49:32 -0400
parents 23dd9c766699
children e9272f7ebd26
line wrap: on
line source


Escape Rhope Name[name:escaped]
{
	escaped <- [[[[[[[[[[[name]Replace["_","__"]
		]Replace["@","_AT_"]
		]Replace[" ","_SP_"]
		]Replace[":","_CN_"]
		]Replace["?","_QN_"]
		]Replace["+","_PL_"]
		]Replace["-","_MN_"]
		]Replace["*","_TM_"]
		]Replace["/","_DV_"]
		]Replace["<","_LT_"]
		]Replace["<","_GT_"]
}

Blueprint AddRef
{
	Value
}

AddRef[value:out]
{
	out <- [Build["AddRef"]]Value <<[value]
}

Make Op@AddRef[addref,func:out]
{
	//TODO: Make me work with other backends
	out <- [["add_ref("]Append[ [[addref]Value >>]Make Op[func] ]]Append[")"]
}

Make Op@String[string,func:out]
{
	out <- [func]Resolve[string]
}

Make Op@Whole Number[num,func:out]
{
	out <- num
}

Make Op@Real Number[num,func:out]
{
	out <- num
}

Blueprint Constant
{
	Var
}

Constant[var:out]
{
	out <- [Build["Constant"]]Var <<[var]
}

Make Op@Constant[const,func:out]
{
	out <- [const]Var >>
}

Blueprint Result
{
	Output Num
}

Result[num:out]
{
	out <- [Build["Result"]]Output Num <<[num]
}

Make Op@Result[result,func:out]
{
	out <- [func]Result Reference[[result]Output Num>>]
}

Blueprint NotCond
{
	Condition
}

NotCond[cond:out]
{
	out <- [Build["NotCond"]]Condition <<[cond]
}

Make Op@NotCond[cond,func:out]
{
	out <- ["!"]Append[[[cond]Condition >>]Make Op[func]]
}