changeset 20:b715532225c0

Differentiate between method and normal calls in dataflow graph compiler
author Mike Pavone <pavone@retrodev.com>
date Wed, 27 May 2009 21:42:37 -0400
parents 90c20dc3f4e5
children e9272f7ebd26
files cbackend.rhope nworker.rhope
diffstat 2 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/cbackend.rhope	Wed May 27 21:29:15 2009 +0000
+++ b/cbackend.rhope	Wed May 27 21:42:37 2009 -0400
@@ -52,9 +52,9 @@
 	}
 }
 
-Method ID@C Method Registry[reg,method:out]
+Method ID@C Method Registry[reg,method:out,notfound]
 {
-	out <- [[reg]Lookup >>]Index[method]
+	out,notfound <- [[reg]Lookup >>]Index[method]
 }
 
 Blueprint C Function
@@ -322,6 +322,11 @@
 	out <- [program]Functions <<[ [[program]Functions >>]Set[ [func]Name >>, func] ]
 }
 
+Method?@C Program[program,funcname:is,isnot]
+{
+	is,isnot <- [[program]Method Registry >>]Method ID[funcname]
+}
+
 _Defs C Program[text,func:out]
 {
 	Print["start _Defs"]
--- a/nworker.rhope	Wed May 27 21:29:15 2009 +0000
+++ b/nworker.rhope	Wed May 27 21:42:37 2009 -0400
@@ -1,4 +1,5 @@
 Import extendlib.rhope
+Import cbackend.rhope
 
 Set@Range[range,index,val:out]
 {
@@ -249,16 +250,22 @@
 
 Compile Node@NWorker[worker,program,func,nodes,current:out]
 {
+	Print[[node]Type >>]
 	node <- [[worker]Nodes >>]Index[[nodes]Index[current]]
-	If[[[node]Type >>] = [""]]
+	If[[[node]Type >>] = ["call"]]
 	{
-		nfunc <- [func]Call[[[node]Data >>]Name >>, ()]
+		[program]Method?[[[node]Data >>]Name >>]
+		{
+			nfunc <- [func]Method Call[[[node]Data >>]Name >>, ()]
+		}{
+			nfunc <- [func]Call[[[node]Data >>]Name >>, ()]
+		}
 	}{
 		nfunc <- Val[func]
 	}
 	[nodes]Next[current]
 	{
-		out <- [worker]Compile Node[program,func,nodes,~]
+		out <- [worker]Compile Node[program,nfunc,nodes,~]
 	}{
 		out <- Val[nfunc]
 	}
@@ -275,7 +282,7 @@
 	}
 	[groups]Next[current]
 	{
-		out <- [worker]Compile Group[program,func,groups,~]
+		out <- [worker]Compile Group[program,nfunc,groups,~]
 	}{
 		out <- Val[nfunc]
 	}
@@ -291,7 +298,7 @@
 	}{
 		final func <- Val[func]
 	}
-	out <- [program]Store Function[func]
+	out <- [program]Store Function[final func]
 }
 
 Test[:out]
@@ -312,3 +319,13 @@
 		]Add Wire[call*,0,outref,0]
 	}}}}}}
 }
+
+Test Compile[:out]
+{
+	out <- [Test[]]Compile Worker[C Program[] "Test"]
+}
+
+Main[]
+{
+	Pretty Print[Test Compile[], ""]
+}