<commit_before>package wyc.util;

import java.io.*;
import java.util.*;

import wybs.lang.*;
import wybs.util.*;
import wyfs.lang.Content;
import wyfs.lang.Path;
import wyfs.util.DirectoryRoot;
import wyfs.util.JarFileRoot;
import wyfs.util.VirtualRoot;
import wyil.transforms.*;
import wyil.builders.Wyil2WyalBuilder;
import wyil.checks.*;
import wyc.builder.WhileyBuilder;
import wyc.lang.WhileyFile;
import wycc.lang.Pipeline;
import wycc.util.Logger;
import wycs.builders.Wyal2WycsBuilder;
import wycs.core.WycsFile;
import wycs.syntax.WyalFile;
import wycs.util.WycsBuildTask;
import wyil.io.WyilFilePrinter;
import wyil.lang.WyilFile;

/**
 * <p>
 * Provides a general-purpose implementation for compiling Whiley source files
 * into Wyil binary files. This is designed to make it easy to write compiler
 * variants, such as for supporting different back-ends (e.g. Java or
 * JavaScript) or for interfacing with other frameworks (e.g. Ant). This class
 * is designed to be extended by clients which are providing some kind of
 * compiler extension.
 * </p>
 * 
 * @author <NAME>
 * 
 */
public class WycBuildTask {
	
