diff cbackend.rhope @ 2:73e978d590c7

Adding WIP compiler code
author Mike Pavone <pavone@retrodev.com>
date Wed, 29 Apr 2009 02:58:03 -0400
parents
children 31f8182f3433
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbackend.rhope	Wed Apr 29 02:58:03 2009 -0400
@@ -0,0 +1,84 @@
+
+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]
+{
+	
+}
\ No newline at end of file