using NUnit.Framework; using System.Collections.Generic; using System.Linq; namespace Obfuz.Virtualization { public abstract class FunctionBase : IFunction { public abstract DataNodeType ReturnType { get; } public abstract void CreateArguments(DataNodeType type, object value, CreateExpressionOptions options, List args); public ConstExpression CreateCallable(DataNodeType type, object value, CreateExpressionOptions options) { var args = new List(); CreateArguments(type, value, options, args); options.depth += 1; var argNodes = new List(); foreach (ConstValue cv in args) { var argNode = options.expressionCreator.CreateRandom(cv.type, cv.value, options); argNodes.Add(argNode); } return new ConstExpression(this, args.Select(a => options.expressionCreator.CreateRandom(a.type, a.value, options)).ToList(), new ConstValue(type, value)); } } }