	/**
	 * The purpose of the source file filter is simply to ensure only source
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter whileyFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".whiley") || f.isDirectory();
		}
	};

	/**
	 * The purpose of the binary file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wyilFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyil") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wyal file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wyalFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyal") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wycs file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wycsFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wycs") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wyil or wycs file filter is simply to ensure only wycs
	 * or wyil files are loaded in a given directory root. It is not strictly
	 * necessary for correct operation, although hopefully it offers some
	 * performance benefits.
	 */
	public static final FileFilter wyilOrWycsFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyil") || f.getName().endsWith(".wycs") || f.isDirectory();
		}
	};
	
	/**
	 * Default implementation of a content registry. This associates whiley and
	 * wyil files with their respective content types.
	 * 
	 * @author <NAME>
	 * 
	 */
	public static class Registry implements Content.Registry {
		public void associate(Path.Entry e) {
			String suffix = e.suffix();
			
			if(suffix.equals("whiley")) {
				e.associate(WhileyFile.ContentType, null);
			} else if(suffix.equals("wyil")) {
				e.associate(WyilFile.ContentType, null);				
			} else if(suffix.equals("wyal")) {
				e.associate(WyalFile.ContentType, null);				
			} else if(suffix.equals("wycs")) {
				e.associate(WycsFile.ContentType, null);				
			} 
		}
		
		public String suffix(Content.Type<?> t) {
			if(t == WhileyFile.ContentType) {
				return "whiley";
			} else if(t == WyilFile.ContentType) {
				return "wyil";
			} else if(t == WyalFile.ContentType) {
				return "wyal";
			} else if(t == WycsFile.ContentType) {
				return "wycs";
			} else {
				return "dat";
			}
		}
	}
	
	public static final List<Pipeline.Template> defaultPipeline = Collections
			.unmodifiableList(new ArrayList<Pipeline.Template>() {
				{
					add(new Pipeline.Template(WyilFilePrinter.class,
					Collections.EMPTY_MAP));		
					add(new Pipeline.Template(DefiniteAssignmentCheck.class,
							Collections.EMPTY_MAP));
					add(new Pipeline.Template(ModuleCheck.class, Collections.EMPTY_MAP));
					add(new Pipeline.Template(RuntimeAssertions.class,
							Collections.EMPTY_MAP));
					add(new Pipeline.Template(BackPropagation.class,
							Collections.EMPTY_MAP));<commit_msg>WyC: disabled debugging output<commit_after>package wyc.util;

import java.io.*;
import java.util.*;

import wybs.lang.*;
import wybs.util.*;
import wyfs.lang.Content;
import wyfs.lang.Path;
import wyfs.util.DirectoryRoot;
import wyfs.util.JarFileRoot;
import wyfs.util.VirtualRoot;
import wyil.transforms.*;
import wyil.builders.Wyil2WyalBuilder;
import wyil.checks.*;
import wyc.builder.WhileyBuilder;
import wyc.lang.WhileyFile;
import wycc.lang.Pipeline;
import wycc.util.Logger;
import wycs.builders.Wyal2WycsBuilder;
import wycs.core.WycsFile;
import wycs.syntax.WyalFile;
import wycs.util.WycsBuildTask;
import wyil.io.WyilFilePrinter;
import wyil.lang.WyilFile;

/**
 * <p>
 * Provides a general-purpose implementation for compiling Whiley source files
 * into Wyil binary files. This is designed to make it easy to write compiler
 * variants, such as for supporting different back-ends (e.g. Java or
 * JavaScript) or for interfacing with other frameworks (e.g. Ant). This class
 * is designed to be extended by clients which are providing some kind of
 * compiler extension.
 * </p>
 * 
 * @author <NAME>
 * 
 */
public class WycBuildTask {
	
	/**
	 * The purpose of the source file filter is simply to ensure only source
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter whileyFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".whiley") || f.isDirectory();
		}
	};

	/**
	 * The purpose of the binary file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wyilFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyil") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wyal file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wyalFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyal") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wycs file filter is simply to ensure only binary
	 * files are loaded in a given directory root. It is not strictly necessary
	 * for correct operation, although hopefully it offers some performance
	 * benefits.
	 */
	public static final FileFilter wycsFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wycs") || f.isDirectory();
		}
	};
	
	/**
	 * The purpose of the wyil or wycs file filter is simply to ensure only wycs
	 * or wyil files are loaded in a given directory root. It is not strictly
	 * necessary for correct operation, although hopefully it offers some
	 * performance benefits.
	 */
	public static final FileFilter wyilOrWycsFileFilter = new FileFilter() {
		public boolean accept(File f) {
			return f.getName().endsWith(".wyil") || f.getName().endsWith(".wycs") || f.isDirectory();
		}
	};
	
	/**
	 * Default implementation of a content registry. This associates whiley and
	 * wyil files with their respective content types.
	 * 
	 * @author <NAME>
	 * 
	 */
	public static class Registry implements Content.Registry {
		public void associate(Path.Entry e) {
			String suffix = e.suffix();
			
			if(suffix.equals("whiley")) {
				e.associate(WhileyFile.ContentType, null);
			} else if(suffix.equals("wyil")) {
				e.associate(WyilFile.ContentType, null);				
			} else if(suffix.equals("wyal")) {
				e.associate(WyalFile.ContentType, null);				
			} else if(suffix.equals("wycs")) {
				e.associate(WycsFile.ContentType, null);				
			} 
		}
		
		public String suffix(Content.Type<?> t) {
			if(t == WhileyFile.ContentType) {
				return "whiley";
			} else if(t == WyilFile.ContentType) {
				return "wyil";
			} else if(t == WyalFile.ContentType) {
				return "wyal";
			} else if(t == WycsFile.ContentType) {
				return "wycs";
			} else {
				return "dat";
			}
		}
	}
	
	public static final List<Pipeline.Template> defaultPipeline = Collections
			.unmodifiableList(new ArrayList<Pipeline.Template>() {
				{
//					add(new Pipeline.Template(WyilFilePrinter.class,
//					Collections.EMPTY_MAP));		
					add(new Pipeline.Template(DefiniteAssignmentCheck.class,
							Collections.EMPTY_MAP));
					add(new Pipeline.Template(ModuleCheck.class, Collections.EMPTY_MAP));
					add(new Pipeline.Template(RuntimeAssertions.class,
							Collections.EMPTY_MAP));
					add(new Pipeline.Template(BackPropagation.class,
							Collections.EMPTY_MAP));
{'fraction_non_alphanumeric': 0.10588720486648108, 'fraction_numerical': 0.00041241365089184453, 'mean_word_length': 3.70873786407767, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5514972', 'n_tokens_mistral': 3202, 'n_tokens_neox': 2822, 'n_words': 928}