Пример #1
0
            private void EvalOperation(Stack <NodeExpr> se, Stack <ETypeBinary> so)
            {
                var pType = so.Pop();

                if (se.Count < 2)
                {
                    throw new InvalidOperationException();
                }

                var r = se.Pop();
                var l = se.Pop();

                se.Push(NodeExpr.Binary(pType, l, r));
            }
Пример #2
0
        public override Task <NodeExpr> Visit(NodeExprBinary e, CancellationToken t)
        {
            return(Task.Run
                   (
                       () =>
            {
                var lt = Visit(e.Left, t);
                var rt = Visit(e.Right, t);

                Task.WaitAll(new[] { lt, rt }, t);

                t.ThrowIfCancellationRequested();

                var l = lt.Result;
                var r = rt.Result;

                return
                ((l is NodeExprNumber <N> ln) && (r is NodeExprNumber <N> rn))
                    ? (NodeExpr)NodeExpr.Number(mAlg.EvalBinaryOperator(e.TypeBinary, ln.Value, rn.Value))
                    : NodeExpr.Binary(e.TypeBinary, l, r);
            }
                   ));
        }