<commit_before>// ----------------------------------------------------------------------
//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 Feb 8, 2005
 */
package org.globus.cog.karajan.compiled.nodes;

import java.util.LinkedList;

import k.rt.ExecutionException;
import k.rt.Stack;
import k.thr.LWThread;

import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.CompilationException;
import org.globus.cog.karajan.analyzer.CompilerSettings;
import org.globus.cog.karajan.analyzer.Scope;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.analyzer.Var;
import org.globus.cog.karajan.parser.WrapperNode;

public class ChannelTo extends InternalFunction {
	private ChannelRef<Object> dst;
	private ChannelRef<Object> c_vargs;
	private String name;
	private Node body;
	
	@Override
	protected Signature getSignature() {
		return new Signature(params(identifier("name"), block("body")));
	}
	
	@Override
	protected void runBody(LWThread thr) {
		if (body != null) {
			if (CompilerSettings.PERFORMANCE_COUNTERS) {
				startCount++;
			}
			body.run(thr);
		}
	}

	@Override
	public Node compile(WrapperNode w, Scope scope) throws CompilationException {
		return super.compile(w, scope);
	}
	
	

	@Override
	public void run(LWThread thr) {
		super.run(thr);
	}

	@Override
	protected void compileBlocks(WrapperNode w, Signature sig, LinkedList<WrapperNode> blocks,
			Scope scope) throws CompilationException {
		Var.Channel cdst = scope.parent.lookupChannel(name, this);
		Var.Channel csrc = scope.addChannel("...");
		c_vargs = new ChannelRef.Redirect<Object>("...", csrc.getIndex(), cdst.getIndex());
		csrc.setValue(cdst.getValue());
		super.compileBlocks(w, sig, blocks, scope);
	}

	@Override
	protected void initializeArgs(Stack stack) {
		try {
			c_vargs.create(stack);
		}
		catch (RuntimeException e) {
			throw new ExecutionException(this, e);
		}
	}
}<commit_msg>don't compile if everything is known at compile-time<commit_after>// ----------------------------------------------------------------------
//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 Feb 8, 2005
 */
package org.globus.cog.karajan.compiled.nodes;

import java.util.LinkedList;

import k.rt.ExecutionException;
import k.rt.Stack;
import k.thr.LWThread;

import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.CompilationException;
import org.globus.cog.karajan.analyzer.CompilerSettings;
import org.globus.cog.karajan.analyzer.Scope;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.analyzer.Var;
import org.globus.cog.karajan.parser.WrapperNode;

public class ChannelTo extends InternalFunction {
	private ChannelRef<Object> dst;
	private ChannelRef<Object> c_vargs;
	private String name;
	private Node body;
	
	@Override
	protected Signature getSignature() {
		return new Signature(params(identifier("name"), block("body")));
	}
	
	@Override
	protected void runBody(LWThread thr) {
		if (body != null) {
			if (CompilerSettings.PERFORMANCE_COUNTERS) {
				startCount++;
			}
			body.run(thr);
		}
	}

	@Override
	public Node compile(WrapperNode w, Scope scope) throws CompilationException {
		Node n = super.compile(w, scope);
		if (c_vargs == null) {
			return null;
		}
		else {
			return n;
		}
	}
	
	@Override
	protected void compileBlocks(WrapperNode w, Signature sig, LinkedList<WrapperNode> blocks,
			Scope scope) throws CompilationException {
		Var.Channel cdst = scope.parent.lookupChannel(name, this);
		Var.Channel csrc = scope.addChannel("...");
		csrc.setValue(cdst.getValue());
		super.compileBlocks(w, sig, blocks, scope);
		if (csrc.isDynamic()) {
			c_vargs = new ChannelRef.Redirect<Object>("...", csrc.getIndex(), scope.parent.getChannelRef(cdst));
		}
	}

	@Override
	protected void initializeArgs(Stack stack) {
		try {
			c_vargs.create(stack);
		}
		catch (RuntimeException e) {
			throw new ExecutionException(this, e);
		}
	}
}
{'fraction_non_alphanumeric': 0.17533499886441062, 'fraction_numerical': 0.0022711787417669773, 'mean_word_length': 3.206303724928367, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3024029', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1357, 'n_words': 330}