<commit_before>package greed.code;

import com.floreysoft.jmte.Engine;
import com.floreysoft.jmte.NamedRenderer;
import com.floreysoft.jmte.RenderFormatInfo;
import com.floreysoft.jmte.Renderer;
import greed.model.Param;
import greed.model.ParamValue;
import greed.model.Primitive;
import greed.model.Type;

import java.util.Locale;

/**
 * Greed is good! Cheers!
 */
public class CSharpRenderer extends CppRenderer {
	public static CSharpRenderer instance = new CSharpRenderer();

	protected CSharpRenderer() { super(); }

	public void registerSelf(Engine engine) {
		super.registerSelf(engine);
		engine.registerRenderer(Primitive.class, new Renderer<Primitive>() {
			@Override
			public String render(Primitive primitive, Locale locale) {
				return renderPrimitive(primitive);
			}
		});
		engine.registerRenderer(Type.class, new Renderer<Type>() {
			@Override
			public String render(Type type, Locale locale) {
				return renderType(type);
			}
		});
		engine.registerRenderer(Param[].class, new Renderer<Param[]>() {
			@Override
			public String render(Param[] params, Locale locale) {
				StringBuffer buf = new StringBuffer();
				for (int i = 0; i < params.length; ++i) {
					if (i > 0) buf.append(", ");
					buf.append(renderParam(params[i]));
				}
				return buf.toString();
			}
		});
		engine.registerNamedRenderer(new NamedRenderer() {
			@Override
			public String render(Object o, String s, Locale locale) {
				if (o instanceof Type) {
					Type t = (Type)o;
					if (t.isArray()) return "new " + renderPrimitive(t.getPrimitive()) + "[] { }";
					switch (t.getPrimitive()) {
						case BOOL: return "false";
						case STRING: return "\"\"";
						case INT:case LONG: return "0";
						case DOUBLE: return "0.0";
					}
				}
				return "";
			}

			@Override
			public String getName() {
				return "ZeroValue";
			}

			@Override
			public RenderFormatInfo getFormatInfo() {
				return null;
			}

			@Override
			public Class<?>[] getSupportedClasses() {
				return new Class<?>[] { Type.class };
			}
		});
	}

	@Override
	protected String renderPrimitive(Primitive o) {
		switch (o) {
			case LONG: return "long";
			default: return super.renderPrimitive(o);
		}
	}

	@Override
	protected String renderType(Type o) {
		String typeName = renderPrimitive(o.getPrimitive());
		if (o.isArray()) typeName += "[]";
		return typeName;
	}

	@Override
	protected String renderParamValue(ParamValue o) {
		Type paramType = o.getParam().getType();
		String value = o.getValue();
		if (paramType.isArray()) {
			return value;
		}

		switch (paramType.getPrimitive()) {
			case STRING: value = "\"" + value + "\""; break;
            case LONG: value += "L"; break;
		}
		return value;
	}
}<commit_msg>- [bugfix] fix the same bug about "" in input, in C# version<commit_after>package greed.code;

import com.floreysoft.jmte.Engine;
import com.floreysoft.jmte.NamedRenderer;
import com.floreysoft.jmte.RenderFormatInfo;
import com.floreysoft.jmte.Renderer;
import greed.model.Param;
import greed.model.ParamValue;
import greed.model.Primitive;
import greed.model.Type;

import java.util.Locale;

/**
 * Greed is good! Cheers!
 */
public class CSharpRenderer extends CppRenderer {
	public static CSharpRenderer instance = new CSharpRenderer();

	protected CSharpRenderer() { super(); }

	public void registerSelf(Engine engine) {
		super.registerSelf(engine);
		engine.registerRenderer(Primitive.class, new Renderer<Primitive>() {
			@Override
			public String render(Primitive primitive, Locale locale) {
				return renderPrimitive(primitive);
			}
		});
		engine.registerRenderer(Type.class, new Renderer<Type>() {
			@Override
			public String render(Type type, Locale locale) {
				return renderType(type);
			}
		});
		engine.registerRenderer(Param[].class, new Renderer<Param[]>() {
			@Override
			public String render(Param[] params, Locale locale) {
				StringBuffer buf = new StringBuffer();
				for (int i = 0; i < params.length; ++i) {
					if (i > 0) buf.append(", ");
					buf.append(renderParam(params[i]));
				}
				return buf.toString();
			}
		});
		engine.registerNamedRenderer(new NamedRenderer() {
			@Override
			public String render(Object o, String s, Locale locale) {
				if (o instanceof Type) {
					Type t = (Type)o;
					if (t.isArray()) return "new " + renderPrimitive(t.getPrimitive()) + "[] { }";
					switch (t.getPrimitive()) {
						case BOOL: return "false";
						case STRING: return "\"\"";
						case INT:case LONG: return "0";
						case DOUBLE: return "0.0";
					}
				}
				return "";
			}

			@Override
			public String getName() {
				return "ZeroValue";
			}

			@Override
			public RenderFormatInfo getFormatInfo() {
				return null;
			}

			@Override
			public Class<?>[] getSupportedClasses() {
				return new Class<?>[] { Type.class };
			}
		});
	}

	@Override
	protected String renderPrimitive(Primitive o) {
		switch (o) {
			case LONG: return "long";
			default: return super.renderPrimitive(o);
		}
	}

	@Override
	protected String renderType(Type o) {
		String typeName = renderPrimitive(o.getPrimitive());
		if (o.isArray()) typeName += "[]";
		return typeName;
	}

	@Override
	protected String renderParamValue(ParamValue o) {
		Type paramType = o.getParam().getType();
		String value = o.getValue();
		if (paramType.isArray()) {
			return value;
		}

		switch (paramType.getPrimitive()) {
            case LONG: value += "L"; break;
		}
		return value;
	}
}
{'fraction_non_alphanumeric': 0.13675685624884962, 'fraction_numerical': 0.0018406037180195105, 'mean_word_length': 3.524562864279767, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6710284', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1717, 'n_words': 432}