Beispiel #1
0
        public override Word PyNotEquals(PyObj obj0, PyObj obj1)
        {
            if (obj1.IsNull())
            {
                return(new MyBoolean(true));
            }
            var intObj0 = (int)((MyChar)obj0).CharValue;

            if (obj1.GetMyType() == TypeConstants.CHAR)
            {
                var intObj1 = (int)((MyChar)obj1).CharValue;
                return(new MyBoolean(intObj0 != intObj1));
            }
            if (obj1.GetMyType() == TypeConstants.INT)
            {
                var intObj1 = ((MyInt)obj1).Int;
                return(new MyBoolean(intObj0 != intObj1));
            }
            if (obj1.GetMyType() == TypeConstants.DOUBLE)
            {
                var doubleObj1 = ((MyDouble)obj1).DoubleValue;
                return(new MyBoolean(intObj0 != doubleObj1));
            }
            return(BinaryError(obj0, BinaryOperator.PyNotEquals, obj1));
        }
 public override Word Plus(PyObj obj0, PyObj obj1)
 {
     if (obj1.IsNull())
     {
         return(BinaryError(obj0, BinaryOperator.Plus, obj1));
     }
     return(new MyString(obj0.MyToString() + obj1.MyToString()));
 }
 public override Word PyNotEquals(PyObj obj0, PyObj obj1)
 {
     if (obj1.IsNull())
     {
         return(new MyBoolean(true));
     }
     if (obj1.GetMyType() != TypeConstants.STRING)
     {
         return(BinaryError(obj0, BinaryOperator.PyNotEquals, obj1));
     }
     return(new MyBoolean(((MyString)obj0).StringValue != ((MyString)obj1).StringValue));
 }
 public override Word PyNotEquals(PyObj obj0, PyObj obj1)
 {
     if (obj1.IsNull())
     {
         return(new MyBoolean(true));
     }
     if (obj1.GetMyType() == TypeConstants.BOOLEAN)
     {
         return(new MyBoolean(((MyBoolean)obj0).Bool != ((MyBoolean)obj1).Bool));
     }
     return(BinaryError(obj0, BinaryOperator.PyNotEquals, obj1));
 }
 public override Word PyNotEquals(PyObj obj0, PyObj obj1)
 {
     if (obj1.IsNull())
     {
         return(new MyBoolean(true));
     }
     //TODO TODO TODO TODO: PROBAR QUE FUNCIONE ESTO!
     if (obj0.GetMyType() == obj1.GetMyType())
     {
         return(new MyBoolean(obj0 != obj1));
     }
     return(BinaryError(obj0, BinaryOperator.PyNotEquals, obj1));
 }
 /// <summary>
 /// Agrega sin verficar que no contenga la llave. Usarse solo si se verifico que no esten presentes los valores antes
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void UnsafeAdd(string key, PyObj value)
 {
     key = key.ToLowerInvariant();
     if (value.IsNull())
     {
         Table[key] = new MemoryBlock(MyNull.GetInstance());
     }
     if (value.IsPrimitive())
     {
         Table[key] = new MemoryBlock(MyPrimitiveFactory.CreateCopy((MyPrimitive)value));
     }
     else//Only option left is for value to be customInstance
     {
         Table[key] = new MemoryBlock(value);
     }
 }
 /// <summary>
 /// Retorna false si no agrego el valor a la tabla de simbolos. Solo se agregan valores que no esten presentes
 /// </summary>
 /// <param name="type"></param
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Add(string key, PyObj value)
 {
     key = key.ToLowerInvariant();
     if (Table.ContainsKey(key))
     {
         return(false);
     }
     if (value.IsNull())
     {
         Table[key] = new MemoryBlock(MyNull.GetInstance());
     }
     if (value.IsPrimitive())
     {
         Table[key] = new MemoryBlock(MyPrimitiveFactory.CreateCopy((MyPrimitive)value));
     }
     else//Only option left is for value to be customInstance
     {
         Table[key] = new MemoryBlock(value);
     }
     return(true);
 }
        /// <summary>
        /// Retorna false si no se cambio el valor de la llave en la tabla de simbolos. Solo se cambian valores que ya estan presentes
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool Set(string key, PyObj value)
        {
            key = key.ToLowerInvariant();
            MemoryBlock memoryBlock;

            if (!Table.TryGetValue(key, out memoryBlock))
            {
                return(false);
            }
            if (value.IsNull())
            {
                memoryBlock.Value = MyNull.GetInstance();
            }
            if (value.IsPrimitive())
            {
                memoryBlock.Value = MyPrimitiveFactory.CreateCopy((MyPrimitive)value);
            }
            else//Only option left is for value to be customInstance
            {
                memoryBlock.Value = value;
            }
            return(true);
        }
Beispiel #9
0
 public override Word PyNotEquals(PyObj obj0, PyObj obj1)
 {
     return(new MyBoolean(!obj1.IsNull()));
 }