protected virtual void CreateEvaluators() { _evaluators.Clear(); if (ShowExpr == null) { return; } if (EnvironmentExt.IsUnix()) { // Ticket #86: temporarily disable it for Mono, because // RuntimeCompile.Compile() does not work there. return; } foreach (ExprFormatter spp in ShowExpr) { StringBuilder code = new StringBuilder(); code.Append("using System;\n"); code.Append("using System.Collections.Generic;\n"); code.Append("using ai.lib.algorithms.tree;\n"); code.Append("public unsafe class _Evaluator: ITextualizeTreeEval {\n"); code.Append(" public object Evaluate(object c, object oTree, object oStack, int d) {\n"); code.AppendFormat(" List<{0}> s = (List<{0}>)oStack;", _contextT); code.AppendFormat(" {0} t = ({0})oTree;", _treeT); code.AppendFormat(" return {0};\n", spp.Expr); code.Append("}}"); Assembly asm = RuntimeCompile.Compile(code.ToString(), _compilerParameters); Object evaluator = asm.CreateInstance("_Evaluator"); _evaluators[spp.Expr] = (ITextualizeTreeEval)evaluator; } }
public void Test_FillArray() { int size = 100000000; if (EnvironmentExt.IsUnix()) { size = 10000000; } FillArray(size, 1, 1, 2); FillArray(size, 1, 2, 2); FillArray(size, 1, 3, 2); FillArray(size, 1, 10, 2); FillArray(size, 1, 33, 2); FillArray(size, 2, 1, 2); FillArray(size, 2, 2, 1); FillArray(size, 2, 3, 1); FillArray(size, 2, 10, 2); FillArray(size, 2, 33, 2); FillArray(size, 3, 1, 2); FillArray(size, 3, 2, 1); FillArray(size, 3, 3, 1); FillArray(size, 3, 4, 2); FillArray(size, 3, 10, 2); FillArray(size, 3, 33, 2); FillArray(size, 23, 23, 2); FillArray(size, 23, 39, 2); }
public void Test_Stress() { int size = 100000000; if (EnvironmentExt.IsUnix()) { size = 10000000; } FillArray(size, 11, 23, 100); }
public static string GetTestResourcesPath() { string subdirName = Path.GetFileNameWithoutExtension(CodeBase.Get(Assembly.GetExecutingAssembly())); string testResourcesPath = Path.Combine(Path.GetDirectoryName(CodeBase.Get()), ".."); if (EnvironmentExt.IsUnix() && !Path.IsPathRooted(testResourcesPath)) { // Fix for mono under linux, it returns a path from root, but without '/' at the // beginning. testResourcesPath = '/' + testResourcesPath; } testResourcesPath = Path.Combine(testResourcesPath, "test"); testResourcesPath = Path.Combine(testResourcesPath, subdirName); return(testResourcesPath); }