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 Div(PyObj obj0, PyObj obj1) { var intObj0 = (int)((MyChar)obj0).CharValue; if (obj1.GetMyType() == TypeConstants.CHAR) { var intObj1 = (int)((MyChar)obj1).CharValue; if (intObj1 == 0) { return(BinaryError(obj0, BinaryOperator.Div, obj1)); } return(new MyInt(intObj0 / intObj1)); } if (obj1.GetMyType() == TypeConstants.INT) { var intObj1 = ((MyInt)obj1).Int; if (intObj1 == 0) { return(BinaryError(obj0, BinaryOperator.Div, obj1)); } return(new MyInt(intObj0 / intObj1)); } if (obj1.GetMyType() == TypeConstants.DOUBLE) { var doubleObj1 = ((MyDouble)obj1).DoubleValue; if (doubleObj1 == 0) { return(BinaryError(obj0, BinaryOperator.Div, obj1)); } return(new MyDouble(intObj0 / doubleObj1)); } return(BinaryError(obj0, BinaryOperator.Div, obj1)); }
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 Or(PyObj obj0, PyObj obj1) { if (obj1.GetMyType() != TypeConstants.BOOLEAN) { return(BinaryError(obj0, BinaryOperator.Or, obj1)); } return(new MyBoolean(((MyBoolean)obj0).Bool || ((MyBoolean)obj1).Bool)); }
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() ))); }
public override Word LessOrEqualTo(PyObj obj0, PyObj obj1) { 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.LessOrEqualTo, obj1)); }
public override Word Pow(PyObj obj0, PyObj obj1) { var intObj0 = (int)((MyChar)obj0).CharValue; if (obj1.GetMyType() == TypeConstants.CHAR) { var intObj1 = (int)((MyChar)obj1).CharValue; return(new MyDouble(Math.Pow(intObj0, intObj1))); } if (obj1.GetMyType() == TypeConstants.INT) { var intObj1 = ((MyInt)obj1).Int; return(new MyDouble(Math.Pow(intObj0, intObj1))); } if (obj1.GetMyType() == TypeConstants.DOUBLE) { var doubleObj1 = ((MyDouble)obj1).DoubleValue; return(new MyDouble(Math.Pow(intObj0, doubleObj1))); } return(BinaryError(obj0, BinaryOperator.Pow, obj1)); }
public override Word GreaterThan(PyObj obj0, PyObj obj1) { var doubleObj0 = ((MyDouble)obj0).DoubleValue; if (obj1.GetMyType() == TypeConstants.CHAR) { var intObj1 = (int)((MyChar)obj1).CharValue; return(new MyBoolean(doubleObj0 > intObj1)); } if (obj1.GetMyType() == TypeConstants.INT) { var intObj1 = ((MyInt)obj1).Int; return(new MyBoolean(doubleObj0 > intObj1)); } if (obj1.GetMyType() == TypeConstants.DOUBLE) { var doubleObj1 = ((MyDouble)obj1).DoubleValue; return(new MyBoolean(doubleObj0 > doubleObj1)); } return(BinaryError(obj0, BinaryOperator.GreaterThan, obj1)); }
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)); }