Ejemplo n.º 1
0
        public override Word Plus(PyObj obj0, PyObj obj1)
        {
            if (obj1.GetMyType() == TypeConstants.STRING)
            {
                return(new MyString(obj0.MyToString() + obj1.MyToString()));
            }
            var intObj0 = (int)((MyChar)obj0).CharValue;

            if (obj1.GetMyType() == TypeConstants.CHAR)
            {
                var intObj1 = (int)((MyChar)obj1).CharValue;
                return(new MyInt(intObj0 + intObj1));
            }
            if (obj1.GetMyType() == TypeConstants.INT)
            {
                var intObj1 = ((MyInt)obj1).Int;
                return(new MyInt(intObj0 + intObj1));
            }
            if (obj1.GetMyType() == TypeConstants.DOUBLE)
            {
                var doubleObj1 = ((MyDouble)obj1).DoubleValue;
                return(new MyDouble(intObj0 + doubleObj1));
            }
            return(BinaryError(obj0, BinaryOperator.Plus, obj1));
        }
 public override Word Plus(PyObj obj0, PyObj obj1)
 {
     if (obj1.GetMyType() != TypeConstants.STRING)
     {
         return(BinaryError(obj0, BinaryOperator.Plus, obj1));
     }
     return(new MyString(obj0.MyToString() + obj1.MyToString()));
 }
 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 virtual MyError UnaryError(UnaryOperator op, PyObj obj0)
 {
     return(new MyError(string.Format("No se puede realizar la operacion unaria: {0} ({1}).  Con tipo: <{2}> y valor: <{3}>"
                                      , op.ToString()
                                      , op.ToStringSymbol()
                                      , TypeConstants.GetMyTypeName(obj0.GetMyType())
                                      , obj0.MyToString()
                                      )));
 }
 public virtual MyError BinaryError(PyObj obj0, BinaryOperator op, PyObj obj1)
 {
     return(new MyError(string.Format("No se puede realizar la operacion binaria: {0} ({1}).  Con tipos: <{2}, {3}> y valores: <{4}, {5}>"
                                      , op.ToString()
                                      , op.ToStringSymbol()
                                      , TypeConstants.GetMyTypeName(obj0.GetMyType())
                                      , TypeConstants.GetMyTypeName(obj1.GetMyType())
                                      , obj0.MyToString()
                                      , obj1.MyToString()
                                      )));
 }
Ejemplo n.º 6
0
 private void DoAlert(PyObj obj)
 {
     MessageBox.Show(obj.MyToString());
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Default PrintLine method.
 /// </summary>
 /// <param name="obj"></param>
 private void DoPrintLine(PyObj obj)
 {
     System.Console.WriteLine(obj.MyToString());
 }
Ejemplo n.º 8
0
        public void ConsolePrintLine(PyObj pyObj)
        {
            var message = ConvertToTextBoxFormat(pyObj.MyToString());

            textBox1.AppendText(Environment.NewLine + message);
        }
Ejemplo n.º 9
0
        public void ConsolePrint(PyObj pyObj)
        {
            var message = ConvertToTextBoxFormat(pyObj.MyToString());

            textBox1.Text += message;
        }