Пример #1
0
 public override EvalObject Multiply(EvalObject obj)
 {
     if (SystemType != obj.SystemType)
     {
         return(Memory.CreateObjectFromValue((GetValue() & obj.GetValue()).ToString()));
     }
     else
     {
         throw new TypeMismatchException();
     }
 }
Пример #2
0
        /// <summary>
        /// Определяет операцию сложения типов
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public virtual EvalObject Add(EvalObject obj)
        {
            if (SystemType != obj.SystemType)
            {
                throw new TypeMismatchException("Can't use operator + on two different types");
            }
            var var1 = GetValue();
            var var2 = obj.GetValue();

            return(Memory.CreateObjectFromValue((var1 + var2).ToString()));
        }
Пример #3
0
        public override EvalObject Add(EvalObject obj)
        {
            string sstr1 = GetValue();
            string sstr2 = obj.GetValue();
            string sub1  = sstr1.Substring(1, sstr1.Length - 2);
            string sub2;

            if (obj.SystemType == SystemTypes.Char)
            {
                sub2 = $"{sstr2[1]}";
            }
            else
            if (obj.SystemType == SystemTypes.String)
            {
                sub2 = sstr2.Substring(1, sstr2.Length - 2);
            }
            else
            {
                throw new TypeMismatchException();
            }
            return((StringObject)Memory.CreateObjectFromValue($"\"{sub1}{sub2}\""));
        }