//----------------------------------------------------------------------
//This code is developed as part of the Java CoG Kit project
//The terms of the license can be found at http://www.cogkit.org/license
//This message may not be removed or altered.
//----------------------------------------------------------------------

/*
 * Created on Dec 18, 2012
 */
package org.globus.cog.karajan.compiled.nodes.functions;

import org.globus.cog.karajan.analyzer.CompilationException;
import org.globus.cog.karajan.analyzer.Param;
import org.globus.cog.karajan.analyzer.Scope;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.compiled.nodes.Node;
import org.globus.cog.karajan.parser.WrapperNode;



public abstract class AbstractSingleValuedFunction extends AbstractFunction {

	protected final Signature getSignature() {
		return new Signature(getParams());
	}

	@Override
	protected Node compileBody(WrapperNode w, Scope argScope, Scope scope)
			throws CompilationException {
		scope.lookupChannel("...").appendDynamic();
		return super.compileBody(w, argScope, scope);
	}


	protected abstract Param[] getParams();
}

@@ -813,14 +813,8 @@
 ted 
-final 
 Sign
@@ -836,16 +836,16 @@
 ure() %7B%0A
+
 %09%09return
@@ -877,16 +877,287 @@
 ));%0A%09%7D%0A%0A
+%09@Override%0A%09protected void resolveChannelReturns(WrapperNode w, Signature sig, Scope scope)%0A%09%09%09throws CompilationException %7B%0A%09    if (sig.getChannelReturns().isEmpty()) %7B%0A%09        sig.addReturn(channel(%22...%22, 1));%0A%09    %7D%0A%09%09super.resolveChannelReturns(w, sig, scope);%0A%09%7D%0A%0A
 %09@Overri
@@ -1378,36 +1378,94 @@
 ted 
-abstract Param%5B%5D getParams();
+Param%5B%5D getParams() %7B%0A%09    throw new RuntimeException(%22Default getParams() called%22);%0A%09%7D
 %0A%7D%0A

allow signatures that don't explicitly mention returns (and do the work for them)