public override GSharpObject PerformBinaryOperation(VirtualMachine vm, BinaryOperation binop, GSharpObject rval) { GSharpInteger intVal = rval as GSharpInteger; if (intVal == null) { throw new System.Exception("Right value must be an integer."); } switch (binop) { case BinaryOperation.Addition: return(new GSharpInteger(Value + intVal.Value)); case BinaryOperation.Subtraction: return(new GSharpInteger(Value - intVal.Value)); case BinaryOperation.Multiplication: return(new GSharpInteger(Value * intVal.Value)); case BinaryOperation.Division: return(new GSharpInteger(Value / intVal.Value)); case BinaryOperation.Modulus: return(new GSharpInteger(Value % intVal.Value)); case BinaryOperation.Equals: return(new GSharpBool(Value == intVal.Value)); case BinaryOperation.NotEqualTo: return(new GSharpBool(Value != intVal.Value)); case BinaryOperation.GreaterThan: return(new GSharpBool(Value > intVal.Value)); case BinaryOperation.GreaterOrEqual: return(new GSharpBool(Value >= intVal.Value)); case BinaryOperation.LessThan: return(new GSharpBool(Value < intVal.Value)); case BinaryOperation.LesserOrEqual: return(new GSharpBool(Value <= intVal.Value)); } return(null); }
public override void SetIndex(VirtualMachine vm, GSharpObject key, GSharpObject value) { GSharpInteger index = key as GSharpInteger; Objects[index.Value] = value; }
public override GSharpObject GetIndex(VirtualMachine vm, GSharpObject key) { GSharpInteger index = key as GSharpInteger; return(new GSharpString(Value[index.Value].ToString())); }
public override GSharpObject GetIndex(VirtualMachine vm, GSharpObject key) { GSharpInteger index = key as GSharpInteger; return(Objects[index.Value]); }