コード例 #1
0
        protected internal override MAst Transform()
        {
            MAst left  = Left.Transform();
            MAst right = Right.Transform();

            switch (Operator)
            {
            case TigerOperator.Add:
                return(MAst.Add(left, right));

            case TigerOperator.Subtract:
                return(MAst.Subtract(left, right));

            case TigerOperator.Multiply:
                return(MAst.Multiply(left, right));

            case TigerOperator.Divide:
                return(MAst.Divide(left, right));

            case TigerOperator.Mod:
                return(MAst.Modulo(left, right));

            case TigerOperator.Power:
                // todo handle doubles in operations
                return
                    (MAst.Convert(
                         MAst.Power(MAst.Convert(left, typeof(double)), MAst.Convert(right, typeof(double))),
                         typeof(int)));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }