Beispiel #1
0
        public CBinOp(EBinOp op, CArg arg1, CArg arg2)
        {
            _op   = op;
            _arg1 = arg1;
            _arg2 = arg2;

            _arg1.SetOwner(this);
            _arg2.SetOwner(this);
        }
Beispiel #2
0
        static KeyValuePair <bool, IMathFunc> BuildTriplet(int inPos, List <SBuildElem> inList, ILogger inLogger)
        {
            if (inPos <= 0 || inPos >= inList.Count - 1)
            {
                LogError(inLogger, EErrorCode.InvalidTripletPosition, $"{inList[inPos].StartLineIndex}");
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            EBinOp     op_type = EBinOp.Undefined;
            SBuildElem el      = inList[inPos];

            if (el.Token != null)
            {
                op_type = el.Token.GetBinOp();
            }

            if (op_type == EBinOp.Undefined)
            {
                if (el.Token != null)
                {
                    LogError(inLogger, EErrorCode.BinOperationUndefined, el.Token);
                }
                else
                {
                    LogError(inLogger, EErrorCode.BinOperationUndefined, string.Format("el.Op {0}", el.Op));
                }
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            //left
            el = inList[inPos - 1];
            CArg left_arg = BuildElemToArg(el, inLogger);

            //right
            el = inList[inPos + 1];
            CArg right_arg = BuildElemToArg(el, inLogger);

            if (left_arg == null || right_arg == null)
            {
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            return(new KeyValuePair <bool, IMathFunc>(true, new CBinOp(op_type, left_arg, right_arg)));
        }