private static IEvaluable CreateUnaryChild(IEvaluable active, Operators op, Func <object, object> evaluate) { UnaryScope <Operators> self = new UnaryScope <Operators>(active, op, evaluate); active.TryAccept(self); return(self); }
/// <summary> /// Sets the expression. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="expression">The expression.</param> public void SetExpression <T>(Expression <Func <T, T, object> > expression) { this.Reset(); SheetExpression <T> sheetExpression = new SheetExpression <T>(expression); this.expression = sheetExpression; }
private IComparable PerformArithmeticOperation(IEvaluable evaluable, IJSONDocument document, ArithmeticOperation operation) { IJsonValue value1, value2; if (!Evaluate(out value1, document)) { return(null); } if (!evaluable.Evaluate(out value2, document)) { return(null); } TypeCode actualType1, actualType2; FieldDataType fieldDataType1 = JSONType.GetJSONType(value1.Value, out actualType1); FieldDataType fieldDataType2 = JSONType.GetJSONType(value2.Value, out actualType2); if (fieldDataType1.CompareTo(fieldDataType2) != 0) { return(null); } return(Evaluator.PerformArithmeticOperation(value1, actualType1, value2, actualType2, operation, fieldDataType1)); }
public static bool Evaluate(IProcessorState processor, ref int bufferLength, ref int currentBufferPosition, out bool faulted) { ITokenTrie tokens = Instance.GetSymbols(processor); ScopeBuilder <Operators, TTokens> builder = processor.ScopeBuilder(tokens, Map, DereferenceInLiteralsSetting); bool isFaulted = false; IEvaluable result = builder.Build(ref bufferLength, ref currentBufferPosition, x => isFaulted = true); if (isFaulted) { faulted = true; return(false); } try { object evalResult = result.Evaluate(); bool r = (bool)Convert.ChangeType(evalResult, typeof(bool)); faulted = false; return(r); } catch { faulted = true; return(false); } }
public IfCastCode(IEvaluable name, ITypeDefinition type, IEvaluable cond, LabelCode else_) { Name = name; Type = type; Condition = cond; Else = else_; }
public InterpretedMethod(string name, string [] parameters,IEvaluable body) { this.name=name; this.parameters=parameters; this.body=body; this.delegatedMethodCall = null; }
public void Init(IEvaluable parent) { evaluable = new IEvaluable(); evaluable.eval = (t) => { return(parent.eval(spawnTime) + dir * t); }; col = GetComponent <Collider>(); //mr = GetComponent<MeshRenderer>(); }
public void Init(IEvaluable parent) { evaluable = new IEvaluable(); evaluable.eval = (t) => { return(parent.eval(parentAgeAtBirth) + Vector3.forward * -0.01f); }; scheduledDeathTime = 1; }
public async Task <LogResult> FilterAsync(AnalogLog log, IEvaluable <LogEntry> filter) { var logs = log != null ? await log.Entries.FilterAsync(filter) : Enumerable.Empty <LogEntry>(); return(await Task.Factory.StartNew(() => LogResult.Build(logs.ToList()))); }
public int Evaluate(IEvaluable evaluable, double salience) { if (evaluable is IAgent) ((IAgent)evaluable).Initialize(this, salience); if (salience > 0) return evaluable.Evaluate(); return 1; }
public virtual IJSONDocument Transform(IJSONDocument document) { IJSONDocument newDocument; if (_criteria.GetAllFields) { newDocument = document.Clone() as IJSONDocument; } else { newDocument = JSONType.CreateNew(); } //if (!_criteria.IsGrouped) // newDocument.Key = document.Key; for (int i = 0; i < _criteria.ProjectionCount; i++) { IEvaluable field = _criteria[i]; IJsonValue finalValue; if (field.Evaluate(out finalValue, document)) { //newDocument[field.ToString()] = finalValue.Value; var binaryExpression = field as BinaryExpression; if (binaryExpression != null) { if (binaryExpression.Alias != null) { newDocument[binaryExpression.Alias] = finalValue.Value; continue; } } newDocument[field.CaseSensitiveInString] = finalValue.Value; } else { return(null); } } if (_criteria.ContainsOrder && !_criteria.IsGrouped) { _criteria.OrderByField.FillWithAttributes(document, newDocument); } else if (_criteria.IsGrouped) { _criteria.GroupByField.FillWithAttributes(document, newDocument); } if (newDocument.Count == 0) { return(null); } return(newDocument); }
public bool Evaluate(IEvaluable evaluable, double salience) { if (evaluable is IAgent) { ((IAgent)evaluable).Initialize(this, salience); } evaluables.Enqueue(evaluable); return(true); }
public static PewParticleLogic PlacePew(IEvaluable parent, float birthTime, float?prebirthSpawnTime) { PewParticleLogic ppl = Instantiate(Resources.Load <PewParticleLogic>("Pew")) as PewParticleLogic; ppl.Init(parent); ppl.spawnTime = birthTime; ppl.prebirthSpawnTime = prebirthSpawnTime; return(ppl); }
public BinaryExpression(IEvaluable lhs, ArithmeticOperation operation = ArithmeticOperation.None, IEvaluable rhs = null, string alias = null) { _lhs = lhs; _operation = operation; _rhs = rhs; Alias = alias; }
public bool TryAccept(IEvaluable child) { if (Operand == null) { Operand = child; return(true); } return(false); }
private static IEvaluable CreateBinaryChild(IEvaluable active, Operators op, Func <Operators, bool> precedesOperator, Func <object, object, object> evaluate) { BinaryScope <Operators> self; //If we could steal an arg... if (!active.IsIndivisible) { BinaryScope <Operators> left = active as BinaryScope <Operators>; if (left != null && precedesOperator(left.Operator)) { self = new BinaryScope <Operators>(active, op, evaluate) { Left = left.Right }; left.Right.Parent = self; left.Right = self; return(self); } } //We couldn't steal an arg, "active" is now our left, inject ourselves into // active's parent in its place self = new BinaryScope <Operators>(active.Parent, op, evaluate); if (active.Parent != null) { UnaryScope <Operators> unary = active.Parent as UnaryScope <Operators>; if (unary != null) { unary.Parent = self; } else { BinaryScope <Operators> binary = active.Parent as BinaryScope <Operators>; if (binary != null) { if (binary.Left == active) { binary.Left = self; } else if (binary.Right == active) { binary.Right = self; } } } } active.Parent = self; self.Left = active; return(self); }
public bool Evaluate(IEvaluable evaluable, double salience) { if (evaluable is IAgent) { ((IAgent)evaluable).Initialize(this, salience); } if (salience > 0) { return(evaluable.Evaluate()); } return(true); }
public override void Init(IEvaluable parent, CardEffect effect) { base.Init(parent, effect); evaluable = new IEvaluable(); evaluable.eval = (t) => { return(parent.eval(spawnTime) + dir * (effect.shotSpeed * BASESHOTSPEEDSCALE) * t); }; RotateThatBitch(); if (t < 0) { Show(false); isBeforeBirth = true; } }
private object EvaluateExpression(IEvaluable expression) { List <object> parameters = new List <object>(); foreach (var par in expression.Parameters) { var pos = ResolveRelativePosition(par); parameters.Add(Table[pos.Column, pos.Row]); } return(expression.Evaluate(parameters.ToArray())); }
void Awake() { mr = GetComponentInChildren <MeshRenderer>(); evaluable = new IEvaluable(); scheduledDeathTime = 10; sc = gameObject.GetComponent <SphereCollider>(); sc.radius = 0.2f; sc.center = Vector3.up * 0.1f; sc.isTrigger = true; activeItem = new List <BulletPool>(); pendingItems = new List <BulletPool>(); pooledItems = new List <BulletPool>(); spawnCount = 0; }
public override void Init(IEvaluable parent, CardEffect effect) { base.Init(parent, effect); evaluable = new IEvaluable(); evaluable.eval = (t) => { return(parent.eval(GameManager.time - 0.09f)); }; //particle.Pause(true); if (t < 0) { Show(false); isBeforeBirth = true; } }
public bool EvaluateOne() { IEvaluable evaluable = evaluables.Dequeue(); bool done = evaluable.Evaluate(); if (evaluable is IAgent) { if (!((IAgent)evaluable).Complete()) { evaluables.Enqueue(evaluable); } } return(done); }
public void AddProjection(string fieldName, IEvaluable field) { if (field is BinaryExpression) { fieldName = ((BinaryExpression)field).Alias; } if (!_projections.ContainsKey(fieldName)) { _projections.Add(fieldName, field); } else { throw new QuerySystemException(ErrorCodes.Query.QUERYCRITERIA_FIELD_ALREADY_EXISTS, new[] { fieldName }); } }
public bool TryAccept(IEvaluable child) { if (Left == null) { Left = child; return(true); } if (Right == null) { Right = child; return(true); } return(false); }
public void PerformOperation() { if (EvaluationType.Equals(EvaluationType.Constant)) { //_lhs = ExpressionHelper.GetConstant(Evaluate(null)); _operation = ArithmeticOperation.None; _rhs = null; } //if (EvaluationType.Equals(EvaluationType.SingleVariable)) //{ // _lhs = AndExpression.GetConstant(Evaluate(null)); // _operation = ArithmeticOperation.None; // _rhs = null; //} }
public void Serialize(SerializationWriter writer) { IEvaluable[] evalscopy = new IEvaluable[evaluables.Count]; evaluables.CopyTo(evalscopy, 0); List <IAgent> agents = new List <IAgent>(); foreach (IEvaluable eval in evalscopy) { if (eval is IAgent) { agents.Add((IAgent)eval); } } writer.WriteList <IAgent>(agents); }
private static ProcessKind GetProcessKind(IProcess process) { if (process.GetType().GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IExecutableWithResult <>))) { return(ProcessKind.jobWithResult); } return(process switch { IRowReader _ => ProcessKind.reader, IRowWriter _ => ProcessKind.writer, IMutator _ => ProcessKind.mutator, IScope _ => ProcessKind.scope, IEvaluable _ => ProcessKind.producer, IExecutable _ => ProcessKind.job, _ => ProcessKind.unknown, });
public DocumentCollector AddAggregateFunction(AggregateFunctionType type, IEvaluable field) { if (_aggregations == null) { _aggregations = new List <DocumentCollector>(); } IAggregation function; switch (type) { case AggregateFunctionType.AVG: function = new AVG(); break; case AggregateFunctionType.COUNT: function = new COUNT(); break; case AggregateFunctionType.MAX: function = new MAX(); break; case AggregateFunctionType.MIN: function = new MIN(); break; case AggregateFunctionType.SUM: function = new SUM(); break; //case AggregateFunctionType.FIRST: // function = new FIRST(field); // break; //case AggregateFunctionType.LAST: // function = new LAST(field); // break; default: throw new QuerySystemException(ErrorCodes.Query.AGGREGATION_INVALID_FUNCTION); } var aggregator = new DocumentCollector(function, field); _aggregations.Add(aggregator); return(aggregator); }
public void AddGroupByField(IEvaluable field) { if (_groupByField == null) { _groupByField = new Field(field, Field.FieldType.Grouped); } else if (_groupByField is CompoundField) { CompoundField gbf = (CompoundField)_groupByField; gbf.AddField(new Field(field, Field.FieldType.Grouped)); } else { CompoundField gbf = new CompoundField(Field.FieldType.Grouped); gbf.AddField(_groupByField); gbf.AddField(new Field(field, Field.FieldType.Grouped)); _groupByField = gbf; } }
public void AddOrderByField(IEvaluable field, SortOrder order) { if (_orderByField == null) { _orderByField = new Field(field, Field.FieldType.Ordered, order); } else if (_orderByField is CompoundField) { CompoundField obf = (CompoundField)_orderByField; obf.AddField(new Field(field, Field.FieldType.Ordered, order)); } else { CompoundField obf = new CompoundField(Field.FieldType.Ordered); obf.AddField(_orderByField); obf.AddField(new Field(field, Field.FieldType.Ordered, order)); _orderByField = obf; } }
public void SplitterTestFirstEvaluatorTakesItAll() { var topic = TestExecuter.GetTopic(); var splitter = new Splitter <DefaultRowQueue>(topic, null) { InputProcess = new EnumerableImporter(topic, null) { InputGenerator = caller => TestData.Person(topic).Evaluate(caller).TakeRowsAndReleaseOwnership(), }, }; var processes = new IEvaluable[4]; for (var i = 0; i < 3; i++) { processes[i] = new CustomMutator(topic, null) { InputProcess = splitter, Then = (proc, row) => { Thread.Sleep(new Random().Next(10)); row.SetValue("ThreadIndex", i); return(true); }, }; } var results = new List <ISlimRow> [3]; for (var i = 0; i < 3; i++) { results[i] = processes[i].Evaluate().TakeRowsAndReleaseOwnership().ToList(); } Assert.AreEqual(7, results[0].Count); Assert.AreEqual(0, results[1].Count); Assert.AreEqual(0, results[2].Count); var exceptions = topic.Context.GetExceptions(); Assert.AreEqual(0, exceptions.Count); }
void Start() { startPos = transform.position; evaluable = new IEvaluable(); scheduledDeathTime = float.MaxValue; evaluable.eval = (t) => { return(new Vector3(0, Mathf.PerlinNoise(0, t * freq) * mag + Mathf.PerlinNoise(2, t * freq * 0.5f) * mag * 2, 0) + startPos); }; hp = maxHP; for (int x = 0; x < tentColor.Length; x++) { tentColor[x].material = new Material(tentColor[x].material); tentDepth[x].material = new Material(tentDepth[x].material); } for (int x = 0; x < headMats.Length; x++) { headMats[x].SetFloat("_Decay", 9999); } }
public bool Evaluate(IEvaluable evaluable, double salience) { AddCodelet(new CodeletEvaluableWrapper(evaluable, this, salience, 1, 1), "Evaluate"); return true; }
protected abstract void OnNext(IObserver<IEvaluable> observer, IEvaluable current, ConcurrentBag<IEvaluable> history, ConcurrentBag<IEvaluableFactoryProvider> factoryProviders);
public CodeletEvaluableWrapper(IEvaluable evaluable, Coderack coderack, double salience, int sp, int tm) : base(coderack, salience, sp, tm) { this.evaluable = evaluable; }
public ExceptionHandler(ChimpyClass klass, string localName, IEvaluable handler) { this.localName=localName; this.klass=klass; this.handler=handler; }
public EvaluableWrapper(IEvaluable evaluable) { this.evaluable = evaluable; }
public void Serialize(SerializationWriter writer) { IEvaluable[] evalscopy = new IEvaluable[evaluables.Count]; evaluables.CopyTo(evalscopy, 0); List<IAgent> agents = new List<IAgent>(); foreach (IEvaluable eval in evalscopy) if (eval is IAgent) agents.Add((IAgent)eval); writer.WriteList<IAgent>(agents); }
public int Evaluate(IEvaluable evaluable, double salience) { if (evaluable is IAgent) ((IAgent)evaluable).Initialize(this, salience); evaluables.Enqueue(evaluable); return 1; }