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