コード例 #1
0
        public override RuntimeValueNode OpGreater(RuntimeValueNode other)
        {
            var strValue = (string)Value;

            switch (other.Value)
            {
            case int i:
                return(Wrap(strValue.Length > i));

            case string s:
                return(Wrap(strValue.Length > s.Length));
            }

            throw new Exceptions.RuntimeException("", DefiningToken);
        }
コード例 #2
0
        public override RuntimeValueNode OpMinus(RuntimeValueNode other)
        {
            var strValue = (string)Value;

            switch (other.Value)
            {
            case int i:
                if (i >= strValue.Length)
                {
                    return(Wrap(strValue.Substring(0, strValue.Length - i)));
                }
                else
                {
                    return(Wrap(""));
                }
            }

            throw new Exceptions.RuntimeException("", DefiningToken);
        }
コード例 #3
0
        public override RuntimeValueNode OpDivide(RuntimeValueNode other)
        {
            var strValue = (string)Value;

            switch (other.Value)
            {
            case int i: {
                if (i == 0)
                {
                    throw new Exceptions.RuntimeException("", DefiningToken);
                }

                var resultLen = strValue.Length / i;
                strValue = strValue.Substring(resultLen);
                if (i < 0)
                {
                    strValue = strValue.Reverse().ToString();
                }
                return(Wrap(strValue));
            }
            }

            throw new Exceptions.RuntimeException("", DefiningToken);
        }
コード例 #4
0
        public override RuntimeValueNode OpMultiply(RuntimeValueNode other)
        {
            var strValue = (string)Value;

            switch (other.Value)
            {
            case int i: {
                var res = "";
                if (i < 0)
                {
                    strValue = strValue.Reverse().ToString();
                    i        = -i;
                }

                for (int j = 0; j < i; ++j)
                {
                    res += strValue;
                }
                return(Wrap(res));
            }
            }

            throw new Exceptions.RuntimeException("", DefiningToken);
        }
コード例 #5
0
 public abstract RuntimeValueNode OpEqual(RuntimeValueNode other);
コード例 #6
0
 public abstract RuntimeValueNode OpGreater(RuntimeValueNode other);
コード例 #7
0
 public abstract RuntimeValueNode OpDivide(RuntimeValueNode other);
コード例 #8
0
 public abstract RuntimeValueNode OpMultiply(RuntimeValueNode other);
コード例 #9
0
 public abstract RuntimeValueNode OpMinus(RuntimeValueNode other);
コード例 #10
0
 public override RuntimeValueNode OpSmaller(RuntimeValueNode other)
 {
     return(Wrap((int)Value < (int)other.Value));
 }
コード例 #11
0
 public override RuntimeValueNode OpGreater(RuntimeValueNode other)
 {
     return(Wrap((int)Value > (int)other.Value));
 }
コード例 #12
0
 public override RuntimeValueNode OpDivide(RuntimeValueNode other)
 {
     return(Wrap((int)Value / (int)other.Value));
 }
コード例 #13
0
 public override RuntimeValueNode OpMultiply(RuntimeValueNode other)
 {
     return(Wrap((int)Value * (int)other.Value));
 }
コード例 #14
0
 public override RuntimeValueNode OpMinus(RuntimeValueNode other)
 {
     return(Wrap((int)Value - (int)other.Value));
 }
コード例 #15
0
 public abstract RuntimeValueNode OpSmaller(RuntimeValueNode other);
コード例 #16
0
 public override RuntimeValueNode OpEqual(RuntimeValueNode other)
 {
     return(Wrap((int)Value == (int)other.Value));
 }
コード例 #17
0
 public override RuntimeValueNode OpSmaller(RuntimeValueNode other)
 {
     throw new Exceptions.RuntimeException("", DefiningToken);
 }
コード例 #18
0
 public override RuntimeValueNode OpPlus(RuntimeValueNode other)
 {
     return(Wrap((string)Value + other.Value.ToString()));
 }