view cbackend.rhope @ 8:8d74ef7fa357

Improved helper macros and added separate Rhope stack in runtime
author Mike Pavone <pavone@retrodev.com>
date Wed, 13 May 2009 23:37:19 -0400
parents 73e978d590c7
children 31f8182f3433
line wrap: on
line source


Blueprint Blueprint Def
{
	Name
	Fixed Size
	Fields
	Methods
}

Blueprint Def[name]
{
	out <- [[[[Build["Blueprint Def"]]Name <<[name]]Fixed Size <<[0]]Fields <<[()]]Methods <<[New@Dictionary[]]
}

Blueprint C Function
{
	Name
	Inputs
	Outputs
	Convention
	Variables
	Statements
}

C Function[name,inputs,outputs,convention:out]
{
	out <- [[[[[[Build["C Function"]
		]Name <<[name]
		]Inputs <<[inputs]
		]Outputs <<[outputs]
		]Convention <<[convention]
		]Variables <<[New@Dictionary[]]
		]Statements <<[()]
}

Allocate Var@C Function[func,name,type:out]
{
	out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ]
}

Add Statement@C Function[func,statement:out]
{
	out <- [func]Statements <<[ [[func]Statements >>]Append[[statement]Append[";"]] ]
}

Add Operator Statement@C Function[func,source1,source2,dest,op:out]
{
	out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]]
}

Add@C Function[func,source1,source2,dest:out]
{
	out <- [func]Add Operator Statement[source1,source2,dest," + "]
}

Sub@C Function[func,source1,source2,dest:out]
{
	out <- [func]Add Operator Statement[source1,source2,dest," - "]
}

Multiply@C Function[func,source1,source2,dest:out]
{
	out <- [func]Add Operator Statement[source1,source2,dest," * "]
}

Divide@C Function[func,source1,source2,dest:out]
{
	out <- [func]Add Operator Statement[source1,source2,dest," / "]
}

Move@C Function[func,source,dest:out]
{
	out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]]
}

Definitions@C Function[func:out]
{
	
}

Text@C Function[func:out]
{
	
}